Class: DuffelAPI::Request
- Inherits:
-
Object
- Object
- DuffelAPI::Request
- Defined in:
- lib/duffel_api/request.rb
Overview
An internal class used within the library that represents a request to be made to the Duffel API, and which is able to dispatch that request
Instance Method Summary collapse
-
#call ⇒ Response
Dispatches the request and returns the response.
-
#initialize(connection, method, path, headers: {}, params: {}, query_params: {}) ⇒ Request
constructor
Initialize a request class, which makes calls to the API.
Constructor Details
#initialize(connection, method, path, headers: {}, params: {}, query_params: {}) ⇒ Request
Initialize a request class, which makes calls to the API
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/duffel_api/request.rb', line 17 def initialize(connection, method, path, headers: {}, params: {}, query_params: {}) @connection = connection @method = method @path = path @headers = headers.transform_keys(&:to_s) @option = params @query_params = query_params @request_body = request_body if @request_body.is_a?(Hash) @request_body = @request_body.to_json @headers["Content-Type"] ||= "application/json" end end |