feat(client): add mci-server event poster
This commit is contained in:
19
channel-service/app/clients/mci_server_client.py
Normal file
19
channel-service/app/clients/mci_server_client.py
Normal file
@@ -0,0 +1,19 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user