Class: WorkOS::Profile
- Inherits:
-
Object
- Object
- WorkOS::Profile
- Includes:
- HashProvider
- Defined in:
- lib/workos/profile.rb
Overview
The Profile class provides a lighweight wrapper around a normalized response from the various IDPs WorkOS supports as part of the SSO integration. This class is not meant to be instantiated in user space, and is instantiated internally but exposed.
Instance Attribute Summary collapse
-
#connection_id ⇒ Object
Returns the value of attribute connection_id.
-
#connection_type ⇒ Object
Returns the value of attribute connection_type.
-
#custom_attributes ⇒ Object
Returns the value of attribute custom_attributes.
-
#email ⇒ Object
Returns the value of attribute email.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#id ⇒ Object
Returns the value of attribute id.
-
#idp_id ⇒ Object
Returns the value of attribute idp_id.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#organization_id ⇒ Object
Returns the value of attribute organization_id.
-
#raw_attributes ⇒ Object
Returns the value of attribute raw_attributes.
-
#role ⇒ Object
Returns the value of attribute role.
Instance Method Summary collapse
-
#full_name ⇒ Object
rubocop:enable Metrics/AbcSize.
-
#initialize(profile_json) ⇒ Profile
constructor
rubocop:disable Metrics/AbcSize.
- #to_json ⇒ Object
Methods included from HashProvider
Constructor Details
#initialize(profile_json) ⇒ Profile
rubocop:disable Metrics/AbcSize
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/workos/profile.rb', line 16 def initialize(profile_json) hash = JSON.parse(profile_json, symbolize_names: true) @id = hash[:id] @email = hash[:email] @first_name = hash[:first_name] @last_name = hash[:last_name] @role = hash[:role] @groups = hash[:groups] @organization_id = hash[:organization_id] @connection_id = hash[:connection_id] @connection_type = hash[:connection_type] @idp_id = hash[:idp_id] @custom_attributes = hash[:custom_attributes] @raw_attributes = hash[:raw_attributes] end |
Instance Attribute Details
#connection_id ⇒ Object
Returns the value of attribute connection_id.
12 13 14 |
# File 'lib/workos/profile.rb', line 12 def connection_id @connection_id end |
#connection_type ⇒ Object
Returns the value of attribute connection_type.
12 13 14 |
# File 'lib/workos/profile.rb', line 12 def connection_type @connection_type end |
#custom_attributes ⇒ Object
Returns the value of attribute custom_attributes.
12 13 14 |
# File 'lib/workos/profile.rb', line 12 def custom_attributes @custom_attributes end |
#email ⇒ Object
Returns the value of attribute email.
12 13 14 |
# File 'lib/workos/profile.rb', line 12 def email @email end |
#first_name ⇒ Object
Returns the value of attribute first_name.
12 13 14 |
# File 'lib/workos/profile.rb', line 12 def first_name @first_name end |
#groups ⇒ Object
Returns the value of attribute groups.
12 13 14 |
# File 'lib/workos/profile.rb', line 12 def groups @groups end |
#id ⇒ Object
Returns the value of attribute id.
12 13 14 |
# File 'lib/workos/profile.rb', line 12 def id @id end |
#idp_id ⇒ Object
Returns the value of attribute idp_id.
12 13 14 |
# File 'lib/workos/profile.rb', line 12 def idp_id @idp_id end |
#last_name ⇒ Object
Returns the value of attribute last_name.
12 13 14 |
# File 'lib/workos/profile.rb', line 12 def last_name @last_name end |
#organization_id ⇒ Object
Returns the value of attribute organization_id.
12 13 14 |
# File 'lib/workos/profile.rb', line 12 def organization_id @organization_id end |
#raw_attributes ⇒ Object
Returns the value of attribute raw_attributes.
12 13 14 |
# File 'lib/workos/profile.rb', line 12 def raw_attributes @raw_attributes end |
#role ⇒ Object
Returns the value of attribute role.
12 13 14 |
# File 'lib/workos/profile.rb', line 12 def role @role end |
Instance Method Details
#full_name ⇒ Object
rubocop:enable Metrics/AbcSize
34 35 36 |
# File 'lib/workos/profile.rb', line 34 def full_name [first_name, last_name].compact.join(' ') end |
#to_json ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/workos/profile.rb', line 38 def to_json(*) { id: id, email: email, first_name: first_name, last_name: last_name, role: role, groups: groups, organization_id: organization_id, connection_id: connection_id, connection_type: connection_type, idp_id: idp_id, custom_attributes: custom_attributes, raw_attributes: raw_attributes, } end |