Client

class toggl2pl.Client(api_token, base_url, user_key, workspace, excluded_projects=None, log_level='info', verify=True)

Bases: object

High-level class which aggregates common methods required to pull, push and sync data between Project Laboratory and Toggl.

Parameters
  • api_token (str) – The Toggl authentication token to use instead of username and password.

  • base_url (str) – The Project Laboratory API base URL in format <scheme>://<domain>/<uri>.

  • user_key (str) – The Project Laboratory authentication token to use instead of username and password.

  • workspace (str) – The Toggl workspace name (case sensitive) to pull information from.

  • excluded_projects (list) – Optional list of Project Laboratory projects names to exclude from pull.

  • log_level (str) – Optional logging level name to configure logging verbosity (default: info).

  • verify (bool) – Optional argument which allows to disable TLS connection verification and suppress warnings.

add_post(date, description, minutes, project, task)

Create a new post in Project Laboratory about specific task execution details.

Parameters
  • date (str) – The date when work was actually done in ISO 8601 (YYYY-MM-DD) format.

  • description (str) – Relatively short description of the work done as a part of the parent task.

  • minutes (int) – Total amount of minutes spent during work on the task entry.

  • project (int) – The project name in Project Laboratory database corresponding task belongs to.

  • task (int) – The task name in Project Laboratory database to create new post.

Returns

Dictionary object with PL API response content.

Return type

dict

static check_workspace(workspace)

Check provided Toggl workspace data format and value.

Parameters

workspace (dict) – Toggl workspace data to check.

Returns

Dictionary object which represents single Toggl workspace.

Return type

dict

Raises

TypeError – In case provided workspace data has type list or None.

posts(since, until)

Wrapper for TogglReportsClient.posts() to pull list of Toggl posts between since and until dates.

Parameters
  • since (str) – The start date in ISO 8601 (YYYY-MM-DD) format to query Toggl Reports API for tasks.

  • until (str) – The end date in ISO 8601 (YYYY-MM-DD) format to query Toggl Reports API for tasks.

Returns

Normalized list of Toggl tasks aggregated by projects.

Return type

list

sync()

Synchronize projects and tasks from Project Laboratory into Toggl.