Sha256: b6b27ac76ef1a1ab1671abbc63813f5c62fe7d3bb00df5769a3eb9aa4c8db62f

Contents?: true

Size: 1.02 KB

Versions: 14

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true
# typed: true

module WorkOS
  # 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.
  class Organization
    extend T::Sig

    attr_accessor :id, :domains, :name

    sig { params(json: String).void }
    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)
    end

    def to_json(*)
      {
        id: id,
        name: name,
        domains: domains,
      }
    end

    private

    sig do
      params(
        json_string: String,
      ).returns(WorkOS::Types::OrganizationStruct)
    end
    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],
      )
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
workos-1.4.0 lib/workos/organization.rb
workos-1.3.0 lib/workos/organization.rb
workos-1.2.1 lib/workos/organization.rb
workos-1.2.0 lib/workos/organization.rb
workos-1.1.0 lib/workos/organization.rb
workos-1.0.0 lib/workos/organization.rb
workos-0.11.2 lib/workos/organization.rb
workos-0.11.1 lib/workos/organization.rb
workos-0.11.0 lib/workos/organization.rb
workos-0.10.3 lib/workos/organization.rb
workos-0.10.2 lib/workos/organization.rb
workos-0.10.1 lib/workos/organization.rb
workos-0.10.0 lib/workos/organization.rb
workos-0.9.2 lib/workos/organization.rb