Class: DeviceCloud::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
10
11
# File 'lib/device_cloud/response.rb', line 5

def initialize(http_response)
  @original_response = http_response
  @code = original_response.code
  @message = original_response.message
  @headers = original_response.header.to_hash
  @body = original_response.body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/device_cloud/response.rb', line 3

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



3
4
5
# File 'lib/device_cloud/response.rb', line 3

def code
  @code
end

#headersObject (readonly)

Returns the value of attribute headers.



3
4
5
# File 'lib/device_cloud/response.rb', line 3

def headers
  @headers
end

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/device_cloud/response.rb', line 3

def message
  @message
end

#original_responseObject (readonly)

Returns the value of attribute original_response.



3
4
5
# File 'lib/device_cloud/response.rb', line 3

def original_response
  @original_response
end

Instance Method Details

#to_hash_from_jsonObject



13
14
15
# File 'lib/device_cloud/response.rb', line 13

def to_hash_from_json
  JSON.parse(body)
end