Class: Spaceship::Tunes::Tester

Inherits:
TunesBase show all
Defined in:
lib/spaceship/tunes/tester.rb

Direct Known Subclasses

External, Internal

Defined Under Namespace

Classes: External, Internal

Instance Attribute Summary collapse

Attributes inherited from Base

#client, #raw_data

App collapse

Subclasses collapse

Helpers collapse

Class Method Summary collapse

Methods inherited from TunesBase

client

Methods inherited from Base

attr_accessor, attr_mapping, #attributes, attributes, #initialize, #inspect, mapping_module, method_missing, set_client, #to_s

Constructor Details

This class inherits a constructor from Spaceship::Base

Instance Attribute Details

#devicesArray

Returns An array of registered devices for this user.

Examples:

[{
  "model": "iPhone 6",
  "os": "iOS",
  "osVersion": "8.3",
  "name": null
}]

Returns:

  • (Array)

    An array of registered devices for this user



42
43
44
# File 'lib/spaceship/tunes/tester.rb', line 42

def devices
  @devices
end

#emailString

Returns The email of this tester.

Examples:

"[email protected]"

Returns:

  • (String)

    The email of this tester



12
13
14
# File 'lib/spaceship/tunes/tester.rb', line 12

def email
  @email
end

#first_nameString

Returns The first name of this tester.

Examples:

"Cary"

Returns:

  • (String)

    The first name of this tester



17
18
19
# File 'lib/spaceship/tunes/tester.rb', line 17

def first_name
  @first_name
end

#groupsArray

Returns an array of associated groups.

Examples:

[{
  "id": "e031e048-4f0f-4c1e-8d8a-a5341a267986",
  "name": {
    "value": "My App Testers"
  }
}]

Returns:

  • (Array)

    an array of associated groups



32
33
34
# File 'lib/spaceship/tunes/tester.rb', line 32

def groups
  @groups
end

#last_nameString

Returns The last name of this tester.

Examples:

"Bennett"

Returns:

  • (String)

    The last name of this tester



22
23
24
# File 'lib/spaceship/tunes/tester.rb', line 22

def last_name
  @last_name
end

#latest_install_app_idInteger

Information about the most recent beta install

Returns:

  • (Integer)

    The ID of the most recently installed app



46
47
48
# File 'lib/spaceship/tunes/tester.rb', line 46

def latest_install_app_id
  @latest_install_app_id
end

#latest_install_dateInteger

Returns Date of the last install of this tester Number of seconds since 1970.

Returns:

  • (Integer)

    Date of the last install of this tester Number of seconds since 1970



50
51
52
# File 'lib/spaceship/tunes/tester.rb', line 50

def latest_install_date
  @latest_install_date
end

#latest_installed_build_numberInteger

Returns The build number of the last installed build.

Returns:

  • (Integer)

    The build number of the last installed build



53
54
55
# File 'lib/spaceship/tunes/tester.rb', line 53

def latest_installed_build_number
  @latest_installed_build_number
end

#latest_installed_version_numberInteger

Returns The version number of the last installed build.

Returns:

  • (Integer)

    The version number of the last installed build



56
57
58
# File 'lib/spaceship/tunes/tester.rb', line 56

def latest_installed_version_number
  @latest_installed_version_number
end

#tester_idString

Returns The identifier of this tester, provided by iTunes Connect.

Examples:

"60f858b4-60a8-428a-963a-f943a3d68d17"

Returns:

  • (String)

    The identifier of this tester, provided by iTunes Connect



7
8
9
# File 'lib/spaceship/tunes/tester.rb', line 7

def tester_id
  @tester_id
end

Class Method Details

.add_all_to_app!(app_id) ⇒ Object

Add all testers to the app received

Parameters:

  • app_id (String)

    (required): The app id to filter the testers



140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/spaceship/tunes/tester.rb', line 140

def add_all_to_app!(app_id)
  all.each do |tester|
    begin
      tester.add_to_app!(app_id)
    rescue => ex
      if ex.to_s.include? "testerEmailExistsInternal" or ex.to_s.include? "duplicate.email"
        # That's a non-relevant error message by iTC
        # ignore that
      else
        raise ex
      end
    end
  end
end

.allArray

Returns all beta testers available for this account

Returns:

  • (Array)

    Returns all beta testers available for this account



84
85
86
# File 'lib/spaceship/tunes/tester.rb', line 84

def all
  client.testers(self).map { |tester| self.factory(tester) }
end

.all_by_app(app_id) ⇒ Array

Returns all beta testers available for this account filtered by app

Parameters:

  • app_id (String)

    (required): The app id to filter the testers

Returns:

  • (Array)

    Returns all beta testers available for this account filtered by app



124
125
126
# File 'lib/spaceship/tunes/tester.rb', line 124

def all_by_app(app_id)
  client.testers_by_app(self, app_id).map { |tester| self.factory(tester) }
end

.create!(email: nil, first_name: nil, last_name: nil, groups: nil) ⇒ Tester

Create new tester in iTunes Connect

Examples:

Spaceship::Tunes::Tester.external.create!(email: "[email protected]", first_name: "Cary", last_name:"Bennett", groups:["Testers"])

Parameters:

  • email (String) (defaults to: nil)

    (required): The email of the new tester

  • first_name (String) (defaults to: nil)

    (optional): The first name of the new tester

  • last_name (String) (defaults to: nil)

    (optional): The last name of the new tester

  • groups (Array) (defaults to: nil)

    (option): Names/IDs of existing groups for the new tester

Returns:

  • (Tester)

    : The newly created tester



109
110
111
112
113
114
115
116
# File 'lib/spaceship/tunes/tester.rb', line 109

def create!(email: nil, first_name: nil, last_name: nil, groups: nil)
  data = client.create_tester!(tester: self,
                                email: email,
                           first_name: first_name,
                            last_name: last_name,
                               groups: groups)
  self.factory(data)
end

.factory(attrs) ⇒ Object

Create a new object based on a hash. This is used to create a new object based on the server response.



79
80
81
# File 'lib/spaceship/tunes/tester.rb', line 79

def factory(attrs)
  self.new(attrs)
end

.find(identifier) ⇒ Spaceship::Tunes::Tester

Returns the tester matching the parameter as either the Tester id or email

Parameters:

  • identifier (String)

    (required): Value used to filter the tester, case insensitive

Returns:



91
92
93
94
95
# File 'lib/spaceship/tunes/tester.rb', line 91

def find(identifier)
  all.find do |tester|
    (tester.tester_id.to_s.casecmp(identifier.to_s).zero? or tester.email.to_s.casecmp(identifier.to_s).zero?)
  end
end

.find_by_app(app_id, identifier) ⇒ Spaceship::Tunes::Tester

Returns the tester matching the parameter as either the Tester id or email

Parameters:

  • app_id (String)

    (required): The app id to filter the testers

  • identifier (String)

    (required): Value used to filter the tester, case insensitive

Returns:



132
133
134
135
136
# File 'lib/spaceship/tunes/tester.rb', line 132

def find_by_app(app_id, identifier)
  all_by_app(app_id).find do |tester|
    (tester.tester_id.to_s.casecmp(identifier.to_s).zero? or tester.email.to_s.casecmp(identifier.to_s).zero?)
  end
end

.groupsObject



97
98
99
# File 'lib/spaceship/tunes/tester.rb', line 97

def groups
  client.groups
end

.urlHash

Returns All urls for the ITC used for web requests.

Returns:

  • (Hash)

    All urls for the ITC used for web requests



73
74
75
# File 'lib/spaceship/tunes/tester.rb', line 73

def url
  raise "You have to use a subclass: Internal or External"
end

Instance Method Details

#add_to_app!(app_id) ⇒ Object

Add current tester to list of the app testers

Parameters:

  • app_id (String)

    (required): The id of the application to which want to modify the list



198
199
200
# File 'lib/spaceship/tunes/tester.rb', line 198

def add_to_app!(app_id)
  client.add_tester_to_app!(self, app_id)
end

#delete!Object

Delete current tester



188
189
190
# File 'lib/spaceship/tunes/tester.rb', line 188

def delete!
  client.delete_tester!(self)
end

#groups_list(separator = ', ') ⇒ Object

Return a list of the Tester’s group, if any

Returns:



214
215
216
217
218
219
# File 'lib/spaceship/tunes/tester.rb', line 214

def groups_list(separator = ', ')
  if groups
    group_names = groups.map { |group| group["name"]["value"] }
    group_names.join(separator)
  end
end

#remove_from_app!(app_id) ⇒ Object

Remove current tester from list of the app testers

Parameters:

  • app_id (String)

    (required): The id of the application to which want to modify the list



204
205
206
# File 'lib/spaceship/tunes/tester.rb', line 204

def remove_from_app!(app_id)
  client.remove_tester_from_app!(self, app_id)
end

#setupObject



156
157
158
# File 'lib/spaceship/tunes/tester.rb', line 156

def setup
  self.devices ||= [] # by default, an empty array instead of nil
end