progress on jwt

This commit is contained in:
lennyaiko
2025-04-03 17:11:37 +01:00
parent f6a3938901
commit 87fe0fb5a0
2 changed files with 46 additions and 1 deletions
+2 -1
View File
@@ -116,4 +116,5 @@ def health_check():
def authorize():
data = request.get_json()
# logger.info(f"Authorize request received: {data}")
return jsonify(data)
response = NotificationCallbackService.process_request(data)
return response
+44
View File
@@ -0,0 +1,44 @@
from flask import request, jsonify
from marshmallow import ValidationError
from app.api.services.base_service import BaseService
from app.utils.logger import logger
from app.api.schemas.authorization import AuthorizeRequestSchema
from app.api.helpers.response_helper import ResponseHelper
class AuthorizationService(BaseService):
@staticmethod
def process_request(data):
"""
Process the Authorization request.
Args:
data (dict): The request data.
Returns:
dict: A standardized response.
"""
try:
logger.info("Processing Authorization request")
# Validate input data using the Authorization schema
schema = AuthorizeRequestSchema()
validated_data = schema.load(data) # Raises ValidationError if invalid
# Simulated processing logic
response_data = {"resultCode": "00", "resultDescription": "Successful"}
return ResponseHelper.success(
data=response_data, message="Authorization processed successfully"
)
except ValidationError as e:
logger.error(f"Validation error: {e}")
return ResponseHelper.bad_request(message=f"Validation error: {e}")
except Exception as e:
logger.error(f"Error processing Authorization request: {e}")
return ResponseHelper.internal_server_error(
message=f"Error processing Authorization request: {e}"
)