class GoCardless::ListResponse
Wraps a response from an API LIST endpoint
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 = {}) @raw_response = options.fetch(:raw_response) @resource_class = options.fetch(:resource_class) @unenveloped_body = options.fetch(:unenveloped_body) @items = @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 30 def after @raw_response.body['meta']['cursors']['after'] end
before()
click to toggle source
return the before cursor for paginating
# File lib/gocardless-pro/list_response.rb, line 25 def before @raw_response.body['meta']['cursors']['before'] end
each(&block)
click to toggle source
iterate over all the response items
# File lib/gocardless-pro/list_response.rb, line 20 def each(&block) @items.each(&block) end