Class: Transfeera::Response
- Inherits:
-
Object
- Object
- Transfeera::Response
- Defined in:
- lib/transfeera/response.rb
Instance Method Summary collapse
- #body ⇒ Object
- #default_response ⇒ Object
- #error ⇒ Object
- #headers ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #status ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
3 4 5 |
# File 'lib/transfeera/response.rb', line 3 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Object
11 12 13 |
# File 'lib/transfeera/response.rb', line 11 def body @body ||= JSON.parse(@response.body, symbolize_names: true) end |
#default_response ⇒ Object
34 35 36 |
# File 'lib/transfeera/response.rb', line 34 def default_response @response end |
#error ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/transfeera/response.rb', line 23 def error return if @response.success? Transfeera::Errors::ResponseError.new( error: body[:error], error_code: body[:error_code], message: body[:message], status_code: body[:statusCode] ) end |
#headers ⇒ Object
7 8 9 |
# File 'lib/transfeera/response.rb', line 7 def headers @response.headers end |
#status ⇒ Object
15 16 17 |
# File 'lib/transfeera/response.rb', line 15 def status @response.status end |
#success? ⇒ Boolean
19 20 21 |
# File 'lib/transfeera/response.rb', line 19 def success? @response.success? end |