Class: DuffelAPI::APIService
- Inherits:
-
Object
- Object
- DuffelAPI::APIService
- Defined in:
- lib/duffel_api/api_service.rb
Instance Method Summary collapse
-
#initialize(base_url, access_token, options = {}) ⇒ APIService
constructor
A new instance of APIService.
- #make_request(method, path, options = {}) ⇒ Object
Constructor Details
#initialize(base_url, access_token, options = {}) ⇒ APIService
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/duffel_api/api_service.rb', line 8 def initialize(base_url, access_token, = {}) @base_url = base_url root_url, @path_prefix = unpack_url(base_url) @connection = Faraday.new(root_url) do |faraday| faraday.response :raise_duffel_errors faraday.adapter(:net_http) end @headers = [:default_headers] || {} @headers["Authorization"] = "Bearer #{access_token}" end |
Instance Method Details
#make_request(method, path, options = {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/duffel_api/api_service.rb', line 22 def make_request(method, path, = {}) raise ArgumentError, "options must be a hash" unless .is_a?(Hash) [:headers] ||= {} [:headers] = @headers.merge([:headers]) Request.new(@connection, method, @path_prefix + path, ).request end |