Class: Bugscriber::Client
- Inherits:
-
Object
- Object
- Bugscriber::Client
- Defined in:
- lib/bugscriber/client.rb
Constant Summary collapse
- BASE_URL =
'https://bugscriber-api.herokuapp.com'
- AUTHORIZATION_HEADER_KEY =
'X-API-KEY'
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#stubs ⇒ Object
readonly
Returns the value of attribute stubs.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #tracks ⇒ Object
Constructor Details
#initialize(adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
10 11 12 13 |
# File 'lib/bugscriber/client.rb', line 10 def initialize(adapter: Faraday.default_adapter, stubs: nil) @adapter = adapter @stubs = stubs end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
8 9 10 |
# File 'lib/bugscriber/client.rb', line 8 def adapter @adapter end |
#stubs ⇒ Object (readonly)
Returns the value of attribute stubs.
8 9 10 |
# File 'lib/bugscriber/client.rb', line 8 def stubs @stubs end |
Instance Method Details
#connection ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bugscriber/client.rb', line 15 def connection @connection ||= Faraday.new(BASE_URL) do |conn| conn.request :json conn.response :json, content_type: 'application/json' unless Bugscriber.config.logger.blank? conn.response :logger, Bugscriber.config.logger, body: true, bodies: { request: true, response: true } end conn.headers[AUTHORIZATION_HEADER_KEY] = Bugscriber.config.api_key conn.adapter adapter, stubs end end |
#tracks ⇒ Object
28 29 30 |
# File 'lib/bugscriber/client.rb', line 28 def tracks Bugscriber::Resources::Tracks.new(self) end |