Class: Telesign::RestClient::Response
- Inherits:
-
Object
- Object
- Telesign::RestClient::Response
- Defined in:
- lib/telesign/rest.rb
Overview
-
http_response
- A net/http response object.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#json ⇒ Object
Returns the value of attribute json.
-
#ok ⇒ Object
Returns the value of attribute ok.
-
#status_code ⇒ Object
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(http_response) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(http_response) ⇒ Response
Returns a new instance of Response.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/telesign/rest.rb', line 30 def initialize(http_response) @status_code = http_response.code @headers = http_response.to_hash @body = http_response.body @ok = http_response.kind_of? Net::HTTPSuccess begin @json = JSON.parse(http_response.body) rescue JSON::JSONError @json = nil end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
28 29 30 |
# File 'lib/telesign/rest.rb', line 28 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
28 29 30 |
# File 'lib/telesign/rest.rb', line 28 def headers @headers end |
#json ⇒ Object
Returns the value of attribute json.
28 29 30 |
# File 'lib/telesign/rest.rb', line 28 def json @json end |
#ok ⇒ Object
Returns the value of attribute ok.
28 29 30 |
# File 'lib/telesign/rest.rb', line 28 def ok @ok end |
#status_code ⇒ Object
Returns the value of attribute status_code.
28 29 30 |
# File 'lib/telesign/rest.rb', line 28 def status_code @status_code end |