(20241213) SMS sending ready.

This commit is contained in:
2024-12-13 19:44:22 +05:30
parent f47e81c411
commit 8c01ca5135
6 changed files with 104 additions and 36 deletions
+4 -4
View File
@@ -10,7 +10,7 @@
OBJECTIVE:
To receive auth details for various software.
To receive auth details for various financial institutions.
REFERENCES:
@@ -81,7 +81,7 @@ import asyncio
# Related to Quart:
sw_auth_bp = Blueprint("sw_auth", __name__)
fi_auth_bp = Blueprint("fi_auth", __name__)
# *****************************************************************************************************************
@@ -101,7 +101,7 @@ sw_auth_bp = Blueprint("sw_auth", __name__)
# *****************************************************************************************************************
@sw_auth_bp.record_once
@fi_auth_bp.record_once
def init(blueprint_setup_state):
# This gets called when the blueprint is registered.
@@ -112,7 +112,7 @@ def init(blueprint_setup_state):
# ---------------------------------------------------------------------------------------------------------------------
@sw_auth_bp.route("/auth", methods = ["POST"])
@fi_auth_bp.route("/auth", methods = ["POST"])
@set_api_version(api_version = "1.0.0")
@read_input(sanitize_headers = False, sanitize_data = False)
@get_session_info(key = "X-Session-Token", session_coro = "get_session")
+15 -23
View File
@@ -157,30 +157,16 @@ async def send_sms(
http_code = HttpCodes.UNAUTHORIZED
)
# Fetch the auth-token to use to send this message:
auth_token = await current_app.sms_auth_model.get(
mongo_conn = current_app.data_mongo,
token_id = inbound_data.tokenId
)
# If no auth-token was found, we return with failure:
if not auth_token: return ResponseModel(
status_code = StatusCodes.FAILED,
http_code = HttpCodes.BAD_REQUEST,
message = f"no such token id"
)
# ┏┓ ┓ ┏┳┓┓ ┏┓┳┳┓┏┓
# ┗┓┏┓┏┓┏┫ ┃ ┣┓┏┓ ┗┓┃┃┃┗┓
# ┗┛┗ ┛┗┗┻ ┻ ┛┗┗ ┗┛┛ ┗┗┛
# client_response = await current_app.sms_send_model.send_sms(
# mongo_conn = current_app.data_mongo,
# token_id = inbound_data.tokenId,
# auth_token = auth_token,
# inbound_data = inbound_data,
# session_token = inbound_headers["X-Session-Token"]
# )
client_response = await current_app.sms_controller.send(
mongo_conn = current_app.data_mongo,
http_client = current_app.http_client,
token_id = inbound_data.tokenId,
messages = inbound_data.message
)
# ┳┓
# ┣┫┏┓┏┏┓┏┓┏┓┏┏┓
@@ -188,10 +174,16 @@ async def send_sms(
# ┛
# Done here:
success = True if client_response.successCount else False
return ResponseModel(
status_code = StatusCodes.OK if client_response.success else StatusCodes.FAILED,
http_code = HttpCodes.SUCCESS if client_response.success else HttpCodes.INTERNAL_SERVER_ERROR,
message = None if client_response.success else f"SMS Client: {client_response.brief}"
status_code = StatusCodes.OK if success else StatusCodes.FAILED,
http_code = HttpCodes.SUCCESS if success else HttpCodes.INTERNAL_SERVER_ERROR,
data = {
"successCount": client_response.successCount,
"failureCount": client_response.failureCount,
"totalCount": client_response.totalCount,
},
message = client_response.message
)