class DuffelAPI::ListResponse

A page of results returned by a “list” action in the API, provides access to the records on the page, and metadata about the page itself.

Attributes

records[R]

Returns the records contained within the page

@return [Array<Resources::BaseResource>] an array of records - for example, for the

list action for offers, this would be a list of `Resources::Offer`s

Public Class Methods

new(options = {}) click to toggle source
# File lib/duffel_api/list_response.rb, line 13
def initialize(options = {})
  @response = options.fetch(:response)
  @resource_class = options.fetch(:resource_class)
  @unenveloped_body = options.fetch(:unenveloped_body)

  @records = @unenveloped_body.map { |item| @resource_class.new(item, @response) }
end

Public Instance Methods

after() click to toggle source

Returns the cursor representing the next page of paginated results, if there is a next page

@return [String, nil]

# File lib/duffel_api/list_response.rb, line 40
def after
  @response.parsed_body["meta"]["after"]
end
api_response() click to toggle source

Returns the raw API response received for this listing request

@return [APIResponse]

# File lib/duffel_api/list_response.rb, line 24
def api_response
  @api_response ||= APIResponse.new(@response)
end
before() click to toggle source

Returns the cursor representing the previous page of paginated results, if there is a previous page

@return [String, nil]

# File lib/duffel_api/list_response.rb, line 32
def before
  @response.parsed_body["meta"]["before"]
end