Class: TogglAPI::Client

Inherits:
BaseClient show all
Defined in:
lib/toggl_api/client.rb

Overview

The Toggl API Client

Constant Summary collapse

API_URL =
"https://www.toggl.com/api/v8"

Constants inherited from BaseClient

BaseClient::DEFAULT_USER_AGENT

Instance Attribute Summary

Attributes inherited from BaseClient

#api_token, #logger

Instance Method Summary collapse

Methods inherited from BaseClient

#credentials, #default_api_token, #default_headers, #default_user_agent, #default_workspace_id, #initialize

Constructor Details

This class inherits a constructor from TogglAPI::BaseClient

Instance Method Details

#get_project_tasks(project_id:) ⇒ Object



30
31
32
33
34
# File 'lib/toggl_api/client.rb', line 30

def get_project_tasks(project_id:)
  perform_request(
    url: "#{API_URL}/projects/#{project_id}/tasks"
  ) || []
end

#get_workspace_projects(workspace_id: default_workspace_id, active: "true") ⇒ Object

Get the projects from the specified workspace.



23
24
25
26
27
28
# File 'lib/toggl_api/client.rb', line 23

def get_workspace_projects(workspace_id: default_workspace_id, active: "true")
  perform_request(
    url: "#{API_URL}/workspaces/#{workspace_id}/projects",
    query: { active: active }
  )
end

#update_time_entry(id:, time_entry:) ⇒ Object

Update the Toggl time entry with the specified ‘ìd` using the provided `time_entry` data.



14
15
16
17
18
19
20
# File 'lib/toggl_api/client.rb', line 14

def update_time_entry(id:, time_entry:)
  perform_request(
    verb: :put,
    url: "#{API_URL}/time_entries/#{id}",
    body: { time_entry: time_entry }
  )["data"]
end