Skip to content

Commit 107d5e3

Browse files
author
Delega Bot
committed
fix: update uses PUT not PATCH, stats endpoint path, add webhooks.delete
- tasks.update() now sends PUT (matches both self-hosted and hosted API) - usage() hits /stats instead of /usage (matches actual API endpoint) - Added webhooks.delete() method (was missing entirely) - Bumped version to 0.1.2 - 52 unit tests pass, 19/19 integration tests pass
1 parent 4234f26 commit 107d5e3

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "delega"
7-
version = "0.1.1"
7+
version = "0.1.2"
88
description = "Official Python SDK for the Delega API"
99
readme = "README.md"
1010
license = "MIT"

src/delega/client.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def update(self, task_id: str, **fields: Any) -> Task:
103103
task_id: The task identifier.
104104
**fields: Fields to update (content, description, priority, etc.).
105105
"""
106-
data = self._http.patch(f"/tasks/{task_id}", body=fields)
106+
data = self._http.put(f"/tasks/{task_id}", body=fields)
107107
return Task.from_dict(data)
108108

109109
def delete(self, task_id: str) -> bool:
@@ -326,6 +326,15 @@ def create(
326326
body["secret"] = secret
327327
return self._http.post("/webhooks", body=body) # type: ignore[no-any-return]
328328

329+
def delete(self, webhook_id: str) -> bool:
330+
"""Delete a webhook.
331+
332+
Args:
333+
webhook_id: The webhook identifier.
334+
"""
335+
self._http.delete(f"/webhooks/{webhook_id}")
336+
return True
337+
329338

330339
class Delega:
331340
"""Synchronous client for the Delega API.
@@ -382,4 +391,4 @@ def usage(self) -> dict[str, Any]:
382391
Returns:
383392
Dictionary with usage statistics.
384393
"""
385-
return self._http.get("/usage") # type: ignore[no-any-return]
394+
return self._http.get("/stats") # type: ignore[no-any-return]

tests/test_client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def test_update_task(self, mock_urlopen: MagicMock) -> None:
165165
task = self.client.tasks.update("t1", content="Updated", priority=1)
166166
self.assertEqual(task.content, "Updated")
167167
request = mock_urlopen.call_args[0][0]
168-
self.assertEqual(request.get_method(), "PATCH")
168+
self.assertEqual(request.get_method(), "PUT")
169169

170170
@patch("urllib.request.urlopen")
171171
def test_delete_task(self, mock_urlopen: MagicMock) -> None:
@@ -309,6 +309,12 @@ def test_create_webhook(self, mock_urlopen: MagicMock) -> None:
309309
)
310310
self.assertEqual(webhook["url"], "https://example.com/hook")
311311

312+
@patch("urllib.request.urlopen")
313+
def test_delete_webhook(self, mock_urlopen: MagicMock) -> None:
314+
mock_urlopen.return_value = _mock_response(None, status=204)
315+
result = self.client.webhooks.delete("w1")
316+
self.assertTrue(result)
317+
312318

313319
class TestTopLevelMethods(unittest.TestCase):
314320
def setUp(self) -> None:

0 commit comments

Comments
 (0)