Class: TogglRb::Client
- Inherits:
-
Object
- Object
- TogglRb::Client
- Defined in:
- lib/toggl_rb/client.rb
Overview
Config class stores global configuration for the TogglRb gem
Constant Summary collapse
- URLS =
{ core: { url: "https://api.track.toggl.com/api/v9" }, reports: { url: "https://api.track.toggl.com/reports/api/v3/" } }.freeze
Instance Attribute Summary collapse
-
#core_connection ⇒ Object
readonly
Returns the value of attribute core_connection.
-
#reports_connection ⇒ Object
readonly
Returns the value of attribute reports_connection.
Instance Method Summary collapse
-
#initialize ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/toggl_rb/client.rb', line 15 def initialize @core_connection = Faraday.new(URLS.dig(:core, :url)).tap do |fc| fc.set_basic_auth(config.username, config.password) if config.basic_auth? fc.set_basic_auth(config.api_token, TogglRb::Config::API_TOKEN_PASSWORD) if config.api_token? fc.headers["Content-Type"] = "application/json" fc.headers["Accept"] = "application/json" end @reports_connection = Faraday.new(URLS.dig(:reports, :url)).tap do |fc| fc.set_basic_auth(config.username, config.password) if config.basic_auth? fc.set_basic_auth(config.api_token, TogglRb::Config::API_TOKEN_PASSWORD) if config.api_token? fc.headers["Content-Type"] = "application/json" fc.headers["Accept"] = "application/json" end end |
Instance Attribute Details
#core_connection ⇒ Object (readonly)
Returns the value of attribute core_connection.
8 9 10 |
# File 'lib/toggl_rb/client.rb', line 8 def core_connection @core_connection end |
#reports_connection ⇒ Object (readonly)
Returns the value of attribute reports_connection.
8 9 10 |
# File 'lib/toggl_rb/client.rb', line 8 def reports_connection @reports_connection end |