made changes on the api to match bank api

This commit was merged in pull request #6.
This commit is contained in:
Chinenye Nmoh
2025-05-18 20:18:15 +01:00
parent 556d51f133
commit d0d51f35c0
26 changed files with 1085 additions and 776 deletions
+28 -29
View File
@@ -2,7 +2,7 @@ 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
from app.api.schemas.rac_check import RACCheckSchema, RACCheckResponseSchema
class RACCheckService:
@staticmethod
@@ -14,50 +14,49 @@ class RACCheckService:
data (dict): The request data.
Returns:
dict: A standardized response.
tuple: JSON response and status code.
"""
try:
logger.info("Processing RACCheck request")
# Validate input data using RACCheckSchema
# Validate input data
schema = RACCheckSchema()
validated_data = schema.load(data) # Raises ValidationError if invalid
validated_data = schema.load(data)
# 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"
# Simulated RAC check logic — create racResponse manually or via logic
rac_response = {
"hasSalaryAccount": True,
"bvnValidated": True,
"creditBureauCheck": False,
"crmsCheck": True,
"accountStatus": True,
"hasLien": False,
"noBouncedCheck": True,
"isWhitelisted": True,
"hasPastDueLoan": False
}
full_response = {
"transactionId": validated_data["transactionId"],
"customerId": validated_data["customerId"],
"accountId": validated_data["accountId"],
"racResponse": rac_response
}
# return ResponseHelper.success(
# data=response_data,
# message="RAC check completed successfully"
# )
response_schema = RACCheckResponseSchema()
result = response_schema.dump(full_response)
return response_data
return jsonify(result), 200
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return jsonify({
"message": "Validation exception"
}) , 422
"message": "Validation exception",
"errors": err.messages
}), 422
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return jsonify({
"message": "Internal Server Error"
}) , 500
}), 500