[UP] OrderNotify+
This commit is contained in:
parent
1f50b09a86
commit
4fe16e768d
1 changed files with 48 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue