Initial commit
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
"""
|
||||
Controller for Risk Acceptance Criteria check endpoints.
|
||||
"""
|
||||
from flask import Blueprint, request, jsonify
|
||||
from api.middleware import api_key_required
|
||||
from api.models import RACCheckRequest, RACCheckResponse, RACResponse
|
||||
import logging
|
||||
|
||||
# Configure logger
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Create blueprint
|
||||
rac_bp = Blueprint('rac', __name__)
|
||||
|
||||
@rac_bp.route('/RACCheck', methods=['POST'])
|
||||
@api_key_required
|
||||
def rac_check():
|
||||
"""
|
||||
Endpoint to check if a customer passes the Risk Acceptance Criteria.
|
||||
|
||||
This method evaluates a customer against the bank's risk criteria.
|
||||
|
||||
Returns:
|
||||
JSON response with RAC check results
|
||||
"""
|
||||
try:
|
||||
# Parse and validate request
|
||||
data = request.get_json()
|
||||
if not data:
|
||||
return jsonify({
|
||||
'resultCode': '400',
|
||||
'resultDescription': 'Invalid JSON payload'
|
||||
}), 400
|
||||
|
||||
# Validate required fields
|
||||
required_fields = ['transactionId', 'fbnTransactionId', 'customerId',
|
||||
'accountId', 'RAC_Array']
|
||||
for field in required_fields:
|
||||
if field not in data:
|
||||
return jsonify({
|
||||
'resultCode': '422',
|
||||
'resultDescription': f'Missing required field: {field}'
|
||||
}), 422
|
||||
|
||||
# Create request model
|
||||
req = RACCheckRequest.from_dict(data)
|
||||
|
||||
# Process RAC check (this would connect to the business logic)
|
||||
# For demonstration, we'll return a mock response with all checks passing
|
||||
|
||||
# Create RAC response object
|
||||
rac_response = RACResponse(
|
||||
SalaryAccount="1",
|
||||
BVN="1",
|
||||
BVNAttachedtoAccount="1",
|
||||
CRMS="1",
|
||||
CRC="1",
|
||||
AccountStatus="1",
|
||||
Lien="1",
|
||||
NoBounchedCheck="1",
|
||||
Whitelist="1",
|
||||
NoPastDueSalaryLoan="1",
|
||||
NoPastDueOtherLoan="1"
|
||||
)
|
||||
|
||||
# Create response
|
||||
response = RACCheckResponse(
|
||||
RACResponse=rac_response.to_dict(),
|
||||
resultCode="00",
|
||||
resultDescription="RAC Check Successful"
|
||||
)
|
||||
|
||||
logger.info(f"Processed RAC check for customer {req.customerId}")
|
||||
return jsonify(response.to_dict())
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error processing RAC check: {str(e)}")
|
||||
return jsonify({
|
||||
'resultCode': '500',
|
||||
'resultDescription': 'Internal server error'
|
||||
}), 500
|
||||
Reference in New Issue
Block a user