PL¶
-
class
toggl2pl.PL(app_key, base_url, user_key, log_level='info', verify=True)¶ Bases:
objectInitialize 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 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.
verify (bool) – Optional argument which allows to disable TLS connection verification and suppress warnings.
-
add_post(date, description, minutes, project_id, task_id)¶ Create a new post in Project Laboratory about specific task execution details.
- Parameters
date (str) – The date when work was actually done in YYYY-MM-DD format (ISO 8601).
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_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.
- Returns
Dictionary object with PL API response content.
- Return type
dict
-
list(endpoint, **kwargs)¶ Wrapper for
post()method especially to execute requests to PL list 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, per_page=-1)¶ List tasks corresponding to the particular project specified by its ID.
- Parameters
project_id (int) – The parent object ID to query list of tasks.
per_page (int) – The maximum number of projects to return in response.
- 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()andlist_tasks()methods to combine projects data with tasks data into single object with machine-readable structure and optionally to exclude particular PL projects.- 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