Class: Conductor::Http::RestResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/conductor/http/rest_client.rb

Overview

Wrapper for Faraday response

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (readonly)

Returns the value of attribute body.



195
196
197
# File 'lib/conductor/http/rest_client.rb', line 195

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



195
196
197
# File 'lib/conductor/http/rest_client.rb', line 195

def headers
  @headers
end

#reasonObject (readonly)

Returns the value of attribute reason.



195
196
197
# File 'lib/conductor/http/rest_client.rb', line 195

def reason
  @reason
end

#statusObject (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

#jsonObject



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