class TogglAPI::BaseClient
Superclass for API clients.
Constants
- DEFAULT_USER_AGENT
Attributes
api_token[R]
logger[R]
Public Class Methods
new(api_token: default_api_token, user_agent: default_user_agent, logger: nil)
click to toggle source
Returns a new instance of the client, configured with the specified parameters.
@param api_token
[String] Toggl API token, for authentication @param user_agent [String] defaults to “TogglCache” @param logger [Logger] used to log messages (in particular fetch
events). Defaults to nil.
# File lib/toggl_api/base_client.rb, line 20 def initialize(api_token: default_api_token, user_agent: default_user_agent, logger: nil) raise "Missing api_token" if api_token.nil? || api_token.empty? @api_token = api_token @user_agent = user_agent @logger = logger end
Public Instance Methods
credentials()
click to toggle source
# File lib/toggl_api/base_client.rb, line 35 def credentials { username: @api_token, password: "api_token" } end
default_api_token()
click to toggle source
# File lib/toggl_api/base_client.rb, line 27 def default_api_token ENV["TOGGL_API_TOKEN"] end
default_headers()
click to toggle source
# File lib/toggl_api/base_client.rb, line 42 def default_headers { "Content-Type" => "application/json" } end
default_user_agent()
click to toggle source
# File lib/toggl_api/base_client.rb, line 31 def default_user_agent DEFAULT_USER_AGENT end
default_workspace_id()
click to toggle source
# File lib/toggl_api/base_client.rb, line 48 def default_workspace_id DEFAULT_WORKSPACE_ID end