class Spaceship::ConnectAPI::Provisioning::Client

Public Class Methods

hostname() click to toggle source
# File spaceship/lib/spaceship/connect_api/provisioning/client.rb, line 18
def self.hostname
  'https://developer.apple.com/services-account/v1/'
end
new(cookie: nil, current_team_id: nil, token: nil, another_client: nil) click to toggle source
Calls superclass method Spaceship::ConnectAPI::APIClient::new
# File spaceship/lib/spaceship/connect_api/provisioning/client.rb, line 9
def initialize(cookie: nil, current_team_id: nil, token: nil, another_client: nil)
  another_client ||= Spaceship::Portal.client if cookie.nil? && token.nil?

  super(cookie: cookie, current_team_id: current_team_id, token: token, another_client: another_client)

  self.extend(Spaceship::ConnectAPI::Provisioning::API)
  self.provisioning_request_client = self
end

Public Instance Methods

delete(url_or_path, params = nil) click to toggle source
Calls superclass method Spaceship::ConnectAPI::APIClient#delete
# File spaceship/lib/spaceship/connect_api/provisioning/client.rb, line 42
def delete(url_or_path, params = nil)
  # The Provisioning App Store Connect API needs to be proxied through a
  # POST request if using web session
  return proxy_delete(url_or_path, params) if web_session?

  super(url_or_path, params)
end
get(url_or_path, params = nil) click to toggle source

Helpers

Calls superclass method Spaceship::ConnectAPI::APIClient#get
# File spaceship/lib/spaceship/connect_api/provisioning/client.rb, line 26
def get(url_or_path, params = nil)
  # The Provisioning App Store Connect API needs to be proxied through a
  # POST request if using web session
  return proxy_get(url_or_path, params) if web_session?

  super(url_or_path, params)
end
post(url_or_path, body) click to toggle source
Calls superclass method Spaceship::ConnectAPI::APIClient#post
# File spaceship/lib/spaceship/connect_api/provisioning/client.rb, line 34
def post(url_or_path, body)
  # The Provisioning App Store Connect API needs teamId added to the body of
  # each post if using web session
  return proxy_post(url_or_path, body) if web_session?

  super(url_or_path, body)
end
proxy_delete(url_or_path, params = nil) click to toggle source
# File spaceship/lib/spaceship/connect_api/provisioning/client.rb, line 76
def proxy_delete(url_or_path, params = nil)
  encoded_params = Faraday::NestedParamsEncoder.encode(params)
  body = { "urlEncodedQueryParams" => encoded_params, "teamId" => team_id }

  response = request(:post) do |req|
    req.url(url_or_path)
    req.body = body.to_json
    req.headers['Content-Type'] = 'application/vnd.api+json'
    req.headers['X-HTTP-Method-Override'] = 'DELETE'
    req.headers['X-Requested-With'] = 'XMLHttpRequest'
  end
  handle_response(response)
end
proxy_get(url_or_path, params = nil) click to toggle source
# File spaceship/lib/spaceship/connect_api/provisioning/client.rb, line 50
def proxy_get(url_or_path, params = nil)
  encoded_params = Faraday::NestedParamsEncoder.encode(params)
  body = { "urlEncodedQueryParams" => encoded_params, "teamId" => team_id }

  response = request(:post) do |req|
    req.url(url_or_path)
    req.body = body.to_json
    req.headers['Content-Type'] = 'application/vnd.api+json'
    req.headers['X-HTTP-Method-Override'] = 'GET'
    req.headers['X-Requested-With'] = 'XMLHttpRequest'
  end
  handle_response(response)
end
proxy_post(url_or_path, body) click to toggle source
# File spaceship/lib/spaceship/connect_api/provisioning/client.rb, line 64
def proxy_post(url_or_path, body)
  body[:data][:attributes][:teamId] = team_id

  response = request(:post) do |req|
    req.url(url_or_path)
    req.body = body.to_json
    req.headers['Content-Type'] = 'application/vnd.api+json'
    req.headers['X-Requested-With'] = 'XMLHttpRequest'
  end
  handle_response(response)
end