Class: AmazonAds::ApiClient::Request
- Inherits:
-
Object
- Object
- AmazonAds::ApiClient::Request
- Defined in:
- app/services/amazon_ads/api_client/request.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Hash, Array
Executes one authenticated request, retrying once after a 401 forces an OAuth refresh.
-
#initialize(connection:, oauth:, method:, path:, profile_id:, content_type:, body:, params:) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(connection:, oauth:, method:, path:, profile_id:, content_type:, body:, params:) ⇒ Request
Returns a new instance of Request.
19 20 21 22 23 |
# File 'app/services/amazon_ads/api_client/request.rb', line 19 def initialize(connection:, oauth:, method:, path:, profile_id:, content_type:, body:, params:) @connection = connection @oauth = oauth @request = { method:, path:, profile_id:, content_type:, body:, params: }.freeze end |
Class Method Details
.call ⇒ Hash, Array
6 7 8 |
# File 'app/services/amazon_ads/api_client/request.rb', line 6 def call(**) new(**).call end |
Instance Method Details
#call ⇒ Hash, Array
Executes one authenticated request, retrying once after a 401 forces an
OAuth refresh. Throttling is returned as typed retry state; this object
never sleeps on the calling Sidekiq thread.
29 30 31 32 33 34 |
# File 'app/services/amazon_ads/api_client/request.rb', line 29 def call response = execute response = refresh_and_retry if response.status == 401 AmazonAds::ApiClient::Response.call(response:, method: @request[:method], path: @request[:path]) end |