Class: Spaceship::ConnectAPI::User
- Inherits:
-
Object
- Object
- Spaceship::ConnectAPI::User
- Includes:
- Model
- Defined in:
- spaceship/lib/spaceship/connect_api/models/user.rb
Defined Under Namespace
Modules: UserRole
Constant Summary collapse
- ESSENTIAL_INCLUDES =
[ "visibleApps" ].join(",")
Instance Attribute Summary collapse
-
#agreed_to_terms ⇒ Object
Returns the value of attribute agreed_to_terms.
-
#all_apps_visible ⇒ Object
Returns the value of attribute all_apps_visible.
-
#email ⇒ Object
Returns the value of attribute email.
-
#email_vetting_required ⇒ Object
Returns the value of attribute email_vetting_required.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#notifications ⇒ Object
Returns the value of attribute notifications.
-
#preferred_currency_territory ⇒ Object
Returns the value of attribute preferred_currency_territory.
-
#provisioning_allowed ⇒ Object
Returns the value of attribute provisioning_allowed.
-
#roles ⇒ Object
Returns the value of attribute roles.
-
#username ⇒ Object
Returns the value of attribute username.
-
#visible_apps ⇒ Object
Returns the value of attribute visible_apps.
Attributes included from Model
Class Method Summary collapse
-
.all(client: nil, filter: {}, includes: ESSENTIAL_INCLUDES, limit: nil, sort: nil) ⇒ Object
API.
- .find(client: nil, email: nil, includes: ESSENTIAL_INCLUDES) ⇒ Object
- .type ⇒ Object
Instance Method Summary collapse
- #delete!(client: nil) ⇒ Object
- #get_visible_apps(client: nil, limit: nil) ⇒ Object
-
#update(client: nil, all_apps_visible: nil, provisioning_allowed: nil, roles: nil, visible_app_ids: nil) ⇒ User
Modified user.
Methods included from Model
#attr_mapping, included, #initialize, #reverse_attr_mapping, #to_json, #update_attributes
Instance Attribute Details
#agreed_to_terms ⇒ Object
Returns the value of attribute agreed_to_terms.
12 13 14 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 12 def agreed_to_terms @agreed_to_terms end |
#all_apps_visible ⇒ Object
Returns the value of attribute all_apps_visible.
14 15 16 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 14 def all_apps_visible @all_apps_visible end |
#email ⇒ Object
Returns the value of attribute email.
10 11 12 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 10 def email @email end |
#email_vetting_required ⇒ Object
Returns the value of attribute email_vetting_required.
16 17 18 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 16 def email_vetting_required @email_vetting_required end |
#first_name ⇒ Object
Returns the value of attribute first_name.
8 9 10 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 8 def first_name @first_name end |
#last_name ⇒ Object
Returns the value of attribute last_name.
9 10 11 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 9 def last_name @last_name end |
#notifications ⇒ Object
Returns the value of attribute notifications.
17 18 19 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 17 def notifications @notifications end |
#preferred_currency_territory ⇒ Object
Returns the value of attribute preferred_currency_territory.
11 12 13 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 11 def preferred_currency_territory @preferred_currency_territory end |
#provisioning_allowed ⇒ Object
Returns the value of attribute provisioning_allowed.
15 16 17 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 15 def provisioning_allowed @provisioning_allowed end |
#roles ⇒ Object
Returns the value of attribute roles.
13 14 15 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 13 def roles @roles end |
#username ⇒ Object
Returns the value of attribute username.
7 8 9 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 7 def username @username end |
#visible_apps ⇒ Object
Returns the value of attribute visible_apps.
19 20 21 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 19 def visible_apps @visible_apps end |
Class Method Details
.all(client: nil, filter: {}, includes: ESSENTIAL_INCLUDES, limit: nil, sort: nil) ⇒ Object
API
63 64 65 66 67 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 63 def self.all(client: nil, filter: {}, includes: ESSENTIAL_INCLUDES, limit: nil, sort: nil) client ||= Spaceship::ConnectAPI resps = client.get_users(filter: filter, includes: includes).all_pages return resps.flat_map(&:to_models) end |
.find(client: nil, email: nil, includes: ESSENTIAL_INCLUDES) ⇒ Object
69 70 71 72 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 69 def self.find(client: nil, email: nil, includes: ESSENTIAL_INCLUDES) client ||= Spaceship::ConnectAPI return all(client: client, filter: { email: email }, includes: includes) end |
.type ⇒ Object
41 42 43 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 41 def self.type return "users" end |
Instance Method Details
#delete!(client: nil) ⇒ Object
98 99 100 101 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 98 def delete!(client: nil) client ||= Spaceship::ConnectAPI client.delete_user(user_id: id) end |
#get_visible_apps(client: nil, limit: nil) ⇒ Object
103 104 105 106 107 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 103 def get_visible_apps(client: nil, limit: nil) client ||= Spaceship::ConnectAPI resp = client.get_user_visible_apps(user_id: id, limit: limit) return resp.to_models end |
#update(client: nil, all_apps_visible: nil, provisioning_allowed: nil, roles: nil, visible_app_ids: nil) ⇒ User
Returns Modified user.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 80 def update(client: nil, all_apps_visible: nil, provisioning_allowed: nil, roles: nil, visible_app_ids: nil) client ||= Spaceship::ConnectAPI all_apps_visible = all_apps_visible.nil? ? self.all_apps_visible : all_apps_visible provisioning_allowed = provisioning_allowed.nil? ? self.provisioning_allowed : provisioning_allowed roles ||= self.roles visible_app_ids ||= self.visible_apps.map(&:id) resp = client.patch_user( user_id: self.id, all_apps_visible: all_apps_visible, provisioning_allowed: provisioning_allowed, roles: roles, visible_app_ids: visible_app_ids ) return resp.to_models.first end |