get_tags fixed workspace_id, start timer can have tags, added add_tag method

This commit is contained in:
Jakub Trllo 2019-03-15 09:51:00 +01:00
parent e0f6ba6eb2
commit bc80648db7

View file

@ -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
):