Class: MyJohnDeere::Response
- Inherits:
-
Object
- Object
- MyJohnDeere::Response
- Defined in:
- lib/myjohndeere/response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#http_body ⇒ Object
Returns the value of attribute http_body.
-
#http_headers ⇒ Object
Returns the value of attribute http_headers.
-
#http_status ⇒ Object
Returns the value of attribute http_status.
-
#request_id ⇒ Object
Returns the value of attribute request_id.
Instance Method Summary collapse
- #code ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/myjohndeere/response.rb', line 8 def initialize(response) self.http_headers = {} response.each_capitalized_name do |n| self.http_headers[n] = response[n] end self.http_body = response.body if response.body then begin self.data = JSON.parse(response.body) rescue JSON::ParserError self.data = nil end else self.data = nil end self.http_status = response.code.to_i end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
7 8 9 |
# File 'lib/myjohndeere/response.rb', line 7 def data @data end |
#http_body ⇒ Object
Returns the value of attribute http_body.
4 5 6 |
# File 'lib/myjohndeere/response.rb', line 4 def http_body @http_body end |
#http_headers ⇒ Object
Returns the value of attribute http_headers.
5 6 7 |
# File 'lib/myjohndeere/response.rb', line 5 def http_headers @http_headers end |
#http_status ⇒ Object
Returns the value of attribute http_status.
6 7 8 |
# File 'lib/myjohndeere/response.rb', line 6 def http_status @http_status end |
#request_id ⇒ Object
Returns the value of attribute request_id.
3 4 5 |
# File 'lib/myjohndeere/response.rb', line 3 def request_id @request_id end |
Instance Method Details
#code ⇒ Object
27 28 29 |
# File 'lib/myjohndeere/response.rb', line 27 def code return http_status end |