Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ def pobo_webhook(request):
sync_products.delay()
elif payload.event == WebhookEvent.CATEGORIES_UPDATE:
sync_categories.delay()
elif payload.event == WebhookEvent.BLOGS_UPDATE:
sync_blogs.delay()

return JsonResponse({"status": "ok"})

Expand All @@ -260,7 +262,7 @@ payload = handler.handle(
### Webhook Payload

```python
payload.event # str: "products.update" or "categories.update"
payload.event # str: "products.update", "categories.update", or "blogs.update"
payload.timestamp # datetime
payload.eshop_id # int
```
Expand Down
1 change: 1 addition & 0 deletions src/pobo/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ class WebhookEvent(str, Enum):

PRODUCTS_UPDATE = "products.update"
CATEGORIES_UPDATE = "categories.update"
BLOGS_UPDATE = "blogs.update"
9 changes: 9 additions & 0 deletions tests/test_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ def test_handle_valid_payload(self, handler, secret):
assert result.event == "products.update"
assert result.eshop_id == 123

def test_handle_blogs_update_payload(self, handler, secret):
payload = json.dumps({"event": "blogs.update", "timestamp": 1704067200, "eshop_id": 456})
signature = self.sign(payload, secret)

result = handler.handle(payload, signature)

assert result.event == "blogs.update"
assert result.eshop_id == 456

def test_handle_missing_signature(self, handler):
payload = json.dumps({"event": "products.update"})

Expand Down