Class: ZohoTools::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/zoho_tools/response.rb', line 5

def response
  @response
end

Instance Method Details

#bodyObject



21
22
23
# File 'lib/zoho_tools/response.rb', line 21

def body
  @body ||= JSON.parse(response.body)
end

#error_messageObject



15
16
17
18
19
# File 'lib/zoho_tools/response.rb', line 15

def error_message
  return body['error'] if response.code == 200

  response.message
end

#success?Boolean

Returns:

  • (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