lib/spaceship/tunes/tunes_client.rb in spaceship-0.4.0 vs lib/spaceship/tunes/tunes_client.rb in spaceship-0.5.0

- old
+ new

@@ -22,11 +22,11 @@ end return cached if cached host = "https://itunesconnect.apple.com" begin - url = host + request(:get, self.class.hostname).body.match(/action="(\/WebObjects\/iTunesConnect.woa\/wo\/.*)"/)[1] + url = host + request(:get, self.class.hostname).body.match(%r{action="(/WebObjects/iTunesConnect.woa/wo/.*)"})[1] raise "" unless url.length > 0 File.write(cache_path, url) return url rescue => ex @@ -55,19 +55,19 @@ "woinst=" + cooks.match(/woinst=(\w+)/)[1], "wosid=" + cooks.match(/wosid=(\w+)/)[1] ] @cookie = to_use.join(';') - rescue => ex + rescue # User Credentials are wrong - raise InvalidUserCredentialsError.new(response) + raise InvalidUserCredentialsError.new, response end return @client else # User Credentials are wrong - raise InvalidUserCredentialsError.new(response) + raise InvalidUserCredentialsError.new, response end end def handle_itc_response(raw) return unless raw @@ -84,36 +84,35 @@ handle_response_hash = lambda do |hash| errors = [] if hash.kind_of? Hash hash.each do |key, value| - errors = errors + handle_response_hash.call(value) + errors += handle_response_hash.call(value) if key == 'errorKeys' and value.kind_of? Array and value.count > 0 - errors = errors + value + errors += value end end elsif hash.kind_of? Array hash.each do |value| - errors = errors + handle_response_hash.call(value) + errors += handle_response_hash.call(value) end - else - # We don't care about simple values + # else: We don't care about simple values end return errors end errors = handle_response_hash.call(data) - errors = errors + data.fetch('sectionErrorKeys') if data['sectionErrorKeys'] + errors += data.fetch('sectionErrorKeys') if data['sectionErrorKeys'] # Sometimes there is a different kind of error in the JSON response # e.g. {"warn"=>nil, "error"=>["operation_failed"], "info"=>nil} different_error = raw.fetch('messages', {}).fetch('error', nil) errors << different_error if different_error if errors.count > 0 # they are separated by `.` by default - raise ITunesConnectError.new(errors.join(' ')) + raise ITunesConnectError.new, errors.join(' ') end puts data['sectionInfoKeys'] if data['sectionInfoKeys'] puts data['sectionWarningKeys'] if data['sectionWarningKeys'] @@ -174,11 +173,11 @@ parse_response(r, 'data') end def get_resolution_center(app_id) r = request(:get, "ra/apps/#{app_id}/resolutionCenter?v=latest") - data = parse_response(r, 'data') + parse_response(r, 'data') end ##################################################### # @!group AppVersions ##################################################### @@ -212,11 +211,11 @@ def build_trains(app_id) raise "app_id is required" unless app_id r = request(:get, "ra/apps/#{app_id}/trains/") - data = parse_response(r, 'data') + parse_response(r, 'data') end def update_build_trains!(app_id, data) raise "app_id is required" unless app_id @@ -240,11 +239,10 @@ def submit_testflight_build_for_review!( # Required: app_id: nil, train: nil, build_number: nil, - cancel_other_submissions: false, # Required Metadata: changelog: nil, description: nil, feedback_email: nil, @@ -254,10 +252,9 @@ review_email: nil, phone_number: nil, # Optional Metadata: privacy_policy_url: nil, - review_notes: nil, review_user_name: nil, review_password: nil, encryption: false) start_url = "ra/apps/#{app_id}/trains/#{train}/builds/#{build_number}/submit/start"