Class: Spaceship::ConnectAPI::User

Inherits:
Object
  • Object
show all
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

Attributes included from Model

#id, #reverse_attr_map

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

#attr_mapping, included, #initialize, #reverse_attr_mapping, #to_json, #update_attributes

Instance Attribute Details

#agreed_to_termsObject

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_visibleObject

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

#emailObject

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_requiredObject

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_nameObject

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_nameObject

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

#notificationsObject

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_territoryObject

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_allowedObject

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

#rolesObject

Returns the value of attribute roles.



13
14
15
# File 'spaceship/lib/spaceship/connect_api/models/user.rb', line 13

def roles
  @roles
end

#usernameObject

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_appsObject

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

.typeObject



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.

Parameters:

  • client (ConnectAPI) (defaults to: nil)

    ConnectAPI client.

  • all_apps_visible (Boolean) (defaults to: nil)

    If all apps must be visible to a user. true - if a user must see all apps, you must not provide visible_app_ids, ‘false` - a user must see only a limited list of apps, and you must provide visible_app_ids. nil if no change is needed.

  • provisioning_allowed (Bool) (defaults to: nil)

    If a user with a Developer or App Manager role must have access to Certificates, Identifiers & Profiles. true - if a user must be able to create new certificates and provisioning profiles, ‘false` - otherwise. nil if no change is needed.

  • roles (Array) (defaults to: nil)

    Array of strings describing user roles. You can use defined constants in the UserRole, or refer to the Apple Documentation developer.apple.com/documentation/appstoreconnectapi/userrole . Pass nil if no change is needed.

  • visible_app_ids (Array) (defaults to: nil)

    Array of strings with application identifiers the user needs access to. nil if no apps change is needed or user must have access to all apps.

Returns:

  • (User)

    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