class WorkOS::DirectoryUser
The DirectoryUser
class provides a lightweight wrapper around a WorkOS
DirectoryUser
resource. This class is not meant to be instantiated in DirectoryUser
space, and is instantiated internally but exposed.
Attributes
custom_attributes[RW]
emails[RW]
first_name[RW]
groups[RW]
id[RW]
idp_id[RW]
last_name[RW]
raw_attributes[RW]
state[RW]
username[RW]
Public Class Methods
new(json)
click to toggle source
# File lib/workos/directory_user.rb, line 16 def initialize(json) raw = parse_json(json) @id = T.let(raw.id, String) @idp_id = T.let(raw.idp_id, String) @emails = T.let(raw.emails, Array) @first_name = raw.first_name @last_name = raw.last_name @username = raw.username @state = raw.state @groups = T.let(raw.groups, Array) @custom_attributes = raw.custom_attributes @raw_attributes = raw.raw_attributes end
Public Instance Methods
to_json(*)
click to toggle source
rubocop:enable Metrics/AbcSize
# File lib/workos/directory_user.rb, line 32 def to_json(*) { id: id, idp_id: idp_id, emails: emails, first_name: first_name, last_name: last_name, username: username, state: state, groups: groups, custom_attributes: custom_attributes, raw_attributes: raw_attributes, } end
Private Instance Methods
parse_json(json_string)
click to toggle source
# File lib/workos/directory_user.rb, line 54 def parse_json(json_string) hash = JSON.parse(json_string, symbolize_names: true) WorkOS::Types::DirectoryUserStruct.new( id: hash[:id], idp_id: hash[:idp_id], emails: hash[:emails], first_name: hash[:first_name], last_name: hash[:last_name], username: hash[:username], state: hash[:state], groups: hash[:groups], custom_attributes: hash[:custom_attributes], raw_attributes: hash[:raw_attributes], ) end