Class: GoCardlessPro::ListResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/gocardless_pro/list_response.rb

Overview

Wraps a response from an API LIST endpoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ListResponse

Initialize a list response

Parameters:

  • options (Hash) (defaults to: {})
  • option (Hash)

    a customizable set of options



11
12
13
14
15
16
17
# 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

Instance Attribute Details

#recordsObject (readonly)

Returns the value of attribute records.



4
5
6
# File 'lib/gocardless_pro/list_response.rb', line 4

def records
  @records
end

Instance Method Details

#afterObject

return the after cursor for paginating



29
30
31
# File 'lib/gocardless_pro/list_response.rb', line 29

def after
  @response.body['meta']['cursors']['after']
end

#api_responseObject



19
20
21
# File 'lib/gocardless_pro/list_response.rb', line 19

def api_response
  @api_response ||= ApiResponse.new(@response)
end

#beforeObject

return the before cursor for paginating



24
25
26
# File 'lib/gocardless_pro/list_response.rb', line 24

def before
  @response.body['meta']['cursors']['before']
end