Sha256: e4877a0389cb0534f2e75e3409f77595270891cd9b2f7cdfec01f1104d2449f3

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

# frozen_string_literal: true
# typed: true

module WorkOS
  # The DirectoryGroup class provides a lightweight wrapper around
  # a WorkOS DirectoryGroup resource. This class is not meant to be instantiated
  # in user space, and is instantiated internally but exposed.
  class DirectoryGroup < DeprecatedHashWrapper
    include HashProvider
    extend T::Sig

    attr_accessor :id, :directory_id, :idp_id, :name, :created_at, :updated_at, :raw_attributes

    # rubocop:disable Metrics/AbcSize
    sig { params(json: String).void }
    def initialize(json)
      raw = parse_json(json)

      @id = T.let(raw.id, String)
      @directory_id = T.let(raw.directory_id, String)
      @idp_id = T.let(raw.idp_id, String)
      @name = T.let(raw.name, String)
      @created_at = T.let(raw.created_at, String)
      @updated_at = T.let(raw.updated_at, String)
      @raw_attributes = raw.raw_attributes

      replace_without_warning(to_json)
    end
    # rubocop:enable Metrics/AbcSize

    def to_json(*)
      {
        id: id,
        directory_id: directory_id,
        idp_id: idp_id,
        name: name,
        created_at: created_at,
        updated_at: updated_at,
        raw_attributes: raw_attributes,
      }
    end

    private

    sig do
      params(
        json_string: String,
      ).returns(WorkOS::Types::DirectoryGroupStruct)
    end
    def parse_json(json_string)
      hash = JSON.parse(json_string, symbolize_names: true)

      WorkOS::Types::DirectoryGroupStruct.new(
        id: hash[:id],
        directory_id: hash[:directory_id],
        idp_id: hash[:idp_id],
        name: hash[:name],
        created_at: hash[:created_at],
        updated_at: hash[:updated_at],
        raw_attributes: hash[:raw_attributes],
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workos-2.3.0 lib/workos/directory_group.rb