Class: SocketLabs::InjectionApi::Core::HttpResponse
- Inherits:
-
Object
- Object
- SocketLabs::InjectionApi::Core::HttpResponse
- Defined in:
- lib/socketlabs/injectionapi/core/http_response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(response) ⇒ HttpResponse
constructor
A new instance of HttpResponse.
-
#to_hash ⇒ Object
Returns the body as a hash.
Constructor Details
#initialize(response) ⇒ HttpResponse
Returns a new instance of HttpResponse.
12 13 14 15 16 |
# File 'lib/socketlabs/injectionapi/core/http_response.rb', line 12 def initialize(response) @status_code = response.code @body = response.body @headers = response.to_hash end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
9 10 11 |
# File 'lib/socketlabs/injectionapi/core/http_response.rb', line 9 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
10 11 12 |
# File 'lib/socketlabs/injectionapi/core/http_response.rb', line 10 def headers @headers end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
8 9 10 |
# File 'lib/socketlabs/injectionapi/core/http_response.rb', line 8 def status_code @status_code end |
Instance Method Details
#to_hash ⇒ Object
Returns the body as a hash
19 20 21 |
# File 'lib/socketlabs/injectionapi/core/http_response.rb', line 19 def to_hash @parsed_body ||= JSON.parse(@body, symbolize_names: true) end |