Class: Lenddo::Response
- Inherits:
-
Object
- Object
- Lenddo::Response
- Defined in:
- lib/lenddo/response.rb
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(http_response) ⇒ Response
constructor
A new instance of Response.
- #response_code ⇒ Object
- #status ⇒ Object
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
#body ⇒ Object
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.) end end |
#response_code ⇒ Object
20 21 22 |
# File 'lib/lenddo/response.rb', line 20 def response_code @http_response.response_code end |
#status ⇒ Object
16 17 18 |
# File 'lib/lenddo/response.rb', line 16 def status @http_response.status end |