Class: Spaceship::Tunes::Application
- Defined in:
- lib/spaceship/tunes/application.rb
Instance Attribute Summary collapse
-
#app_icon_preview_url ⇒ String
The URL to a low resolution app icon of this app (340x340px).
-
#apple_id ⇒ String
The App identifier of this app, provided by iTunes Connect.
-
#bundle_id ⇒ String
The bundle_id (app identifier) of your app.
-
#issues_count ⇒ Integer
The number of issues provided by iTunes Connect.
-
#last_modified ⇒ String
Last modified.
-
#name ⇒ String
The name you provided for this app (in the default language).
-
#vendor_id ⇒ String
The Vendor ID provided by iTunes Connect.
Attributes inherited from Base
Getting information collapse
- #details ⇒ Object
-
#edit_version ⇒ Spaceship::AppVersion
Receive the version that can fully be edited.
-
#latest_version ⇒ Spaceship::AppVersion
This will return the ‘edit_version` if available and fallback to the `live_version`.
-
#live_version ⇒ Spaceship::AppVersion
Receive the version that is currently live on the App Store.
-
#platform ⇒ Object
kept for backward compatibility tries to guess the platform of the currently submitted apps note that as ITC now supports multiple app types, this might break if your app supports more than one.
- #ratings ⇒ Object
-
#resolution_center ⇒ Hash
Contains the reason for rejection.
-
#url ⇒ String
An URL to this specific resource.
- #versions_history ⇒ Object
Modifying collapse
-
#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.
-
#ensure_version!(version_number) ⇒ Bool
Will make sure the current edit_version matches the given version number This will either create a new version or change the version number from an existing version.
-
#price_tier ⇒ Object
The current price tier.
-
#update_price_tier!(price_tier) ⇒ Object
set the price tier.
Builds collapse
-
#all_build_train_numbers(platform: nil) ⇒ Array
The numbers of all build trains that were uploaded.
-
#all_builds_for_train(train: nil, platform: nil) ⇒ Object
Receive the build details for a specific build useful if the app is not listed in the TestFlight build list which might happen if you don’t use TestFlight This is used to receive dSYM files from Apple.
-
#all_invalid_builds ⇒ Array
A list of all builds in an invalid state.
-
#all_processing_builds ⇒ Array
This will return an array of all processing builds this include pre-processing or standard processing.
-
#build_trains ⇒ Hash
TestFlight: A reference to all the build trains.
-
#builds ⇒ Object
Get all builds that are already processed for all build trains You can either use the return value (array) or pass a block.
Submit for Review collapse
-
#cancel_all_testflight_submissions! ⇒ Object
Cancels all ongoing TestFlight beta submission for this application.
- #create_submission ⇒ Object
release collapse
General collapse
Testers collapse
-
#add_all_testers! ⇒ Object
Add all testers (internal and external) to the current app list.
-
#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.
-
#external_testers ⇒ Array
Returns all external testers available for this app.
-
#find_external_tester(identifier) ⇒ Spaceship::Tunes::Tester.external
Returns the external tester matching the parameter as either the Tester id or email.
-
#find_internal_tester(identifier) ⇒ Spaceship::Tunes::Tester.internal
Returns the internal tester matching the parameter as either the Tester id or email.
-
#internal_testers ⇒ Array
Returns all internal testers available for this app.
-
#remove_external_tester!(identifier) ⇒ Object
Remove external tester from the current app list that matching the parameter as either the Tester id or email.
Promo codes collapse
-
#ensure_not_a_bundle ⇒ Object
private to module.
- #promocodes ⇒ Object
- #promocodes_history ⇒ Object
Class Method Summary collapse
-
.all ⇒ Array
Returns all apps available for this account.
-
.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.
-
.factory(attrs) ⇒ Object
Create a new object based on a hash.
-
.find(identifier) ⇒ Spaceship::Tunes::Application
Returns the application matching the parameter as either the App ID or the bundle identifier.
Methods inherited from TunesBase
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_url ⇒ String
Returns The URL to a low resolution app icon of this app (340x340px). Might be nil.
35 36 37 |
# File 'lib/spaceship/tunes/application.rb', line 35 def app_icon_preview_url @app_icon_preview_url end |
#apple_id ⇒ String
Returns The App identifier of this app, provided by iTunes Connect.
7 8 9 |
# File 'lib/spaceship/tunes/application.rb', line 7 def apple_id @apple_id end |
#bundle_id ⇒ String
Returns The bundle_id (app identifier) of your app.
22 23 24 |
# File 'lib/spaceship/tunes/application.rb', line 22 def bundle_id @bundle_id end |
#issues_count ⇒ Integer
Returns The number of issues provided by iTunes Connect.
28 29 30 |
# File 'lib/spaceship/tunes/application.rb', line 28 def issues_count @issues_count end |
#last_modified ⇒ String
Returns Last modified.
25 26 27 |
# File 'lib/spaceship/tunes/application.rb', line 25 def last_modified @last_modified end |
#name ⇒ String
Returns The name you provided for this app (in the default language).
12 13 14 |
# File 'lib/spaceship/tunes/application.rb', line 12 def name @name end |
#vendor_id ⇒ String
Returns The Vendor ID provided by iTunes Connect.
17 18 19 |
# File 'lib/spaceship/tunes/application.rb', line 17 def vendor_id @vendor_id end |
Class Method Details
.all ⇒ Array
Returns all apps available for this account
55 56 57 |
# File 'lib/spaceship/tunes/application.rb', line 55 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.
79 80 81 82 83 84 85 86 87 |
# File 'lib/spaceship/tunes/application.rb', line 79 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.
50 51 52 |
# File 'lib/spaceship/tunes/application.rb', line 50 def factory(attrs) return self.new(attrs) end |
.find(identifier) ⇒ Spaceship::Tunes::Application
Returns the application matching the parameter as either the App ID or the bundle identifier
61 62 63 64 65 |
# File 'lib/spaceship/tunes/application.rb', line 61 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
311 312 313 314 |
# File 'lib/spaceship/tunes/application.rb', line 311 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
344 345 346 347 348 349 350 351 |
# File 'lib/spaceship/tunes/application.rb', line 344 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_build_train_numbers(platform: nil) ⇒ Array
The numbers of all build trains that were uploaded
210 211 212 213 214 |
# File 'lib/spaceship/tunes/application.rb', line 210 def all_build_train_numbers(platform: nil) client.all_build_trains(app_id: self.apple_id, platform: platform).fetch("trains").collect do |current| current["versionString"] end end |
#all_builds_for_train(train: nil, platform: nil) ⇒ Object
Receive the build details for a specific build useful if the app is not listed in the TestFlight build list which might happen if you don’t use TestFlight This is used to receive dSYM files from Apple
220 221 222 223 224 225 |
# File 'lib/spaceship/tunes/application.rb', line 220 def all_builds_for_train(train: nil, platform: nil) client.all_builds_for_train(app_id: self.apple_id, train: train, platform: platform).fetch("items", []).collect do |attrs| attrs[:apple_id] = self.apple_id Tunes::Build.factory(attrs) end end |
#all_invalid_builds ⇒ Array
Returns A list of all builds in an invalid state.
228 229 230 231 232 233 234 235 236 |
# File 'lib/spaceship/tunes/application.rb', line 228 def all_invalid_builds builds = [] self.build_trains.values.each do |train| builds.concat(train.invalid_builds) end return builds end |
#all_processing_builds ⇒ Array
Returns This will return an array of all processing builds this include pre-processing or standard processing.
240 241 242 243 244 245 246 247 248 |
# File 'lib/spaceship/tunes/application.rb', line 240 def all_processing_builds builds = [] self.build_trains.values.each do |train| builds.concat(train.processing_builds) end return builds end |
#build_trains ⇒ Hash
TestFlight: A reference to all the build trains
204 205 206 |
# File 'lib/spaceship/tunes/application.rb', line 204 def build_trains Tunes::BuildTrain.all(self, self.apple_id) end |
#builds ⇒ Object
Get all builds that are already processed for all build trains You can either use the return value (array) or pass a block
252 253 254 255 256 257 258 259 260 261 |
# File 'lib/spaceship/tunes/application.rb', line 252 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
277 278 279 280 281 282 283 284 285 286 |
# File 'lib/spaceship/tunes/application.rb', line 277 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_submission ⇒ Object
267 268 269 270 271 272 273 274 |
# File 'lib/spaceship/tunes/application.rb', line 267 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
159 160 161 162 163 164 165 166 167 |
# File 'lib/spaceship/tunes/application.rb', line 159 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 |
#details ⇒ Object
137 138 139 140 141 |
# File 'lib/spaceship/tunes/application.rb', line 137 def details attrs = client.app_details(apple_id) attrs[:application] = self Tunes::AppDetails.factory(attrs) end |
#edit_version ⇒ Spaceship::AppVersion
Returns Receive the version that can fully be edited.
101 102 103 |
# File 'lib/spaceship/tunes/application.rb', line 101 def edit_version Spaceship::AppVersion.find(self, self.apple_id, false) end |
#ensure_not_a_bundle ⇒ Object
private to module
382 383 384 385 386 |
# File 'lib/spaceship/tunes/application.rb', line 382 def ensure_not_a_bundle # we only support applications platform = Spaceship::Tunes::AppVersionCommon.find_platform(raw_data['versionSets']) raise "We do not support BUNDLE types right now" if platform['type'] == 'BUNDLE' end |
#ensure_version!(version_number) ⇒ Bool
Will make sure the current edit_version matches the given version number This will either create a new version or change the version number from an existing version
173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/spaceship/tunes/application.rb', line 173 def ensure_version!(version_number) if (e = edit_version) if e.version.to_s != version_number.to_s # Update an existing version e.version = version_number e.save! return true end return false else create_version!(version_number) return true end end |
#external_testers ⇒ Array
Returns all external testers available for this app
317 318 319 |
# File 'lib/spaceship/tunes/application.rb', line 317 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
329 330 331 |
# File 'lib/spaceship/tunes/application.rb', line 329 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
336 337 338 |
# File 'lib/spaceship/tunes/application.rb', line 336 def find_internal_tester(identifier) Tunes::Tester.internal.find_by_app(self.apple_id, identifier) end |
#internal_testers ⇒ Array
Returns all internal testers available for this app
322 323 324 |
# File 'lib/spaceship/tunes/application.rb', line 322 def internal_testers Tunes::Tester.internal.all_by_app(self.apple_id) end |
#latest_version ⇒ Spaceship::AppVersion
Returns This will return the ‘edit_version` if available and fallback to the `live_version`. Use this to just access the latest data.
107 108 109 |
# File 'lib/spaceship/tunes/application.rb', line 107 def latest_version edit_version || live_version end |
#live_version ⇒ Spaceship::AppVersion
Returns Receive the version that is currently live on the App Store. You can’t modify all values there, so be careful.
96 97 98 |
# File 'lib/spaceship/tunes/application.rb', line 96 def live_version Spaceship::AppVersion.find(self, self.apple_id, true) end |
#platform ⇒ Object
kept for backward compatibility tries to guess the platform of the currently submitted apps note that as ITC now supports multiple app types, this might break if your app supports more than one
133 134 135 |
# File 'lib/spaceship/tunes/application.rb', line 133 def platform Spaceship::Tunes::AppVersionCommon.find_platform(raw_data['versionSets'])['platformString'] end |
#price_tier ⇒ Object
The current price tier
194 195 196 |
# File 'lib/spaceship/tunes/application.rb', line 194 def price_tier client.price_tier(self.apple_id) end |
#promocodes ⇒ Object
367 368 369 370 371 372 |
# File 'lib/spaceship/tunes/application.rb', line 367 def promocodes data = client.app_promocodes(app_id: self.apple_id) data.map do |attrs| Tunes::AppVersionPromocodes.factory(attrs) end end |
#promocodes_history ⇒ Object
374 375 376 377 378 379 |
# File 'lib/spaceship/tunes/application.rb', line 374 def promocodes_history data = client.app_promocodes_history(app_id: self.apple_id) data.map do |attrs| Tunes::AppVersionGeneratedPromocodes.factory(attrs) end end |
#ratings ⇒ Object
123 124 125 126 127 |
# File 'lib/spaceship/tunes/application.rb', line 123 def attrs = client.(apple_id, platform) attrs[:application] = self Tunes::AppRatings.factory(attrs) end |
#release! ⇒ Object
292 293 294 295 296 297 298 |
# File 'lib/spaceship/tunes/application.rb', line 292 def release! version = self.edit_version if version.nil? raise "Could not find a valid version to release" end version.release! 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
356 357 358 359 360 361 362 |
# File 'lib/spaceship/tunes/application.rb', line 356 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_center ⇒ Hash
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”=>[]}`.
119 120 121 |
# File 'lib/spaceship/tunes/application.rb', line 119 def resolution_center client.get_resolution_center(apple_id, platform) end |
#setup ⇒ Object
303 304 |
# File 'lib/spaceship/tunes/application.rb', line 303 def setup end |
#update_price_tier!(price_tier) ⇒ Object
set the price tier. This method doesn’t require ‘save` to be called
189 190 191 |
# File 'lib/spaceship/tunes/application.rb', line 189 def update_price_tier!(price_tier) client.update_price_tier!(self.apple_id, price_tier) end |
#url ⇒ String
Returns An URL to this specific resource. You can enter this URL into your browser.
112 113 114 |
# File 'lib/spaceship/tunes/application.rb', line 112 def url "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/#{self.apple_id}" end |
#versions_history ⇒ Object
143 144 145 146 147 148 149 150 |
# File 'lib/spaceship/tunes/application.rb', line 143 def versions_history ensure_not_a_bundle versions = client.versions_history(apple_id, platform) versions.map do |attrs| attrs[:application] = self Tunes::AppVersionHistory.factory(attrs) end end |