fids/subscription-domain/subscription-manager/src/api/schemas/chat.py

52 lines
1.1 KiB
Python

from datetime import datetime
from typing import Any
from pydantic import BaseModel, validator
class Chat(BaseModel):
user_id: int
chat_id: str
class Update(BaseModel):
update_id: int
message: Any
class ChatCreateData(BaseModel):
user_id: int
class FlightData(BaseModel):
id: int
flight_code: str
status: str
origin: str
destination: str
departure_time: str
arrival_time: str
gate: str = None
@validator("departure_time", "arrival_time", pre=True, always=True)
def parse_datetime(cls, value):
if isinstance(value, datetime):
return value.strftime("%Y-%m-%d %I:%M %p")
return value
class FlightData(BaseModel):
id: int
flight_code: str
status: str
origin: str
destination: str
departure_time: str
arrival_time: str
gate: str = None
@validator("departure_time", "arrival_time", pre=True, always=True)
def parse_datetime(cls, value):
if isinstance(value, datetime):
return value.strftime("%Y-%m-%d %I:%M %p")
return value