Class: Pipekit::Result
- Inherits:
-
Object
- Object
- Pipekit::Result
- Defined in:
- lib/pipekit/result.rb
Class Method Summary collapse
Instance Method Summary collapse
- #+(other) ⇒ Object
- #fetch_next_request? ⇒ Boolean
-
#initialize(response_data) ⇒ Result
constructor
A new instance of Result.
- #next_start ⇒ Object
- #response(resource) ⇒ Object
Constructor Details
#initialize(response_data) ⇒ Result
Returns a new instance of Result.
5 6 7 8 |
# File 'lib/pipekit/result.rb', line 5 def initialize(response_data) @response_data = response_data raise UnsuccessfulRequestError.new(response_data) unless success? end |
Class Method Details
.response(resource, response_data) ⇒ Object
28 29 30 |
# File 'lib/pipekit/result.rb', line 28 def self.response(resource, response_data) new(response_data).response(resource) end |
Instance Method Details
#+(other) ⇒ Object
16 17 18 |
# File 'lib/pipekit/result.rb', line 16 def +(other) self.class.new(other.merged_response(response_body)) end |
#fetch_next_request? ⇒ Boolean
20 21 22 |
# File 'lib/pipekit/result.rb', line 20 def fetch_next_request? Config.fetch(:request_all_pages, true) && pagination_data["more_items_in_collection"] end |
#next_start ⇒ Object
24 25 26 |
# File 'lib/pipekit/result.rb', line 24 def next_start pagination_data["next_start"] end |
#response(resource) ⇒ Object
10 11 12 13 14 |
# File 'lib/pipekit/result.rb', line 10 def response(resource) raise ResourceNotFoundError.new(response_data) unless resource_found? return Response.new(resource, response_body) unless response_body.is_a? Array response_body.map { |data| Response.new(resource, data) } end |