Class: WorkOS::Profile

Inherits:
Types::BaseModel show all
Defined in:
lib/workos/sso/profile.rb

Constant Summary collapse

HASH_ATTRS =
{
  object: :object,
  id: :id,
  organization_id: :organization_id,
  connection_id: :connection_id,
  connection_type: :connection_type,
  idp_id: :idp_id,
  email: :email,
  first_name: :first_name,
  last_name: :last_name,
  role: :role,
  roles: :roles,
  groups: :groups,
  custom_attributes: :custom_attributes,
  raw_attributes: :raw_attributes
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Types::BaseModel

#last_response

Instance Method Summary collapse

Methods inherited from Types::BaseModel

normalize

Methods included from HashProvider

#inspect, #to_h, #to_json

Constructor Details

#initialize(json) ⇒ Profile

Returns a new instance of Profile.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/workos/sso/profile.rb', line 40

def initialize(json)
  hash = self.class.normalize(json)
  @object = hash[:object]
  @id = hash[:id]
  @organization_id = hash[:organization_id]
  @connection_id = hash[:connection_id]
  @connection_type = hash[:connection_type]
  @idp_id = hash[:idp_id]
  @email = hash[:email]
  @first_name = hash[:first_name]
  @last_name = hash[:last_name]
  @role = hash[:role] ? WorkOS::SlimRole.new(hash[:role]) : nil
  @roles = (hash[:roles] || []).map { |item| item ? WorkOS::SlimRole.new(item) : nil }
  @groups = hash[:groups] || []
  @custom_attributes = hash[:custom_attributes] || {}
  @raw_attributes = hash[:raw_attributes] || {}
end

Instance Attribute Details

#connection_idObject

Returns the value of attribute connection_id.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def connection_id
  @connection_id
end

#connection_typeObject

Returns the value of attribute connection_type.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def connection_type
  @connection_type
end

#custom_attributesObject

Returns the value of attribute custom_attributes.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def custom_attributes
  @custom_attributes
end

#emailObject

Returns the value of attribute email.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def email
  @email
end

#first_nameObject

Returns the value of attribute first_name.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def first_name
  @first_name
end

#groupsObject

Returns the value of attribute groups.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def groups
  @groups
end

#idObject

Returns the value of attribute id.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def id
  @id
end

#idp_idObject

Returns the value of attribute idp_id.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def idp_id
  @idp_id
end

#last_nameObject

Returns the value of attribute last_name.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def last_name
  @last_name
end

#objectObject

Returns the value of attribute object.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def object
  @object
end

#organization_idObject

Returns the value of attribute organization_id.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def organization_id
  @organization_id
end

#raw_attributesObject

Returns the value of attribute raw_attributes.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def raw_attributes
  @raw_attributes
end

#roleObject

Returns the value of attribute role.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def role
  @role
end

#rolesObject

Returns the value of attribute roles.



24
25
26
# File 'lib/workos/sso/profile.rb', line 24

def roles
  @roles
end