Class: GoCardlessPro::ListResponse
- Inherits:
-
Object
- Object
- GoCardlessPro::ListResponse
- Defined in:
- lib/gocardless_pro/list_response.rb
Overview
Wraps a response from an API LIST endpoint
Instance Attribute Summary collapse
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
-
#after ⇒ Object
return the after cursor for paginating.
- #api_response ⇒ Object
-
#before ⇒ Object
return the before cursor for paginating.
-
#initialize(options = {}) ⇒ ListResponse
constructor
Initialize a list response.
Constructor Details
#initialize(options = {}) ⇒ ListResponse
Initialize a list response
11 12 13 14 15 16 17 |
# File 'lib/gocardless_pro/list_response.rb', line 11 def initialize( = {}) @response = .fetch(:response) @resource_class = .fetch(:resource_class) @unenveloped_body = .fetch(:unenveloped_body) @records = @unenveloped_body.map { |item| @resource_class.new(item) } end |
Instance Attribute Details
#records ⇒ Object (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
#after ⇒ Object
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_response ⇒ Object
19 20 21 |
# File 'lib/gocardless_pro/list_response.rb', line 19 def api_response @api_response ||= ApiResponse.new(@response) end |
#before ⇒ Object
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 |