[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"
|
TAXI = "TAXI"
|
||||||
CLIENT = "CLIENT"
|
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
|
# Models
|
||||||
class ApiKeyOut(BaseModel):
|
class ApiKeyOut(BaseModel):
|
||||||
api_key: str
|
api_key: str
|
||||||
|
|
@ -154,6 +166,22 @@ class OrderOut(BaseModel):
|
||||||
to_latitude: Optional[str] = None
|
to_latitude: Optional[str] = None
|
||||||
to_longitude: 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):
|
class PromptIn(BaseModel):
|
||||||
name: str = Field(max_length=255)
|
name: str = Field(max_length=255)
|
||||||
content: str
|
content: str
|
||||||
|
|
@ -376,6 +404,26 @@ class TaxisClient:
|
||||||
result = await self._request("DELETE", f"/orders/{order_id}/driver")
|
result = await self._request("DELETE", f"/orders/{order_id}/driver")
|
||||||
return OrderOut(**result)
|
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
|
# Settings
|
||||||
async def get_global_settings(self, **params) -> 'GlobalSettingsOut':
|
async def get_global_settings(self, **params) -> 'GlobalSettingsOut':
|
||||||
result = await self._request("GET", "/settings/global", params=params)
|
result = await self._request("GET", "/settings/global", params=params)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue