simulator

This commit is contained in:
Azeez Muibi
2025-05-06 10:55:52 +01:00
parent b6250230c9
commit a5ef85d331
8 changed files with 658 additions and 8 deletions
+13 -2
View File
@@ -11,7 +11,8 @@ from app.api.services import (
StatusCallService,
LoanStatusService,
SMSService,
BulkSMSService
BulkSMSService,
CompleteRACcheckService # Add the new service
)
from app.utils.logger import logger
from app.api.middlewares import require_api_key, require_app_id, enforce_json
@@ -49,6 +50,16 @@ def rac_check():
response = RACCheckService.process_request(data)
return response
# CompleteRACcheck Endpoint
@api.route('/CompleteRACcheck', methods=['POST'])
@require_api_key
@require_app_id
def complete_rac_check():
data = request.get_json()
# logger.info(f"CompleteRACcheck request received: {data}")
response = CompleteRACcheckService.process_request(data)
return response
# Disbursement Endpoint
@api.route('/Disbursement', methods=['POST'])
@require_api_key
@@ -152,4 +163,4 @@ def bulk_sms():
# Health Check Endpoint
@api.route('/health', methods=['GET'])
def health_check():
return {"status": "ok"}, 200
return {"status": "ok"}, 200
+17
View File
@@ -0,0 +1,17 @@
from marshmallow import Schema, fields, validate
# CompleteRACcheck Request Schema
class CompleteRACcheckSchema(Schema):
transactionId = fields.Str(required=True, description="Unique identifier of transaction. This transaction Id must be consistent across all platforms")
customerId = fields.Str(required=True, description="Unique identifier of a user")
accountId = fields.Str(required=True, description="Specific identifier of a user's account")
RAC_Array = fields.Dict(required=True, description="Risk Acceptance Criteria array")
# CompleteRACcheck Response Schema
class CompleteRACcheckResponseSchema(Schema):
transactionId = fields.Str(required=True, description="Unique identifier of transaction in Simbrella system")
customerId = fields.Str(required=True, description="Unique identifier of a user")
accountId = fields.Str(required=True, description="Specific identifier of a user's account")
CompleteRACCheckResponse = fields.Dict(required=True, description="Complete RAC check response details")
resultCode = fields.Str(required=True, description="Result code of executed transaction, e.g. (00 Success etc.) see result codes table")
resultDescription = fields.Str(required=True, description="Description of provided result code")
+2 -1
View File
@@ -10,4 +10,5 @@ from app.api.services.penal_charge import PenalChargeService
from app.api.services.lien_check import LienCheckService
from app.api.services.status_call import StatusCallService
from app.api.services.sms import SMSService
from app.api.services.bulk_sms import BulkSMSService
from app.api.services.bulk_sms import BulkSMSService
from app.api.services.complete_rac_check_service import CompleteRACcheckService
@@ -0,0 +1,107 @@
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:
logger.info("Processing CompleteRACcheck request")
# 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
+18 -5
View File
@@ -15,9 +15,6 @@
},
"servers": [
{
<<<<<<< HEAD
"url": "https://devcore.digifi.chiefsoft.net/v1/api/salary"
=======
"url": "http://localhost:6337"
},
{
@@ -25,7 +22,6 @@
},
{
"url": "https://bank-emulator.dev.simbrellang.net"
>>>>>>> 6f24d16b73f50f441b55c26e0bf3b6f9a5449bc7
}
],
"tags": [
@@ -77,6 +73,14 @@
"url": "https://www.simbrellang.net"
}
},
{
"name": "CompleteRACcheck",
"description": "Complete Risk Acceptance Criteria Request",
"externalDocs": {
"description": "Find out more",
"url": "https://www.simbrellang.net"
}
},
{
"name": "Disbursement",
"description": "Loan Disbursement Request",
@@ -161,6 +165,9 @@
"/RACCheck": {
"$ref": "./paths/RACCheck.json"
},
"/CompleteRACcheck": {
"$ref": "./paths/CompleteRACcheck.json"
},
"/Disbursement": {
"$ref": "./paths/Disbursement.json"
},
@@ -218,6 +225,12 @@
"RACCheckResponse": {
"$ref": "./schemas/RACCheckResponse.json"
},
"CompleteRACcheckRequest": {
"$ref": "./schemas/CompleteRACcheckRequest.json"
},
"CompleteRACcheckResponse": {
"$ref": "./schemas/CompleteRACcheckResponse.json"
},
"DisbursementRequest": {
"$ref": "./schemas/DisbursementRequest.json"
},
@@ -295,4 +308,4 @@
}
}
}
}
}
+60
View File
@@ -0,0 +1,60 @@
{
"post": {
"tags": ["CompleteRACcheck"],
"summary": "Complete Risk Acceptance Criteria check",
"description": "This request is used to check if a customer passes the Complete Bank Risk Acceptance Criteria",
"operationId": "completeRACcheck",
"requestBody": {
"description": "Complete RAC check request details",
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/CompleteRACcheckRequest.json"
}
},
"application/xml": {
"schema": {
"$ref": "../schemas/CompleteRACcheckRequest.json"
}
},
"application/x-www-form-urlencoded": {
"schema": {
"$ref": "../schemas/CompleteRACcheckRequest.json"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Complete RAC Check Successful",
"content": {
"application/json": {
"schema": {
"$ref": "../schemas/CompleteRACcheckResponse.json"
}
},
"application/xml": {
"schema": {
"$ref": "../schemas/CompleteRACcheckResponse.json"
}
}
}
},
"400": {
"description": "Invalid request parameters"
},
"401": {
"description": "Authentication failed"
},
"500": {
"description": "Internal server error"
}
},
"security": [
{
"basic_auth": []
}
]
}
}
@@ -0,0 +1,109 @@
{
"type": "object",
"required": ["transactionId", "customerId", "accountId", "RAC_Array"],
"properties": {
"transactionId": {
"type": "string",
"description": "Unique identifier of transaction. This transaction Id must be consistent across all platforms",
"example": "T001"
},
"fbnTransactionId": {
"type": "string",
"description": "FirstBank transaction ID",
"example": "Tr201712RK9232P115"
},
"customerId": {
"type": "string",
"description": "Unique identifier of a user",
"example": "CN621868"
},
"accountId": {
"type": "string",
"description": "Specific identifier of a user's account",
"example": "2017821799"
},
"RAC_Array": {
"type": "object",
"description": "Risk Acceptance Criteria array",
"properties": {
"Salary account": {
"type": "string",
"description": "Has Salary account or Not",
"example": "1"
},
"BVN": {
"type": "string",
"description": "BVN Ok",
"example": "1"
},
"BVN attached to account": {
"type": "string",
"description": "BVN attached to account",
"example": "1"
},
"CRC": {
"type": "string",
"description": "No Delinquent loan",
"example": "1"
},
"CRMS": {
"type": "string",
"description": "No Delinquent loan",
"example": "1"
},
"Account status": {
"type": "string",
"description": "Has 'Regular' account status",
"example": "1"
},
"Lien": {
"type": "string",
"description": "No Lien on account",
"example": "1"
},
"No bounced check": {
"type": "string",
"description": "No Bounced (Ever?)",
"example": "1"
},
"Whitelist": {
"type": "string",
"description": "False if blacklisted",
"example": "1"
},
"No Past Due Salary Loan": {
"type": "string",
"description": "No Past Due Salary Loan",
"example": "1"
},
"No Past Due Other Loans": {
"type": "string",
"description": "No Past Due Other Loans",
"example": "1"
}
}
}
},
"example": {
"transactionId": "T001",
"fbnTransactionId": "Tr201712RK9232P115",
"customerId": "CN621868",
"accountId": "2017821799",
"RAC_Array": {
"Salary account": "1",
"BVN": "1",
"BVN attached to account": "1",
"CRC": "1",
"CRMS": "1",
"Account status": "1",
"Lien": "1",
"No bounced check": "1",
"Whitelist": "1",
"No Past Due Salary Loan": "1",
"No Past Due Other Loans": "1"
}
},
"xml": {
"name": "CompleteRACcheckRequest"
}
}
@@ -0,0 +1,332 @@
{
"type": "object",
"required": [
"transactionId",
"customerId",
"accountId",
"CompleteRACCheckResponse",
"resultCode",
"resultDescription"
],
"properties": {
"transactionId": {
"type": "string",
"description": "Unique identifier of transaction in Simbrella system",
"example": "T001"
},
"customerId": {
"type": "string",
"description": "Unique identifier of a user",
"example": "CN621868"
},
"accountId": {
"type": "string",
"description": "Specific identifier of a user's account",
"example": "2017821799"
},
"CompleteRACCheckResponse": {
"type": "object",
"description": "Complete RAC check response details",
"properties": {
"PROCESS_DATE": {
"type": "string",
"description": "RAC process Date",
"example": "2025-05-06"
},
"CIF_ID": {
"type": "string",
"description": "Customer Information File ID",
"example": "123456789"
},
"CUST_FIRST_NAME": {
"type": "string",
"description": "Customer's First Name",
"example": "Ade"
},
"CUST_MIDDLE_NAME": {
"type": "string",
"description": "Customer's Middlename",
"example": "Isaac"
},
"CUST_LAST_NAME": {
"type": "string",
"description": "Customer's Last name",
"example": "Juwon"
},
"BVN": {
"type": "string",
"description": "Bank Verification Number",
"example": "44834386619"
},
"GENDER": {
"type": "string",
"description": "Customers gender (M/F)",
"example": "MALE"
},
"AGE": {
"type": "string",
"description": "Customer's Age",
"example": "31"
},
"CRM_EMAIL": {
"type": "string",
"description": "Customer's Email address",
"example": "test@test.com"
},
"ALERT_EMAIL": {
"type": "string",
"description": "Alert Email Address",
"example": ""
},
"CRM_PHONE": {
"type": "string",
"description": "Customer's Phone Number",
"example": "2.34804E+12"
},
"ALERT_PHONE": {
"type": "string",
"description": "Alert Phone number",
"example": ""
},
"CRM_ADDRESS": {
"type": "string",
"description": "Customer's Address",
"example": ""
},
"OCCUPATION": {
"type": "string",
"description": "Customer's Occupation",
"example": "Analyst"
},
"AVERAGE_SALARY": {
"type": "string",
"description": "Customer's Avg Salary",
"example": "1,000,000.00"
},
"STAFF_STAT": {
"type": "string",
"description": "Staff Status",
"example": "N"
},
"SALACCT_1": {
"type": "string",
"description": "Salary account 1",
"example": "253844780"
},
"SALACCT_2": {
"type": "string",
"description": "Salary account 2",
"example": ""
},
"SALACCT_3": {
"type": "string",
"description": "Salary account 3",
"example": ""
},
"LOAN_OUSTANDING_BAL": {
"type": "string",
"description": "Outstanding Balance",
"example": "0"
},
"EMI": {
"type": "string",
"description": "Equated Monthly Installment",
"example": "0"
},
"ELIG_AMT": {
"type": "string",
"description": "Eligible Amount",
"example": "500,000"
},
"RULE1": {
"type": "string",
"description": "Rule 1",
"example": "Y"
},
"RULE2": {
"type": "string",
"description": "Rule 2",
"example": "Y"
},
"RULE3": {
"type": "string",
"description": "Rule 3",
"example": "Y"
},
"RULE4": {
"type": "string",
"description": "Rule 4",
"example": "Y"
},
"RULE5": {
"type": "string",
"description": "Rule 5",
"example": "Y"
},
"RULE6": {
"type": "string",
"description": "Rule 6",
"example": "Y"
},
"RULE7": {
"type": "string",
"description": "Rule 7",
"example": "Y"
},
"RULE8": {
"type": "string",
"description": "Rule 8",
"example": "Y"
},
"RULE9": {
"type": "string",
"description": "Rule 9",
"example": "Y"
},
"RULE10": {
"type": "string",
"description": "Rule 10",
"example": "Y"
},
"RULE11": {
"type": "string",
"description": "Rule 11",
"example": "Y"
},
"RULE12": {
"type": "string",
"description": "Rule 12",
"example": "Y"
},
"RULE13": {
"type": "string",
"description": "Rule 13",
"example": "Y"
},
"RULE14": {
"type": "string",
"description": "Rule 14",
"example": "Y"
},
"RULE15": {
"type": "string",
"description": "Rule 15",
"example": "Y"
},
"OVERALL_ELIG": {
"type": "string",
"description": "Overall Eligible Amount",
"example": "Y"
},
"SALARYPAYMENT_1": {
"type": "string",
"description": "Salary Payment 1",
"example": "1000000"
},
"SALARYPAYMENT_2": {
"type": "string",
"description": "Salary Payment 2",
"example": "1000000"
},
"SALARYPAYMENT_3": {
"type": "string",
"description": "Salary Payment 3",
"example": "1000000"
},
"SALARYPAYMENT_4": {
"type": "string",
"description": "Salary Payment 4",
"example": "0"
},
"SALARYPAYMENT_5": {
"type": "string",
"description": "Salary Payment 5",
"example": "0"
},
"SALARYPAYMENT_6": {
"type": "string",
"description": "Salary Payment 6",
"example": "0"
},
"OTHERACCT_SAVINGS": {
"type": "string",
"description": "Other customer's account_Saving",
"example": ""
},
"OTHERACCT_CURRENT": {
"type": "string",
"description": "Other Customer's account_Current",
"example": ""
}
}
},
"resultCode": {
"type": "string",
"description": "Result code of executed transaction, e.g. (00 Success etc.) see result codes table",
"example": "00"
},
"resultDescription": {
"type": "string",
"description": "Description of provided result code",
"example": "RAC Check Successful"
}
},
"example": {
"transactionId": "T001",
"customerId": "CN621868",
"accountId": "2017821799",
"CompleteRACCheckResponse": {
"PROCESS_DATE": "2025-05-06",
"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"
},
"xml": {
"name": "CompleteRACcheckResponse"
}
}