Major update

This commit is contained in:
Azeez Muibi
2025-03-27 08:21:20 +01:00
parent 1a36416094
commit ba4d878daf
24 changed files with 776 additions and 254 deletions
+34 -25
View File
@@ -1,8 +1,8 @@
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
@@ -24,40 +24,49 @@ class RACCheckService:
validated_data = schema.load(data) # Raises ValidationError if invalid
# Simulated processing logic
# In a real implementation, this would interact with your business logic
# to check the RAC criteria
# For demonstration, we'll simulate all checks passing
rac_response = {
"Salary account": "1",
"BVN": "1",
"BVNAttachedToAccount": "1",
"CRMS": "1",
"CRC": "1",
"AccountStatus": "1",
"Lien": "1",
"NoBouncedCheck": "1",
"Whitelist": "1",
"NoPastDueSalaryLoan": "1",
"NoPastDueOtherLoan": "1"
}
response_data = {
"transactionId": validated_data.get('transactionId'),
"customerId": validated_data.get('customerId'),
"accountId": validated_data.get('accountId'),
"RACResponse": rac_response,
"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"
}
# Validate the response using the response schema
response_schema = RACCheckResponseSchema()
validated_response = response_schema.dump(response_data)
# return ResponseHelper.success(
# data=response_data,
# message="RAC check completed successfully"
# )
return response_data
return jsonify(validated_response)
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return jsonify({
"message": "Validation exception"
}) , 422
"resultCode": "01",
"resultDescription": f"Validation error: {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
"resultCode": "08",
"resultDescription": f"Error occurred: {str(e)}"
}), 500