Class: DuffelAPI::APIResponse

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/duffel_api/api_response.rb

Overview

An HTTP response returned from the API

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ APIResponse

Builds an `APIResponse` from a `Response`, the library's internal representation of an HTTP response

Parameters:



13
14
15
# File 'lib/duffel_api/api_response.rb', line 13

def initialize(response)
  @response = response
end

Instance Method Details

#bodyString

Returns the raw body of the HTTP response

Returns:

  • (String)


27
28
29
# File 'lib/duffel_api/api_response.rb', line 27

def body
  @response.raw_body
end

#headersHash

Returns the HTTP response headers

Returns:

  • (Hash)


20
21
22
# File 'lib/duffel_api/api_response.rb', line 20

def headers
  @response.headers
end

#request_idString?

Returns the request ID from the Duffel API, included in the response headers. This could be `nil` if the response didn't make it to the Duffel API itself and, for example, only reached a load balancer.

Returns:

  • (String, nil)


43
44
45
# File 'lib/duffel_api/api_response.rb', line 43

def request_id
  @response.request_id
end

#status_codeInteger

Returns the HTTP status code of the HTTP response

Returns:

  • (Integer)


34
35
36
# File 'lib/duffel_api/api_response.rb', line 34

def status_code
  @response.status_code
end