from pydantic import BaseModel, Field from datetime import datetime class SMSAttributes(BaseModel): amount_display: str amount_nanodollars: str message: str = Field(alias="body") direction: str from_number: str = Field(alias="from") is_mms: bool message_callback_url: str message_encoding: int message_type: str status: str timestamp: datetime to_number: str = Field(alias="to") class SMSData(BaseModel): attributes: SMSAttributes sms_type: str = Field(alias="type") sms_id: str = Field(alias="id") class SMSMessage(BaseModel): data: SMSData class Config: from_attributes = True arbitrary_types_allowed = True populate_by_name = True