Class: Transfeera::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/transfeera/response.rb

Instance Method Summary collapse

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

#bodyObject



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

def body
  @body ||= JSON.parse(@response.body, symbolize_names: true)
end

#default_responseObject



34
35
36
# File 'lib/transfeera/response.rb', line 34

def default_response
  @response
end

#errorObject



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

#headersObject



7
8
9
# File 'lib/transfeera/response.rb', line 7

def headers
  @response.headers
end

#statusObject



15
16
17
# File 'lib/transfeera/response.rb', line 15

def status
  @response.status
end

#success?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/transfeera/response.rb', line 19

def success?
  @response.success?
end