class DuffelAPI::APIResponse

An HTTP response returned from the API

Public Class Methods

new(response) click to toggle source

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

@param response [Response] @return [APIResponse]

# File lib/duffel_api/api_response.rb, line 13
def initialize(response)
  @response = response
end

Public Instance Methods

body() click to toggle source

Returns the raw body of the HTTP response

@return [String]

# File lib/duffel_api/api_response.rb, line 27
def body
  @response.raw_body
end
headers() click to toggle source

Returns the HTTP response headers

@return [Hash]

# File lib/duffel_api/api_response.rb, line 20
def headers
  @response.headers
end
request_id() click to toggle source

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.

@return [String, nil]

# File lib/duffel_api/api_response.rb, line 43
def request_id
  @response.request_id
end
status_code() click to toggle source

Returns the HTTP status code of the HTTP response

@return [Integer]

# File lib/duffel_api/api_response.rb, line 34
def status_code
  @response.status_code
end