Class: DuffelAPI::APIResponse
- Inherits:
-
Object
- Object
- DuffelAPI::APIResponse
- Extended by:
- Forwardable
- Defined in:
- lib/duffel_api/api_response.rb
Overview
An HTTP response returned from the API
Instance Method Summary collapse
-
#body ⇒ String
Returns the raw body of the HTTP response.
-
#headers ⇒ Hash
Returns the HTTP response headers.
-
#initialize(response) ⇒ APIResponse
constructor
Builds an
APIResponsefrom aResponse, the library’s internal representation of an HTTP response. -
#request_id ⇒ String?
Returns the request ID from the Duffel API, included in the response headers.
-
#status_code ⇒ Integer
Returns the HTTP status code of the HTTP response.
Constructor Details
#initialize(response) ⇒ APIResponse
Builds an APIResponse from a Response, the library’s internal representation of an HTTP response
13 14 15 |
# File 'lib/duffel_api/api_response.rb', line 13 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ String
Returns the raw body of the HTTP response
27 28 29 |
# File 'lib/duffel_api/api_response.rb', line 27 def body @response.raw_body end |
#headers ⇒ Hash
Returns the HTTP response headers
20 21 22 |
# File 'lib/duffel_api/api_response.rb', line 20 def headers @response.headers end |
#request_id ⇒ String?
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.
43 44 45 |
# File 'lib/duffel_api/api_response.rb', line 43 def request_id @response.request_id end |
#status_code ⇒ Integer
Returns the HTTP status code of the HTTP response
34 35 36 |
# File 'lib/duffel_api/api_response.rb', line 34 def status_code @response.status_code end |