Class: APIClientBuilder::GetItemRequest
- Defined in:
- lib/api_client_builder/get_item_request.rb
Overview
The single item response object to be used as the container for singular responses from the defined API
Instance Attribute Summary
Attributes inherited from Request
#body, #error_handlers_collection, #response_handler, #type
Instance Method Summary collapse
-
#response ⇒ JSON
Reads the first page from the pagination solution and yields the items if the response was successful.
Methods inherited from Request
#error_handlers, #initialize, #on_error
Constructor Details
This class inherits a constructor from APIClientBuilder::Request
Instance Method Details
#response ⇒ JSON
Reads the first page from the pagination solution and yields the items if the response was successful. Else handles the error. Will retry the response if a retry strategy is defined concretely on the response handler.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/api_client_builder/get_item_request.rb', line 11 def response page = response_handler.get_first_page if page.success? page.body elsif response_handler.respond_to?(:retryable?) && response_handler.retryable?(page.status_code) retried_page = attempt_retry retried_page.body else error_handlers.each do |handler| handler.call(page, self) end end end |