Class: ZohoTools::Response
- Inherits:
-
Object
- Object
- ZohoTools::Response
- Defined in:
- lib/zoho_tools/response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #body ⇒ Object
- #error_message ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
7 8 9 |
# File 'lib/zoho_tools/response.rb', line 7 def initialize(response) @response = response end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/zoho_tools/response.rb', line 5 def response @response end |
Instance Method Details
#body ⇒ Object
21 22 23 |
# File 'lib/zoho_tools/response.rb', line 21 def body @body ||= JSON.parse(response.body) end |
#error_message ⇒ Object
15 16 17 18 19 |
# File 'lib/zoho_tools/response.rb', line 15 def return body['error'] if response.code == 200 response. end |
#success? ⇒ Boolean
11 12 13 |
# File 'lib/zoho_tools/response.rb', line 11 def success? response.code == 200 && (!body['status'] || body['status'] == 'success') && !body['error'] end |