Spaces:
Paused
Paused
Download app/clickup_client.py from Leon4gr45/clickup_mcp: direct link, hf CLI and curl.
- Browser
- Download file 2.03 kB
-
https://huggingface.co/spaces/Leon4gr45/clickup_mcp/resolve/71bbd3e474077cd8ad5a9d85bc05a1bd62c5a10c/app/clickup_client.py
- Command line
-
hf download hf://spaces/Leon4gr45/clickup_mcp@71bbd3e474077cd8ad5a9d85bc05a1bd62c5a10c/app/clickup_client.py
-
curl -L -o clickup_client.py https://huggingface.co/spaces/Leon4gr45/clickup_mcp/resolve/71bbd3e474077cd8ad5a9d85bc05a1bd62c5a10c/app/clickup_client.py
2.03 kB
| import httpx | |
| import os | |
| from typing import Any, Dict, List, Optional | |
| class ClickUpClient: | |
| def __init__(self, api_key: Optional[str] = None): | |
| self.api_key = api_key or os.getenv("CLICKUP_API_KEY") | |
| if not self.api_key: | |
| raise ValueError("CLICKUP_API_KEY must be set") | |
| self.base_url = "https://api.clickup.com/api/v2" | |
| self.headers = { | |
| "Authorization": self.api_key, | |
| "Content-Type": "application/json" | |
| } | |
| async def get_tasks(self, list_id: str, archived: bool = False) -> List[Dict[str, Any]]: | |
| async with httpx.AsyncClient() as client: | |
| response = await client.get( | |
| f"{self.base_url}/list/{list_id}/task", | |
| headers=self.headers, | |
| params={"archived": str(archived).lower()} | |
| ) | |
| response.raise_for_status() | |
| return response.json().get("tasks", []) | |
| async def get_task(self, task_id: str) -> Dict[str, Any]: | |
| async with httpx.AsyncClient() as client: | |
| response = await client.get( | |
| f"{self.base_url}/task/{task_id}", | |
| headers=self.headers | |
| ) | |
| response.raise_for_status() | |
| return response.json() | |
| async def create_task(self, list_id: str, data: Dict[str, Any]) -> Dict[str, Any]: | |
| async with httpx.AsyncClient() as client: | |
| response = await client.post( | |
| f"{self.base_url}/list/{list_id}/task", | |
| headers=self.headers, | |
| json=data | |
| ) | |
| response.raise_for_status() | |
| return response.json() | |
| async def update_task(self, task_id: str, data: Dict[str, Any]) -> Dict[str, Any]: | |
| async with httpx.AsyncClient() as client: | |
| response = await client.put( | |
| f"{self.base_url}/task/{task_id}", | |
| headers=self.headers, | |
| json=data | |
| ) | |
| response.raise_for_status() | |
| return response.json() | |