Class: GoCardlessPro::Response
- Inherits:
-
Object
- Object
- GoCardlessPro::Response
- Extended by:
- Forwardable
- Defined in:
- lib/gocardless_pro/response.rb
Overview
A class to wrap an API response
Instance Method Summary collapse
-
#body ⇒ Object
Return the body of parsed JSON body of the API response.
-
#initialize(response) ⇒ Response
constructor
Initialize a response instance.
-
#limit ⇒ Object
Returns the limit parameter from the response.
-
#meta ⇒ Object
Returns the meta hash of the response.
Constructor Details
#initialize(response) ⇒ Response
Initialize a response instance
11 12 13 |
# File 'lib/gocardless_pro/response.rb', line 11 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Object
Return the body of parsed JSON body of the API response
16 17 18 |
# File 'lib/gocardless_pro/response.rb', line 16 def body JSON.parse(@response.body) unless @response.body.empty? end |
#limit ⇒ Object
Returns the limit parameter from the response
26 27 28 |
# File 'lib/gocardless_pro/response.rb', line 26 def limit .fetch('limit', nil) end |
#meta ⇒ Object
Returns the meta hash of the response
21 22 23 |
# File 'lib/gocardless_pro/response.rb', line 21 def json_body.fetch('meta', {}) end |