Class: Lenddo::Response

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

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
10
11
12
13
14
# File 'lib/lenddo/response.rb', line 5

def initialize(http_response)
  @http_response = http_response

  http_code = http_response.response_code
  if http_code == 500
    raise Lenddo::Errors::InternalErrorException
  elsif http_code > 500
    raise Lenddo::Errors::UnknownException.new(http_response.status)
  end
end

Instance Method Details

#bodyObject



24
25
26
27
28
29
30
# File 'lib/lenddo/response.rb', line 24

def body
  begin
    JSON.parse(@http_response.body)
  rescue => e
    raise Lenddo::Errors::UnknownException.new(e.message)
  end
end

#response_codeObject



20
21
22
# File 'lib/lenddo/response.rb', line 20

def response_code
  @http_response.response_code
end

#statusObject



16
17
18
# File 'lib/lenddo/response.rb', line 16

def status
  @http_response.status
end