Class: APIClientBuilder::GetCollectionRequest
- Includes:
- Enumerable
- Defined in:
- lib/api_client_builder/get_collection_request.rb
Overview
The multi item response object to be used as the container for collection responses from the defined API
Instance Attribute Summary
Attributes inherited from Request
#body, #error_handlers_collection, #response_handler, #type
Instance Method Summary collapse
-
#each ⇒ JSON
Iterates over the pages and yields their items if they’re successful responses.
Methods inherited from Request
#error_handlers, #initialize, #on_error
Constructor Details
This class inherits a constructor from APIClientBuilder::Request
Instance Method Details
#each ⇒ JSON
Iterates over the pages and yields their items if they’re successful responses. Else handles the error. Will retry the response if a retry strategy is defined concretely on the response handler.
rubocop:disable Metrics/AbcSize
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/api_client_builder/get_collection_request.rb', line 13 def each if block_given? each_page do |page| if page.success? page.body.each do |item| yield(item) end elsif response_handler.respond_to?(:retryable?) && response_handler.retryable?(page.status_code) retried_page = attempt_retry retried_page.body.each do |item| yield(item) end else notify_error_handlers(page) end end else Enumerator.new(self, :each) end end |