class GoCardlessPro::ListResponse

Wraps a response from an API LIST endpoint

Attributes

records[R]

Public Class Methods

new(options = {}) click to toggle source

Initialize a list response @param options [Hash] @option option :raw_response the raw API response @option option :resource_class the class for the resource returned by the API @option option :unenveloped_body the parsed response from the API

# File lib/gocardless_pro/list_response.rb, line 11
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) }
end

Public Instance Methods

after() click to toggle source

return the after cursor for paginating

# File lib/gocardless_pro/list_response.rb, line 29
def after
  @response.body['meta']['cursors']['after']
end
api_response() click to toggle source
# File lib/gocardless_pro/list_response.rb, line 19
def api_response
  @api_response ||= ApiResponse.new(@response)
end
before() click to toggle source

return the before cursor for paginating

# File lib/gocardless_pro/list_response.rb, line 24
def before
  @response.body['meta']['cursors']['before']
end