diff --git a/app/api/routes/routes.py b/app/api/routes/routes.py index 4396dbc..18b5f83 100644 --- a/app/api/routes/routes.py +++ b/app/api/routes/routes.py @@ -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 diff --git a/app/api/services/authorization.py b/app/api/services/authorization.py index e69de29..ad133f1 100644 --- a/app/api/services/authorization.py +++ b/app/api/services/authorization.py @@ -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}" + )