Sha256: 5eef8d804ca0080c76336bfa3aed51cff4cc72347a2d06e37d95875c2b8e0f8e

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 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, :name, :custom_attributes, :raw_attributes

    sig { params(json: String).void }
    def initialize(json)
      raw = parse_json(json)

      @id = T.let(raw.id, String)
      @name = T.let(raw.name, String)

      replace_without_warning(to_json)
    end

    def to_json(*)
      {
        id: id,
        name: name,
      }
    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],
        name: hash[:name],
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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