Class: Lyft::Client::Api::Base
- Inherits:
-
Object
- Object
- Lyft::Client::Api::Base
- Defined in:
- lib/lyft/client/api/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
- #connection(access_token = nil) ⇒ Object
-
#initialize(configuration) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(configuration) ⇒ Base
Returns a new instance of Base.
7 8 9 |
# File 'lib/lyft/client/api/base.rb', line 7 def initialize(configuration) @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
5 6 7 |
# File 'lib/lyft/client/api/base.rb', line 5 def configuration @configuration end |
Instance Method Details
#connection(access_token = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lyft/client/api/base.rb', line 11 def connection(access_token = nil) Faraday.new(url: BASE_URL) do |conn| # Headers conn.headers = configuration.headers if access_token conn. :Bearer, access_token else conn.basic_auth( configuration.client_id, configuration.client_secret ) end # Request conn.request :json # Response conn.response :json conn.response :logger conn.adapter Faraday.default_adapter end end |