(20250115) Can accept WhatsApp (Nimbus) integrations now.

This commit is contained in:
2025-01-15 16:29:48 +05:30
parent 77b7ad08dd
commit efd7dda9f0
9 changed files with 571 additions and 27 deletions
+36 -4
View File
@@ -95,6 +95,32 @@ class TelegramAuth(BaseModel):
# ---------------------------------------------------------------------------------------------------------------------
class WhatsAppNimbusAuth(BaseModel):
apiKey: str = Field(
description = "???",
min_length = 1,
frozen = True
)
senderId: str = Field(
description = "???",
min_length = 1,
frozen = True
)
# ┏┓ ┏•
# ┃ ┏┓┏┓╋┓┏┓
# ┗┛┗┛┛┗┛┗┗┫
# ┛
class Config:
extra = "forbid"
# ---------------------------------------------------------------------------------------------------------------------
class ChatAuthRequestHeaders(BaseModel):
sessionToken: str = Field(
@@ -121,8 +147,12 @@ class ChatAuthRequestHeaders(BaseModel):
class ChatAuthRequestData(BaseModel):
chatClient: Literal["telegram", "whatsapp"] = Field(alias = "client")
auth: Union[TelegramAuth]
chatClient: Literal[
"telegram", # ........ Official Telegram API.
"whatsapp", # ........ Official WhatsApp API.
"whatsappNimbus" # ... Nimbus IT's unofficial WhatsApp API.
] = Field(alias = "client")
auth: Union[TelegramAuth, WhatsAppNimbusAuth]
# ┏┓ ┏•
# ┃ ┏┓┏┓╋┓┏┓
@@ -138,10 +168,12 @@ class ChatAuthRequestData(BaseModel):
@model_validator(mode = "after")
def ensure_harmony(cls, values):
client = values.client
client = values.chatClient
auth = values.auth
harmony_map = {
"telegram": TelegramAuth
"telegram": TelegramAuth,
# "whatsapp": None,
"whatsappNimbus": WhatsAppNimbusAuth
}
if not isinstance(auth, harmony_map[client]):
raise ValueError(f"incorrect 'auth' for selected client '{client}'")
+1 -1
View File
@@ -106,7 +106,7 @@ class CoreAuthTokenModel(BaseModel):
client: Literal[
"gmail", "outlook", # ............................. Mail Clients
"telegram", "whatsapp", # ......................... Chat Clients
"telegram", "whatsapp", "whatsappNimbus", # ....... Chat Clients
"nimbusSmsIndia", "savvyBulkSmsKenya", # .......... SMS Clients
"razorpay", "safaricomMPesaExpress", # ............ Payment Gateways
"zerodhaKite", "iciciBreeze", "paperTrading", # ... Stock Brokers
+3 -3
View File
@@ -112,9 +112,9 @@ class CoreMessageModel(BaseModel):
)
client: Literal[
"gmail", "outlook", # ...................... Mail Clients
"telegram", "whatsapp", # .................. Chat Clients
"nimbusSmsIndia", "savvyBulkSmsKenya", # ... SMS Clients
"gmail", "outlook", # ........................................ Mail Clients
"telegram", "whatsapp", "whatsappNimbus", # .................. Chat Clients
"nimbusSmsIndia", "savvyBulkSmsKenya", # ..................... SMS Clients
] = Field(
description = "the third-part client that was used",
frozen = True