Class: Slk::Models::Profile
- Inherits:
-
Data
- Object
- Data
- Slk::Models::Profile
- Defined in:
- lib/slk/models/profile.rb
Overview
Composite model representing a Slack user profile, merged from users.profile.get + users.info + team.profile.get schema.
custom_fields is an Array<ProfileField>. resolved_users is a mutable Hash<user_id, Profile> populated by ProfileResolver one level deep for type:user fields (e.g. Supervisor).
Instance Attribute Summary collapse
-
#custom_fields ⇒ Object
readonly
Returns the value of attribute custom_fields.
-
#deleted ⇒ Object
readonly
Returns the value of attribute deleted.
-
#display_name ⇒ Object
readonly
Returns the value of attribute display_name.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#home_team_name ⇒ Object
readonly
Returns the value of attribute home_team_name.
-
#image_url ⇒ Object
readonly
Returns the value of attribute image_url.
-
#is_admin ⇒ Object
readonly
Returns the value of attribute is_admin.
-
#is_bot ⇒ Object
readonly
Returns the value of attribute is_bot.
-
#is_external ⇒ Object
readonly
Returns the value of attribute is_external.
-
#is_owner ⇒ Object
readonly
Returns the value of attribute is_owner.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
-
#phone ⇒ Object
readonly
Returns the value of attribute phone.
-
#presence ⇒ Object
readonly
Returns the value of attribute presence.
-
#pronouns ⇒ Object
readonly
Returns the value of attribute pronouns.
-
#real_name ⇒ Object
readonly
Returns the value of attribute real_name.
-
#resolved_users ⇒ Object
readonly
Returns the value of attribute resolved_users.
-
#sections ⇒ Object
readonly
Returns the value of attribute sections.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
-
#status_emoji ⇒ Object
readonly
Returns the value of attribute status_emoji.
-
#status_expiration ⇒ Object
readonly
Returns the value of attribute status_expiration.
-
#status_text ⇒ Object
readonly
Returns the value of attribute status_text.
-
#team_id ⇒ Object
readonly
Returns the value of attribute team_id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#tz ⇒ Object
readonly
Returns the value of attribute tz.
-
#tz_label ⇒ Object
readonly
Returns the value of attribute tz_label.
-
#tz_offset ⇒ Object
readonly
Returns the value of attribute tz_offset.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
- #best_name ⇒ Object
- #external? ⇒ Boolean
- #fields_in_section(section_id) ⇒ Object
- #people_fields ⇒ Object
- #presence_label ⇒ Object
- #reports_field ⇒ Object
- #section(section_id) ⇒ Object
-
#supervisor_ids ⇒ Object
User IDs from the first non-inverse Supervisor-like field.
-
#visible_fields ⇒ Object
Custom fields with values, ordered by ordering then label.
Instance Attribute Details
#custom_fields ⇒ Object (readonly)
Returns the value of attribute custom_fields
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def custom_fields @custom_fields end |
#deleted ⇒ Object (readonly)
Returns the value of attribute deleted
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def deleted @deleted end |
#display_name ⇒ Object (readonly)
Returns the value of attribute display_name
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def display_name @display_name end |
#email ⇒ Object (readonly)
Returns the value of attribute email
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def email @email end |
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def first_name @first_name end |
#home_team_name ⇒ Object (readonly)
Returns the value of attribute home_team_name
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def home_team_name @home_team_name end |
#image_url ⇒ Object (readonly)
Returns the value of attribute image_url
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def image_url @image_url end |
#is_admin ⇒ Object (readonly)
Returns the value of attribute is_admin
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def is_admin @is_admin end |
#is_bot ⇒ Object (readonly)
Returns the value of attribute is_bot
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def is_bot @is_bot end |
#is_external ⇒ Object (readonly)
Returns the value of attribute is_external
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def is_external @is_external end |
#is_owner ⇒ Object (readonly)
Returns the value of attribute is_owner
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def is_owner @is_owner end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def last_name @last_name end |
#phone ⇒ Object (readonly)
Returns the value of attribute phone
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def phone @phone end |
#presence ⇒ Object (readonly)
Returns the value of attribute presence
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def presence @presence end |
#pronouns ⇒ Object (readonly)
Returns the value of attribute pronouns
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def pronouns @pronouns end |
#real_name ⇒ Object (readonly)
Returns the value of attribute real_name
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def real_name @real_name end |
#resolved_users ⇒ Object (readonly)
Returns the value of attribute resolved_users
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def resolved_users @resolved_users end |
#sections ⇒ Object (readonly)
Returns the value of attribute sections
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def sections @sections end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def start_date @start_date end |
#status_emoji ⇒ Object (readonly)
Returns the value of attribute status_emoji
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def status_emoji @status_emoji end |
#status_expiration ⇒ Object (readonly)
Returns the value of attribute status_expiration
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def status_expiration @status_expiration end |
#status_text ⇒ Object (readonly)
Returns the value of attribute status_text
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def status_text @status_text end |
#team_id ⇒ Object (readonly)
Returns the value of attribute team_id
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def team_id @team_id end |
#title ⇒ Object (readonly)
Returns the value of attribute title
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def title @title end |
#tz ⇒ Object (readonly)
Returns the value of attribute tz
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def tz @tz end |
#tz_label ⇒ Object (readonly)
Returns the value of attribute tz_label
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def tz_label @tz_label end |
#tz_offset ⇒ Object (readonly)
Returns the value of attribute tz_offset
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def tz_offset @tz_offset end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id
11 12 13 |
# File 'lib/slk/models/profile.rb', line 11 def user_id @user_id end |
Instance Method Details
#best_name ⇒ Object
27 28 29 30 31 32 |
# File 'lib/slk/models/profile.rb', line 27 def best_name return display_name unless display_name.to_s.empty? return real_name unless real_name.to_s.empty? user_id end |
#external? ⇒ Boolean
34 35 36 |
# File 'lib/slk/models/profile.rb', line 34 def external? is_external end |
#fields_in_section(section_id) ⇒ Object
50 51 52 |
# File 'lib/slk/models/profile.rb', line 50 def fields_in_section(section_id) visible_fields.select { |f| f.section_id == section_id } end |
#people_fields ⇒ Object
46 47 48 |
# File 'lib/slk/models/profile.rb', line 46 def people_fields visible_fields.select { |f| f.type == 'user' } end |
#presence_label ⇒ Object
20 21 22 23 24 25 |
# File 'lib/slk/models/profile.rb', line 20 def presence_label case presence when 'active' then 'Active' when 'away' then 'Away' end end |
#reports_field ⇒ Object
66 67 68 |
# File 'lib/slk/models/profile.rb', line 66 def reports_field custom_fields.find { |f| f.type == 'user' && f.inverse } end |
#section(section_id) ⇒ Object
54 55 56 |
# File 'lib/slk/models/profile.rb', line 54 def section(section_id) sections.find { |s| s['id'] == section_id } end |
#supervisor_ids ⇒ Object
User IDs from the first non-inverse Supervisor-like field. Prefers a field literally labeled “Supervisor”.
60 61 62 63 64 |
# File 'lib/slk/models/profile.rb', line 60 def supervisor_ids preferred = people_fields.find { |f| f.label.to_s.casecmp('Supervisor').zero? && !f.inverse } preferred ||= people_fields.find { |f| !f.inverse } preferred ? preferred.user_ids : [] end |
#visible_fields ⇒ Object
Custom fields with values, ordered by ordering then label. Hidden fields are filtered unless explicitly requested.
40 41 42 43 44 |
# File 'lib/slk/models/profile.rb', line 40 def visible_fields custom_fields .reject { |f| f.empty? || f.hidden } .sort_by { |f| [f.ordering.to_i, f.label.to_s] } end |