(20241213) SMS sending ready.
This commit is contained in:
@@ -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
@@ -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
|
||||
)
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -92,7 +92,7 @@ from api.blueprints.mail.retrieve.list import mail_list_bp
|
||||
from api.blueprints.mail.retrieve.get import mail_get_bp
|
||||
from api.blueprints.mail.tags.update import mail_tags_update_bp
|
||||
from api.blueprints.sms.auth import sms_auth_bp
|
||||
# from api.blueprints.sms.send import sms_send_bp
|
||||
from api.blueprints.sms.send import sms_send_bp
|
||||
# from api.blueprints.chat.auth import chat_auth_bp
|
||||
# from api.blueprints.chat.webhook import chat_webhook_bp
|
||||
from api.blueprints.software.auth import sw_auth_bp
|
||||
@@ -133,7 +133,7 @@ app.register_blueprint(mail_list_bp, url_prefix = f"/{MODULE_BASE}/mail")
|
||||
app.register_blueprint(mail_get_bp, url_prefix = f"/{MODULE_BASE}/mail")
|
||||
app.register_blueprint(mail_tags_update_bp, url_prefix = f"/{MODULE_BASE}/mail")
|
||||
app.register_blueprint(sms_auth_bp, url_prefix = f"/{MODULE_BASE}/sms")
|
||||
# app.register_blueprint(sms_send_bp, url_prefix = f"/{MODULE_BASE}/sms")
|
||||
app.register_blueprint(sms_send_bp, url_prefix = f"/{MODULE_BASE}/sms")
|
||||
# app.register_blueprint(chat_auth_bp, url_prefix = f"/{MODULE_BASE}/chat")
|
||||
# app.register_blueprint(chat_webhook_bp, url_prefix = f"/{MODULE_BASE}/chat")
|
||||
app.register_blueprint(sw_auth_bp, url_prefix = f"/{MODULE_BASE}/software")
|
||||
|
||||
Reference in New Issue
Block a user