From 4fe16e768d29f48b6b3f2a66e6e6fb86607d1655 Mon Sep 17 00:00:00 2001 From: "Evgeny (Krymmy) Momotov" Date: Thu, 25 Sep 2025 12:20:52 +0300 Subject: [PATCH] [UP] OrderNotify+ --- src/TaxisLibrary/taxis_client.py | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/TaxisLibrary/taxis_client.py b/src/TaxisLibrary/taxis_client.py index d7c44ed..a4ab2ac 100644 --- a/src/TaxisLibrary/taxis_client.py +++ b/src/TaxisLibrary/taxis_client.py @@ -24,6 +24,18 @@ class PromptFor(str, Enum): TAXI = "TAXI" CLIENT = "CLIENT" + +class OrderNotifySide(str, Enum): + CLIENT = "client" + DRIVER = "driver" + + +class OrderNotifyType(str, Enum): + CANCELED_BY_CLIENT = "canceled_by_client" + CANCELED_BY_DRIVER = "canceled_by_driver" + DRIVER_ARRIVED = "driver_arrived" + + # Models class ApiKeyOut(BaseModel): api_key: str @@ -154,6 +166,22 @@ class OrderOut(BaseModel): to_latitude: Optional[str] = None to_longitude: Optional[str] = None + +class OrderNotificationsIn(BaseModel): + order: int + notify_side: OrderNotifySide + notify_type: OrderNotifyType + processed: Optional[bool] = False + +class OrderNotificationsOut(BaseModel): + id: int + order: OrderOut + notify_side: OrderNotifySide + notify_type: OrderNotifyType + processed: bool + created_at: datetime + updated_at: datetime + class PromptIn(BaseModel): name: str = Field(max_length=255) content: str @@ -376,6 +404,26 @@ class TaxisClient: result = await self._request("DELETE", f"/orders/{order_id}/driver") return OrderOut(**result) + # Order Notifications + async def list_order_notifications(self, **params) -> List['OrderNotificationsOut']: + result = await self._request("GET", "/order_notifications/", params=params) + return [OrderNotificationsOut(**item) for item in result] + + async def create_order_notification(self, notification: 'OrderNotificationsIn') -> 'OrderNotificationsOut': + result = await self._request("POST", "/order_notifications/", json_data=notification.dict()) + return OrderNotificationsOut(**result) + + async def get_order_notification(self, notification_id: int, **params) -> 'OrderNotificationsOut': + result = await self._request("GET", f"/order_notifications/{notification_id}", params=params) + return OrderNotificationsOut(**result) + + async def mark_order_notification_processed(self, notification_id: int, processed: bool) -> 'OrderNotificationsOut': + result = await self._request("PATCH", f"/order_notifications/{notification_id}/processed", params={"processed": processed}) + return OrderNotificationsOut(**result) + + async def delete_order_notification(self, notification_id: int) -> None: + await self._request("DELETE", f"/order_notifications/{notification_id}") + # Settings async def get_global_settings(self, **params) -> 'GlobalSettingsOut': result = await self._request("GET", "/settings/global", params=params)