PL

class toggl2pl.PL(app_key, base_url, user_key, log_level='warning', verify=True)

Bases: object

Initialize a new instance of class object to communicate with PL.

Parameters
  • app_key (str) – The required application key used to gather application usage statistic.

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

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

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

add_post(project_id, task_id, description, date, taken)

Create new post in PL database related to corresponding project and task with such required information as date, description and time taken.

Parameters
  • project_id (int) – The project ID in PL database corresponding task belongs to.

  • task_id (int) – The task ID in PL database to create new post.

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

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

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

Returns

Dictionary object with PL API response content.

Return type

dict

list(endpoint, **kwargs)

Wrapper for PL.post() method especially to execute requests to list PL endpoints.

Parameters
  • endpoint (str) – The PL entity (projects, tasks and so on) to list objects via API request.

  • kwargs – Request parameters specific to each entity (please see the official PL API reference).

Returns

Dictionary object with list of requested PL entities.

Return type

dict

list_projects(include_inactive=False)

List projects visible for the provided user-key (i.e. only list projects the provided user-key is authorized to view).

Parameters

include_inactive (bool) – Optional argument which allows to include inactive tasks in the result list.

Returns

Dictionary object with list of PL projects visible for the user-key.

Return type

dict

list_tasks(project_id)

List tasks corresponding to the particular project specified by its ID.

Parameters

project_id (int) – The parent object ID to query list of tasks.

Returns

Dictionary object with list of PL tasks related to requested project.

Return type

dict

static normalize(items)

Helper function to normalize dictionaries keys and make them compatible with PL API request parameters names.

Parameters

items (dict) – Dictionary object with request parameters to normalize before send request to remote PL API.

Returns

Dictionary object with keys updated according to PL API specific (hyphens instead of underscores).

Return type

dict

post(endpoint, **kwargs)

Prepare provided keyword arguments and send them to the specified PL API endpoint using HTTP POST request.

Parameters
  • endpoint (str) – The PL API endpoint to send data using HTTP POST request.

  • kwargs – Request parameters specific to each endpoint (please see the official PL API reference).

Returns

Dictionary object with PL API endpoint response content.

Return type

dict

projects(excluded_projects=None)

Wrapper for list_projects and list_tasks methods to exclude particular PL projects and combine projects data with tasks data into single object with machine-readable structure.

Parameters

excluded_projects (list) – List of PL projects names to exclude from result.

Returns

Dictionary object with combined information about PL projects and their tasks.

Return type

dict