Class: Spaceship::Tunes::Application

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

Instance Attribute Summary collapse

Attributes inherited from Base

#client, #raw_data

Getting information collapse

Modifying collapse

Builds collapse

Submit for Review collapse

General collapse

Testers 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

#app_icon_preview_urlString

Returns The URL to a low resolution app icon of this app (340x340px). Might be nil.

Examples:

"https://is1-ssl.mzstatic.com/image/thumb/Purple7/v4/cd/a3/e2/cda3e2ac-4034-c6af-ee0c-3e4d9a0bafaa/pr_source.png/340x340bb-80.png"
nil

Returns:

  • (String)

    The URL to a low resolution app icon of this app (340x340px). Might be nil



41
42
43
# File 'lib/spaceship/tunes/application.rb', line 41

def app_icon_preview_url
  @app_icon_preview_url
end

#apple_idString

Returns The App identifier of this app, provided by iTunes Connect.

Examples:

"1013943394"

Returns:

  • (String)

    The App identifier of this app, provided by iTunes Connect



8
9
10
# File 'lib/spaceship/tunes/application.rb', line 8

def apple_id
  @apple_id
end

#bundle_idString

Returns The bundle_id (app identifier) of your app.

Examples:

"com.krausefx.app"

Returns:

  • (String)

    The bundle_id (app identifier) of your app



28
29
30
# File 'lib/spaceship/tunes/application.rb', line 28

def bundle_id
  @bundle_id
end

#issues_countInteger

Returns The number of issues provided by iTunes Connect.

Returns:

  • (Integer)

    The number of issues provided by iTunes Connect



34
35
36
# File 'lib/spaceship/tunes/application.rb', line 34

def issues_count
  @issues_count
end

#last_modifiedString

Returns Last modified.

Returns:



31
32
33
# File 'lib/spaceship/tunes/application.rb', line 31

def last_modified
  @last_modified
end

#nameString

Returns The name you provided for this app (in the default language).

Examples:

"Spaceship App"

Returns:

  • (String)

    The name you provided for this app (in the default language)



13
14
15
# File 'lib/spaceship/tunes/application.rb', line 13

def name
  @name
end

#platformString

Returns the supported platform of this app.

Examples:

"ios"

Returns:

  • (String)

    the supported platform of this app



18
19
20
# File 'lib/spaceship/tunes/application.rb', line 18

def platform
  @platform
end

#vendor_idString

Returns The Vendor ID provided by iTunes Connect.

Examples:

"1435592086"

Returns:

  • (String)

    The Vendor ID provided by iTunes Connect



23
24
25
# File 'lib/spaceship/tunes/application.rb', line 23

def vendor_id
  @vendor_id
end

Class Method Details

.allArray

Returns all apps available for this account

Returns:

  • (Array)

    Returns all apps available for this account



62
63
64
# File 'lib/spaceship/tunes/application.rb', line 62

def all
  client.applications.map { |application| self.factory(application) }
end

.create!(name: nil, primary_language: nil, version: nil, sku: nil, bundle_id: nil, bundle_id_suffix: nil, company_name: nil) ⇒ Object

Creates a new application on iTunes Connect It cannot be changed after you create your first app.

Parameters:

  • name (String) (defaults to: nil)

    : The name of your app as it will appear on the App Store. This can’t be longer than 255 characters.

  • primary_language (String) (defaults to: nil)

    : If localized app information isn’t available in an App Store territory, the information from your primary language will be used instead.

  • version (String) (defaults to: nil)

    : The version number is shown on the App Store and should match the one you used in Xcode.

  • sku (String) (defaults to: nil)

    : A unique ID for your app that is not visible on the App Store.

  • bundle_id (String) (defaults to: nil)

    : The bundle ID must match the one you used in Xcode. It can’t be changed after you submit your first build.

  • company_name (String) (defaults to: nil)

    : The company name or developer name to display on the App Store for your apps.



86
87
88
89
90
91
92
93
94
# File 'lib/spaceship/tunes/application.rb', line 86

def create!(name: nil, primary_language: nil, version: nil, sku: nil, bundle_id: nil, bundle_id_suffix: nil, company_name: nil)
  client.create_application!(name: name,
                 primary_language: primary_language,
                          version: version,
                              sku: sku,
                        bundle_id: bundle_id,
                        bundle_id_suffix: bundle_id_suffix,
                        company_name: company_name)
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.



57
58
59
# File 'lib/spaceship/tunes/application.rb', line 57

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

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

Returns the application matching the parameter as either the App ID or the bundle identifier

Returns:



68
69
70
71
72
# File 'lib/spaceship/tunes/application.rb', line 68

def find(identifier)
  all.find do |app|
    (app.apple_id == identifier.to_s or app.bundle_id == identifier)
  end
end

Instance Method Details

#add_all_testers!Object

Add all testers (internal and external) to the current app list



243
244
245
246
# File 'lib/spaceship/tunes/application.rb', line 243

def add_all_testers!
  Tunes::Tester.external.add_all_to_app!(self.apple_id)
  Tunes::Tester.internal.add_all_to_app!(self.apple_id)
end

#add_external_tester!(email: nil, first_name: nil, last_name: nil) ⇒ Object

Add external tester to the current app list, if it doesn’t exist will be created

Parameters:

  • email (String) (defaults to: nil)

    (required): The email of the tester

  • first_name (String) (defaults to: nil)

    (optional): The first name of the tester (Ignored if user already exist)

  • last_name (String) (defaults to: nil)

    (optional): The last name of the tester (Ignored if user already exist)



276
277
278
279
280
281
282
283
# File 'lib/spaceship/tunes/application.rb', line 276

def add_external_tester!(email: nil, first_name: nil, last_name: nil)
  raise "Tester is already on #{self.name} betatesters" if find_external_tester(email)

  tester = Tunes::Tester.external.find(email) || Tunes::Tester.external.create!(email: email,
                                                                           first_name: first_name,
                                                                            last_name: last_name)
  tester.add_to_app!(self.apple_id)
end

#all_processing_buildsArray

Returns This will return an array of all processing builds this include pre-processing or standard processing.

Returns:

  • (Array)

    This will return an array of all processing builds this include pre-processing or standard processing



182
183
184
185
186
187
188
189
190
191
192
# File 'lib/spaceship/tunes/application.rb', line 182

def all_processing_builds
  builds = self.pre_processing_builds

  self.build_trains.each do |version_number, train|
    train.processing_builds.each do |build|
      builds << build
    end
  end

  return builds
end

#build_trainsHash

A reference to all the build trains

Returns:

  • (Hash)

    a hash, the version number being the key



160
161
162
# File 'lib/spaceship/tunes/application.rb', line 160

def build_trains
  Tunes::BuildTrain.all(self, self.apple_id)
end

#buildsObject

Get all builds that are already processed for all build trains You can either use the return value (array) or pass a block



196
197
198
199
200
201
202
203
204
205
# File 'lib/spaceship/tunes/application.rb', line 196

def builds
  all_builds = []
  self.build_trains.each do |version_number, train|
    train.builds.each do |build|
      yield(build) if block_given?
      all_builds << build unless block_given?
    end
  end
  all_builds
end

#cancel_all_testflight_submissions!Object

Cancels all ongoing TestFlight beta submission for this application



221
222
223
224
225
226
227
228
229
230
# File 'lib/spaceship/tunes/application.rb', line 221

def cancel_all_testflight_submissions!
  self.builds do |build|
    begin
      build.cancel_beta_review!
    rescue
      # We really don't care about any errors here
    end
  end
  true
end

#create_submissionObject



211
212
213
214
215
216
217
218
# File 'lib/spaceship/tunes/application.rb', line 211

def create_submission
  version = self.latest_version
  if version.nil?
    raise "Could not find a valid version to submit for review"
  end

  Spaceship::AppSubmission.create(self, version)
end

#create_version!(version_number) ⇒ Object

Create a new version of your app Since we have stored the outdated raw_data, we need to refresh this object otherwise ‘edit_version` will return nil



144
145
146
147
148
149
150
151
152
# File 'lib/spaceship/tunes/application.rb', line 144

def create_version!(version_number)
  if edit_version
    raise "Cannot create a new version for this app as there already is an `edit_version` available"
  end

  client.create_version!(apple_id, version_number)

  # Future: implemented -reload method
end

#edit_versionSpaceship::AppVersion

Returns Receive the version that can fully be edited.

Returns:



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

def edit_version
  # Apple's server will respond with the same version if there is only one, for both v=live and v=
  # That's why we have to check in the app_summary.json request if there are 2 versions or just one
  # if there is only one version, we'll return nil
  if raw_data['versions'].count == 1
    return nil # only live version, user should create a new version
  end

  Spaceship::AppVersion.find(self, self.apple_id, false)
end

#external_testersArray

Returns all external testers available for this app

Returns:

  • (Array)

    Returns all external testers available for this app



249
250
251
# File 'lib/spaceship/tunes/application.rb', line 249

def external_testers
  Tunes::Tester.external.all_by_app(self.apple_id)
end

#find_external_tester(identifier) ⇒ Spaceship::Tunes::Tester.external

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

Parameters:

  • identifier (String)

    (required): Value used to filter the tester

Returns:

  • (Spaceship::Tunes::Tester.external)

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



261
262
263
# File 'lib/spaceship/tunes/application.rb', line 261

def find_external_tester(identifier)
  Tunes::Tester.external.find_by_app(self.apple_id, identifier)
end

#find_internal_tester(identifier) ⇒ Spaceship::Tunes::Tester.internal

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

Parameters:

  • identifier (String)

    (required): Value used to filter the tester

Returns:

  • (Spaceship::Tunes::Tester.internal)

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



268
269
270
# File 'lib/spaceship/tunes/application.rb', line 268

def find_internal_tester(identifier)
  Tunes::Tester.internal.find_by_app(self.apple_id, identifier)
end

#internal_testersArray

Returns all internal testers available for this app

Returns:

  • (Array)

    Returns all internal testers available for this app



254
255
256
# File 'lib/spaceship/tunes/application.rb', line 254

def internal_testers
  Tunes::Tester.internal.all_by_app(self.apple_id)
end

#latest_versionSpaceship::AppVersion

Returns This will return the ‘edit_version` if available and fallback to the `edit_version`. Use this to just access the latest data.

Returns:

  • (Spaceship::AppVersion)

    This will return the ‘edit_version` if available and fallback to the `edit_version`. Use this to just access the latest data



121
122
123
# File 'lib/spaceship/tunes/application.rb', line 121

def latest_version
  edit_version || live_version
end

#live_versionSpaceship::AppVersion

Returns Receive the version that is currently live on the App Store. You can’t modify all values there, so be careful.

Returns:

  • (Spaceship::AppVersion)

    Receive the version that is currently live on the App Store. You can’t modify all values there, so be careful.



103
104
105
# File 'lib/spaceship/tunes/application.rb', line 103

def live_version
  Spaceship::AppVersion.find(self, self.apple_id, true)
end

#pre_processing_buildsArray

Returns A list of binaries which are not even yet processing based on the version These are all build that have no information except the upload date Those builds can also be the builds that are stuck on iTC.

Returns:

  • (Array)

    A list of binaries which are not even yet processing based on the version These are all build that have no information except the upload date Those builds can also be the builds that are stuck on iTC.



167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/spaceship/tunes/application.rb', line 167

def pre_processing_builds
  data = client.build_trains(apple_id) # we need to fetch all trains here to get the builds

  builds = data.fetch('processingBuilds', []).collect do |attrs|
    attrs.merge!(build_train: self)
    Tunes::ProcessingBuild.factory(attrs)
  end

  builds.delete_if { |a| a.state == "ITC.apps.betaProcessingStatus.InvalidBinary" }

  builds
end

#remove_external_tester!(identifier) ⇒ Object

Remove external tester from the current app list that matching the parameter

as either the Tester id or email

Parameters:

  • identifier (String)

    (required): Value used to filter the tester



288
289
290
291
292
293
294
# File 'lib/spaceship/tunes/application.rb', line 288

def remove_external_tester!(identifier)
  tester = find_external_tester(identifier)

  raise "Tester is not on #{self.name} betatesters" unless tester

  tester.remove_from_app!(self.apple_id)
end

#resolution_centerHash

Returns Contains the reason for rejection. if everything is alright, the result will be ‘“sectionInfoKeys”=>[], “sectionWarningKeys”=>[], “replyConstraints”=>{“minLength”=>1, “maxLength”=>4000, “appNotes”=>“threads”=>[], “betaNotes”=>“threads”=>[], “appMessages”=>“threads”=>[]}`.

Returns:

  • (Hash)

    Contains the reason for rejection. if everything is alright, the result will be ‘“sectionInfoKeys”=>[], “sectionWarningKeys”=>[], “replyConstraints”=>{“minLength”=>1, “maxLength”=>4000, “appNotes”=>“threads”=>[], “betaNotes”=>“threads”=>[], “appMessages”=>“threads”=>[]}`



133
134
135
# File 'lib/spaceship/tunes/application.rb', line 133

def resolution_center
  client.get_resolution_center(apple_id)
end

#setupObject



235
236
# File 'lib/spaceship/tunes/application.rb', line 235

def setup
end

#urlString

Returns An URL to this specific resource. You can enter this URL into your browser.

Returns:

  • (String)

    An URL to this specific resource. You can enter this URL into your browser



126
127
128
# File 'lib/spaceship/tunes/application.rb', line 126

def url
  "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/#{self.apple_id}"
end