Class: GoCardlessPro::Response

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/gocardless_pro/response.rb

Overview

A class to wrap an API response

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Initialize a response instance

Parameters:

  • response

    an API response



11
12
13
# File 'lib/gocardless_pro/response.rb', line 11

def initialize(response)
  @response = response
end

Instance Method Details

#bodyObject

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

#limitObject

Returns the limit parameter from the response



26
27
28
# File 'lib/gocardless_pro/response.rb', line 26

def limit
  meta.fetch('limit', nil)
end

#metaObject

Returns the meta hash of the response



21
22
23
# File 'lib/gocardless_pro/response.rb', line 21

def meta
  json_body.fetch('meta', {})
end