Class: LogSnag::Client
- Inherits:
-
Object
- Object
- LogSnag::Client
- Defined in:
- lib/log_snag/client.rb
Constant Summary collapse
- BASE_URL =
"https://api.logsnag.com/v1"
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(token:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #insight(project:, title:, value:, **params) ⇒ Object
- #log(project:, channel:, event:, **params) ⇒ Object
Constructor Details
#initialize(token:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 |
# File 'lib/log_snag/client.rb', line 7 def initialize(token:, adapter: Faraday.default_adapter, stubs: nil) @token = token @adapter = adapter # Test stubs for requests @stubs = stubs end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/log_snag/client.rb', line 5 def adapter @adapter end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
5 6 7 |
# File 'lib/log_snag/client.rb', line 5 def token @token end |
Instance Method Details
#connection ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/log_snag/client.rb', line 25 def connection @connection ||= Faraday.new(BASE_URL) do |conn| conn.request :authorization, :Bearer, token conn.request :json conn.response :json conn.adapter adapter, @stubs end end |