Coverage for fastid / webhooks / senders / httpx.py: 100%
13 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-10-18 16:37 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-10-18 16:37 +0000
1from typing import Any
3import httpx
6class WebhookSender:
7 def __init__(self, client: httpx.AsyncClient) -> None:
8 self.client = client
10 async def send(self, url: str, payload: dict[str, Any], headers: dict[str, str]) -> dict[str, Any]:
11 try:
12 response = await self.client.post(url, json=payload, headers=headers)
13 except httpx.RequestError as e:
14 return {"status_code": 0, "content": {"error": str(e)}}
15 try:
16 content = response.json()
17 except Exception: # noqa: BLE001
18 content = {"text": response.text}
19 return {"status_code": response.status_code, "content": content}