106 lines
4.0 KiB
Python
106 lines
4.0 KiB
Python
from flask import request, jsonify
|
|
from marshmallow import ValidationError
|
|
from app.utils.logger import logger
|
|
from app.api.schemas.complete_rac_check import CompleteRACcheckSchema, CompleteRACcheckResponseSchema
|
|
from datetime import datetime
|
|
|
|
class CompleteRACcheckService:
|
|
@staticmethod
|
|
def process_request(data):
|
|
"""
|
|
Process the CompleteRACcheck request.
|
|
|
|
Args:
|
|
data (dict): The request data.
|
|
|
|
Returns:
|
|
dict: A standardized response.
|
|
"""
|
|
try:
|
|
# Validate input data using CompleteRACcheckSchema
|
|
schema = CompleteRACcheckSchema()
|
|
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 complete RAC criteria
|
|
|
|
# For demonstration, we'll simulate a successful RAC check with sample data
|
|
current_date = datetime.now().strftime("%Y-%m-%d")
|
|
|
|
response_data = {
|
|
"transactionId": validated_data.get('transactionId'),
|
|
"customerId": validated_data.get('customerId'),
|
|
"accountId": validated_data.get('accountId'),
|
|
"CompleteRACCheckResponse": {
|
|
"PROCESS_DATE": current_date,
|
|
"CIF_ID": "123456789",
|
|
"CUST_FIRST_NAME": "Ade",
|
|
"CUST_MIDDLE_NAME": "Isaac",
|
|
"CUST_LAST_NAME": "Juwon",
|
|
"BVN": "44834386619",
|
|
"GENDER": "MALE",
|
|
"AGE": "31",
|
|
"CRM_EMAIL": "test@test.com",
|
|
"ALERT_EMAIL": "",
|
|
"CRM_PHONE": "2.34804E+12",
|
|
"ALERT_PHONE": "",
|
|
"CRM_ADDRESS": "",
|
|
"OCCUPATION": "Analyst",
|
|
"AVERAGE_SALARY": "1,000,000.00",
|
|
"STAFF_STAT": "N",
|
|
"SALACCT_1": "253844780",
|
|
"SALACCT_2": "",
|
|
"SALACCT_3": "",
|
|
"LOAN_OUSTANDING_BAL": "0",
|
|
"EMI": "0",
|
|
"ELIG_AMT": "500,000",
|
|
"RULE1": "Y",
|
|
"RULE2": "Y",
|
|
"RULE3": "Y",
|
|
"RULE4": "Y",
|
|
"RULE5": "Y",
|
|
"RULE6": "Y",
|
|
"RULE7": "Y",
|
|
"RULE8": "Y",
|
|
"RULE9": "Y",
|
|
"RULE10": "Y",
|
|
"RULE11": "Y",
|
|
"RULE12": "Y",
|
|
"RULE13": "Y",
|
|
"RULE14": "Y",
|
|
"RULE15": "Y",
|
|
"OVERALL_ELIG": "Y",
|
|
"SALARYPAYMENT_1": "1000000",
|
|
"SALARYPAYMENT_2": "1000000",
|
|
"SALARYPAYMENT_3": "1000000",
|
|
"SALARYPAYMENT_4": "0",
|
|
"SALARYPAYMENT_5": "0",
|
|
"SALARYPAYMENT_6": "0",
|
|
"OTHERACCT_SAVINGS": "",
|
|
"OTHERACCT_CURRENT": ""
|
|
},
|
|
"resultCode": "00",
|
|
"resultDescription": "RAC Check Successful"
|
|
}
|
|
|
|
# Validate the response using the response schema
|
|
response_schema = CompleteRACcheckResponseSchema()
|
|
validated_response = response_schema.dump(response_data)
|
|
|
|
return jsonify(validated_response)
|
|
|
|
except ValidationError as err:
|
|
logger.error(f"Validation Error: {err.messages}")
|
|
return jsonify({
|
|
"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({
|
|
"resultCode": "08",
|
|
"resultDescription": f"Error occurred: {str(e)}"
|
|
}), 500
|