148 lines
5.2 KiB
Python
148 lines
5.2 KiB
Python
"""
|
|
|
|
AUTHOR:
|
|
|
|
Khushal P Soonderji
|
|
|
|
DATE:
|
|
|
|
Tuesday, 3rd Dec., 2024.
|
|
|
|
OBJECTIVE:
|
|
|
|
To provide a structure to query the full payload of an email.
|
|
|
|
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
|
|
from typing import Optional, Literal, List, Any
|
|
|
|
# My utils:
|
|
from utils_v2.string import regex
|
|
from utils_v2.date_time import date_time
|
|
|
|
# To work with date and time:
|
|
import datetime
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** MACROS / ONE-TIME INIT ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# RegEx Patterns:
|
|
REGEX_SESSION_TOKEN = r"^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$"
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** VARIABLES ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# --- Nothing Yet
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** FUNCTIONS ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
class MailListRequestHeaders(BaseModel):
|
|
|
|
sessionToken: str = Field(
|
|
description = "the session token of the user who is requesting the service",
|
|
pattern = REGEX_SESSION_TOKEN,
|
|
frozen = True,
|
|
alias = "X-Session-Token"
|
|
)
|
|
|
|
# ┏┓ ┏•
|
|
# ┃ ┏┓┏┓╋┓┏┓
|
|
# ┗┛┗┛┛┗┛┗┗┫
|
|
# ┛
|
|
|
|
class Config:
|
|
extra = "allow"
|
|
|
|
def model_dump(self, *args, **kwargs):
|
|
return super().model_dump(*args, by_alias = True, **kwargs)
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
class MailListRequestData(BaseModel):
|
|
|
|
tokenIds: str | List[str] = Field(
|
|
description = "the token identifier(s) that tell you which auth-tokens were used for fetching those messages",
|
|
frozen = True
|
|
)
|
|
|
|
count: int = Field(
|
|
description = "the no. of mails to list",
|
|
default = 25,
|
|
ge = 1,
|
|
le = 500,
|
|
frozen = True
|
|
)
|
|
|
|
fromCount: int = Field(
|
|
description = "the no. of mails to skip before picking mails to list; useful for pagination",
|
|
ge = 0,
|
|
default = 0,
|
|
frozen = True
|
|
)
|
|
|
|
tags: List[Any] | None = Field(
|
|
description = "any no. of tags that you want to filter by",
|
|
default = None
|
|
)
|
|
|
|
# ┏┓ ┏•
|
|
# ┃ ┏┓┏┓╋┓┏┓
|
|
# ┗┛┗┛┛┗┛┗┗┫
|
|
# ┛
|
|
|
|
class Config:
|
|
extra = "forbid"
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** MAIN PROGRAM ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
pass
|