from flask import request, jsonify from marshmallow import ValidationError from app.utils.logger import logger from app.api.helpers.response_helper import ResponseHelper from app.api.schemas.rac_check import RACCheckSchema class RACCheckService: @staticmethod def process_request(data): """ Process the RACCheck request. Args: data (dict): The request data. Returns: dict: A standardized response. """ try: logger.info("Processing RACCheck request") # Validate input data using RACCheckSchema schema = RACCheckSchema() validated_data = schema.load(data) # Raises ValidationError if invalid # Simulated processing logic response_data = { "resultCode": "00", "RACResponse": { "SalaryAccount": "1", "BVN": "1", "BVNAttachedToAccount": "1", "CRMS": "1", "CRC": "1", "AccountStatus": "1", "Lien": "1", "NoBouncedCheck": "1", "Whitelist": "1", "NoPastDueSalaryLoan": "1", "NoPastDueOtherLoan": "1" }, "resultDescription": "RAC Check Successful" } # return ResponseHelper.success( # data=response_data, # message="RAC check completed successfully" # ) return response_data except ValidationError as err: logger.error(f"Validation Error: {err.messages}") return jsonify({ "message": "Validation exception" }) , 422 except Exception as e: logger.error(f"An error occurred: {str(e)}", exc_info=True) return jsonify({ "message": "Internal Server Error" }) , 500