Sha256: f8a6046b24fdbee3434c3469555049462b68550046135a17621836dbc2d8901f
Contents?: true
Size: 1.68 KB
Versions: 22
Compression:
Stored size: 1.68 KB
Contents
# frozen_string_literal: true # typed: true module WorkOS # The Directory class provides a lightweight wrapper around # a WorkOS Directory resource. This class is not meant to be instantiated # in user space, and is instantiated internally but exposed. class Directory include HashProvider extend T::Sig attr_accessor :id, :domain, :name, :type, :state, :organization_id, :created_at, :updated_at # rubocop:disable Metrics/AbcSize sig { params(json: String).void } def initialize(json) raw = parse_json(json) @id = T.let(raw.id, String) @name = T.let(raw.name, String) @domain = raw.domain @type = T.let(raw.type, String) @state = T.let(raw.state, String) @organization_id = raw.organization_id @created_at = T.let(raw.created_at, String) @updated_at = T.let(raw.updated_at, String) end # rubocop:enable Metrics/AbcSize def to_json(*) { id: id, name: name, domain: domain, type: type, state: state, organization_id: organization_id, created_at: created_at, updated_at: updated_at, } end private sig do params( json_string: String, ).returns(WorkOS::Types::DirectoryStruct) end def parse_json(json_string) hash = JSON.parse(json_string, symbolize_names: true) WorkOS::Types::DirectoryStruct.new( id: hash[:id], name: hash[:name], domain: hash[:domain], type: hash[:type], state: hash[:state], organization_id: hash[:organization_id], created_at: hash[:created_at], updated_at: hash[:updated_at], ) end end end
Version data entries
22 entries across 22 versions & 1 rubygems