From bc80648db708d33ccfe11a59ed49f1de3b6b1216 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 15 Mar 2019 09:51:00 +0100 Subject: [PATCH] get_tags fixed workspace_id, start timer can have tags, added add_tag method --- pype/clockify/clockify_api.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pype/clockify/clockify_api.py b/pype/clockify/clockify_api.py index d6897ec299..f5ebac0cef 100644 --- a/pype/clockify/clockify_api.py +++ b/pype/clockify/clockify_api.py @@ -147,7 +147,7 @@ class ClockifyAPI(metaclass=Singleton): project["name"]: project["id"] for project in response.json() } - def get_tags(self, workspace_id): + def get_tags(self, workspace_id=None): if workspace_id is None: workspace_id = self.workspace_id action_url = 'workspaces/{}/tags/'.format(workspace_id) @@ -213,7 +213,7 @@ class ClockifyAPI(metaclass=Singleton): return str(datetime.datetime.utcnow().isoformat())+'Z' def start_time_entry( - self, description, project_id, task_id, + self, description, project_id, task_id=None, tag_ids=[], workspace_id=None, billable=True ): # Workspace @@ -246,7 +246,7 @@ class ClockifyAPI(metaclass=Singleton): "description": description, "projectId": project_id, "taskId": task_id, - "tagIds": None + "tagIds": tag_ids } response = requests.post( self.endpoint + action_url, @@ -374,6 +374,20 @@ class ClockifyAPI(metaclass=Singleton): ) return response.json() + def add_tag(self, name, workspace_id=None): + if workspace_id is None: + workspace_id = self.workspace_id + action_url = 'workspaces/{}/tags'.format(workspace_id) + body = { + "name": name + } + response = requests.post( + self.endpoint + action_url, + headers=self.headers, + json=body + ) + return response.json() + def delete_project( self, project_id, workspace_id=None ):