class WorkOS::Organization

The Organization class provides a lightweight wrapper around a WorkOS Organization resource. This class is not meant to be instantiated in user space, and is instantiated internally but exposed.

Attributes

created_at[RW]
domains[RW]
id[RW]
name[RW]
updated_at[RW]

Public Class Methods

new(json) click to toggle source
# File lib/workos/organization.rb, line 14
def initialize(json)
  raw = parse_json(json)

  @id = T.let(raw.id, String)
  @name = T.let(raw.name, String)
  @domains = T.let(raw.domains, Array)
  @created_at = T.let(raw.created_at, String)
  @updated_at = T.let(raw.updated_at, String)
end

Public Instance Methods

to_json(*) click to toggle source
# File lib/workos/organization.rb, line 24
def to_json(*)
  {
    id: id,
    name: name,
    domains: domains,
    created_at: created_at,
    updated_at: updated_at,
  }
end

Private Instance Methods

parse_json(json_string) click to toggle source
# File lib/workos/organization.rb, line 41
def parse_json(json_string)
  hash = JSON.parse(json_string, symbolize_names: true)

  WorkOS::Types::OrganizationStruct.new(
    id: hash[:id],
    name: hash[:name],
    domains: hash[:domains],
    created_at: hash[:created_at],
    updated_at: hash[:updated_at],
  )
end