(20250121) With APIs to send, list, and update tags on WhatsApp messages (through Nimbus).

This commit is contained in:
2025-01-21 15:27:53 +05:30
parent f94d9e1a4b
commit cadbc19f28
13 changed files with 498 additions and 182 deletions
+8 -8
View File
@@ -6,11 +6,11 @@
DATE:
Tuesday, 3rd Dec., 2024.
Tuesday, 21st Jan., 2025.
OBJECTIVE:
To provide a structure to query the full payload of an email.
To provide a structure to query the full payload of chat message(s).
REFERENCES:
@@ -75,10 +75,10 @@ REGEX_SESSION_TOKEN = r"^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]
# *****************************************************************************************************************
class SMSListRequestHeaders(BaseModel):
class ChatMessageListRequestHeaders(BaseModel):
sessionToken: str = Field(
description = "the session token of the user who is requesting the service",
description = "The session token of the user who is requesting the service.",
pattern = REGEX_SESSION_TOKEN,
frozen = True,
alias = "X-Session-Token"
@@ -99,10 +99,10 @@ class SMSListRequestHeaders(BaseModel):
# ---------------------------------------------------------------------------------------------------------------------
class SMSListRequestData(BaseModel):
class ChatMessageListRequestData(BaseModel):
tokenKeys: str | List[str] = Field(
description = "the token identifier(s) that tell you which auth-tokens were used for fetching those messages",
description = "The token identifier(s) that tell you which auth-tokens were used for fetching those messages.",
frozen = True,
)
@@ -115,14 +115,14 @@ class SMSListRequestData(BaseModel):
)
fromCount: int = Field(
description = "the no. of mails to skip before picking mails to list; useful for pagination",
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",
description = "Any no. of tags that you want to filter by.",
default = None
)
+9 -10
View File
@@ -6,11 +6,11 @@
DATE:
Monday, 9th Dec., 2024.
Tuesday, 21st Jan., 2025.
OBJECTIVE:
To provide a structure to receive API calls to send SMS messages from various third-party clients.
To provide a structure to receive API calls to send chat messages from various third-party clients.
REFERENCES:
@@ -46,11 +46,10 @@ from utils_v2.date_time import date_time
# Models:
from models.core.message import CoreMessageModel
from utils_v2.sms.models.sms_message import SentSMSMessageModel
from models.message.sms.send import (
NimbusSMSIndiaMessage,
SavvyBulkSMSKenyaMessage,
SMSSendOneResult,
SMSSendManyResults
from models.message.chat.send import (
NimbusWhatsAppMessage,
ChatSendOneResult,
ChatSendManyResults
)
# To work with date and time:
@@ -88,7 +87,7 @@ REGEX_SESSION_TOKEN = r"^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]
# *****************************************************************************************************************
class SMSSendRequestHeaders(BaseModel):
class ChatSendRequestHeaders(BaseModel):
sessionToken: str | None = Field(
description = "the session token of the user who is requesting the service",
@@ -113,10 +112,10 @@ class SMSSendRequestHeaders(BaseModel):
# ---------------------------------------------------------------------------------------------------------------------
class SMSSendRequestData(BaseModel):
class ChatSendRequestData(BaseModel):
tokenKey: ObjectId
message: List[NimbusSMSIndiaMessage] | List[SavvyBulkSMSKenyaMessage]
message: List[NimbusWhatsAppMessage]
tags: List[Any] | None = Field(default = None, validate_default = True)
# ┏┓ ┏•
+8 -8
View File
@@ -6,11 +6,11 @@
DATE:
Thursday, 19th Dec., 2024.
Tuesday, 21st Jan., 2025.
OBJECTIVE:
To provide a structure to work with the tags on SMS messages.
To provide a structure to work with the tags on chat messages.
REFERENCES:
@@ -75,10 +75,10 @@ REGEX_SESSION_TOKEN = r"^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]
# *****************************************************************************************************************
class SMSUpdateTagsRequestHeaders(BaseModel):
class ChatMessageUpdateTagsRequestHeaders(BaseModel):
sessionToken: str = Field(
description = "the session token of the user who is requesting the service",
description = "The session token of the user who is requesting the service.",
pattern = REGEX_SESSION_TOKEN,
frozen = True,
alias = "X-Session-Token"
@@ -99,21 +99,21 @@ class SMSUpdateTagsRequestHeaders(BaseModel):
# ---------------------------------------------------------------------------------------------------------------------
class SMSUpdateTagsRequestData(BaseModel):
class ChatMessageUpdateTagsRequestData(BaseModel):
messageId: str = Field(
description = "the mail identifier (Mongo ObjectId) of the document that holds the mail",
description = "The message identifier (Mongo ObjectId) of the document that holds the chat message.",
frozen = True
)
unsetTags: List[Any] | None = Field(
description = "the list of tags to remove from the mail",
description = "The list of tags to remove from the message.",
frozen = True,
default = None
)
setTags: List[Any] | None = Field(
description = "the list of tags to add to the mail",
description = "The list of tags to add to the message.",
frozen = True,
default = None
)