Class: Teems::Models::UserProfile
- Inherits:
-
Data
- Object
- Data
- Teems::Models::UserProfile
- Defined in:
- lib/teems/models/user_profile.rb
Overview
Rich user profile with extended fields for who/org commands
Instance Attribute Summary collapse
-
#business_phones ⇒ Object
readonly
Returns the value of attribute business_phones.
-
#department ⇒ Object
readonly
Returns the value of attribute department.
-
#display_name ⇒ Object
readonly
Returns the value of attribute display_name.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#job_title ⇒ Object
readonly
Returns the value of attribute job_title.
-
#mobile_phone ⇒ Object
readonly
Returns the value of attribute mobile_phone.
-
#office_location ⇒ Object
readonly
Returns the value of attribute office_location.
-
#user_principal_name ⇒ Object
readonly
Returns the value of attribute user_principal_name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#business_phones ⇒ Object (readonly)
Returns the value of attribute business_phones
6 7 8 |
# File 'lib/teems/models/user_profile.rb', line 6 def business_phones @business_phones end |
#department ⇒ Object (readonly)
Returns the value of attribute department
6 7 8 |
# File 'lib/teems/models/user_profile.rb', line 6 def department @department end |
#display_name ⇒ Object (readonly)
Returns the value of attribute display_name
6 7 8 |
# File 'lib/teems/models/user_profile.rb', line 6 def display_name @display_name end |
#email ⇒ Object (readonly)
Returns the value of attribute email
6 7 8 |
# File 'lib/teems/models/user_profile.rb', line 6 def email @email end |
#id ⇒ Object (readonly)
Returns the value of attribute id
6 7 8 |
# File 'lib/teems/models/user_profile.rb', line 6 def id @id end |
#job_title ⇒ Object (readonly)
Returns the value of attribute job_title
6 7 8 |
# File 'lib/teems/models/user_profile.rb', line 6 def job_title @job_title end |
#mobile_phone ⇒ Object (readonly)
Returns the value of attribute mobile_phone
6 7 8 |
# File 'lib/teems/models/user_profile.rb', line 6 def mobile_phone @mobile_phone end |
#office_location ⇒ Object (readonly)
Returns the value of attribute office_location
6 7 8 |
# File 'lib/teems/models/user_profile.rb', line 6 def office_location @office_location end |
#user_principal_name ⇒ Object (readonly)
Returns the value of attribute user_principal_name
6 7 8 |
# File 'lib/teems/models/user_profile.rb', line 6 def user_principal_name @user_principal_name end |
Class Method Details
.detail_attrs(data) ⇒ Object
26 27 28 29 30 |
# File 'lib/teems/models/user_profile.rb', line 26 def self.detail_attrs(data) { job_title: data['jobTitle'], department: data['department'], office_location: data['officeLocation'], business_phones: data['businessPhones'] || [], mobile_phone: data['mobilePhone'] } end |
.from_api(data) ⇒ Object
17 18 19 |
# File 'lib/teems/models/user_profile.rb', line 17 def self.from_api(data) new(**identity_attrs(data), **detail_attrs(data)) end |
.identity_attrs(data) ⇒ Object
21 22 23 24 |
# File 'lib/teems/models/user_profile.rb', line 21 def self.identity_attrs(data) { id: data['id'], display_name: data['displayName'], email: data['mail'] || data['email'], user_principal_name: data['userPrincipalName'] } end |
Instance Method Details
#best_name ⇒ Object
32 33 34 |
# File 'lib/teems/models/user_profile.rb', line 32 def best_name [display_name, email, user_principal_name, id].find { |value| value && !value.empty? } end |
#json_attrs ⇒ Object
36 37 38 |
# File 'lib/teems/models/user_profile.rb', line 36 def json_attrs [to_h, id] end |
#search_display ⇒ Object
40 41 42 |
# File 'lib/teems/models/user_profile.rb', line 40 def search_display [best_name, job_title, email] end |