b0VIM 8.1*4_=bjoshJoshs-Mac-mini.local~josh/Projects/fastlane/fastlane/spaceship/lib/spaceship/connect_api/client.rbutf-8 U3210#"! Utp.^nmb=adV.jIH7$} ~ B  ]  { q p  X P P H VU9D  {z[D$'pI?>ka`~ts% ~zyhU-}|: def initialize(cookie: nil, current_team_id: nil, token: nil, another_client: nil) # Instantiates a client with cookie session or a JWT token. ##################################################### # @!group Client Init ##################################################### attr_accessor :token class APIClient < Spaceship::Client class ConnectAPImodule Spaceshipend end end end ) another_client: tunes_client token: token, current_team_id: current_team_id, cookie: cookie, self.users_request_client = Spaceship::ConnectAPI::Users::Client.new( ) another_client: portal_client token: token, current_team_id: current_team_id, cookie: cookie, self.provisioning_request_client = Spaceship::ConnectAPI::Provisioning::Client.new( ) another_client: tunes_client token: token, current_team_id: current_team_id, cookie: cookie, self.tunes_request_client = Spaceship::ConnectAPI::Tunes::Client.new( ) another_client: tunes_client token: token, current_team_id: current_team_id, cookie: cookie, self.test_flight_request_client = Spaceship::ConnectAPI::TestFlight::Client.new( def set_indvidual_clients(cookie: nil, current_team_id: nil, token: nil, tunes_client: nil, portal_client: nil) private end ) portal_client: portal_client tunes_client: tunes_client, token: nil, # @ret def self.login(user = def self.login(user = nil, password = nil, team_id: nil, team_name: nil) # @return (Spaceship::Client) The client the login method was called for # # @raise InvalidUserCredentialsError: raised if authentication failed # # @param team_name (String) (optional): The team name # @param team_id (String) (optional): The team id # @param password (String) (optional): The password # @param user (String) (optional): The username (usually the email address) # # and fetch the password from the Keychain (if available) # This method will automatically use the username from the Appfile (if available) # # to generate a valid session. # Authenticates with Apple's web services. This method has to be called once end return ConnectAPI::Client.new(token: token) token = Spaceship::ConnectAPI::Token.create(key_id: key_id, issuer_id: issuer_id, filepath: filepath) def self.auth(key_id: nil, issuer_id: nil, filepath: nil) # @return (Spaceship::Client) The client the login method was called for # # @raise InvalidUserCredentialsError: raised if authentication failed # # @param filepath (String) (optional): The filepath # @param issuer_id (String) (optional): The issuer id # @param key_id (String) (optional): The key id # # All three parameters are needed to authenticate. # # variables if not given. # This method will automatically use the key id, issuer id, and filepath from environment # # Initializes client with Apple's App Store Connect JWT auth key. attr_accessor :portal_client attr_accessor :tunes_client class Client class ConnectAPImodule Spaceshiprequire_relative './users/users'require_relative './tunes/tunes'require_relative './testflight/testflight'require_relative './provisioning/provisioning'require_relative './token'ad 3 ML! v l d ^ 7 3 2 end # rubocop:enable Metrics/ClassLength end end end self.provider.provider_id return team_id if self.provider.nil? def provider_id end end binding.eval(name.to_s) else binding.local_variable_get(name) if binding.respond_to?(:local_variable_get) def local_variable_get(binding, name) private end end.flatten.join("\n") end [[associated_error["title"], associated_error["detail"]].compact.join(" - ")] messages + associated_errors.values.flatten.map do |associated_error| associated_errors = meta["associatedErrors"] || {} meta = error["meta"] || {}ad|^;xlk  s  K ; S R 3  ~ t s ? s S =  Vxnm3T:\A@i def initialize(cookie: nil, current_team_id: nil, token: nil, another_client: nil) # Instantiates a client with cookie session or a JWT token. ##################################################### # @!group Client Init ##################################################### attr_accessor :token class APIClient < Spaceship::Client class ConnectAPImodule Spaceshipend end end end ) another_client: tunes_client token: token, current_team_id: current_team_id, cookie: cookie, self.users_request_client = Spaceship::ConnectAPI::Users::Client.new( ) another_client: portal_client token: token, current_team_id: current_team_id, cookie: cookie, self.provisioning_request_client = Spaceship::ConnectAPI::Provisioning::Client.new( ) another_client: tunes_client token: token, current_team_id: current_team_id, cookie: cookie, self.tunes_request_client = Spaceship::ConnectAPI::Tunes::Client.new( ) another_client: tunes_client token: token, current_team_id: current_team_id, cookie: cookie, self.test_flight_request_client = Spaceship::ConnectAPI::TestFlight::Client.new( def set_indvidual_clients(cookie: nil, current_team_id: nil, token: nil, tunes_client: nil, portal_client: nil) private end ) portal_client: portal_client tunes_client: tunes_client, token: nil, current_team_id: nil, cookie: nil, set_indvidual_clients( @portal_client.select_team(team_id: team_id, team_name: team_name) @tunes_client.select_team(team_id: team_id, team_name: team_name) def select_team(team_id: nil, team_name: nil) end ) portal_client: portal_client tunes_client: tunes_client, token: token, current_team_id: current_team_id, cookie: cookie, set_indvidual_clients( self.extend(Spaceship::ConnectAPI::Users::API) self.extend(Spaceship::ConnectAPI::Provisioning::API) self.extend(Spaceship::ConnectAPI::Tunes::API) self.extend(Spaceship::ConnectAPI::TestFlight::API) # Each # Extending this instance to add API endpoints from these modules @portal_client = portal_client @tunes_client = tunes_client # Spaceship::Portal is needed for Provisioning::API # Spaceship::Tunes is needed for TestFlight::API, Tunes::API, and Users::API # If using web session... def initialize(cookie: nil, current_team_id: nil, token: nil, tunes_client: nil, portal_client: nil) end return ConnectAPI::Client.new(tunes_client: tunes_client, portal_client: portal_client) end portal_client.select_team(team_id: team_id, team_name: team_name) tunes_client.select_team(team_id: team_id, team_name: team_name) if !team_id.nil? || !team_name.nil? # The clients will automatically select the first team if none is given portal_client = PortalClient.login(user, password) tunes_client = TunesClient.login(user, password)adnvgg#  F  r 2 1 b $ d T S 7 { z r b Z Y B '   rq4ukjAj-lK'[8zpo7}S' req.headers['Content-Type'] = 'application/json' if body req.body = body.to_json if body req.params = params if params req.options.params_encoder = Faraday::NestedParamsEncoder if params req.url(url_or_path) request(:delete) do |req| response = with_asc_retry do def delete(url_or_path, params = nil, body = nil) end handle_response(response) end end req.headers['Content-Type'] = 'application/json' req.body = body.to_json req.url(url_or_path) request(:patch) do |req| response = with_asc_retry do def patch(url_or_path, body) end handle_response(response) end end req.headers['Content-Type'] = 'application/json' req.body = body.to_json req.url(url_or_path) request(:post) do |req| response = with_asc_retry(tries) do def post(url_or_path, body, tries: 5) end handle_response(response) end end req.headers['Content-Type'] = 'application/json' req.params = params if params req.options.params_encoder = Faraday::NestedParamsEncoder req.url(url_or_path) request(:get) do |req| response = with_asc_retry do def get(url_or_path, params = nil) end return params params[:cursor] = cursor if cursor params[:sort] = sort if sort params[:limit] = limit if limit params[:include] = includes if includes params[:filter] = filter if filter && !filter.empty? filter = filter.delete_if { |k, v| v.nil? } if filter params = {} def build_params(filter: nil, includes: nil, limit: nil, sort: nil, cursor: nil) end return @token.nil? def web_session? # # Helpers # end return nil def self.hostname end end end end puts("To run spaceship through a local proxy, use SPACESHIP_DEBUG") if ENV["DEBUG"] end c.ssl[:verify_mode] = OpenSSL::SSL::VERIFY_NONE if ENV["SPACESHIP_PROXY_SSL_VERIFY_NONE"] c.proxy = ENV["SPACESHIP_PROXY"] elsif ENV["SPACESHIP_PROXY"] c.ssl[:verify_mode] = OpenSSL::SSL::VERIFY_NONE c.proxy = "https://127.0.0.1:8888" # This enables tracking of networking requests using Charles Web Proxy # for debugging only if ENV['SPACESHIP_DEBUG'] c.headers["Authorization"] = "Bearer #{token.text}" c.adapter(Faraday.default_adapter) c.use(FaradayMiddleware::RelsMiddleware) c.response(:plist, content_type: /\bplist$/) c.response(:json, content_type: /\bjson$/) @client = Faraday.new(hostname, options) do |c| hostname = "https://api.appstoreconnect.apple.com/v1/" @current_team_id = current_team_id @token = token } } open_timeout: (ENV["SPACESHIP_TIMEOUT"] || 300).to_i timeout: (ENV["SPACESHIP_TIMEOUT"] || 300).to_i, request: { options = { else end super(cookie: another_client.instance_variable_get(:@cookie), current_team_id: another_client.team_id) else super(cookie: cookie, current_team_id: current_team_id, timeout: 1200) if another_client.nil? if token.nil?ad&b{B)(}i]\D. _ r q E    ] \ E ; :  k E b4JuIhGmFwg[ON messages = [[error['title'], error['detail']].compact.join(" - ")] return response.body['errors'].map do |error| # } # ] # } # } # } # ] # } # } # "pointer":"/data/attributes/usesNonExemptEncryption" # "source":{ # "detail":"You must provide a value for the attribute 'usesNonExemptEncryption' with this request", # "title":"The provided entity is missing a required attribute", # "code":"ENTITY_ERROR.ATTRIBUTE.REQUIRED", # "status":"409", # "id":"e421fe6f-0e3b-464b-89dc-ba437e7bb77d", # { # "/v1/builds/d710b6fa-5235-4fe4-b791-2b80d6818db0":[ # ], # } # "title":"App screenshot missing (APP_WATCH_SERIES_4)." # "code":"STATE_ERROR.SCREENSHOT_REQUIRED.APP_WATCH_SERIES_4", # "status":"409", # "id":"db993030-0a93-48e9-9fd7-7e5676633431", # { # }, # "title":"App screenshot missing (APP_WATCH_SERIES_4)." # "code":"STATE_ERROR.SCREENSHOT_REQUIRED.APP_WATCH_SERIES_4", # "status":"409", # "id":"23d1734f-b81f-411a-98e4-6d3e763d54ed", # { # "/v1/appScreenshots/":[ # "associatedErrors":{ # "meta":{ # "detail":"Submit for review errors found.", # "title":"The request cannot be fulfilled because of the state of another resource.", # "code":"STATE_ERROR", # "status":"409", # "id":"cbfd8674-4802-4857-bfe8-444e1ea36e32", # { # "errors":[ # { # Example error format def handle_errors(response) end return Spaceship::ConnectAPI::Response.new(body: response.body, status: response.status, client: self) store_csrf_tokens(response) raise UnexpectedResponse, "Temporary App Store Connect error: #{response.body}" if response.body['statusCode'] == 'ERROR' raise UnexpectedResponse, handle_errors(response) if response.body['errors'] raise UnexpectedResponse, response.body['error'] if response.body['error'] end raise UnexpectedResponse, response.body unless response.body.kind_of?(Hash) raise InternalServerError, "Server error got #{response.status}" if (500...600).cover?(response.status) end return if (200...300).cover?(response.status) && (response.body.nil? || response.body.empty?) def handle_response(response) end end retry else return response if tries.zero? puts(error) if Spaceship::Globals.verbose? tries -= 1 rescue => error return response end raise msg msg = "Timeout received! Retrying after 3 seconds (remaining: #{tries})..." if [500, 504].include?(status) status = response.status if response response = yield tries = 1 if Object.const_defined?("SpecHelper") def with_asc_retry(tries = 5, &_block) protected end handle_response(response) end end