Class: MoesifApi::HttpResponse
- Inherits:
-
Object
- Object
- MoesifApi::HttpResponse
- Defined in:
- lib/moesif_api/http/http_response.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#json_body ⇒ Object
Returns the value of attribute json_body.
-
#raw_body ⇒ Object
Returns the value of attribute raw_body.
-
#status_code ⇒ Object
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(status_code, headers, raw_body) ⇒ HttpResponse
constructor
The constructor.
Constructor Details
#initialize(status_code, headers, raw_body) ⇒ HttpResponse
The constructor.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/moesif_api/http/http_response.rb', line 11 def initialize(status_code, headers, raw_body) @status_code = status_code @headers = headers @raw_body = raw_body begin if !raw_body.nil? and raw_body.is_a?(String) and (raw_body.start_with?("{") || raw_body.start_with?("[")) @json_body = JSON.parse(raw_body) end rescue StandardError => e # we can't parse json body # but it is ok, move forward anyways # print "can't parse json " + e.to_s end end |
Instance Attribute Details
#headers ⇒ Object
Returns the value of attribute headers.
5 6 7 |
# File 'lib/moesif_api/http/http_response.rb', line 5 def headers @headers end |
#json_body ⇒ Object
Returns the value of attribute json_body.
5 6 7 |
# File 'lib/moesif_api/http/http_response.rb', line 5 def json_body @json_body end |
#raw_body ⇒ Object
Returns the value of attribute raw_body.
5 6 7 |
# File 'lib/moesif_api/http/http_response.rb', line 5 def raw_body @raw_body end |
#status_code ⇒ Object
Returns the value of attribute status_code.
5 6 7 |
# File 'lib/moesif_api/http/http_response.rb', line 5 def status_code @status_code end |