Class: Spaceship::TunesClient
- Defined in:
- lib/spaceship/tunes/tunes_client.rb
Overview
rubocop:disable Metrics/ClassLength
Defined Under Namespace
Classes: ITunesConnectError, ITunesConnectTemporaryError
Constant Summary
Constants inherited from Client
Client::PROTOCOL_VERSION, Client::USER_AGENT
Instance Attribute Summary collapse
-
#du_client ⇒ Object
readonly
Returns the value of attribute du_client.
Attributes inherited from Client
#client, #csrf_tokens, #logger, #user
Init and Login collapse
- .hostname ⇒ Object
-
#handle_itc_response(raw) ⇒ Object
rubocop:disable Metrics/PerceivedComplexity.
-
#select_team ⇒ Object
Shows a team selection for the user in the terminal.
- #send_login_request(user, password) ⇒ Object
-
#team_id ⇒ String
The currently selected Team ID.
-
#team_id=(team_id) ⇒ Object
Set a new team ID which will be used from now on.
-
#team_information ⇒ Hash
Fetches all information of the currently used team.
-
#teams ⇒ Array
A list of all available teams.
Applications collapse
- #app_details(app_id) ⇒ Object
- #applications ⇒ Object
-
#create_application!(name: nil, primary_language: nil, version: nil, sku: nil, bundle_id: nil, bundle_id_suffix: nil, company_name: nil) ⇒ Object
Creates a new application on iTunes Connect.
- #create_version!(app_id, version_number, platform = 'ios') ⇒ Object
- #get_rating_summary(app_id, platform, versionId = '') ⇒ Object
- #get_resolution_center(app_id, platform) ⇒ Object
- #get_reviews(app_id, platform, storefront, versionId = '') ⇒ Object
- #update_app_details!(app_id, data) ⇒ Object
AppVersions collapse
- #app_version(app_id, is_live) ⇒ Object
- #app_version_data(app_id, version_platform: nil, version_id: nil) ⇒ Object
- #update_app_version!(app_id, version_id, data) ⇒ Object
Pricing collapse
- #price_tier(app_id) ⇒ Object
-
#pricing_tiers ⇒ Array
Returns an array of all available pricing tiers.
-
#supported_countries ⇒ Object
An array of supported countries [{ “code”: “AL”, “name”: “Albania”, “region”: “Europe” }, { .…
- #update_price_tier!(app_id, price_tier) ⇒ Object
App Icons collapse
-
#ref_data ⇒ AppVersionRef
Fetches the App Version Reference information from ITC.
-
#upload_geojson(app_version, upload_file) ⇒ JSON
Uploads the transit app file.
-
#upload_large_icon(app_version, upload_image) ⇒ JSON
Uploads a large icon.
-
#upload_screenshot(app_version, upload_image, device) ⇒ JSON
Uploads a screenshot.
-
#upload_trailer(app_version, upload_trailer) ⇒ JSON
Uploads the transit app file.
-
#upload_trailer_preview(app_version, upload_trailer_preview) ⇒ JSON
Uploads the trailer preview.
-
#upload_watch_icon(app_version, upload_image) ⇒ JSON
Uploads a watch icon.
-
#user_detail_data ⇒ UserDetail
Fetches the User Detail information from ITC.
CandiateBuilds collapse
Build Trains collapse
-
#all_build_trains(app_id: nil, platform: nil) ⇒ Object
All build trains, even if there is no TestFlight.
- #all_builds_for_train(app_id: nil, train: nil, platform: nil) ⇒ Object
- #build_details(app_id: nil, train: nil, build_number: nil, platform: nil) ⇒ Object
- #build_trains(app_id, testing_type) ⇒ Object
-
#get_build_info_for_review(app_id: nil, train: nil, build_number: nil, platform: 'ios') ⇒ Object
rubocop:enable Metrics/ParameterLists.
- #remove_testflight_build_from_review!(app_id: nil, train: nil, build_number: nil, platform: 'ios') ⇒ Object
-
#submit_testflight_build_for_review!(app_id: nil, train: nil, build_number: nil, platform: 'ios', changelog: nil, description: nil, feedback_email: nil, marketing_url: nil, first_name: nil, last_name: nil, review_email: nil, phone_number: nil, significant_change: false, privacy_policy_url: nil, review_user_name: nil, review_password: nil, review_notes: nil, encryption: false, encryption_updated: false, is_exempt: false, proprietary: false, third_party: false) ⇒ Object
rubocop:disable Metrics/ParameterLists.
- #update_build_information!(app_id: nil, train: nil, build_number: nil, whats_new: nil, description: nil, feedback_email: nil, platform: 'ios') ⇒ Object
- #update_build_trains!(app_id, testing_type, data) ⇒ Object
Submit for Review collapse
release collapse
Testers collapse
- #add_tester_to_app!(tester, app_id) ⇒ Object
- #create_tester!(tester: nil, email: nil, first_name: nil, last_name: nil) ⇒ Object
- #delete_tester!(tester) ⇒ Object
- #remove_tester_from_app!(tester, app_id) ⇒ Object
- #testers(tester) ⇒ Object
- #testers_by_app(tester, app_id) ⇒ Object
Sandbox Testers collapse
- #create_sandbox_tester!(tester_class: nil, email: nil, password: nil, first_name: nil, last_name: nil, country: nil) ⇒ Object
- #delete_sandbox_testers!(tester_class, emails) ⇒ Object
- #sandbox_testers(tester_class) ⇒ Object
State History collapse
- #version_states_history(app_id, platform, version_id) ⇒ Object
- #versions_history(app_id, platform) ⇒ Object
Promo codes collapse
- #app_promocodes(app_id: nil) ⇒ Object
- #app_promocodes_history(app_id: nil) ⇒ Object
- #generate_app_version_promocodes!(app_id: nil, version_id: nil, quantity: nil) ⇒ Object
Class Method Summary collapse
-
.video_preview_resolution_for(device, is_portrait) ⇒ Object
trailer preview screenshots are required to have a specific size.
Instance Method Summary collapse
-
#initialize ⇒ TunesClient
constructor
A new instance of TunesClient.
Methods inherited from Client
#UI, #cookie, #handle_two_factor, #handle_two_step, #itc_service_key, #load_session_from_env, #load_session_from_file, login, #login, #page_size, #paging, #parse_response, #persistent_cookie_path, #request, #select_device, #send_shared_login_request, #store_cookie, #store_session, #with_retry
Constructor Details
#initialize ⇒ TunesClient
Returns a new instance of TunesClient.
16 17 18 19 20 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 16 def initialize super @du_client = DUClient.new end |
Instance Attribute Details
#du_client ⇒ Object (readonly)
Returns the value of attribute du_client.
14 15 16 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 14 def du_client @du_client end |
Class Method Details
.hostname ⇒ Object
43 44 45 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 43 def self.hostname "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/" end |
.video_preview_resolution_for(device, is_portrait) ⇒ Object
trailer preview screenshots are required to have a specific size
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 24 def video_preview_resolution_for(device, is_portrait) resolutions = { 'iphone4' => [1136, 640], 'iphone6' => [1334, 750], 'iphone6Plus' => [2208, 1242], 'ipad' => [1024, 768], 'ipadPro' => [2732, 2048] } r = resolutions[device] r = [r[1], r[0]] if is_portrait r end |
Instance Method Details
#add_tester_to_app!(tester, app_id) ⇒ Object
852 853 854 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 852 def add_tester_to_app!(tester, app_id) update_tester_from_app!(tester, app_id, true) end |
#all_build_trains(app_id: nil, platform: nil) ⇒ Object
All build trains, even if there is no TestFlight
589 590 591 592 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 589 def all_build_trains(app_id: nil, platform: nil) r = request(:get, "ra/apps/#{app_id}/buildHistory?platform=#{platform || 'ios'}") handle_itc_response(r.body) end |
#all_builds_for_train(app_id: nil, train: nil, platform: nil) ⇒ Object
594 595 596 597 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 594 def all_builds_for_train(app_id: nil, train: nil, platform: nil) r = request(:get, "ra/apps/#{app_id}/trains/#{train}/buildHistory?platform=#{platform || 'ios'}") handle_itc_response(r.body) end |
#app_details(app_id) ⇒ Object
238 239 240 241 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 238 def app_details(app_id) r = request(:get, "ra/apps/#{app_id}/details") parse_response(r, 'data') end |
#app_promocodes(app_id: nil) ⇒ Object
925 926 927 928 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 925 def app_promocodes(app_id: nil) r = request(:get, "ra/apps/#{app_id}/promocodes/versions") parse_response(r, 'data')['versions'] end |
#app_promocodes_history(app_id: nil) ⇒ Object
944 945 946 947 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 944 def app_promocodes_history(app_id: nil) r = request(:get, "ra/apps/#{app_id}/promocodes/history") parse_response(r, 'data')['requests'] end |
#app_version(app_id, is_live) ⇒ Object
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 328 def app_version(app_id, is_live) raise "app_id is required" unless app_id # 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'] platform = Spaceship::Tunes::AppVersionCommon.find_platform(platforms) return nil unless platform version_id = Spaceship::Tunes::AppVersionCommon.find_version_id(platform, is_live) return nil unless version_id version_platform = platform['platformString'] app_version_data(app_id, version_platform: version_platform, version_id: version_id) end |
#app_version_data(app_id, version_platform: nil, version_id: nil) ⇒ Object
346 347 348 349 350 351 352 353 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 346 def app_version_data(app_id, version_platform: nil, version_id: nil) raise "app_id is required" unless app_id raise "version_platform is required" unless version_platform raise "version_id is required" unless version_id r = request(:get, "ra/apps/#{app_id}/platforms/#{version_platform}/versions/#{version_id}") parse_response(r, 'data') end |
#applications ⇒ Object
233 234 235 236 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 233 def applications r = request(:get, 'ra/apps/manageyourapps/summary/v2') parse_response(r, 'data')['summaries'] end |
#build_details(app_id: nil, train: nil, build_number: nil, platform: nil) ⇒ Object
599 600 601 602 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 599 def build_details(app_id: nil, train: nil, build_number: nil, platform: nil) r = request(:get, "ra/apps/#{app_id}/platforms/#{platform || 'ios'}/trains/#{train}/builds/#{build_number}/details") handle_itc_response(r.body) end |
#build_trains(app_id, testing_type) ⇒ Object
558 559 560 561 562 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 558 def build_trains(app_id, testing_type) raise "app_id is required" unless app_id r = request(:get, "ra/apps/#{app_id}/trains/?testingType=#{testing_type}") parse_response(r, 'data') end |
#candidate_builds(app_id, version_id) ⇒ Object
548 549 550 551 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 548 def candidate_builds(app_id, version_id) r = request(:get, "ra/apps/#{app_id}/versions/#{version_id}/candidateBuilds") parse_response(r, 'data')['builds'] end |
#create_application!(name: nil, primary_language: nil, version: nil, sku: nil, bundle_id: nil, bundle_id_suffix: nil, company_name: nil) ⇒ Object
Creates a new application on iTunes Connect
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 263 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 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 # some values are nil, that's why there is a hash data['versionString'] = { value: version } data['name'] = { value: name } data['bundleId'] = { value: bundle_id } data['primaryLanguage'] = { value: primary_language || 'English' } data['vendorId'] = { value: sku } data['bundleIdSuffix'] = { value: bundle_id_suffix } data['companyName'] = { value: company_name } if company_name data['enabledPlatformsForCreation'] = { value: [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/v2' req.body = data.to_json req.headers['Content-Type'] = 'application/json' end data = parse_response(r, 'data') handle_itc_response(data) end |
#create_sandbox_tester!(tester_class: nil, email: nil, password: nil, first_name: nil, last_name: nil, country: nil) ⇒ Object
869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 869 def create_sandbox_tester!(tester_class: nil, email: nil, password: nil, first_name: nil, last_name: nil, country: nil) url = tester_class.url[:create] r = request(:post) do |req| req.url url req.body = { user: { emailAddress: { value: email }, password: { value: password }, confirmPassword: { value: password }, firstName: { value: first_name }, lastName: { value: last_name }, storeFront: { value: country }, birthDay: { value: 1 }, birthMonth: { value: 1 }, secretQuestion: { value: SecureRandom.hex }, secretAnswer: { value: SecureRandom.hex }, sandboxAccount: nil } }.to_json req.headers['Content-Type'] = 'application/json' end parse_response(r, 'data')['user'] end |
#create_tester!(tester: nil, email: nil, first_name: nil, last_name: nil) ⇒ Object
788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 788 def create_tester!(tester: nil, email: nil, first_name: nil, last_name: nil) url = tester.url[:create] raise "Action not provided for this tester type." unless url tester_data = { emailAddress: { value: email }, firstName: { value: first_name || "" }, lastName: { value: last_name || "" }, testing: { value: true } } data = { testers: [tester_data] } r = request(:post) do |req| req.url url req.body = data.to_json req.headers['Content-Type'] = 'application/json' end data = parse_response(r, 'data')['testers'] handle_itc_response(data) || data[0] end |
#create_version!(app_id, version_number, platform = 'ios') ⇒ Object
294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 294 def create_version!(app_id, version_number, platform = 'ios') r = request(:post) do |req| req.url "ra/apps/#{app_id}/platforms/#{platform}/versions/create/" req.body = { version: { value: version_number.to_s } }.to_json req.headers['Content-Type'] = 'application/json' end data = parse_response(r, 'data') handle_itc_response(data) end |
#delete_sandbox_testers!(tester_class, emails) ⇒ Object
893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 893 def delete_sandbox_testers!(tester_class, emails) url = tester_class.url[:delete] request(:post) do |req| req.url url req.body = emails.map do |email| { emailAddress: { value: email } } end.to_json req.headers['Content-Type'] = 'application/json' end true end |
#delete_tester!(tester) ⇒ Object
819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 819 def delete_tester!(tester) url = tester.class.url[:delete] raise "Action not provided for this tester type." unless url data = [ { emailAddress: { value: tester.email }, firstName: { value: tester.first_name }, lastName: { value: tester.last_name }, testing: { value: false }, userName: tester.email, testerId: tester.tester_id } ] r = request(:post) do |req| req.url url req.body = data.to_json req.headers['Content-Type'] = 'application/json' end data = parse_response(r, 'data')['testers'] handle_itc_response(data) || data[0] end |
#generate_app_version_promocodes!(app_id: nil, version_id: nil, quantity: nil) ⇒ Object
930 931 932 933 934 935 936 937 938 939 940 941 942 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 930 def generate_app_version_promocodes!(app_id: nil, version_id: nil, quantity: nil) data = { numberOfCodes: { value: quantity }, agreedToContract: { value: true } } url = "ra/apps/#{app_id}/promocodes/versions/#{version_id}" r = request(:post) do |req| req.url url req.body = data.to_json req.headers['Content-Type'] = 'application/json' end parse_response(r, 'data') end |
#get_build_info_for_review(app_id: nil, train: nil, build_number: nil, platform: 'ios') ⇒ Object
rubocop:enable Metrics/ParameterLists
706 707 708 709 710 711 712 713 714 715 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 706 def get_build_info_for_review(app_id: nil, train: nil, build_number: nil, platform: 'ios') url = "ra/apps/#{app_id}/platforms/#{platform}/trains/#{train}/builds/#{build_number}/testInformation" r = request(:get) do |req| req.url url req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) r.body['data'] end |
#get_rating_summary(app_id, platform, versionId = '') ⇒ Object
314 315 316 317 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 314 def (app_id, platform, versionId = '') r = request(:get, "ra/apps/#{app_id}/reviews/summary?platform=#{platform}&versionId=#{versionId}") parse_response(r, 'data') end |
#get_resolution_center(app_id, platform) ⇒ Object
309 310 311 312 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 309 def get_resolution_center(app_id, platform) r = request(:get, "ra/apps/#{app_id}/platforms/#{platform}/resolutionCenter?v=latest") parse_response(r, 'data') end |
#get_reviews(app_id, platform, storefront, versionId = '') ⇒ Object
319 320 321 322 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 319 def get_reviews(app_id, platform, storefront, versionId = '') r = request(:get, "ra/apps/#{app_id}/reviews?platform=#{platform}&storefront=#{storefront}&versionId=#{versionId}") parse_response(r, 'data')['reviews'] end |
#handle_itc_response(raw) ⇒ Object
rubocop:disable Metrics/PerceivedComplexity
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 164 def handle_itc_response(raw) return unless raw return unless raw.kind_of? Hash data = raw['data'] || raw # sometimes it's with data, sometimes it isn't if data.fetch('sectionErrorKeys', []).count == 0 and data.fetch('sectionInfoKeys', []).count == 0 and data.fetch('sectionWarningKeys', []).count == 0 and data.fetch('validationErrors', []).count == 0 logger.debug("Request was successful") end # We pass on the `current_language` so that the error message tells the user # what language the error was caused in handle_response_hash = lambda do |hash, current_language = nil| errors = [] if hash.kind_of?(Hash) current_language ||= hash["language"] hash.each do |key, value| errors += handle_response_hash.call(value, current_language) next unless key == 'errorKeys' and value.kind_of?(Array) and value.count > 0 # Prepend the error with the language so it's easier to understand for the user errors += value.collect do || current_language ? "[#{current_language}]: #{}" : end end elsif hash.kind_of? Array hash.each do |value| errors += handle_response_hash.call(value) end # else: We don't care about simple values end return errors end errors = handle_response_hash.call(data) errors += data.fetch('sectionErrorKeys', []) errors += data.fetch('validationErrors', []) # 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 if errors.count == 1 and errors.first == "You haven't made any changes." # This is a special error which we really don't care about elsif errors.count == 1 and errors.first.include?("try again later") raise ITunesConnectTemporaryError.new, errors.first else raise ITunesConnectError.new, errors.join(' ') end end puts data['sectionInfoKeys'] if data['sectionInfoKeys'] puts data['sectionWarningKeys'] if data['sectionWarningKeys'] return data end |
#prepare_app_submissions(app_id, version) ⇒ Object
721 722 723 724 725 726 727 728 729 730 731 732 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 721 def prepare_app_submissions(app_id, version) raise "app_id is required" unless app_id raise "version is required" unless version r = request(:get) do |req| req.url "ra/apps/#{app_id}/versions/#{version}/submit/summary" req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) parse_response(r, 'data') end |
#price_tier(app_id) ⇒ Object
405 406 407 408 409 410 411 412 413 414 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 405 def price_tier(app_id) r = request(:get, "ra/apps/#{app_id}/pricing/intervals") data = parse_response(r, 'data') begin data["pricingIntervalsFieldTO"]["value"].first["tierStem"] rescue nil end end |
#pricing_tiers ⇒ Array
Although this information is publicly available, the current spaceship implementation requires you to have a logged in client to access it
Returns an array of all available pricing tiers
[{
"tierStem": "0",
"tierName": "Free",
"pricingInfo": [{
"country": "United States",
"countryCode": "US",
"currencySymbol": "$",
"currencyCode": "USD",
"wholesalePrice": 0.0,
"retailPrice": 0.0,
"fRetailPrice": "$0.00",
"fWholesalePrice": "$0.00"
}, {
...
}, { …
437 438 439 440 441 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 437 def pricing_tiers r = request(:get, 'ra/apps/pricing/matrix') data = parse_response(r, 'data')['pricingTiers'] data.map { |tier| Spaceship::Tunes::PricingTier.factory(tier) } end |
#ref_data ⇒ AppVersionRef
Fetches the App Version Reference information from ITC
528 529 530 531 532 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 528 def ref_data r = request(:get, '/WebObjects/iTunesConnect.woa/ra/apps/version/ref') data = parse_response(r, 'data') Spaceship::Tunes::AppVersionRef.factory(data) end |
#release!(app_id, version) ⇒ Object
759 760 761 762 763 764 765 766 767 768 769 770 771 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 759 def release!(app_id, version) raise "app_id is required" unless app_id raise "version is required" unless version r = request(:post) do |req| req.url "ra/apps/#{app_id}/versions/#{version}/releaseToStore" req.headers['Content-Type'] = 'application/json' req.body = app_id.to_s end handle_itc_response(r.body) parse_response(r, 'data') end |
#remove_tester_from_app!(tester, app_id) ⇒ Object
856 857 858 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 856 def remove_tester_from_app!(tester, app_id) update_tester_from_app!(tester, app_id, false) end |
#remove_testflight_build_from_review!(app_id: nil, train: nil, build_number: nil, platform: 'ios') ⇒ Object
579 580 581 582 583 584 585 586 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 579 def remove_testflight_build_from_review!(app_id: nil, train: nil, build_number: nil, platform: 'ios') r = request(:post) do |req| req.url "ra/apps/#{app_id}/platforms/#{platform}/trains/#{train}/builds/#{build_number}/reject" req.body = {}.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) end |
#sandbox_testers(tester_class) ⇒ Object
863 864 865 866 867 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 863 def sandbox_testers(tester_class) url = tester_class.url[:index] r = request(:get, url) parse_response(r, 'data') end |
#select_team ⇒ Object
Shows a team selection for the user in the terminal. This should not be called on CI systems
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 101 def select_team t_id = (ENV['FASTLANE_ITC_TEAM_ID'] || '').strip t_name = (ENV['FASTLANE_ITC_TEAM_NAME'] || '').strip if t_name.length > 0 && t_id.length.zero? # we prefer IDs over names, they are unique puts "Looking for iTunes Connect Team with name #{t_name}" if $verbose teams.each do |t| t_id = t['contentProvider']['contentProviderId'].to_s if t['contentProvider']['name'].casecmp(t_name.downcase).zero? end puts "Could not find team with name '#{t_name}', trying to fallback to default team" if t_id.length.zero? end t_id = teams.first['contentProvider']['contentProviderId'].to_s if teams.count == 1 if t_id.length > 0 puts "Looking for iTunes Connect Team with ID #{t_id}" if $verbose # actually set the team id here self.team_id = t_id return end # user didn't specify a team... #thisiswhywecanthavenicethings loop do puts "Multiple iTunes Connect teams found, please enter the number of the team you want to use: " puts "Note: to automatically choose the team, provide either the iTunes Connect Team ID, or the Team Name in your fastlane/Appfile:" first_team = teams.first["contentProvider"] puts "" puts " itc_team_id \"#{first_team['contentProviderId']}\"" puts "" puts "or" puts "" puts " itc_team_name \"#{first_team['name']}\"" puts "" teams.each_with_index do |team, i| puts "#{i + 1}) \"#{team['contentProvider']['name']}\" (#{team['contentProvider']['contentProviderId']})" end selected = ($stdin.gets || '').strip.to_i - 1 team_to_use = teams[selected] if selected >= 0 if team_to_use self.team_id = team_to_use['contentProvider']['contentProviderId'].to_s # actually set the team id here break end end end |
#send_app_submission(app_id, data) ⇒ Object
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 734 def send_app_submission(app_id, data) raise "app_id is required" unless app_id # ra/apps/1039164429/version/submit/complete r = request(:post) do |req| req.url "ra/apps/#{app_id}/version/submit/complete" req.body = data.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) if r.body.fetch('messages').fetch('info').last == "Successful POST" # success else raise "Something went wrong when submitting the app for review. Make sure to pass valid options to submit your app for review" end parse_response(r, 'data') end |
#send_login_request(user, password) ⇒ Object
158 159 160 161 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 158 def send_login_request(user, password) clear_user_cached_data send_shared_login_request(user, password) end |
#submit_testflight_build_for_review!(app_id: nil, train: nil, build_number: nil, platform: 'ios', changelog: nil, description: nil, feedback_email: nil, marketing_url: nil, first_name: nil, last_name: nil, review_email: nil, phone_number: nil, significant_change: false, privacy_policy_url: nil, review_user_name: nil, review_password: nil, review_notes: nil, encryption: false, encryption_updated: false, is_exempt: false, proprietary: false, third_party: false) ⇒ Object
rubocop:disable Metrics/ParameterLists
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 636 def submit_testflight_build_for_review!(app_id: nil, train: nil, build_number: nil, platform: 'ios', # Required Metadata: changelog: nil, description: nil, feedback_email: nil, marketing_url: nil, first_name: nil, last_name: nil, review_email: nil, phone_number: nil, significant_change: false, # Optional Metadata: privacy_policy_url: nil, review_user_name: nil, review_password: nil, review_notes: nil, encryption: false, encryption_updated: false, is_exempt: false, proprietary: false, third_party: false) build_info = get_build_info_for_review(app_id: app_id, train: train, build_number: build_number, platform: platform) # Now fill in the values provided by the user # First the localised values: build_info['details'].each do |current| current['whatsNew']['value'] = changelog if changelog current['description']['value'] = description if description current['feedbackEmail']['value'] = feedback_email if feedback_email current['marketingUrl']['value'] = marketing_url if marketing_url current['privacyPolicyUrl']['value'] = privacy_policy_url if privacy_policy_url current['pageLanguageValue'] = current['language'] # There is no valid reason why we need this, only iTC being iTC end review_info = { "significantChange" => { "value" => significant_change }, "buildTestInformationTO" => build_info, "exportComplianceTO" => { "usesEncryption" => { "value" => encryption }, "encryptionUpdated" => { "value" => encryption_updated }, "isExempt" => { "value" => is_exempt }, "containsProprietaryCryptography" => { "value" => proprietary }, "containsThirdPartyCryptography" => { "value" => third_party } } } r = request(:post) do |req| # same URL, but a POST request req.url "ra/apps/#{app_id}/platforms/#{platform}/trains/#{train}/builds/#{build_number}/review/submit" req.body = review_info.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) end |
#supported_countries ⇒ Object
An array of supported countries [
"code": "AL",
"name": "Albania",
"region": "Europe"
, { …
450 451 452 453 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 450 def supported_countries r = request(:get, "ra/apps/pricing/supportedCountries") parse_response(r, 'data') end |
#team_id ⇒ String
Returns The currently selected Team ID.
60 61 62 63 64 65 66 67 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 60 def team_id return @current_team_id if @current_team_id if teams.count > 1 puts "The current user is in #{teams.count} teams. Pass a team ID or call `select_team` to choose a team. Using the first one for now." end @current_team_id ||= teams[0]['contentProvider']['contentProviderId'] end |
#team_id=(team_id) ⇒ Object
Set a new team ID which will be used from now on
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 70 def team_id=(team_id) # First, we verify the team actually exists, because otherwise iTC would return the # following confusing error message # # invalid content provider id # available_teams = teams.collect do |team| (team["contentProvider"] || {})["contentProviderId"] end result = available_teams.find do |available_team_id| team_id.to_s == available_team_id.to_s end unless result raise ITunesConnectError.new, "Could not set team ID to '#{team_id}', only found the following available teams: #{available_teams.join(', ')}" end response = request(:post) do |req| req.url "ra/v1/session/webSession" req.body = { contentProviderId: team_id }.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(response.body) @current_team_id = team_id end |
#team_information ⇒ Hash
Returns Fetches all information of the currently used team.
152 153 154 155 156 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 152 def team_information teams.find do |t| t['teamId'] == team_id end end |
#teams ⇒ Array
Returns A list of all available teams.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 48 def teams return @teams if @teams r = request(:get, "ra/user/detail") @teams = parse_response(r, 'data')['associatedAccounts'].sort_by do |team| [ team['contentProvider']['name'], team['contentProvider']['contentProviderId'] ] end end |
#testers(tester) ⇒ Object
776 777 778 779 780 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 776 def testers(tester) url = tester.url[:index] r = request(:get, url) parse_response(r, 'data')['testers'] end |
#testers_by_app(tester, app_id) ⇒ Object
782 783 784 785 786 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 782 def testers_by_app(tester, app_id) url = tester.url(app_id)[:index_by_app] r = request(:get, url) parse_response(r, 'data')['users'] end |
#update_app_details!(app_id, data) ⇒ Object
243 244 245 246 247 248 249 250 251 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 243 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 |
#update_app_version!(app_id, version_id, data) ⇒ Object
355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 355 def update_app_version!(app_id, version_id, data) raise "app_id is required" unless app_id raise "version_id is required" unless version_id.to_i > 0 with_tunes_retry do r = request(:post) do |req| req.url "ra/apps/#{app_id}/platforms/ios/versions/#{version_id}" req.body = data.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) end end |
#update_build_information!(app_id: nil, train: nil, build_number: nil, whats_new: nil, description: nil, feedback_email: nil, platform: 'ios') ⇒ Object
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 604 def update_build_information!(app_id: nil, train: nil, build_number: nil, # optional: whats_new: nil, description: nil, feedback_email: nil, platform: 'ios') url = "ra/apps/#{app_id}/platforms/#{platform}/trains/#{train}/builds/#{build_number}/testInformation" build_info = get_build_info_for_review(app_id: app_id, train: train, build_number: build_number, platform: platform) build_info["details"].each do |current| current["whatsNew"]["value"] = whats_new if whats_new current["description"]["value"] = description if description current["feedbackEmail"]["value"] = feedback_email if feedback_email end review_user_name = build_info['reviewUserName']['value'] review_password = build_info['reviewPassword']['value'] build_info['reviewAccountRequired']['value'] = (review_user_name.to_s + review_password.to_s).length > 0 # Now send everything back to iTC r = request(:post) do |req| # same URL, but a POST request req.url url req.body = build_info.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) end |
#update_build_trains!(app_id, testing_type, data) ⇒ Object
564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 564 def update_build_trains!(app_id, testing_type, data) raise "app_id is required" unless app_id # The request fails if this key is present in the data data.delete("dailySubmissionCountByPlatform") r = request(:post) do |req| req.url "ra/apps/#{app_id}/testingTypes/#{testing_type}/trains/" req.body = data.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) end |
#update_price_tier!(app_id, price_tier) ⇒ Object
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 374 def update_price_tier!(app_id, price_tier) r = request(:get, "ra/apps/#{app_id}/pricing/intervals") data = parse_response(r, 'data') first_price = (data["pricingIntervalsFieldTO"]["value"] || []).count == 0 # first price data["pricingIntervalsFieldTO"]["value"] ||= [] data["pricingIntervalsFieldTO"]["value"] << {} if data["pricingIntervalsFieldTO"]["value"].count == 0 data["pricingIntervalsFieldTO"]["value"].first["tierStem"] = price_tier.to_s effective_date = (first_price ? nil : Time.now.to_i * 1000) data["pricingIntervalsFieldTO"]["value"].first["priceTierEffectiveDate"] = effective_date data["pricingIntervalsFieldTO"]["value"].first["priceTierEndDate"] = nil data["countriesChanged"] = first_price data["theWorld"] = true if first_price # first price, need to set all countries data["countries"] = supported_countries.collect do |c| c.delete('region') # we don't care about le region c end end # send the changes back to Apple r = request(:post) do |req| req.url "ra/apps/#{app_id}/pricing/intervals" req.body = data.to_json req.headers['Content-Type'] = 'application/json' end handle_itc_response(r.body) end |
#upload_geojson(app_version, upload_file) ⇒ JSON
Uploads the transit app file
497 498 499 500 501 502 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 497 def upload_geojson(app_version, upload_file) raise "app_version is required" unless app_version raise "upload_file is required" unless upload_file du_client.upload_geojson(app_version, upload_file, content_provider_id, sso_token_for_image) end |
#upload_large_icon(app_version, upload_image) ⇒ JSON
Uploads a large icon
462 463 464 465 466 467 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 462 def upload_large_icon(app_version, upload_image) raise "app_version is required" unless app_version raise "upload_image is required" unless upload_image du_client.upload_large_icon(app_version, upload_image, content_provider_id, sso_token_for_image) end |
#upload_screenshot(app_version, upload_image, device) ⇒ JSON
Uploads a screenshot
485 486 487 488 489 490 491 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 485 def upload_screenshot(app_version, upload_image, device) raise "app_version is required" unless app_version raise "upload_image is required" unless upload_image raise "device is required" unless device du_client.upload_screenshot(app_version, upload_image, content_provider_id, sso_token_for_image, device) end |
#upload_trailer(app_version, upload_trailer) ⇒ JSON
Uploads the transit app file
508 509 510 511 512 513 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 508 def upload_trailer(app_version, upload_trailer) raise "app_version is required" unless app_version raise "upload_trailer is required" unless upload_trailer du_client.upload_trailer(app_version, upload_trailer, content_provider_id, sso_token_for_video) end |
#upload_trailer_preview(app_version, upload_trailer_preview) ⇒ JSON
Uploads the trailer preview
519 520 521 522 523 524 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 519 def upload_trailer_preview(app_version, upload_trailer_preview) raise "app_version is required" unless app_version raise "upload_trailer_preview is required" unless upload_trailer_preview du_client.upload_trailer_preview(app_version, upload_trailer_preview, content_provider_id, sso_token_for_image) end |
#upload_watch_icon(app_version, upload_image) ⇒ JSON
Uploads a watch icon
473 474 475 476 477 478 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 473 def upload_watch_icon(app_version, upload_image) raise "app_version is required" unless app_version raise "upload_image is required" unless upload_image du_client.upload_watch_icon(app_version, upload_image, content_provider_id, sso_token_for_image) end |
#user_detail_data ⇒ UserDetail
Fetches the User Detail information from ITC. This gets called often and almost never changes so we cache it
537 538 539 540 541 542 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 537 def user_detail_data return @cached if @cached r = request(:get, '/WebObjects/iTunesConnect.woa/ra/user/detail') data = parse_response(r, 'data') @cached ||= Spaceship::Tunes::UserDetail.factory(data) end |
#version_states_history(app_id, platform, version_id) ⇒ Object
917 918 919 920 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 917 def version_states_history(app_id, platform, version_id) r = request(:get, "ra/apps/#{app_id}/versions/#{version_id}/stateHistory?platform=#{platform}") parse_response(r, 'data') end |
#versions_history(app_id, platform) ⇒ Object
912 913 914 915 |
# File 'lib/spaceship/tunes/tunes_client.rb', line 912 def versions_history(app_id, platform) r = request(:get, "ra/apps/#{app_id}/stateHistory?platform=#{platform}") parse_response(r, 'data')['versions'] end |