Class: Conductor::Http::RestResponse
- Inherits:
-
Object
- Object
- Conductor::Http::RestResponse
- Defined in:
- lib/conductor/http/rest_client.rb
Overview
Wrapper for Faraday response
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(faraday_response) ⇒ RestResponse
constructor
A new instance of RestResponse.
- #json ⇒ Object
Constructor Details
#initialize(faraday_response) ⇒ RestResponse
Returns a new instance of RestResponse.
197 198 199 200 201 202 |
# File 'lib/conductor/http/rest_client.rb', line 197 def initialize(faraday_response) @status = faraday_response.status @reason = faraday_response.reason_phrase @body = faraday_response.body @headers = faraday_response.headers.to_h end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
195 196 197 |
# File 'lib/conductor/http/rest_client.rb', line 195 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
195 196 197 |
# File 'lib/conductor/http/rest_client.rb', line 195 def headers @headers end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
195 196 197 |
# File 'lib/conductor/http/rest_client.rb', line 195 def reason @reason end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
195 196 197 |
# File 'lib/conductor/http/rest_client.rb', line 195 def status @status end |
Instance Method Details
#json ⇒ Object
204 205 206 207 208 |
# File 'lib/conductor/http/rest_client.rb', line 204 def json @json ||= JSON.parse(@body) if @body && !@body.empty? rescue JSON::ParserError nil end |