Files
sino-mci/channel-service/app/clients/mci_server_client.py

20 lines
591 B
Python

from __future__ import annotations
import httpx
from app.models.event import OutboundEvent
class MciServerClient:
def __init__(self, base_url: str, timeout: float = 10.0):
self.base_url = base_url.rstrip("/")
self.timeout = timeout
async def post_event(self, event: OutboundEvent) -> None:
async with httpx.AsyncClient(timeout=self.timeout) as client:
response = await client.post(
f"{self.base_url}/api/v1/channel-account/event",
json=event.to_payload(),
)
response.raise_for_status()