Skip to content

Commit f12d7c6

Browse files
author
Daniel Bush
committed
feat: task tagging
1 parent 96c6a95 commit f12d7c6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

sypht/client.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import os
3+
from typing import List, Optional
34
from base64 import b64encode
45
from datetime import datetime, timedelta
56
from urllib.parse import quote_plus, urlencode, urljoin
@@ -812,3 +813,30 @@ def submit_task(
812813
return self._parse_response(
813814
self.requests.post(endpoint, data=json.dumps(task), headers=headers)
814815
)
816+
817+
def add_tags_to_tasks(self, task_ids: List[str], tags: List[str], company_id: Optional[str]=None, endpoint: Optional[str]=None):
818+
company_id = company_id or self.company_id
819+
endpoint = urljoin(
820+
endpoint or self.base_endpoint,
821+
f"app/company/{company_id}/tasks/tags/batch",
822+
)
823+
headers = self._get_headers()
824+
headers["Accept"] = "application/json"
825+
headers["Content-Type"] = "application/json"
826+
data = {"taskIds": task_ids, "add": tags, "remove": []}
827+
return self._parse_response(
828+
self.requests.post(
829+
endpoint, data=json.dumps(data), headers=headers
830+
)
831+
)
832+
833+
def get_tags_for_task(self, task_id: str, company_id: Optional[str]=None, endpoint: Optional[str]=None):
834+
company_id = company_id or self.company_id
835+
endpoint = urljoin(
836+
endpoint or self.base_endpoint,
837+
f"app/company/{company_id}/tasks/{task_id}/tags",
838+
)
839+
headers = self._get_headers()
840+
headers["Accept"] = "application/json"
841+
headers["Content-Type"] = "application/json"
842+
return self._parse_response(self.requests.get(endpoint, headers=headers))

0 commit comments

Comments
 (0)