Class: Spaceship::ConnectAPI::UserInvitation

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
spaceship/lib/spaceship/connect_api/models/user_invitation.rb

Constant Summary collapse

ESSENTIAL_INCLUDES =
[
  "visibleApps"
].join(",")
UserRole =
Spaceship::ConnectAPI::User::UserRole

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

#all_apps_visibleObject

Returns the value of attribute all_apps_visible.



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

def all_apps_visible
  @all_apps_visible
end

#emailObject

Returns the value of attribute email.



11
12
13
# File 'spaceship/lib/spaceship/connect_api/models/user_invitation.rb', line 11

def email
  @email
end

#first_nameObject

Returns the value of attribute first_name.



9
10
11
# File 'spaceship/lib/spaceship/connect_api/models/user_invitation.rb', line 9

def first_name
  @first_name
end

#last_nameObject

Returns the value of attribute last_name.



10
11
12
# File 'spaceship/lib/spaceship/connect_api/models/user_invitation.rb', line 10

def last_name
  @last_name
end

#provisioning_allowedObject

Returns the value of attribute provisioning_allowed.



14
15
16
# File 'spaceship/lib/spaceship/connect_api/models/user_invitation.rb', line 14

def provisioning_allowed
  @provisioning_allowed
end

#rolesObject

Returns the value of attribute roles.



12
13
14
# File 'spaceship/lib/spaceship/connect_api/models/user_invitation.rb', line 12

def roles
  @roles
end

#visible_appsObject

Returns the value of attribute visible_apps.



16
17
18
# File 'spaceship/lib/spaceship/connect_api/models/user_invitation.rb', line 16

def visible_apps
  @visible_apps
end

Class Method Details

.all(client: nil, filter: {}, includes: ESSENTIAL_INCLUDES, sort: nil) ⇒ Object

Managing invitations



43
44
45
46
47
# File 'spaceship/lib/spaceship/connect_api/models/user_invitation.rb', line 43

def self.all(client: nil, filter: {}, includes: ESSENTIAL_INCLUDES, sort: nil)
  client ||= Spaceship::ConnectAPI
  resps = client.get_user_invitations(filter: filter, includes: includes, sort: sort).all_pages
  return resps.flat_map(&:to_models)
end

.create(client: nil, email: nil, first_name: nil, last_name: nil, roles: [], provisioning_allowed: nil, all_apps_visible: nil, visible_app_ids: []) ⇒ Object

Create and post user invitation App Store Connect allows for the following combinations of ‘all_apps_visible` and `visible_app_ids`:

  • if ‘all_apps_visible` is `nil`, you don’t have to provide values for ‘visible_app_ids`

  • if ‘all_apps_visible` is false, you must provide values for `visible_app_ids`.

  • if ‘all_apps_visible` is true, you must not provide values for `visible_app_ids`.



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'spaceship/lib/spaceship/connect_api/models/user_invitation.rb', line 59

def self.create(client: nil, email: nil, first_name: nil, last_name: nil, roles: [], provisioning_allowed: nil, all_apps_visible: nil, visible_app_ids: [])
  client ||= Spaceship::ConnectAPI
  resp = client.post_user_invitation(
    email: email,
    first_name: first_name,
    last_name: last_name,
    roles: roles,
    provisioning_allowed: provisioning_allowed,
    all_apps_visible: all_apps_visible,
    visible_app_ids: visible_app_ids
  )
  return resp.to_models.first
end

.find(client: nil, email: nil, includes: ESSENTIAL_INCLUDES) ⇒ Object



49
50
51
52
# File 'spaceship/lib/spaceship/connect_api/models/user_invitation.rb', line 49

def self.find(client: nil, email: nil, includes: ESSENTIAL_INCLUDES)
  client ||= Spaceship::ConnectAPI
  return all(client: client, filter: { email: email }, includes: includes)
end

.typeObject



35
36
37
# File 'spaceship/lib/spaceship/connect_api/models/user_invitation.rb', line 35

def self.type
  return "userInvitations"
end

Instance Method Details

#delete!(client: nil) ⇒ Object



73
74
75
76
# File 'spaceship/lib/spaceship/connect_api/models/user_invitation.rb', line 73

def delete!(client: nil)
  client ||= Spaceship::ConnectAPI
  client.delete_user_invitation(user_invitation_id: id)
end

#get_visible_apps(client: nil, limit: nil) ⇒ Object

Get visible apps for invited user



79
80
81
82
83
# File 'spaceship/lib/spaceship/connect_api/models/user_invitation.rb', line 79

def get_visible_apps(client: nil, limit: nil)
  client ||= Spaceship::ConnectAPI
  resp = client.get_user_invitation_visible_apps(user_invitation_id: id, limit: limit)
  return resp.to_models
end