spaceship/lib/spaceship/connect_api/models/app_screenshot.rb in fastlane-2.167.0 vs spaceship/lib/spaceship/connect_api/models/app_screenshot.rb in fastlane-2.168.0

- old
+ new

@@ -77,11 +77,12 @@ # # API # # - def self.create(app_screenshot_set_id: nil, path: nil, wait_for_processing: true) + def self.create(client: nil, app_screenshot_set_id: nil, path: nil, wait_for_processing: true) + client ||= Spaceship::ConnectAPI require 'faraday' filename = File.basename(path) filesize = File.size(path) bytes = File.binread(path) @@ -91,11 +92,11 @@ fileName: filename } # Create placeholder to upload screenshot begin - screenshot = Spaceship::ConnectAPI.post_app_screenshot( + screenshot = client.post_app_screenshot( app_screenshot_set_id: app_screenshot_set_id, attributes: post_attributes ).first rescue => error # Sometimes creating a screenshot with the web session App Store Connect API @@ -115,11 +116,11 @@ # It should handle errors based on what status code is. puts("Waiting for screenshots to appear before uploading. This is unlikely to be recovered unless it's 503 error. error=\"#{error}\"") sleep(30) screenshots = Spaceship::ConnectAPI::AppScreenshotSet - .get(app_screenshot_set_id: app_screenshot_set_id) + .get(client: client, app_screenshot_set_id: app_screenshot_set_id) .app_screenshots screenshot = screenshots.find do |s| s.awaiting_upload? && s.file_size == filesize end @@ -150,11 +151,11 @@ attributes: patch_attributes ).first rescue => error puts("Failed to patch app screenshot. Update may have gone through so verifying") if Spaceship::Globals.verbose? - screenshot = Spaceship::ConnectAPI.get_app_screenshot(app_screenshot_id: screenshot.id).first + screenshot = client.get_app_screenshot(app_screenshot_id: screenshot.id).first raise error unless screenshot.complete? end # Wait for processing if wait_for_processing @@ -170,18 +171,19 @@ # Poll every 2 seconds sleep_time = 2 puts("Waiting #{sleep_time} seconds before checking status of processing...") if Spaceship::Globals.verbose? sleep(sleep_time) - screenshot = Spaceship::ConnectAPI.get_app_screenshot(app_screenshot_id: screenshot.id).first + screenshot = client.get_app_screenshot(app_screenshot_id: screenshot.id).first end end return screenshot end - def delete!(filter: {}, includes: nil, limit: nil, sort: nil) - Spaceship::ConnectAPI.delete_app_screenshot(app_screenshot_id: id) + def delete!(client: nil, filter: {}, includes: nil, limit: nil, sort: nil) + client ||= Spaceship::ConnectAPI + client.delete_app_screenshot(app_screenshot_id: id) end end end end