Class: AmazonAds::ApiClient::Response

Inherits:
Object
  • Object
show all
Defined in:
app/services/amazon_ads/api_client/response.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response:, method:, path:) ⇒ Response

Returns a new instance of Response.

Parameters:

  • response (Faraday::Response)
  • method (Symbol)
  • path (String)


19
20
21
22
23
# File 'app/services/amazon_ads/api_client/response.rb', line 19

def initialize(response:, method:, path:)
  @response = response
  @method = method
  @path = path
end

Class Method Details

.call(response:, method:, path:) ⇒ Hash, Array

Parameters:

  • response (Faraday::Response)
  • method (Symbol)
  • path (String)

Returns:

  • (Hash, Array)


11
12
13
# File 'app/services/amazon_ads/api_client/response.rb', line 11

def call(response:, method:, path:)
  new(response:, method:, path:).call
end

Instance Method Details

#callHash, Array

Returns:

  • (Hash, Array)

Raises:



28
29
30
31
32
33
# File 'app/services/amazon_ads/api_client/response.rb', line 28

def call
  raise throttled_error if @response.status == 429
  raise failure_error unless @response.success?

  @response.body
end