104 lines
3.6 KiB
Python
104 lines
3.6 KiB
Python
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, RACCheckResponseSchema
|
|
from datetime import datetime
|
|
from decimal import Decimal
|
|
|
|
class RACCheckService:
|
|
@staticmethod
|
|
def process_request(data):
|
|
"""
|
|
Process the RACCheck request.
|
|
|
|
Args:
|
|
data (dict): The request data.
|
|
|
|
Returns:
|
|
tuple: JSON response and status code.
|
|
"""
|
|
try:
|
|
logger.info("Processing RACCheck request")
|
|
|
|
# Validate input data
|
|
schema = RACCheckSchema()
|
|
validated_data = schema.load(data)
|
|
|
|
# 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
|
|
# }
|
|
|
|
rac_response = {
|
|
"procesS_DATE": datetime.strptime("2025-06-05", "%Y-%m-%d").date(),
|
|
"ciF_ID": "416405737",
|
|
"customeR_id": "7032744",
|
|
"salaccT_1": "4142904114",
|
|
"alerT_PHONE": "2348039301606",
|
|
"averagE_SALARY": 5000,
|
|
"loaN_OUSTANDING_BAL": 0,
|
|
"emi": 1000,
|
|
"eliG_AMT": 25000,
|
|
"rule1_45day_sal": True,
|
|
"rule2_2m_sal": True,
|
|
"rule3_no_bounced_check": True,
|
|
"rule4_current_loan_payments": True,
|
|
"rule5_no_past_due_fadv_loan": True,
|
|
"rule6_no_past_due_other_loan": True,
|
|
"rule7_consistent_salary_amount": True,
|
|
"rule8_whitelisted": True,
|
|
"rule9_regular_account": True,
|
|
"rule10_bvn_validation": True,
|
|
"rule11_CRC_no_delinquency": True,
|
|
"rule12_CRMS_no_delinquency": True,
|
|
"rule13_BVN_ignore": True,
|
|
"rule14_no_lien": True,
|
|
"rule15_null_ignore": True,
|
|
"overalL_ELIG": True,
|
|
"salarypaymenT_1": 180000,
|
|
"salarypaymenT_2": 50000,
|
|
"salarypaymenT_3": 70000,
|
|
"salarypaymenT_4": 0,
|
|
"salarypaymenT_5": 0,
|
|
"salarypaymenT_6": 0
|
|
}
|
|
|
|
|
|
full_response = {
|
|
"transactionId": validated_data["transactionId"],
|
|
"customerId": validated_data["customerId"],
|
|
"accountId": validated_data["accountId"],
|
|
"racResponse": rac_response
|
|
}
|
|
|
|
# response_schema = RACCheckResponseSchema()
|
|
result = {
|
|
"responseCode": "00",
|
|
"responseMessage": "Operation Successful",
|
|
"data": full_response
|
|
}
|
|
|
|
return jsonify(result), 200
|
|
|
|
except ValidationError as err:
|
|
logger.error(f"Validation Error: {err.messages}")
|
|
return jsonify({
|
|
"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
|