""" AUTHOR: Khushal P Soonderji DATE: Monday, 9th Dec., 2024. OBJECTIVE: To define how messages will be stored in the database. REFERENCES: N/A DOWNLOADS: N/A """ # ***************************************************************************************************************** # ***** **** # *** IMPORT *** # ***** **** # ***************************************************************************************************************** # To make sibling directories accessible for imports: import sys sys.path.append(".") sys.path.append("..") # For making data behaviour_models: from pydantic import BaseModel, Field, field_validator, PastDatetime, AwareDatetime from typing import Optional, Literal, Union, Any # My utils: from utils_v2.string import regex from utils_v2.date_time import date_time # To work with MongoDB: from bson.objectid import ObjectId # To work with date and time: import datetime # ***************************************************************************************************************** # ***** **** # *** MACROS / ONE-TIME INIT *** # ***** **** # ***************************************************************************************************************** # --- Nothing Yet # ***************************************************************************************************************** # ***** **** # *** VARIABLES *** # ***** **** # ***************************************************************************************************************** # --- Nothing Yet # ***************************************************************************************************************** # ***** **** # *** FUNCTIONS *** # ***** **** # ***************************************************************************************************************** class SentSMSMessageModel(BaseModel): ts: AwareDatetime = Field( description = "the time (utc) at which this message was sent by the sender", frozen = True, default_factory = lambda: date_time.get_current_utc_date_time(as_string = False) ) sender: dict = Field( description = "the sender of this message", frozen = True ) recipient: dict = Field( description = "the recipient of this message", frozen = True ) text: str = Field( description = "the actual text that was sent", frozen = True ) length: int = Field( description = "the no. of chars in this message", frozen = True ) isFlash: bool = Field( description = "to know whether this message is a flash message or a regular message", frozen = True ) success: bool = Field( description = "to know whether this message was sent successfully or not", default = False ) brief: str | None = Field( description = "a brief message about what happened; useful when something goes wrong", default = None ) metadata: dict | None = Field( description = "any extra data about this message", frozen = True ) rawResponse: Any | None = Field( description = "the raw response from the third-party client", default = None ) messageId: int | str | None = Field( description = "how the client recognizes this message", frozen = False, default = None ) # ┏┓ ┏• # ┃ ┏┓┏┓╋┓┏┓ # ┗┛┗┛┛┗┛┗┗┫ # ┛ class Config: extra = "allow" # ***************************************************************************************************************** # ***** **** # *** MAIN PROGRAM *** # ***** **** # ***************************************************************************************************************** if __name__ == "__main__": pass