From eeb0f6e38c17f1076c12577821682d0febb1021d Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Thu, 24 Sep 2015 14:44:09 -0700 Subject: [PATCH 01/15] WIP --- Rakefile | 13 +++++++++++++ lib/spaceship/client.rb | 2 +- lib/spaceship/tunes/app_version.rb | 1 + lib/spaceship/tunes/application.rb | 7 ++++--- lib/spaceship/tunes/language_item.rb | 2 ++ lib/spaceship/tunes/tunes_client.rb | 14 +++++++++++--- 6 files changed, 32 insertions(+), 7 deletions(-) diff --git a/Rakefile b/Rakefile index bf203bd..012f831 100644 --- a/Rakefile +++ b/Rakefile @@ -8,3 +8,16 @@ task default: :spec task :test do sh "../fastlane/bin/fastlane test" end + +task :beta do + require 'spaceship' + Spaceship::Tunes.login('flapple@krausefx.com') + app = Spaceship::Application.find("tools.fastlane.app") + require 'pry' + + app.edit_version + binding.pry + # binding.pry + # puts app.live_version + # binding.pry +end \ No newline at end of file diff --git a/lib/spaceship/client.rb b/lib/spaceship/client.rb index c573038..5b9969a 100644 --- a/lib/spaceship/client.rb +++ b/lib/spaceship/client.rb @@ -67,7 +67,7 @@ def initialize # for debugging only # This enables tracking of networking requests using Charles Web Proxy c.response :logger - c.proxy "https://127.0.0.1:8888" + # c.proxy "https://127.0.0.1:8888" end end end diff --git a/lib/spaceship/tunes/app_version.rb b/lib/spaceship/tunes/app_version.rb index da13b16..56628a3 100644 --- a/lib/spaceship/tunes/app_version.rb +++ b/lib/spaceship/tunes/app_version.rb @@ -172,6 +172,7 @@ def factory(attrs) # @param is_live (Boolean) Is that the version that's live in the App Store? def find(application, app_id, is_live = false) attrs = client.app_version(app_id, is_live) + return nil unless attrs attrs.merge!(application: application) attrs.merge!(is_live: is_live) diff --git a/lib/spaceship/tunes/application.rb b/lib/spaceship/tunes/application.rb index 9e4ffc8..101219c 100644 --- a/lib/spaceship/tunes/application.rb +++ b/lib/spaceship/tunes/application.rb @@ -109,9 +109,10 @@ 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 + # if raw_data['versions'].count == 1 + # return nil # only live version, user should create a new version + # end + # TODO: Fix Spaceship::AppVersion.find(self, self.apple_id, false) end diff --git a/lib/spaceship/tunes/language_item.rb b/lib/spaceship/tunes/language_item.rb index bf31554..ea9a4ef 100644 --- a/lib/spaceship/tunes/language_item.rb +++ b/lib/spaceship/tunes/language_item.rb @@ -11,6 +11,8 @@ def initialize(identifier, ref) end def [](key) + require 'pry' + binding.pry get_lang(key)[identifier]['value'] end diff --git a/lib/spaceship/tunes/tunes_client.rb b/lib/spaceship/tunes/tunes_client.rb index 36029d3..10f3381 100644 --- a/lib/spaceship/tunes/tunes_client.rb +++ b/lib/spaceship/tunes/tunes_client.rb @@ -141,7 +141,7 @@ def handle_itc_response(raw) ##################################################### def applications - r = request(:get, 'ra/apps/manageyourapps/summary') + r = request(:get, 'ra/apps/manageyourapps/summary/v2') parse_response(r, 'data')['summaries'] end @@ -202,9 +202,17 @@ def get_resolution_center(app_id) def app_version(app_id, is_live) raise "app_id is required" unless app_id - v_text = (is_live ? 'live' : nil) + # First we need to fetch the IDs for the edit / live version + r = request(:get, "ra/apps/#{app_id}/overview") + platforms = parse_response(r, 'data')['platforms'] + + platforms = platforms.first # TODO: that won't work for mac apps + + version = platforms[(is_live ? 'deliverableVersion' : 'inFlightVersion')] + return nil unless version + version_id = version['id'] - r = request(:get, "ra/apps/version/#{app_id}", {v: v_text}) + r = request(:get, "ra/apps/#{app_id}/platforms/ios/versions/#{version_id}") parse_response(r, 'data') end From 0155288eec240e22b2a3205a00f0bdefbb81a896 Mon Sep 17 00:00:00 2001 From: KrauseFx Date: Thu, 24 Sep 2015 16:18:23 -0700 Subject: [PATCH 02/15] Added new AppDetails class for localised name and privacy url Added fetching and updating of localised app data --- docs/iTunesConnect.md | 2 +- lib/spaceship.rb | 3 +- lib/spaceship/base.rb | 4 +- lib/spaceship/client.rb | 2 +- lib/spaceship/tunes/app_details.rb | 56 ++++++++++++++++++++++++++++ lib/spaceship/tunes/app_version.rb | 16 ++------ lib/spaceship/tunes/application.rb | 8 +++- lib/spaceship/tunes/language_item.rb | 6 +-- lib/spaceship/tunes/tunes.rb | 2 + lib/spaceship/tunes/tunes_client.rb | 15 ++++++++ 10 files changed, 94 insertions(+), 20 deletions(-) create mode 100644 lib/spaceship/tunes/app_details.rb diff --git a/docs/iTunesConnect.md b/docs/iTunesConnect.md index f42147e..fdca756 100644 --- a/docs/iTunesConnect.md +++ b/docs/iTunesConnect.md @@ -72,7 +72,7 @@ v.version # => "0.9.14" v.copyright = "#{Time.now.year} Felix Krause" # Get a list of available languages for this app -v.name.keys # => ["German", "English"] +v.description.languages # => ["German", "English"] # Update localised app metadata v.name["English"] = "New Title" diff --git a/lib/spaceship.rb b/lib/spaceship.rb index a035764..eea3d20 100644 --- a/lib/spaceship.rb +++ b/lib/spaceship.rb @@ -10,7 +10,8 @@ # iTunes Connect require 'spaceship/tunes/tunes' require 'spaceship/tunes/spaceship' -require 'spaceship/tunes/tester' + +require 'pry' # To support legacy code module Spaceship diff --git a/lib/spaceship/base.rb b/lib/spaceship/base.rb index e43eb53..c1789b8 100644 --- a/lib/spaceship/base.rb +++ b/lib/spaceship/base.rb @@ -45,7 +45,9 @@ def lookup(keys) end def to_json - @hash.to_json + h = @hash.dup + h.delete(:application) + h.to_json end end diff --git a/lib/spaceship/client.rb b/lib/spaceship/client.rb index 5b9969a..c573038 100644 --- a/lib/spaceship/client.rb +++ b/lib/spaceship/client.rb @@ -67,7 +67,7 @@ def initialize # for debugging only # This enables tracking of networking requests using Charles Web Proxy c.response :logger - # c.proxy "https://127.0.0.1:8888" + c.proxy "https://127.0.0.1:8888" end end end diff --git a/lib/spaceship/tunes/app_details.rb b/lib/spaceship/tunes/app_details.rb new file mode 100644 index 0000000..d7a961f --- /dev/null +++ b/lib/spaceship/tunes/app_details.rb @@ -0,0 +1,56 @@ +module Spaceship + module Tunes + class AppDetails < TunesBase + attr_accessor :application + + #### + # Localized values + #### + + # @return (Array) Raw access the all available languages. You shouldn't use it probbaly + attr_accessor :languages + + # @return (Hash) A hash representing the app name in all languages + attr_reader :name + + # @return (Hash) A hash representing the keywords in all languages + attr_reader :privacy_url + + attr_mapping( + 'localizedMetadata.value' => :languages + ) + + class << self + # Create a new object based on a hash. + # This is used to create a new object based on the server response. + def factory(attrs) + obj = self.new(attrs) + obj.unfold_languages + + return obj + end + end + + # Prefill name, privacy url + def unfold_languages + { + name: :name, + privacyPolicyUrl: :privacy_url + }.each do |json, attribute| + instance_variable_set("@#{attribute}".to_sym, LanguageItem.new(json, languages)) + end + end + + # Push all changes that were made back to iTunes Connect + def save! + client.update_app_details!(application.apple_id, raw_data) + end + + ##################################################### + # @!group General + ##################################################### + def setup + end + end + end +end diff --git a/lib/spaceship/tunes/app_version.rb b/lib/spaceship/tunes/app_version.rb index 56628a3..1cf6d5f 100644 --- a/lib/spaceship/tunes/app_version.rb +++ b/lib/spaceship/tunes/app_version.rb @@ -100,9 +100,6 @@ class AppVersion < TunesBase # @return (Array) Raw access the all available languages. You shouldn't use it probbaly attr_accessor :languages - # @return (Hash) A hash representing the app name in all languages - attr_reader :name - # @return (Hash) A hash representing the keywords in all languages attr_reader :keywords @@ -112,9 +109,6 @@ class AppVersion < TunesBase # @return (Hash) The changelog attr_reader :release_notes - # @return (Hash) A hash representing the keywords in all languages - attr_reader :privacy_url - # @return (Hash) A hash representing the keywords in all languages attr_reader :support_url @@ -169,12 +163,12 @@ def factory(attrs) # @param application (Spaceship::Tunes::Application) The app this version is for # @param app_id (String) The unique Apple ID of this app - # @param is_live (Boolean) Is that the version that's live in the App Store? - def find(application, app_id, is_live = false) - attrs = client.app_version(app_id, is_live) + # @param version_id (String) + def find(application, app_id, version_id) + attrs = client.app_version(app_id, version_id) return nil unless attrs attrs.merge!(application: application) - attrs.merge!(is_live: is_live) + attrs.merge!(version_id: version_id) return self.factory(attrs) end @@ -247,10 +241,8 @@ def setup # Prefill name, keywords, etc... def unfold_languages { - name: :name, keywords: :keywords, description: :description, - privacyURL: :privacy_url, supportURL: :support_url, marketingURL: :marketing_url, releaseNotes: :release_notes diff --git a/lib/spaceship/tunes/application.rb b/lib/spaceship/tunes/application.rb index 101219c..379774b 100644 --- a/lib/spaceship/tunes/application.rb +++ b/lib/spaceship/tunes/application.rb @@ -55,7 +55,7 @@ class << self # Create a new object based on a hash. # This is used to create a new object based on the server response. def factory(attrs) - self.new(attrs) + return self.new(attrs) end # @return (Array) Returns all apps available for this account @@ -135,6 +135,12 @@ def resolution_center client.get_resolution_center(apple_id) end + def details + attrs = client.app_details(apple_id) + attrs.merge!(application: self) + Tunes::AppDetails.factory(attrs) + end + ##################################################### # @!group Modifying ##################################################### diff --git a/lib/spaceship/tunes/language_item.rb b/lib/spaceship/tunes/language_item.rb index ea9a4ef..3af3509 100644 --- a/lib/spaceship/tunes/language_item.rb +++ b/lib/spaceship/tunes/language_item.rb @@ -6,13 +6,13 @@ class LanguageItem attr_accessor :original_array # reference to original array def initialize(identifier, ref) + raise "ref is nil" if ref.nil? + self.identifier = identifier.to_s self.original_array = ref end def [](key) - require 'pry' - binding.pry get_lang(key)[identifier]['value'] end @@ -22,7 +22,7 @@ def []=(key, value) def get_lang(lang) result = self.original_array.find do |current| - current['language'] == lang + current['language'] == lang or current['localeCode'] == lang #  being consistent end return result if result diff --git a/lib/spaceship/tunes/tunes.rb b/lib/spaceship/tunes/tunes.rb index f71a7df..184c466 100644 --- a/lib/spaceship/tunes/tunes.rb +++ b/lib/spaceship/tunes/tunes.rb @@ -10,3 +10,5 @@ require 'spaceship/tunes/build' require 'spaceship/tunes/processing_build' require 'spaceship/tunes/build_train' +require 'spaceship/tunes/tester' +require 'spaceship/tunes/app_details' diff --git a/lib/spaceship/tunes/tunes_client.rb b/lib/spaceship/tunes/tunes_client.rb index 10f3381..62ebaa9 100644 --- a/lib/spaceship/tunes/tunes_client.rb +++ b/lib/spaceship/tunes/tunes_client.rb @@ -145,6 +145,21 @@ def applications parse_response(r, 'data')['summaries'] end + def app_details(app_id) + r = request(:get, "ra/apps/#{app_id}/details") + parse_response(r, 'data') + end + + def update_app_details!(app_id, data) + r = request(:post) do |req| + req.url "ra/apps/#{app_id}/details" + req.body = data.to_json + req.headers['Content-Type'] = 'application/json' + end + + handle_itc_response(r.body) + end + # Creates a new application on iTunes Connect # @param name (String): The name of your app as it will appear on the App Store. # This can't be longer than 255 characters. From 8bc87b4bfc2c5f13ce1ba90df5a514632953a5f1 Mon Sep 17 00:00:00 2001 From: KrauseFx Date: Thu, 24 Sep 2015 17:46:10 -0700 Subject: [PATCH 03/15] Updated create_application! to work with the new iTC --- lib/spaceship/tunes/tunes_client.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/spaceship/tunes/tunes_client.rb b/lib/spaceship/tunes/tunes_client.rb index 62ebaa9..9b686d0 100644 --- a/lib/spaceship/tunes/tunes_client.rb +++ b/lib/spaceship/tunes/tunes_client.rb @@ -172,21 +172,27 @@ def update_app_details!(app_id, data) # can't be changed after you submit your first build. def create_application!(name: nil, primary_language: nil, version: nil, sku: nil, bundle_id: nil, bundle_id_suffix: nil, company_name: nil) # First, we need to fetch the data from Apple, which we then modify with the user's values - r = request(:get, 'ra/apps/create/?appType=ios') + app_type = 'ios' + r = request(:get, "ra/apps/create/v2/?platformString=#{app_type}") data = parse_response(r, 'data') # Now fill in the values we have - data['versionString']['value'] = version - data['newApp']['name']['value'] = name + # some values are nil, that's why there is a hash + data['versionString'] = { value: version } + data['newApp']['name'] = { value: name } data['newApp']['bundleId']['value'] = bundle_id data['newApp']['primaryLanguage']['value'] = primary_language || 'English' - data['newApp']['vendorId']['value'] = sku + data['newApp']['vendorId'] = {value: sku } data['newApp']['bundleIdSuffix']['value'] = bundle_id_suffix data['companyName']['value'] = company_name if company_name + data['newApp']['appType'] = app_type + + data['initialPlatform'] = app_type + data['enabledPlatformsForCreation']['value'] = [app_type] # Now send back the modified hash r = request(:post) do |req| - req.url 'ra/apps/create/?appType=ios' + req.url 'ra/apps/create/v2' req.body = data.to_json req.headers['Content-Type'] = 'application/json' end From 92efc03e5ad0ef7d38c5a033a7fe4481e58b1ba2 Mon Sep 17 00:00:00 2001 From: KrauseFx Date: Thu, 24 Sep 2015 17:53:36 -0700 Subject: [PATCH 04/15] Updated docs for app details --- docs/iTunesConnect.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/iTunesConnect.md b/docs/iTunesConnect.md index fdca756..a3a2a24 100644 --- a/docs/iTunesConnect.md +++ b/docs/iTunesConnect.md @@ -44,6 +44,15 @@ app = Spaceship::Tunes::Application.create!(name: "App Name", bundle_id: "com.krausefx.app") ``` +To update non version specific details, use the following code + +```ruby +details = app.details +details.name['en-US'] = "App Name" +details.privacy_url['en-US'] = "https://fastlane.tools" +details.save! +``` + ## AppVersions From 2c4999906acee95744bf14c8841742ad14cfca1e Mon Sep 17 00:00:00 2001 From: KrauseFx Date: Thu, 24 Sep 2015 17:58:09 -0700 Subject: [PATCH 05/15] Moved category options into app_details --- Rakefile | 22 ++++++++++--- docs/iTunesConnect.md | 1 - lib/spaceship/tunes/app_details.rb | 53 +++++++++++++++++++++++++++++- lib/spaceship/tunes/app_version.rb | 49 --------------------------- 4 files changed, 69 insertions(+), 56 deletions(-) diff --git a/Rakefile b/Rakefile index 012f831..94576c2 100644 --- a/Rakefile +++ b/Rakefile @@ -11,13 +11,25 @@ end task :beta do require 'spaceship' + puts "Login..." Spaceship::Tunes.login('flapple@krausefx.com') app = Spaceship::Application.find("tools.fastlane.app") require 'pry' - app.edit_version - binding.pry - # binding.pry - # puts app.live_version - # binding.pry + # puts app.name["en-US"] + # puts app.privacy_url["en-US"] + + details = app.details + details.name['en-US'] = "Updated by fastlane" + details.privacy_url['en-US'] = "https://fastlane.tools" + details.primary_category = 'Sports' + details.secondary_category = 'Family' + details.save! + + # v = app.edit_version + + # puts v.marketing_url['de-DE'] + # v.marketing_url['en-US'] = "https://neu.com" + # v.marketing_url['de-DE'] = "https://suchdeutsch.com" + end \ No newline at end of file diff --git a/docs/iTunesConnect.md b/docs/iTunesConnect.md index a3a2a24..23f650e 100644 --- a/docs/iTunesConnect.md +++ b/docs/iTunesConnect.md @@ -143,7 +143,6 @@ attr_reader :name attr_reader :keywords attr_reader :description attr_reader :release_notes -attr_reader :privacy_url attr_reader :support_url attr_reader :marketing_url attr_reader :screenshots diff --git a/lib/spaceship/tunes/app_details.rb b/lib/spaceship/tunes/app_details.rb index d7a961f..2573c01 100644 --- a/lib/spaceship/tunes/app_details.rb +++ b/lib/spaceship/tunes/app_details.rb @@ -16,8 +16,27 @@ class AppDetails < TunesBase # @return (Hash) A hash representing the keywords in all languages attr_reader :privacy_url + # Categories (e.g. MZGenre.Business) + attr_accessor :primary_category + + attr_accessor :primary_first_sub_category + + attr_accessor :primary_second_sub_category + + attr_accessor :secondary_category + + attr_accessor :secondary_first_sub_category + + attr_accessor :secondary_second_sub_category + attr_mapping( - 'localizedMetadata.value' => :languages + 'localizedMetadata.value' => :languages, + 'primaryCategory.value' => :primary_category, + 'primaryFirstSubCategory.value' => :primary_first_sub_category, + 'primarySecondSubCategory.value' => :primary_second_sub_category, + 'secondaryCategory.value' => :secondary_category, + 'secondaryFirstSubCategory.value' => :secondary_first_sub_category, + 'secondarySecondSubCategory.value' => :secondary_second_sub_category ) class << self @@ -46,6 +65,38 @@ def save! client.update_app_details!(application.apple_id, raw_data) end + # Custom Setters + # + def primary_category=(value) + value = "MZGenre.#{value}" unless value.include? "MZGenre" + super(value) + end + + def primary_first_sub_category=(value) + value = "MZGenre.#{value}" unless value.include? "MZGenre" + super(value) + end + + def primary_second_sub_category=(value) + value = "MZGenre.#{value}" unless value.include? "MZGenre" + super(value) + end + + def secondary_category=(value) + value = "MZGenre.#{value}" unless value.include? "MZGenre" + super(value) + end + + def secondary_first_sub_category=(value) + value = "MZGenre.#{value}" unless value.include? "MZGenre" + super(value) + end + + def secondary_second_sub_category=(value) + value = "MZGenre.#{value}" unless value.include? "MZGenre" + super(value) + end + ##################################################### # @!group General ##################################################### diff --git a/lib/spaceship/tunes/app_version.rb b/lib/spaceship/tunes/app_version.rb index 1cf6d5f..5fac606 100644 --- a/lib/spaceship/tunes/app_version.rb +++ b/lib/spaceship/tunes/app_version.rb @@ -20,19 +20,6 @@ class AppVersion < TunesBase # @return (Bool) Is that the version that's currently available in the App Store? attr_accessor :is_live - # Categories (e.g. MZGenre.Business) - attr_accessor :primary_category - - attr_accessor :primary_first_sub_category - - attr_accessor :primary_second_sub_category - - attr_accessor :secondary_category - - attr_accessor :secondary_first_sub_category - - attr_accessor :secondary_second_sub_category - # @return (String) App Status (e.g. 'readyForSale'). You should use `app_status` instead attr_accessor :raw_status @@ -127,13 +114,7 @@ class AppVersion < TunesBase 'details.value' => :languages, 'largeAppIcon.value.originalFileName' => :app_icon_original_name, 'largeAppIcon.value.url' => :app_icon_url, - 'primaryCategory.value' => :primary_category, - 'primaryFirstSubCategory.value' => :primary_first_sub_category, - 'primarySecondSubCategory.value' => :primary_second_sub_category, 'releaseOnApproval.value' => :release_on_approval, - 'secondaryCategory.value' => :secondary_category, - 'secondaryFirstSubCategory.value' => :secondary_first_sub_category, - 'secondarySecondSubCategory.value' => :secondary_second_sub_category, 'status' => :raw_status, 'supportsAppleWatch' => :supports_apple_watch, 'versionId' => :version_id, @@ -261,36 +242,6 @@ def supports_apple_watch !super.nil? end - def primary_category=(value) - value = "MZGenre.#{value}" unless value.include? "MZGenre" - super(value) - end - - def primary_first_sub_category=(value) - value = "MZGenre.#{value}" unless value.include? "MZGenre" - super(value) - end - - def primary_second_sub_category=(value) - value = "MZGenre.#{value}" unless value.include? "MZGenre" - super(value) - end - - def secondary_category=(value) - value = "MZGenre.#{value}" unless value.include? "MZGenre" - super(value) - end - - def secondary_first_sub_category=(value) - value = "MZGenre.#{value}" unless value.include? "MZGenre" - super(value) - end - - def secondary_second_sub_category=(value) - value = "MZGenre.#{value}" unless value.include? "MZGenre" - super(value) - end - private # generates the nested data structure to represent screenshots From 8563c2e5e24bf84e189036255a8d32187386a61a Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Thu, 24 Sep 2015 18:13:06 -0700 Subject: [PATCH 06/15] Added support for retreiving TestFlight build status --- lib/spaceship/tunes/build.rb | 103 ++++++++++++++++------------- lib/spaceship/tunes/build_train.rb | 10 ++- 2 files changed, 64 insertions(+), 49 deletions(-) diff --git a/lib/spaceship/tunes/build.rb b/lib/spaceship/tunes/build.rb index b88fea3..ae9d514 100644 --- a/lib/spaceship/tunes/build.rb +++ b/lib/spaceship/tunes/build.rb @@ -40,9 +40,11 @@ class Build < TunesBase # @return (Integer): When is the external build going to expire? attr_accessor :external_expiry_date - # @return (Boolean): Is this build available for external beta testing - # this is only true after the build was approved by Apple - attr_accessor :external_testing_enabled + # @return (Bool) Is external beta testing enabled for this train? Only one train can have enabled testing. + attr_reader :external_testing_enabled + + # @return (Bool) Is internal beta testing enabled for this train? Only one train can have enabled testing. + attr_reader :internal_testing_enabled # @return (Bool) Does this build support WatchKit? attr_accessor :watch_kit_enabled @@ -87,7 +89,9 @@ class Build < TunesBase 'internalExpiry' => :internal_expiry_date, 'externalExpiry' => :external_expiry_date, 'watchKitEnabled' => :watch_kit_enabled, - 'readyToInstall' => :ready_to_install + 'readyToInstall' => :ready_to_install, + 'internalTesting.value' => :internal_testing_enabled, + 'externalTesting.value' => :external_testing_enabled, ) class << self @@ -102,7 +106,7 @@ def setup super self.external_expiry_date ||= 0 - @external_testing_enabled = self.external_expiry_date > 0 + self.internal_expiry_date ||= 0 end # This will submit this build for TestFlight beta review @@ -160,14 +164,8 @@ def submit_for_beta_review!(metadata) # @examples: # External, Internal, Inactive, Expired def testing_status - testing ||= "External" if self.external_expiry_date > 0 - - if self.build_train.testing_enabled - # only the latest build is actually valid - if self.build_train.builds.find_all { |b| b.upload_date > self.upload_date }.count == 0 - testing ||= "Internal" - end - end + testing ||= "External" if self.external_testing_enabled + testing ||= "Internal" if self.internal_testing_enabled if Time.at(self.internal_expiry_date / 1000) > Time.now testing ||= "Inactive" @@ -188,36 +186,49 @@ def cancel_beta_review! end end -# Example response -# "buildVersion": "0.9.10", -# "trainVersion": "0.9.10", -# "uploadDate": 1413966436000, -# "iconUrl": "https://is5-ssl.mzstatic.com/image/thumb/Newsstand5/v4/e8/ab/f8/e8abf8ca-6c22-a519-aa1b-c73901c4917e/Icon-60@2x.png.png/150x150bb-80.png", -# "appName": "Yeahaa", -# "platform": "ios", -# "betaEntitled": false, -# "id": 523299, -# "valid": true, -# "missingExportCompliance": false, -# "waitingForExportComplianceApproval": false, -# "addedInternalUsersCount": 0, -# "addedExternalUsersCount": 0, -# "invitedExternalUsersCount": 0, -# "invitedInternalUsersCount": 0, -# "acceptedInternalUsersCount": 0, -# "acceptedExternalUsersCount": 0, -# "installCount": 0, -# "internalInstallCount": 0, -# "externalInstallCount": 0, -# "sessionCount": null, -# "crashCount": null, -# "promotedVersion": null, -# "internalState": "noBetaEntitlement", -# "betaState": "noBetaEntitlement", -# "internalExpiry": 1416562036000, -# "externalExpiry": 0, -# "watchKitEnabled": false, -# "readyToInstall": false, -# "sdkBuildWhitelisted": true, -# "internalTesting": null, -# "externalTesting": null +# Example Response + # {"sectionErrorKeys"=>[], + # "sectionInfoKeys"=>[], + # "sectionWarningKeys"=>[], + # "buildVersion"=>"1", + # "trainVersion"=>"1.0", + # "uploadDate"=>1441975590000, + # "iconUrl"=> + # "https://is2-ssl.mzstatic.com/image/thumb/Newsstand3/v4/a9/f9/8b/a9f98b23-592d-af2e-6e10-a04873bed5df/Icon-76@2x.png.png/150x150bb-80.png", + # "iconAssetToken"=> + # "Newsstand3/v4/a9/f9/8b/a9f98b23-592d-af2e-6e10-a04873bed5df/Icon-76@2x.png.png", + # "appName"=>"Updated by fastlane", + # "platform"=>"ios", + # "betaEntitled"=>true, + # "exceededFileSizeLimit"=>false, + # "wentLiveWithVersion"=>false, + # "processing"=>false, + # "id"=>5298023, + # "valid"=>true, + # "missingExportCompliance"=>false, + # "waitingForExportComplianceApproval"=>false, + # "addedInternalUsersCount"=>0, + # "addedExternalUsersCount"=>0, + # "invitedExternalUsersCount"=>0, + # "invitedInternalUsersCount"=>0, + # "acceptedInternalUsersCount"=>1, + # "acceptedExternalUsersCount"=>0, + # "installCount"=>0, + # "internalInstallCount"=>0, + # "externalInstallCount"=>0, + # "sessionCount"=>0, + # "internalSessionCount"=>0, + # "externalSessionCount"=>0, + # "crashCount"=>0, + # "internalCrashCount"=>0, + # "externalCrashCount"=>0, + # "promotedVersion"=>nil, + # "internalState"=>"inactive", + # "betaState"=>"submitForReview", + # "internalExpiry"=>1444567590000, + # "externalExpiry"=>0, + # "watchKitEnabled"=>false, + # "readyToInstall"=>true, + # "sdkBuildWhitelisted"=>true, + # "internalTesting"=>{"value"=>false, "isEditable"=>true, "isRequired"=>false, "errorKeys"=>nil}, + # "externalTesting"=>{"value"=>false, "isEditable"=>true, "isRequired"=>false, "errorKeys"=>nil} diff --git a/lib/spaceship/tunes/build_train.rb b/lib/spaceship/tunes/build_train.rb index cda45a8..a948bc3 100644 --- a/lib/spaceship/tunes/build_train.rb +++ b/lib/spaceship/tunes/build_train.rb @@ -17,8 +17,11 @@ class BuildTrain < TunesBase # @return (String) Platform (e.g. "ios") attr_reader :platform - # @return (Bool) Is beta testing enabled for this train? Only one train can have enabled testing. - attr_reader :testing_enabled + # @return (Bool) Is external beta testing enabled for this train? Only one train can have enabled testing. + attr_reader :external_testing_enabled + + # @return (Bool) Is internal beta testing enabled for this train? Only one train can have enabled testing. + attr_reader :internal_testing_enabled # @return (Array) An array of all builds that are inside this train (Spaceship::Tunes::Build) # I never got this to work to properly try and debug this @@ -27,7 +30,8 @@ class BuildTrain < TunesBase attr_mapping( 'versionString' => :version_string, 'platform' => :platform, - 'testing.value' => :testing_enabled + 'externalTesting.value' => :external_testing_enabled, + 'internalTesting.value' => :internal_testing_enabled ) class << self From 8bead609e7ee7e8e2a8b485dade3afbf0094d1e3 Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Thu, 24 Sep 2015 18:14:12 -0700 Subject: [PATCH 07/15] Code style improvements --- lib/spaceship/tunes/app_details.rb | 2 +- lib/spaceship/tunes/build.rb | 92 ++++++++++++++-------------- lib/spaceship/tunes/language_item.rb | 4 +- lib/spaceship/tunes/tunes_client.rb | 2 +- 4 files changed, 50 insertions(+), 50 deletions(-) diff --git a/lib/spaceship/tunes/app_details.rb b/lib/spaceship/tunes/app_details.rb index 2573c01..d73e781 100644 --- a/lib/spaceship/tunes/app_details.rb +++ b/lib/spaceship/tunes/app_details.rb @@ -66,7 +66,7 @@ def save! end # Custom Setters - # + # def primary_category=(value) value = "MZGenre.#{value}" unless value.include? "MZGenre" super(value) diff --git a/lib/spaceship/tunes/build.rb b/lib/spaceship/tunes/build.rb index ae9d514..79b4121 100644 --- a/lib/spaceship/tunes/build.rb +++ b/lib/spaceship/tunes/build.rb @@ -91,7 +91,7 @@ class Build < TunesBase 'watchKitEnabled' => :watch_kit_enabled, 'readyToInstall' => :ready_to_install, 'internalTesting.value' => :internal_testing_enabled, - 'externalTesting.value' => :external_testing_enabled, + 'externalTesting.value' => :external_testing_enabled ) class << self @@ -187,48 +187,48 @@ def cancel_beta_review! end # Example Response - # {"sectionErrorKeys"=>[], - # "sectionInfoKeys"=>[], - # "sectionWarningKeys"=>[], - # "buildVersion"=>"1", - # "trainVersion"=>"1.0", - # "uploadDate"=>1441975590000, - # "iconUrl"=> - # "https://is2-ssl.mzstatic.com/image/thumb/Newsstand3/v4/a9/f9/8b/a9f98b23-592d-af2e-6e10-a04873bed5df/Icon-76@2x.png.png/150x150bb-80.png", - # "iconAssetToken"=> - # "Newsstand3/v4/a9/f9/8b/a9f98b23-592d-af2e-6e10-a04873bed5df/Icon-76@2x.png.png", - # "appName"=>"Updated by fastlane", - # "platform"=>"ios", - # "betaEntitled"=>true, - # "exceededFileSizeLimit"=>false, - # "wentLiveWithVersion"=>false, - # "processing"=>false, - # "id"=>5298023, - # "valid"=>true, - # "missingExportCompliance"=>false, - # "waitingForExportComplianceApproval"=>false, - # "addedInternalUsersCount"=>0, - # "addedExternalUsersCount"=>0, - # "invitedExternalUsersCount"=>0, - # "invitedInternalUsersCount"=>0, - # "acceptedInternalUsersCount"=>1, - # "acceptedExternalUsersCount"=>0, - # "installCount"=>0, - # "internalInstallCount"=>0, - # "externalInstallCount"=>0, - # "sessionCount"=>0, - # "internalSessionCount"=>0, - # "externalSessionCount"=>0, - # "crashCount"=>0, - # "internalCrashCount"=>0, - # "externalCrashCount"=>0, - # "promotedVersion"=>nil, - # "internalState"=>"inactive", - # "betaState"=>"submitForReview", - # "internalExpiry"=>1444567590000, - # "externalExpiry"=>0, - # "watchKitEnabled"=>false, - # "readyToInstall"=>true, - # "sdkBuildWhitelisted"=>true, - # "internalTesting"=>{"value"=>false, "isEditable"=>true, "isRequired"=>false, "errorKeys"=>nil}, - # "externalTesting"=>{"value"=>false, "isEditable"=>true, "isRequired"=>false, "errorKeys"=>nil} +# {"sectionErrorKeys"=>[], +# "sectionInfoKeys"=>[], +# "sectionWarningKeys"=>[], +# "buildVersion"=>"1", +# "trainVersion"=>"1.0", +# "uploadDate"=>1441975590000, +# "iconUrl"=> +# "https://is2-ssl.mzstatic.com/image/thumb/Newsstand3/v4/a9/f9/8b/a9f98b23-592d-af2e-6e10-a04873bed5df/Icon-76@2x.png.png/150x150bb-80.png", +# "iconAssetToken"=> +# "Newsstand3/v4/a9/f9/8b/a9f98b23-592d-af2e-6e10-a04873bed5df/Icon-76@2x.png.png", +# "appName"=>"Updated by fastlane", +# "platform"=>"ios", +# "betaEntitled"=>true, +# "exceededFileSizeLimit"=>false, +# "wentLiveWithVersion"=>false, +# "processing"=>false, +# "id"=>5298023, +# "valid"=>true, +# "missingExportCompliance"=>false, +# "waitingForExportComplianceApproval"=>false, +# "addedInternalUsersCount"=>0, +# "addedExternalUsersCount"=>0, +# "invitedExternalUsersCount"=>0, +# "invitedInternalUsersCount"=>0, +# "acceptedInternalUsersCount"=>1, +# "acceptedExternalUsersCount"=>0, +# "installCount"=>0, +# "internalInstallCount"=>0, +# "externalInstallCount"=>0, +# "sessionCount"=>0, +# "internalSessionCount"=>0, +# "externalSessionCount"=>0, +# "crashCount"=>0, +# "internalCrashCount"=>0, +# "externalCrashCount"=>0, +# "promotedVersion"=>nil, +# "internalState"=>"inactive", +# "betaState"=>"submitForReview", +# "internalExpiry"=>1444567590000, +# "externalExpiry"=>0, +# "watchKitEnabled"=>false, +# "readyToInstall"=>true, +# "sdkBuildWhitelisted"=>true, +# "internalTesting"=>{"value"=>false, "isEditable"=>true, "isRequired"=>false, "errorKeys"=>nil}, +# "externalTesting"=>{"value"=>false, "isEditable"=>true, "isRequired"=>false, "errorKeys"=>nil} diff --git a/lib/spaceship/tunes/language_item.rb b/lib/spaceship/tunes/language_item.rb index 3af3509..b3b64f7 100644 --- a/lib/spaceship/tunes/language_item.rb +++ b/lib/spaceship/tunes/language_item.rb @@ -7,7 +7,7 @@ class LanguageItem def initialize(identifier, ref) raise "ref is nil" if ref.nil? - + self.identifier = identifier.to_s self.original_array = ref end @@ -22,7 +22,7 @@ def []=(key, value) def get_lang(lang) result = self.original_array.find do |current| - current['language'] == lang or current['localeCode'] == lang #  being consistent + current['language'] == lang or current['localeCode'] == lang # Apple being consistent end return result if result diff --git a/lib/spaceship/tunes/tunes_client.rb b/lib/spaceship/tunes/tunes_client.rb index 9b686d0..c02451c 100644 --- a/lib/spaceship/tunes/tunes_client.rb +++ b/lib/spaceship/tunes/tunes_client.rb @@ -186,7 +186,7 @@ def create_application!(name: nil, primary_language: nil, version: nil, sku: nil data['newApp']['bundleIdSuffix']['value'] = bundle_id_suffix data['companyName']['value'] = company_name if company_name data['newApp']['appType'] = app_type - + data['initialPlatform'] = app_type data['enabledPlatformsForCreation']['value'] = [app_type] From c89f24c502df99337eeab8fb349013df5cab3895 Mon Sep 17 00:00:00 2001 From: KrauseFx Date: Thu, 24 Sep 2015 20:23:31 -0700 Subject: [PATCH 08/15] Added support for putting builds into internal TestFlight mode --- docs/iTunesConnect.md | 2 +- lib/spaceship/tunes/build.rb | 2 +- lib/spaceship/tunes/build_train.rb | 22 ++++++++++++++-------- lib/spaceship/tunes/tunes_client.rb | 10 +++++----- spec/tunes/build_train_spec.rb | 2 +- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/docs/iTunesConnect.md b/docs/iTunesConnect.md index 23f650e..f4dda34 100644 --- a/docs/iTunesConnect.md +++ b/docs/iTunesConnect.md @@ -175,7 +175,7 @@ build = train.builds.first # Enable beta testing for a build train # This will put the latest build into beta testing mode # and turning off beta testing for all other build trains -train.update_testing_status!(true) +train.update_testing_status!(true, 'internal') ``` ## Builds diff --git a/lib/spaceship/tunes/build.rb b/lib/spaceship/tunes/build.rb index 79b4121..92340b3 100644 --- a/lib/spaceship/tunes/build.rb +++ b/lib/spaceship/tunes/build.rb @@ -131,7 +131,7 @@ def setup # } def submit_for_beta_review!(metadata) # First, enable beta testing for this train (per iTC requirement) - self.build_train.update_testing_status!(true) + self.build_train.update_testing_status!(true, 'external') parameters = { app_id: self.build_train.application.apple_id, diff --git a/lib/spaceship/tunes/build_train.rb b/lib/spaceship/tunes/build_train.rb index a948bc3..71b286f 100644 --- a/lib/spaceship/tunes/build_train.rb +++ b/lib/spaceship/tunes/build_train.rb @@ -44,9 +44,12 @@ def factory(attrs) # @param application (Spaceship::Tunes::Application) The app this train is for # @param app_id (String) The unique Apple ID of this app def all(application, app_id) - data = client.build_trains(app_id) + trains = [] + trains += client.build_trains(app_id, 'internal')['trains'] + trains += client.build_trains(app_id, 'external')['trains'] + result = {} - data['trains'].each do |attrs| + trains.each do |attrs| attrs.merge!(application: application) current = self.factory(attrs) result[current.version_string] = current @@ -70,14 +73,17 @@ def setup end end - def update_testing_status!(new_value) - data = client.build_trains(self.application.apple_id) + # @param (testing_type) internal or external + def update_testing_status!(new_value, testing_type) + data = client.build_trains(self.application.apple_id, testing_type) + data['trains'].each do |train| - train['testing']['value'] = false - train['testing']['value'] = new_value if train['versionString'] == version_string + train["#{testing_type}Testing"]['value'] = false + train["#{testing_type}Testing"]['value'] = new_value if train['versionString'] == version_string end - result = client.update_build_trains!(application.apple_id, data) - self.testing_enabled = new_value + result = client.update_build_trains!(application.apple_id, testing_type, data) + self.internal_testing_enabled = new_value if testing_type == 'internal' + self.external_testing_enabled = new_value if testing_type == 'external' result end end diff --git a/lib/spaceship/tunes/tunes_client.rb b/lib/spaceship/tunes/tunes_client.rb index c02451c..c15e1ee 100644 --- a/lib/spaceship/tunes/tunes_client.rb +++ b/lib/spaceship/tunes/tunes_client.rb @@ -255,18 +255,18 @@ def update_app_version!(app_id, is_live, data) # @!group Build Trains ##################################################### - def build_trains(app_id) + # @param (testing_type) internal or external + def build_trains(app_id, testing_type) raise "app_id is required" unless app_id - - r = request(:get, "ra/apps/#{app_id}/trains/") + r = request(:get, "ra/apps/#{app_id}/trains/?testingType=#{testing_type}") parse_response(r, 'data') end - def update_build_trains!(app_id, data) + def update_build_trains!(app_id, testing_type, data) raise "app_id is required" unless app_id r = request(:post) do |req| - req.url "ra/apps/#{app_id}/trains/" + req.url "ra/apps/#{app_id}/testingTypes/#{testing_type}/trains/" req.body = data.to_json req.headers['Content-Type'] = 'application/json' end diff --git a/spec/tunes/build_train_spec.rb b/spec/tunes/build_train_spec.rb index a815bf4..15f2011 100644 --- a/spec/tunes/build_train_spec.rb +++ b/spec/tunes/build_train_spec.rb @@ -73,7 +73,7 @@ expect(train1.testing_enabled).to eq(false) expect(train2.testing_enabled).to eq(true) - train1.update_testing_status!(true) + train1.update_testing_status!(true, 'internal') expect(train1.testing_enabled).to eq(true) end From 38a8a5362e85526d8eda1af71a3ae6842094dfa2 Mon Sep 17 00:00:00 2001 From: KrauseFx Date: Thu, 24 Sep 2015 20:53:11 -0700 Subject: [PATCH 09/15] Worked on tests --- spec/tunes/application_spec.rb | 2 +- spec/tunes/fixtures/app_overview.json | 72 +++++++++++++++++++ .../create_application_prefill_request.json | 54 +++++++------- spec/tunes/tunes_stubbing.rb | 41 +++++++---- 4 files changed, 125 insertions(+), 44 deletions(-) create mode 100644 spec/tunes/fixtures/app_overview.json diff --git a/spec/tunes/application_spec.rb b/spec/tunes/application_spec.rb index b89b980..72f9fbc 100644 --- a/spec/tunes/application_spec.rb +++ b/spec/tunes/application_spec.rb @@ -90,7 +90,7 @@ end end - describe "#create! first app" do + describe "#create! first app (company name required)" do it "works with valid data and defaults to English" do itc_stub_applications_first_create Spaceship::Tunes::Application.create!(name: "My Name", diff --git a/spec/tunes/fixtures/app_overview.json b/spec/tunes/fixtures/app_overview.json new file mode 100644 index 0000000..92e1024 --- /dev/null +++ b/spec/tunes/fixtures/app_overview.json @@ -0,0 +1,72 @@ +{ + "data": { + "sectionErrorKeys": [], + "sectionInfoKeys": [], + "sectionWarningKeys": [], + "adamId": "1039164429", + "primaryLocaleCode": "en-US", + "features": ["PRERELEASE", "PRICING", "GAMECENTER"], + "appTransferState": null, + "localizedMetadata": [{ + "localeCode": "en-US", + "name": "Updated by fastlane" + }, { + "localeCode": "de-DE", + "name": "why new itc 2" + }], + "platforms": [{ + "type": "APP", + "platformString": "ios", + "inFlightVersion": { + "type": "APP", + "id": "813314674", + "version": "1.0", + "state": "prepareForUpload", + "stateKey": "prepareForUpload", + "stateGroup": "preRelease", + "largeAppIcon": { + "assetToken": "Purple3/v4/42/45/f2/4245f2ee-3a37-a34d-a659-1f5f403ab2fe/pr_source.png", + "sortOrder": null, + "url": "https://is3-ssl.mzstatic.com/image/thumb/Purple3/v4/42/45/f2/4245f2ee-3a37-a34d-a659-1f5f403ab2fe/pr_source.png/1024x1024ss-80.png", + "thumbNailUrl": "https://is3-ssl.mzstatic.com/image/thumb/Purple3/v4/42/45/f2/4245f2ee-3a37-a34d-a659-1f5f403ab2fe/pr_source.png/500x500bb-80.png", + "originalFileName": "noalpha.png" + }, + "supportedHardware": ["iphone"], + "issuesCount": 0 + }, + "deliverableVersion": { + "type": "APP", + "id": "813314674", + "version": "1.0", + "state": "...", + "stateKey": "...", + "stateGroup": "...", + "largeAppIcon": { + "assetToken": "Purple3/v4/42/45/f2/4245f2ee-3a37-a34d-a659-1f5f403ab2fe/pr_source.png", + "sortOrder": null, + "url": "https://is3-ssl.mzstatic.com/image/thumb/Purple3/v4/42/45/f2/4245f2ee-3a37-a34d-a659-1f5f403ab2fe/pr_source.png/1024x1024ss-80.png", + "thumbNailUrl": "https://is3-ssl.mzstatic.com/image/thumb/Purple3/v4/42/45/f2/4245f2ee-3a37-a34d-a659-1f5f403ab2fe/pr_source.png/500x500bb-80.png", + "originalFileName": "noalpha.png" + }, + "supportedHardware": ["iphone"], + "issuesCount": 0 + }, + "deliverableVersion": null + }], + "allowedNewVersionPlatforms": ["appletvos"], + "submittablePlatforms": ["ios", "osx"], + "appStoreUrl": "https://itunes.apple.com/us/app/why-new-itc-2/id1039164429?ls=1&mt=8", + "analyticsUrl": null, + "salesAndTrendsUrl": null, + "canCreateAddOn": true, + "everSubmittedAnAddon": false, + "everSubmittedFreeSubscriptionAddon": true, + "freeSubscriptionAddonCount": 0 + }, + "messages": { + "warn": null, + "error": null, + "info": null + }, + "statusCode": "SUCCESS" +} \ No newline at end of file diff --git a/spec/tunes/fixtures/create_application_prefill_request.json b/spec/tunes/fixtures/create_application_prefill_request.json index 1b1fa41..832c105 100644 --- a/spec/tunes/fixtures/create_application_prefill_request.json +++ b/spec/tunes/fixtures/create_application_prefill_request.json @@ -4,37 +4,43 @@ "sectionInfoKeys": [], "sectionWarningKeys": [], "companyName": { - "value": "SunApps GmbH", + "value": "Felix Krause", "isEditable": false, "isRequired": false, "errorKeys": null }, - "versionString": { + "versionString": null, + "appRegInfo": null, + "bundleIds": { + "*": "Xcode iOS Wildcard App ID - *" + }, + "enabledPlatformsForCreation": { + "value": ["appletvos", "ios"], + "isEditable": true, + "isRequired": true, + "errorKeys": null + }, + "name": null, + "primaryLanguage": { "value": null, "isEditable": true, "isRequired": true, "errorKeys": null }, - "appRegInfo": null, - "bundleIds": { - "com.krausefx.app_name": "Spaceship App - com.krausefx.app_name", - "net.sunapps.*": "SunApps - net.sunapps.*", - "net.sunapps.947474": "My App Name - net.sunapps.947474", - "*": "Xcode iOS Wildcard App ID - *", - "net.sunapps.100": "Baconfy - net.sunapps.100" + "bundleId": { + "value": null, + "isEditable": true, + "isRequired": true, + "errorKeys": null }, - "enabledPlatformsForCreation": { - "value": ["ios"], + "bundleIdSuffix": { + "value": null, "isEditable": true, "isRequired": true, "errorKeys": null }, - "name": null, - "primaryLanguage": null, - "bundleId": null, - "bundleIdSuffix": null, "vendorId": null, - "initialPlatform": null, + "initialPlatform": "ios", "adamId": null, "newApp": { "sectionErrorKeys": [], @@ -47,25 +53,15 @@ "errorKeys": null }, "bundleIdSuffix": { - "value": null, - "isEditable": true, - "isRequired": false, - "errorKeys": null - }, - "vendorId": { "value": null, "isEditable": true, "isRequired": true, "errorKeys": null }, + "vendorId": null, "adamId": null, - "appType": "iOS App", - "name": { - "value": null, - "isEditable": true, - "isRequired": true, - "errorKeys": null - }, + "appType": "ios", + "name": null, "liveVersion": null, "inFlightVersion": null, "primaryLanguage": { diff --git a/spec/tunes/tunes_stubbing.rb b/spec/tunes/tunes_stubbing.rb index da07f3a..adf8d45 100644 --- a/spec/tunes/tunes_stubbing.rb +++ b/spec/tunes/tunes_stubbing.rb @@ -32,7 +32,7 @@ def itc_stub_login end def itc_stub_applications - stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/manageyourapps/summary"). + stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/manageyourapps/summary/v2"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('app_summary.json'), headers: {'Content-Type' => 'application/json'}) @@ -44,38 +44,49 @@ def itc_stub_applications # Create Application # Pre-Fill request - stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/?appType=ios"). + stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/v2/?platformString=ios"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('create_application_prefill_request.json'), headers: {'Content-Type' => 'application/json'}) + # Actual sucess request - stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/?appType=ios"). + stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/v2"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('create_application_success.json'), headers: {'Content-Type' => 'application/json'}) + + + # Overview of application to get the versions + stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/1013943394/overview"). + with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie'=>'myacinfo=DAWTKN;woinst=3363;itctx=abc:def;wosid=xBJMOVttbAQ1Cwlt8ktafw', 'User-Agent'=>'spaceship'}). + to_return(:status => 200, body: itc_read_fixture_file('app_overview.json'), headers: {'Content-Type' => 'application/json'}) + + stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/overview"). + with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie'=>'myacinfo=DAWTKN;woinst=3363;itctx=abc:def;wosid=xBJMOVttbAQ1Cwlt8ktafw', 'User-Agent'=>'spaceship'}). + to_return(:status => 200, body: itc_read_fixture_file('app_overview.json'), headers: {'Content-Type' => 'application/json'}) end def itc_stub_applications_first_create # Create First Application # Pre-Fill request - stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/?appType=ios"). + stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/v2/?platformString=ios"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('create_application_prefill_first_request.json'), headers: {'Content-Type' => 'application/json'}) # end end def itc_stub_applications_broken_first_create - stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/?appType=ios"). + stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/v2"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('create_application_first_broken.json'), headers: {'Content-Type' => 'application/json'}) end def itc_stub_broken_create - stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/?appType=ios"). + stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/v2"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('create_application_broken.json'), headers: {'Content-Type' => 'application/json'}) end def itc_stub_broken_create_wildcard - stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/?appType=ios"). + stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/v2"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('create_application_wildcard_broken.json'), headers: {'Content-Type' => 'application/json'}) end @@ -124,13 +135,15 @@ def itc_stub_resolution_center end def itc_stub_build_trains - stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/"). - with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). - to_return(status: 200, body: itc_read_fixture_file('build_trains.json'), headers: {'Content-Type' => 'application/json'}) - # Update build trains - stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/"). - with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). - to_return(status: 200, body: itc_read_fixture_file('build_trains.json'), headers: {'Content-Type' => 'application/json'}) + %w[internal external].each do |type| + stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/?testingType=#{type}"). + with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). + to_return(status: 200, body: itc_read_fixture_file('build_trains.json'), headers: {'Content-Type' => 'application/json'}) + # Update build trains + stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/?testingType=#{type}"). + with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). + to_return(status: 200, body: itc_read_fixture_file('build_trains.json'), headers: {'Content-Type' => 'application/json'}) + end end def itc_stub_testers From b7b8b5f960a330e1f0d514da958d6ecf918d5789 Mon Sep 17 00:00:00 2001 From: KrauseFx Date: Thu, 24 Sep 2015 21:40:23 -0700 Subject: [PATCH 10/15] Fixed more tests --- lib/spaceship/tunes/app_version.rb | 12 ++- lib/spaceship/tunes/application.rb | 3 +- lib/spaceship/tunes/build_train.rb | 2 + spec/tunes/app_version_spec.rb | 4 +- spec/tunes/build_spec.rb | 28 +++--- spec/tunes/build_train_spec.rb | 29 +++--- spec/tunes/fixtures/app_overview.json | 7 +- spec/tunes/fixtures/app_summary.json | 2 +- spec/tunes/fixtures/build_trains.json | 138 +++++++++++++++++--------- spec/tunes/tunes_stubbing.rb | 15 +-- 10 files changed, 146 insertions(+), 94 deletions(-) diff --git a/lib/spaceship/tunes/app_version.rb b/lib/spaceship/tunes/app_version.rb index 5fac606..9e55294 100644 --- a/lib/spaceship/tunes/app_version.rb +++ b/lib/spaceship/tunes/app_version.rb @@ -144,12 +144,12 @@ def factory(attrs) # @param application (Spaceship::Tunes::Application) The app this version is for # @param app_id (String) The unique Apple ID of this app - # @param version_id (String) - def find(application, app_id, version_id) - attrs = client.app_version(app_id, version_id) + # @param is_live (Boolean) + def find(application, app_id, is_live) + attrs = client.app_version(app_id, is_live) return nil unless attrs attrs.merge!(application: application) - attrs.merge!(version_id: version_id) + attrs.merge!(is_live: is_live) return self.factory(attrs) end @@ -202,7 +202,9 @@ def save! # @return (String) An URL to this specific resource. You can enter this URL into your browser def url - "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/#{self.application.apple_id}/" + (self.is_live? ? "cur" : "") + url = "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/904332168/ios/versioninfo/" + url += "deliverable" if self.is_live? + return url end # Private methods diff --git a/lib/spaceship/tunes/application.rb b/lib/spaceship/tunes/application.rb index 379774b..ec1542c 100644 --- a/lib/spaceship/tunes/application.rb +++ b/lib/spaceship/tunes/application.rb @@ -106,7 +106,6 @@ def live_version # @return (Spaceship::AppVersion) Receive the version that can fully be edited 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 @@ -172,7 +171,7 @@ def build_trains # These are all build that have no information except the upload date # Those builds can also be the builds that are stuck on iTC. def pre_processing_builds - data = client.build_trains(apple_id) # we need to fetch all trains here to get the builds + data = client.build_trains(apple_id, 'internal') # we need to fetch all trains here to get the builds builds = data.fetch('processingBuilds', []).collect do |attrs| attrs.merge!(build_train: self) diff --git a/lib/spaceship/tunes/build_train.rb b/lib/spaceship/tunes/build_train.rb index 71b286f..435da4d 100644 --- a/lib/spaceship/tunes/build_train.rb +++ b/lib/spaceship/tunes/build_train.rb @@ -81,9 +81,11 @@ def update_testing_status!(new_value, testing_type) train["#{testing_type}Testing"]['value'] = false train["#{testing_type}Testing"]['value'] = new_value if train['versionString'] == version_string end + result = client.update_build_trains!(application.apple_id, testing_type, data) self.internal_testing_enabled = new_value if testing_type == 'internal' self.external_testing_enabled = new_value if testing_type == 'external' + result end end diff --git a/spec/tunes/app_version_spec.rb b/spec/tunes/app_version_spec.rb index ca6105d..c10849c 100644 --- a/spec/tunes/app_version_spec.rb +++ b/spec/tunes/app_version_spec.rb @@ -67,11 +67,11 @@ describe "#url" do it "live version" do - expect(app.live_version.url).to eq('https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/898536088/cur') + expect(app.live_version.url).to eq('https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/904332168/ios/versioninfo/deliverable') end it "edit version" do - expect(app.edit_version.url).to eq('https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/898536088/') + expect(app.edit_version.url).to eq('https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/904332168/ios/versioninfo/') end end diff --git a/spec/tunes/build_spec.rb b/spec/tunes/build_spec.rb index 7490184..c8668b7 100644 --- a/spec/tunes/build_spec.rb +++ b/spec/tunes/build_spec.rb @@ -18,36 +18,36 @@ build = train.builds.first expect(build.build_train).to eq(train) - expect(build.upload_date).to eq(1413966436000) + expect(build.upload_date).to eq(1443144470000) expect(build.valid).to eq(true) - expect(build.id).to eq(523299) - expect(build.build_version).to eq("123123") - expect(build.train_version).to eq("0.9.10") - expect(build.upload_date).to eq(1413966436000) - expect(build.icon_url).to eq('https://is5-ssl.mzstatic.com/image/thumb/Newsstand5/v4/e8/ab/f8/e8abf8ca-6c22-a519-aa1b-c73901c4917e/Icon-60@2x.png.png/150x150bb-80.png') - expect(build.app_name).to eq('Yeahaa') + expect(build.id).to eq(5577102) + expect(build.build_version).to eq("10") + expect(build.train_version).to eq("1.0") + expect(build.icon_url).to eq('https://is3-ssl.mzstatic.com/image/thumb/Newsstand3/v4/94/80/28/948028c9-59e7-7b29-e75b-f57e97421ece/Icon-76@2x.png.png/150x150bb-80.png') + expect(build.app_name).to eq('Updated by fastlane') expect(build.platform).to eq('ios') - expect(build.internal_expiry_date).to eq(1416562036000) + expect(build.internal_expiry_date).to eq(1445737214000) expect(build.external_expiry_date).to eq(0) + expect(build.internal_testing_enabled).to eq(true) expect(build.external_testing_enabled).to eq(false) expect(build.watch_kit_enabled).to eq(false) - expect(build.ready_to_install).to eq(false) + expect(build.ready_to_install).to eq(true) # Analytics expect(build.install_count).to eq(0) expect(build.internal_install_count).to eq(0) expect(build.external_install_count).to eq(0) - expect(build.session_count).to eq(nil) - expect(build.crash_count).to eq(nil) + expect(build.session_count).to eq(0) + expect(build.crash_count).to eq(0) end describe "#testing_status" do it "properly describes a build" do build1 = app.build_trains.values.first.builds.first - expect(build1.testing_status).to eq("Expired") + expect(build1.testing_status).to eq("Internal") build2 = app.build_trains.values.last.builds.first - expect(build1.testing_status).to eq("Expired") + expect(build1.testing_status).to eq("Internal") end end @@ -68,7 +68,7 @@ expect(r).to eq({ app_id: "898536088", - train: "0.9.10", + train: "1.0", build_number: "123123", changelog: "Custom Changelog", description: "No app description provided", diff --git a/spec/tunes/build_train_spec.rb b/spec/tunes/build_train_spec.rb index 15f2011..b9df176 100644 --- a/spec/tunes/build_train_spec.rb +++ b/spec/tunes/build_train_spec.rb @@ -19,13 +19,15 @@ expect(trains.count).to eq(2) train = trains.values.first - expect(train.version_string).to eq("0.9.10") + expect(train.version_string).to eq("1.0") expect(train.platform).to eq("ios") expect(train.application).to eq(app) # TestFlight - expect(trains.values.first.testing_enabled).to eq(false) - expect(trains.values.last.testing_enabled).to eq(true) + expect(trains.values.first.external_testing_enabled).to eq(false) + expect(trains.values.first.internal_testing_enabled).to eq(true) + expect(trains.values.last.external_testing_enabled).to eq(false) + expect(trains.values.last.internal_testing_enabled).to eq(false) end it "returns all processing builds" do @@ -43,10 +45,11 @@ end it "lets the user fetch the builds using the version as a key" do - train = app.build_trains['0.9.10'] - expect(train.version_string).to eq('0.9.10') + train = app.build_trains['1.0'] + expect(train.version_string).to eq('1.0') expect(train.platform).to eq('ios') - expect(train.testing_enabled).to eq(false) + expect(train.internal_testing_enabled).to eq(true) + expect(train.external_testing_enabled).to eq(false) expect(train.builds.count).to eq(1) end end @@ -61,21 +64,21 @@ end it "properly extracted the processing builds from a train" do - train = app.build_trains['0.9.10'] + train = app.build_trains['1.0'] expect(train.processing_builds.count).to eq(0) end end describe "#update_testing_status" do it "just works (tm)" do - train1 = app.build_trains['0.9.10'] - train2 = app.build_trains['0.9.11'] - expect(train1.testing_enabled).to eq(false) - expect(train2.testing_enabled).to eq(true) + train1 = app.build_trains['1.0'] + train2 = app.build_trains['1.1'] + expect(train1.internal_testing_enabled).to eq(true) + expect(train2.internal_testing_enabled).to eq(false) - train1.update_testing_status!(true, 'internal') + train2.update_testing_status!(true, 'internal') - expect(train1.testing_enabled).to eq(true) + expect(train2.internal_testing_enabled).to eq(true) end end end diff --git a/spec/tunes/fixtures/app_overview.json b/spec/tunes/fixtures/app_overview.json index 92e1024..5520189 100644 --- a/spec/tunes/fixtures/app_overview.json +++ b/spec/tunes/fixtures/app_overview.json @@ -36,8 +36,8 @@ }, "deliverableVersion": { "type": "APP", - "id": "813314674", - "version": "1.0", + "id": "113314675", + "version": "1.1", "state": "...", "stateKey": "...", "stateGroup": "...", @@ -50,8 +50,7 @@ }, "supportedHardware": ["iphone"], "issuesCount": 0 - }, - "deliverableVersion": null + } }], "allowedNewVersionPlatforms": ["appletvos"], "submittablePlatforms": ["ios", "osx"], diff --git a/spec/tunes/fixtures/app_summary.json b/spec/tunes/fixtures/app_summary.json index 70c6ead..1337788 100644 --- a/spec/tunes/fixtures/app_summary.json +++ b/spec/tunes/fixtures/app_summary.json @@ -32,7 +32,7 @@ "issuesCount": 0 }, { "id": null, - "version": "0.9.10", + "version": "1.0", "state": "Prepare for Upload", "stateKey": "prepareForUpload", "stateGroup": "preRelease", diff --git a/spec/tunes/fixtures/build_trains.json b/spec/tunes/fixtures/build_trains.json index 8704bc3..0506235 100644 --- a/spec/tunes/fixtures/build_trains.json +++ b/spec/tunes/fixtures/build_trains.json @@ -4,105 +4,151 @@ "sectionInfoKeys": [], "sectionWarningKeys": [], "trains": [{ - "versionString": "0.9.10", + "versionString": "1.0", "platform": "ios", - "testing": { + "testing": null, + "internalTesting": { + "value": true, + "isEditable": true, + "isRequired": false, + "errorKeys": null + }, + "externalTesting": { "value": false, "isEditable": true, "isRequired": false, "errorKeys": null }, - "internalTesting": null, - "externalTesting": null, - "internalActivated": null, + "internalActivated": 1443151227000, "externalActivated": null, "builds": [{ "sectionErrorKeys": [], "sectionInfoKeys": [], "sectionWarningKeys": [], - "buildVersion": "123123", - "trainVersion": "0.9.10", - "uploadDate": 1413966436000, - "iconUrl": "https://is5-ssl.mzstatic.com/image/thumb/Newsstand5/v4/e8/ab/f8/e8abf8ca-6c22-a519-aa1b-c73901c4917e/Icon-60@2x.png.png/150x150bb-80.png", - "appName": "Yeahaa", + "buildVersion": "10", + "trainVersion": "1.0", + "uploadDate": 1443144470000, + "iconUrl": "https://is3-ssl.mzstatic.com/image/thumb/Newsstand3/v4/94/80/28/948028c9-59e7-7b29-e75b-f57e97421ece/Icon-76@2x.png.png/150x150bb-80.png", + "iconAssetToken": "Newsstand3/v4/94/80/28/948028c9-59e7-7b29-e75b-f57e97421ece/Icon-76@2x.png.png", + "appName": "Updated by fastlane", "platform": "ios", - "betaEntitled": false, - "id": 523299, + "betaEntitled": true, + "exceededFileSizeLimit": false, + "wentLiveWithVersion": false, + "processing": false, + "id": 5577102, "valid": true, "missingExportCompliance": false, "waitingForExportComplianceApproval": false, "addedInternalUsersCount": 0, - "addedExternalUsersCount": 0, + "addedExternalUsersCount": 1, "invitedExternalUsersCount": 0, "invitedInternalUsersCount": 0, - "acceptedInternalUsersCount": 0, + "acceptedInternalUsersCount": 1, "acceptedExternalUsersCount": 0, "installCount": 0, "internalInstallCount": 0, "externalInstallCount": 0, - "sessionCount": null, - "crashCount": null, + "sessionCount": 0, + "internalSessionCount": 0, + "externalSessionCount": 0, + "crashCount": 0, + "internalCrashCount": 0, + "externalCrashCount": 0, "promotedVersion": null, - "internalState": "noBetaEntitlement", - "betaState": "noBetaEntitlement", - "internalExpiry": 1416562036000, + "internalState": "active", + "betaState": "submitForReview", + "internalExpiry": 1445737214000, "externalExpiry": 0, "watchKitEnabled": false, - "readyToInstall": false, + "readyToInstall": true, "sdkBuildWhitelisted": true, - "internalTesting": null, - "externalTesting": null + "internalTesting": { + "value": true, + "isEditable": true, + "isRequired": false, + "errorKeys": null + }, + "externalTesting": { + "value": false, + "isEditable": true, + "isRequired": false, + "errorKeys": null + } }], "buildsInProcessing": [] }, { - "versionString": "0.9.11", + "versionString": "1.1", "platform": "ios", - "testing": { - "value": true, + "testing": null, + "internalTesting": { + "value": false, + "isEditable": true, + "isRequired": false, + "errorKeys": null + }, + "externalTesting": { + "value": false, "isEditable": true, "isRequired": false, "errorKeys": null }, - "internalTesting": null, - "externalTesting": null, "internalActivated": null, "externalActivated": null, "builds": [{ "sectionErrorKeys": [], "sectionInfoKeys": [], "sectionWarningKeys": [], - "buildVersion": "0.9.11", - "trainVersion": "0.9.11", - "uploadDate": 1414069911000, - "iconUrl": "https://is4-ssl.mzstatic.com/image/thumb/Newsstand3/v4/c3/d9/27/c3d9272e-7c1b-7159-58b7-e58b824041f6/Icon-60@2x.png.png/150x150bb-80.png", - "appName": "Yeahaa", + "buildVersion": "9", + "trainVersion": "1.1", + "uploadDate": 1443150586000, + "iconUrl": "https://is5-ssl.mzstatic.com/image/thumb/Newsstand3/v4/70/6a/7f/706a7f53-bac9-0a43-eb07-9f2cbb9a7d71/Icon-76@2x.png.png/150x150bb-80.png", + "iconAssetToken": "Newsstand3/v4/70/6a/7f/706a7f53-bac9-0a43-eb07-9f2cbb9a7d71/Icon-76@2x.png.png", + "appName": "Updated by fastlane", "platform": "ios", - "betaEntitled": false, - "id": 539702, + "betaEntitled": true, + "exceededFileSizeLimit": false, + "wentLiveWithVersion": false, + "processing": false, + "id": 5578620, "valid": true, "missingExportCompliance": false, "waitingForExportComplianceApproval": false, "addedInternalUsersCount": 0, - "addedExternalUsersCount": 0, + "addedExternalUsersCount": 1, "invitedExternalUsersCount": 0, "invitedInternalUsersCount": 0, - "acceptedInternalUsersCount": 0, + "acceptedInternalUsersCount": 1, "acceptedExternalUsersCount": 0, "installCount": 0, "internalInstallCount": 0, "externalInstallCount": 0, - "sessionCount": null, - "crashCount": null, + "sessionCount": 0, + "internalSessionCount": 0, + "externalSessionCount": 0, + "crashCount": 0, + "internalCrashCount": 0, + "externalCrashCount": 0, "promotedVersion": null, - "internalState": "noBetaEntitlement", - "betaState": "noBetaEntitlement", - "internalExpiry": 1416665511000, + "internalState": "inactive", + "betaState": "submitForReview", + "internalExpiry": 1445742586000, "externalExpiry": 0, "watchKitEnabled": false, - "readyToInstall": false, + "readyToInstall": true, "sdkBuildWhitelisted": true, - "internalTesting": null, - "externalTesting": null + "internalTesting": { + "value": false, + "isEditable": true, + "isRequired": false, + "errorKeys": null + }, + "externalTesting": { + "value": false, + "isEditable": true, + "isRequired": false, + "errorKeys": null + } }], "buildsInProcessing": [] }], @@ -127,10 +173,10 @@ "trainVersion": null, "state": "ITC.apps.betaProcessingStatus.Created" }], - "currentTestingApps": 5, + "currentTestingApps": 1, "maxTestingApps": 10, "isBetaDataAvailable": true, - "submissionLimitReached": false + "dailySubmissionCount": 0 }, "messages": { "warn": null, diff --git a/spec/tunes/tunes_stubbing.rb b/spec/tunes/tunes_stubbing.rb index adf8d45..c9af448 100644 --- a/spec/tunes/tunes_stubbing.rb +++ b/spec/tunes/tunes_stubbing.rb @@ -61,7 +61,7 @@ def itc_stub_applications stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/overview"). with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie'=>'myacinfo=DAWTKN;woinst=3363;itctx=abc:def;wosid=xBJMOVttbAQ1Cwlt8ktafw', 'User-Agent'=>'spaceship'}). - to_return(:status => 200, body: itc_read_fixture_file('app_overview.json'), headers: {'Content-Type' => 'application/json'}) + to_return(:status => 200, body: itc_read_fixture_file('app_overview.json'), headers: {'Content-Type' => 'application/json'}) end def itc_stub_applications_first_create @@ -93,10 +93,10 @@ def itc_stub_broken_create_wildcard def itc_stub_app_versions # Receiving app version - stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/version/898536088?v="). + stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/versions/813314674"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('app_version.json'), headers: {'Content-Type' => 'application/json'}) - stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/version/898536088?v=live"). + stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/versions/113314675"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('app_version.json'), headers: {'Content-Type' => 'application/json'}) end @@ -139,8 +139,9 @@ def itc_stub_build_trains stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/?testingType=#{type}"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('build_trains.json'), headers: {'Content-Type' => 'application/json'}) + # Update build trains - stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/?testingType=#{type}"). + stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/testingTypes/#{type}/trains/"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('build_trains.json'), headers: {'Content-Type' => 'application/json'}) end @@ -160,17 +161,17 @@ def itc_stub_testers def itc_stub_testflight # Reject review - stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/0.9.10/builds/123123/reject"). + stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/1.0/builds/123123/reject"). with(body: "{}", headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: "{}", headers: {'Content-Type' => 'application/json'}) # Prepare submission - stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/0.9.10/builds/123123/submit/start"). + stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/1.0/builds/123123/submit/start"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('testflight_submission_start.json'), headers: {'Content-Type' => 'application/json'}) # First step of submission - stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/0.9.10/builds/123123/submit/start"). + stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/1.0/builds/123123/submit/start"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('testflight_submission_submit.json'), headers: {'Content-Type' => 'application/json'}) end From 70500f45f346ddc679a71257b3e19b7c985c5f4d Mon Sep 17 00:00:00 2001 From: KrauseFx Date: Thu, 24 Sep 2015 21:48:04 -0700 Subject: [PATCH 11/15] Updated/Added more tests --- spec/tunes/app_details_spec.rb | 49 ++++++++++ spec/tunes/app_version_spec.rb | 31 +----- spec/tunes/fixtures/app_details.json | 137 +++++++++++++++++++++++++++ spec/tunes/tunes_stubbing.rb | 5 + 4 files changed, 193 insertions(+), 29 deletions(-) create mode 100644 spec/tunes/app_details_spec.rb create mode 100644 spec/tunes/fixtures/app_details.json diff --git a/spec/tunes/app_details_spec.rb b/spec/tunes/app_details_spec.rb new file mode 100644 index 0000000..df84db4 --- /dev/null +++ b/spec/tunes/app_details_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' + +describe Spaceship::Tunes::AppDetails do + before { Spaceship::Tunes.login } + + let(:client) { Spaceship::AppVersion.client } + let(:app) { Spaceship::Application.all.first } + + describe "App Details are properly loaded" do + it "contains all the relevant information" do + details = app.details + + expect(details.name['en-US']).to eq("Updated by fastlane") + expect(details.privacy_url['en-US']).to eq('https://fastlane.tools') + expect(details.primary_category).to eq('MZGenre.Sports') + end + end + + describe "Modifying the app category" do + it "prefixes the category with the correct value for all category types" do + details = app.details + + details.primary_category = "Weather" + expect(details.primary_category).to eq("MZGenre.Weather") + + details.primary_first_sub_category = "Weather" + expect(details.primary_first_sub_category).to eq("MZGenre.Weather") + + details.primary_second_sub_category = "Weather" + expect(details.primary_second_sub_category).to eq("MZGenre.Weather") + + details.secondary_category = "Weather" + expect(details.secondary_category).to eq("MZGenre.Weather") + + details.secondary_first_sub_category = "Weather" + expect(details.secondary_first_sub_category).to eq("MZGenre.Weather") + + details.secondary_second_sub_category = "Weather" + expect(details.secondary_second_sub_category).to eq("MZGenre.Weather") + end + + it "doesn't prefix if the prefix is already there" do + details = app.details + + details.primary_category = "MZGenre.Weather" + expect(details.primary_category).to eq("MZGenre.Weather") + end + end +end diff --git a/spec/tunes/app_version_spec.rb b/spec/tunes/app_version_spec.rb index c10849c..c38d5c3 100644 --- a/spec/tunes/app_version_spec.rb +++ b/spec/tunes/app_version_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Spaceship::AppVersion do +describe Spaceship::AppVersion, all: true do before { Spaceship::Tunes.login } let(:client) { Spaceship::AppVersion.client } @@ -123,33 +123,6 @@ end end - describe "Modifying the category" do - it "prefixes the category with the correct value for all category types" do - version.primary_category = "Weather" - expect(version.primary_category).to eq("MZGenre.Weather") - - version.primary_first_sub_category = "Weather" - expect(version.primary_first_sub_category).to eq("MZGenre.Weather") - - version.primary_second_sub_category = "Weather" - expect(version.primary_second_sub_category).to eq("MZGenre.Weather") - - version.secondary_category = "Weather" - expect(version.secondary_category).to eq("MZGenre.Weather") - - version.secondary_first_sub_category = "Weather" - expect(version.secondary_first_sub_category).to eq("MZGenre.Weather") - - version.secondary_second_sub_category = "Weather" - expect(version.secondary_second_sub_category).to eq("MZGenre.Weather") - end - - it "doesn't prefix if the prefix is already there" do - version.primary_category = "MZGenre.Weather" - expect(version.primary_category).to eq("MZGenre.Weather") - end - end - it "allows modifications of localized values" do new_title = 'New Title' version.name['English'] = new_title @@ -175,7 +148,7 @@ describe "Accessing different languages" do it "raises an exception if language is not available" do expect do - version.name["English_CA"] + version.description["English_CA"] end.to raise_error "Language 'English_CA' is not activated for this app version." end diff --git a/spec/tunes/fixtures/app_details.json b/spec/tunes/fixtures/app_details.json new file mode 100644 index 0000000..853d051 --- /dev/null +++ b/spec/tunes/fixtures/app_details.json @@ -0,0 +1,137 @@ +{ + "data": { + "sectionErrorKeys": [], + "sectionInfoKeys": [], + "sectionWarningKeys": [], + "adamId": "1039164429", + "localizedMetadata": { + "value": [{ + "localeCode": "en-US", + "name": { + "value": "Updated by fastlane", + "isEditable": true, + "isRequired": true, + "errorKeys": null, + "maxLength": 255, + "minLength": 2 + }, + "privacyPolicyUrl": { + "value": "https://fastlane.tools", + "isEditable": true, + "isRequired": false, + "errorKeys": null, + "maxLength": 255, + "minLength": 0 + }, + "privacyPolicy": { + "value": null, + "isEditable": false, + "isRequired": false, + "errorKeys": null + } + }, { + "localeCode": "de-DE", + "name": { + "value": "why new itc 2", + "isEditable": true, + "isRequired": true, + "errorKeys": null, + "maxLength": 255, + "minLength": 2 + }, + "privacyPolicyUrl": { + "value": null, + "isEditable": true, + "isRequired": false, + "errorKeys": null, + "maxLength": 255, + "minLength": 0 + }, + "privacyPolicy": { + "value": null, + "isEditable": false, + "isRequired": false, + "errorKeys": null + } + }], + "isEditable": true, + "isRequired": true, + "errorKeys": null + }, + "availablePrimaryLocaleCodes": ["en-US", "de-DE"], + "primaryLocaleCode": { + "value": "en-US", + "isEditable": true, + "isRequired": true, + "errorKeys": null + }, + "primaryCategory": { + "value": "MZGenre.Sports", + "isEditable": true, + "isRequired": false, + "errorKeys": null + }, + "primaryFirstSubCategory": { + "value": null, + "isEditable": true, + "isRequired": false, + "errorKeys": null + }, + "primarySecondSubCategory": { + "value": null, + "isEditable": true, + "isRequired": false, + "errorKeys": null + }, + "secondaryCategory": { + "value": "MZGenre.Games", + "isEditable": true, + "isRequired": false, + "errorKeys": null + }, + "secondaryFirstSubCategory": { + "value": "MZGenre.Educational", + "isEditable": true, + "isRequired": false, + "errorKeys": null + }, + "secondarySecondSubCategory": { + "value": "MZGenre.Puzzle", + "isEditable": true, + "isRequired": false, + "errorKeys": null + }, + "availableBundleIds": null, + "bundleId": { + "value": "tools.fastlane.app", + "isEditable": false, + "isRequired": true, + "errorKeys": null + }, + "bundleIdSuffix": { + "value": null, + "isEditable": false, + "isRequired": true, + "errorKeys": null + }, + "license": { + "countries": null, + "isEditable": true, + "isRequired": false, + "errorKeys": null, + "isEmptyValue": true, + "EULAText": null + }, + "vendorId": "1441930512", + "rating": null, + "ageBandMinAge": null, + "ageBandMaxAge": null, + "countryRatings": null + }, + "messages": { + "warn": null, + "error": null, + "info": null + }, + "statusCode": "SUCCESS" +} \ No newline at end of file diff --git a/spec/tunes/tunes_stubbing.rb b/spec/tunes/tunes_stubbing.rb index c9af448..d6f2983 100644 --- a/spec/tunes/tunes_stubbing.rb +++ b/spec/tunes/tunes_stubbing.rb @@ -62,6 +62,11 @@ def itc_stub_applications stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/overview"). with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie'=>'myacinfo=DAWTKN;woinst=3363;itctx=abc:def;wosid=xBJMOVttbAQ1Cwlt8ktafw', 'User-Agent'=>'spaceship'}). to_return(:status => 200, body: itc_read_fixture_file('app_overview.json'), headers: {'Content-Type' => 'application/json'}) + + # App Details + stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/details"). + with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie'=>'myacinfo=DAWTKN;woinst=3363;itctx=abc:def;wosid=xBJMOVttbAQ1Cwlt8ktafw', 'User-Agent'=>'spaceship'}). + to_return(:status => 200, body: itc_read_fixture_file('app_details.json'), headers: {'Content-Type' => 'application/json'}) end def itc_stub_applications_first_create From f0741ffde61f4028bb6ce63fdf6b1f6ba4716de2 Mon Sep 17 00:00:00 2001 From: KrauseFx Date: Thu, 24 Sep 2015 22:15:21 -0700 Subject: [PATCH 12/15] More updated tests and docs --- docs/iTunesConnect.md | 1 - spec/tunes/app_version_spec.rb | 9 ++------- spec/tunes/application_spec.rb | 13 +------------ spec/tunes/build_spec.rb | 2 +- spec/tunes/language_item_spec.rb | 4 ++-- spec/tunes/tunes_stubbing.rb | 6 +++--- 6 files changed, 9 insertions(+), 26 deletions(-) diff --git a/docs/iTunesConnect.md b/docs/iTunesConnect.md index f4dda34..fa3cee2 100644 --- a/docs/iTunesConnect.md +++ b/docs/iTunesConnect.md @@ -204,7 +204,6 @@ parameters = { # Optional Metadata: privacy_policy_url: nil, - review_notes: nil, review_user_name: nil, review_password: nil, encryption: false diff --git a/spec/tunes/app_version_spec.rb b/spec/tunes/app_version_spec.rb index c38d5c3..617224b 100644 --- a/spec/tunes/app_version_spec.rb +++ b/spec/tunes/app_version_spec.rb @@ -18,8 +18,6 @@ expect(version.is_live?).to eq(false) expect(version.copyright).to eq("2015 SunApps GmbH") expect(version.version_id).to eq(812106519) - expect(version.primary_category).to eq('MZGenre.Reference') - expect(version.secondary_category).to eq('MZGenre.Business') expect(version.raw_status).to eq('readyForSale') expect(version.can_reject_version).to eq(false) expect(version.can_prepare_for_upload).to eq(false) @@ -37,13 +35,10 @@ it "parses the localized values correctly" do version = app.edit_version - expect(version.name['English']).to eq('App Name 123') - expect(version.name['German']).to eq("yep, that's the name") expect(version.description['English']).to eq('Super Description here') expect(version.description['German']).to eq('My title') expect(version.keywords['English']).to eq('Some random titles') expect(version.keywords['German']).to eq('More random stuff') - expect(version.privacy_url['English']).to eq('http://privacy.sunapps.net') expect(version.support_url['German']).to eq('http://url.com') expect(version.marketing_url['English']).to eq('https://sunapps.net') expect(version.release_notes['German']).to eq('Wow, News') @@ -125,9 +120,9 @@ it "allows modifications of localized values" do new_title = 'New Title' - version.name['English'] = new_title + version.description['English'] = new_title lang = version.languages.find { |a| a['language'] == 'English' } - expect(lang['name']['value']).to eq(new_title) + expect(lang['description']['value']).to eq(new_title) end describe "Pushing the changes back to the server" do diff --git a/spec/tunes/application_spec.rb b/spec/tunes/application_spec.rb index 72f9fbc..fa23b0b 100644 --- a/spec/tunes/application_spec.rb +++ b/spec/tunes/application_spec.rb @@ -144,17 +144,12 @@ describe "Access app_versions" do describe "#edit_version" do - it "returns nil if there is only a live version" do - app = Spaceship::Application.all.find { |a| a.apple_id == '1013943394' } - expect(app.edit_version).to eq(nil) - end - it "returns the edit version if there is an edit version" do app = Spaceship::Application.all.first v = app.edit_version expect(v.class).to eq(Spaceship::AppVersion) expect(v.application).to eq(app) - expect(v.name['German']).to eq("yep, that's the name") + expect(v.description['German']).to eq("My title") expect(v.is_live).to eq(false) end end @@ -182,12 +177,6 @@ app.create_version!('0.1') end.to raise_error "Cannot create a new version for this app as there already is an `edit_version` available" end - - it "works if there is no `edit_version` already available" do - app = Spaceship::Application.all.find { |a| a.apple_id == '1013943394' } - expect(app.edit_version).to eq(nil) - app.create_version!('0.1') - end end end end diff --git a/spec/tunes/build_spec.rb b/spec/tunes/build_spec.rb index c8668b7..87d772c 100644 --- a/spec/tunes/build_spec.rb +++ b/spec/tunes/build_spec.rb @@ -69,7 +69,7 @@ expect(r).to eq({ app_id: "898536088", train: "1.0", - build_number: "123123", + build_number: "10", changelog: "Custom Changelog", description: "No app description provided", feedback_email: "contact@company.com", diff --git a/spec/tunes/language_item_spec.rb b/spec/tunes/language_item_spec.rb index aecfb46..579f9d8 100644 --- a/spec/tunes/language_item_spec.rb +++ b/spec/tunes/language_item_spec.rb @@ -7,8 +7,8 @@ describe "#inspect" do it "prints out all languages with their values" do - str = Spaceship::Application.all.first.edit_version.name.inspect - expect(str).to eq("German: yep, that's the name\nEnglish: App Name 123\n") + str = Spaceship::Application.all.first.edit_version.description.inspect + expect(str).to eq("German: My title\nEnglish: Super Description here\n") end end end diff --git a/spec/tunes/tunes_stubbing.rb b/spec/tunes/tunes_stubbing.rb index d6f2983..26639d5 100644 --- a/spec/tunes/tunes_stubbing.rb +++ b/spec/tunes/tunes_stubbing.rb @@ -166,17 +166,17 @@ def itc_stub_testers def itc_stub_testflight # Reject review - stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/1.0/builds/123123/reject"). + stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/1.0/builds/10/reject"). with(body: "{}", headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: "{}", headers: {'Content-Type' => 'application/json'}) # Prepare submission - stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/1.0/builds/123123/submit/start"). + stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/1.0/builds/10/submit/start"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('testflight_submission_start.json'), headers: {'Content-Type' => 'application/json'}) # First step of submission - stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/1.0/builds/123123/submit/start"). + stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/1.0/builds/10/submit/start"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('testflight_submission_submit.json'), headers: {'Content-Type' => 'application/json'}) end From 573940871a269368c511b3205d5b7df4cade3cfc Mon Sep 17 00:00:00 2001 From: KrauseFx Date: Thu, 24 Sep 2015 22:22:54 -0700 Subject: [PATCH 13/15] Improved code style --- Rakefile | 25 ------------------------- lib/spaceship/tunes/build_train.rb | 2 +- lib/spaceship/tunes/tunes_client.rb | 4 ++++ spec/tunes/tunes_stubbing.rb | 17 ++++++++--------- 4 files changed, 13 insertions(+), 35 deletions(-) diff --git a/Rakefile b/Rakefile index 94576c2..bf203bd 100644 --- a/Rakefile +++ b/Rakefile @@ -8,28 +8,3 @@ task default: :spec task :test do sh "../fastlane/bin/fastlane test" end - -task :beta do - require 'spaceship' - puts "Login..." - Spaceship::Tunes.login('flapple@krausefx.com') - app = Spaceship::Application.find("tools.fastlane.app") - require 'pry' - - # puts app.name["en-US"] - # puts app.privacy_url["en-US"] - - details = app.details - details.name['en-US'] = "Updated by fastlane" - details.privacy_url['en-US'] = "https://fastlane.tools" - details.primary_category = 'Sports' - details.secondary_category = 'Family' - details.save! - - # v = app.edit_version - - # puts v.marketing_url['de-DE'] - # v.marketing_url['en-US'] = "https://neu.com" - # v.marketing_url['de-DE'] = "https://suchdeutsch.com" - -end \ No newline at end of file diff --git a/lib/spaceship/tunes/build_train.rb b/lib/spaceship/tunes/build_train.rb index 435da4d..1ce3cf8 100644 --- a/lib/spaceship/tunes/build_train.rb +++ b/lib/spaceship/tunes/build_train.rb @@ -85,7 +85,7 @@ def update_testing_status!(new_value, testing_type) result = client.update_build_trains!(application.apple_id, testing_type, data) self.internal_testing_enabled = new_value if testing_type == 'internal' self.external_testing_enabled = new_value if testing_type == 'external' - + result end end diff --git a/lib/spaceship/tunes/tunes_client.rb b/lib/spaceship/tunes/tunes_client.rb index c15e1ee..6f7a40c 100644 --- a/lib/spaceship/tunes/tunes_client.rb +++ b/lib/spaceship/tunes/tunes_client.rb @@ -81,6 +81,8 @@ def send_login_request(user, password) end end + # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/PerceivedComplexity def handle_itc_response(raw) return unless raw return unless raw.kind_of? Hash @@ -135,6 +137,8 @@ def handle_itc_response(raw) return data end + # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity ##################################################### # @!group Applications diff --git a/spec/tunes/tunes_stubbing.rb b/spec/tunes/tunes_stubbing.rb index 26639d5..192c1e8 100644 --- a/spec/tunes/tunes_stubbing.rb +++ b/spec/tunes/tunes_stubbing.rb @@ -53,20 +53,19 @@ def itc_stub_applications with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('create_application_success.json'), headers: {'Content-Type' => 'application/json'}) - # Overview of application to get the versions stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/1013943394/overview"). - with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie'=>'myacinfo=DAWTKN;woinst=3363;itctx=abc:def;wosid=xBJMOVttbAQ1Cwlt8ktafw', 'User-Agent'=>'spaceship'}). - to_return(:status => 200, body: itc_read_fixture_file('app_overview.json'), headers: {'Content-Type' => 'application/json'}) + with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie' => 'myacinfo=DAWTKN;woinst=3363;itctx=abc:def;wosid=xBJMOVttbAQ1Cwlt8ktafw', 'User-Agent' => 'spaceship'}). + to_return(status: 200, body: itc_read_fixture_file('app_overview.json'), headers: {'Content-Type' => 'application/json'}) stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/overview"). - with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie'=>'myacinfo=DAWTKN;woinst=3363;itctx=abc:def;wosid=xBJMOVttbAQ1Cwlt8ktafw', 'User-Agent'=>'spaceship'}). - to_return(:status => 200, body: itc_read_fixture_file('app_overview.json'), headers: {'Content-Type' => 'application/json'}) + with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie' => 'myacinfo=DAWTKN;woinst=3363;itctx=abc:def;wosid=xBJMOVttbAQ1Cwlt8ktafw', 'User-Agent' => 'spaceship'}). + to_return(status: 200, body: itc_read_fixture_file('app_overview.json'), headers: {'Content-Type' => 'application/json'}) # App Details stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/details"). - with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie'=>'myacinfo=DAWTKN;woinst=3363;itctx=abc:def;wosid=xBJMOVttbAQ1Cwlt8ktafw', 'User-Agent'=>'spaceship'}). - to_return(:status => 200, body: itc_read_fixture_file('app_details.json'), headers: {'Content-Type' => 'application/json'}) + with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie' => 'myacinfo=DAWTKN;woinst=3363;itctx=abc:def;wosid=xBJMOVttbAQ1Cwlt8ktafw', 'User-Agent' => 'spaceship'}). + to_return(status: 200, body: itc_read_fixture_file('app_details.json'), headers: {'Content-Type' => 'application/json'}) end def itc_stub_applications_first_create @@ -140,11 +139,11 @@ def itc_stub_resolution_center end def itc_stub_build_trains - %w[internal external].each do |type| + %w(internal external).each do |type| stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/?testingType=#{type}"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). to_return(status: 200, body: itc_read_fixture_file('build_trains.json'), headers: {'Content-Type' => 'application/json'}) - + # Update build trains stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/testingTypes/#{type}/trains/"). with(headers: {'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type' => 'application/json', 'Cookie' => itc_cookie, 'User-Agent' => 'spaceship'}). From ad16b511f5d3fffd80119f9cf8d4a682359ca5f2 Mon Sep 17 00:00:00 2001 From: KrauseFx Date: Thu, 24 Sep 2015 22:38:04 -0700 Subject: [PATCH 14/15] Improved edit_version and live_version fetcher Removed debug code --- lib/spaceship.rb | 2 -- lib/spaceship/tunes/application.rb | 20 ++++++++++++++------ lib/spaceship/tunes/tunes_client.rb | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/spaceship.rb b/lib/spaceship.rb index eea3d20..99be1ca 100644 --- a/lib/spaceship.rb +++ b/lib/spaceship.rb @@ -11,8 +11,6 @@ require 'spaceship/tunes/tunes' require 'spaceship/tunes/spaceship' -require 'pry' - # To support legacy code module Spaceship # Dev Portal diff --git a/lib/spaceship/tunes/application.rb b/lib/spaceship/tunes/application.rb index ec1542c..919bd95 100644 --- a/lib/spaceship/tunes/application.rb +++ b/lib/spaceship/tunes/application.rb @@ -101,17 +101,25 @@ def create!(name: nil, primary_language: nil, version: nil, sku: nil, bundle_id: # @return (Spaceship::AppVersion) Receive the version that is currently live on the # App Store. You can't modify all values there, so be careful. def live_version + if raw_data['versions'].count == 1 + v = raw_data['versions'].last + if ['Prepare for Upload', 'prepareForUpload'].include?(v['state']) # this only applies for the initial version + return nil + end + end + Spaceship::AppVersion.find(self, self.apple_id, true) end # @return (Spaceship::AppVersion) Receive the version that can fully be edited def edit_version - # 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 - # TODO: Fix + if raw_data['versions'].count == 1 + v = raw_data['versions'].last + + unless ['Prepare for Upload', 'prepareForUpload'].include?(v['state']) # this only applies for the initial version + return nil # only live version, user should create a new version + end + end Spaceship::AppVersion.find(self, self.apple_id, false) end diff --git a/lib/spaceship/tunes/tunes_client.rb b/lib/spaceship/tunes/tunes_client.rb index 6f7a40c..3494fa2 100644 --- a/lib/spaceship/tunes/tunes_client.rb +++ b/lib/spaceship/tunes/tunes_client.rb @@ -231,7 +231,7 @@ def app_version(app_id, is_live) r = request(:get, "ra/apps/#{app_id}/overview") platforms = parse_response(r, 'data')['platforms'] - platforms = platforms.first # TODO: that won't work for mac apps + platforms = platforms.first # That won't work for mac apps version = platforms[(is_live ? 'deliverableVersion' : 'inFlightVersion')] return nil unless version From 9d1b24315050407ec77699cb6399aaf6aee6ea52 Mon Sep 17 00:00:00 2001 From: KrauseFx Date: Thu, 24 Sep 2015 22:39:10 -0700 Subject: [PATCH 15/15] Updated docs --- docs/iTunesConnect.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/iTunesConnect.md b/docs/iTunesConnect.md index fa3cee2..2391c5f 100644 --- a/docs/iTunesConnect.md +++ b/docs/iTunesConnect.md @@ -84,7 +84,6 @@ v.copyright = "#{Time.now.year} Felix Krause" v.description.languages # => ["German", "English"] # Update localised app metadata -v.name["English"] = "New Title" v.description["English"] = "App Description" # Push the changes back to the server @@ -139,7 +138,6 @@ attr_accessor :review_notes #### attr_accessor :languages -attr_reader :name attr_reader :keywords attr_reader :description attr_reader :release_notes