[add]: Bank to simbrella calls

This commit is contained in:
VivianDee
2025-03-25 06:39:27 +01:00
parent 0bb36be246
commit f4c2e25025
79 changed files with 1428 additions and 938 deletions
+7
View File
@@ -0,0 +1,7 @@
from app.api.services.eligibility_check import EligibilityCheckService
from app.api.services.select_offer import SelectOfferService
from app.api.services.provide_loan import ProvideLoanService
from app.api.services.loan_information import LoanInformationService
from app.api.services.repayment import RepaymentService
from app.api.services.customer_consent import CustomerConsentService
from app.api.services.notification_callback import NotificationCallbackService
+50
View File
@@ -0,0 +1,50 @@
from flask import request, jsonify
from marshmallow import ValidationError
from app.utils.logger import logger
from app.api.schemas.customer_consent import CustomerConsentSchema
class CustomerConsentService:
@staticmethod
def process_request(data):
"""
Process the CustomerConsent request.
Args:
data (dict): The request data.
Returns:
dict: A standardized response.
"""
try:
logger.info("Processing CustomerConsent request")
# Validate input data using the CustomerConsent schema
schema = CustomerConsentSchema()
validated_data = schema.load(data) # Raises ValidationError if invalid
# Simulated processing logic
response_data = {
"resultCode": "00",
"resultDescription": "Request is received"
}
# return ResponseHelper.success(
# data=response_data,
# message="Customer consent processed successfully"
# )
return response_data
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return jsonify({
"message": "Validation exception"
}) , 422
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return jsonify({
"message": "Internal Server Error"
}) , 500
+68
View File
@@ -0,0 +1,68 @@
from flask import session, jsonify
from app.utils.logger import logger
from app.api.schemas.eligibility_check import EligibilityCheckSchema
from marshmallow import ValidationError
class EligibilityCheckService:
@staticmethod
def process_request(data):
"""
Process the EligibilityCheck request.
Args:
data (dict): The request data.
Returns:
dict: A standardized response.
"""
try:
logger.info("Processing EligibilityCheck request")
# Validate input data using Schema
schema = EligibilityCheckSchema()
validated_data = schema.load(data) # Raises an error if invalid
# Simulate processing
response_data = {
"customerId": "CN621868",
"transactionId": "Tr201712RK9232P115",
"msisdn": "3451342",
"eligibleOffers": [
{
"minamount": 5000,
"maxamount": 20000,
"productId": 101,
"offerid": 101,
"Tenor": 30
},
{
"minamount": 20000,
"maxamount": 50000,
"productId": 102,
"offerid": 102,
"Tenor": 60
}
],
"resultCode": "00",
"resultDescription": "Successful"
}
# Return a success response
# return ResponseHelper.success(
# data=response_data,
# message="Eligibility check completed successfully"
# )
return response_data
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return jsonify({
"message": "Validation exception"
}) , 422
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return jsonify({
"message": "Internal Server Error"
}) , 500
+62
View File
@@ -0,0 +1,62 @@
from flask import request, jsonify
from marshmallow import ValidationError
from app.utils.logger import logger
from app.api.schemas.loan_information import LoanInformationSchema
class LoanInformationService:
@staticmethod
def process_request(data):
"""
Process the Loan Information request.
Args:
data (dict): The request data.
Returns:
dict: A standardized response.
"""
try:
logger.info("Processing LoanInformation request")
# Validate input data using the imported schema
schema = LoanInformationSchema()
validated_data = schema.load(data) # Raises ValidationError if invalid
# Simulated processing logic
response_data = {
"customerId": "CN621868",
"loans": [
{
"debtId": "123456789",
"loanDate": "2019-10-18 14:26:21.063",
"dueDate": "2019-11-20 14:26:21.063",
"currentLoanAmount": 8500.0,
"initialLoanAmount": 10000.0,
"defaultFee": 0.0,
"continuousFee": 0.0,
"productId": "101"
}
],
"resultCode": "00",
"resultDescription": "Successful"
}
# return ResponseHelper.success(
# data=response_data,
# message="Loan information retrieved successfully"
# )
return response_data
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return jsonify({
"message": "Validation exception"
}) , 422
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return jsonify({
"message": "Internal Server Error"
}) , 500
+49
View File
@@ -0,0 +1,49 @@
from flask import request, jsonify
from marshmallow import ValidationError
from app.utils.logger import logger
from app.api.schemas.notification_callback import NotificationCallbackSchema
class NotificationCallbackService:
@staticmethod
def process_request(data):
"""
Process the NotificationCallback request.
Args:
data (dict): The request data.
Returns:
dict: A standardized response.
"""
try:
logger.info("Processing NotificationCallback request")
# Validate input data using the NotificationCallback schema
schema = NotificationCallbackSchema()
validated_data = schema.load(data) # Raises ValidationError if invalid
# Simulated processing logic
response_data = {
"resultCode": "00",
"resultDescription": "Successful"
}
# return ResponseHelper.success(
# data=response_data,
# message="Notification callback processed successfully"
# )
return response_data
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return jsonify({
"message": "Validation exception"
}) , 422
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return jsonify({
"message": "Internal Server Error"
}) , 500
+54
View File
@@ -0,0 +1,54 @@
from flask import request, jsonify
from marshmallow import ValidationError
from app.utils.logger import logger
from app.api.schemas.provide_loan import ProvideLoanSchema
class ProvideLoanService:
@staticmethod
def process_request(data):
"""
Process the ProvideLoan request.
Args:
data (dict): The request data.
Returns:
dict: A standardized response.
"""
try:
logger.info("Processing ProvideLoan request")
# Validate input data using the imported schema
schema = ProvideLoanSchema()
validated_data = schema.load(data) # Raises ValidationError if invalid
# Business logic - providing a loan
response_data ={
"requestId": "202111170001371256908",
"transactionId": "Tr201712RK9232P115",
"customerId": "CN621868",
"accountId": "ACN8263457",
"msisdn": "3451342",
"resultCode": "00",
"resultDescription": "Successful"
}
# return ResponseHelper.success(
# data=response_data,
# message="Loan successfully provided"
# )
return response_data
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return jsonify({
"message": "Validation exception"
}) , 422
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return jsonify({
"message": "Internal Server Error"
}) , 500
+49
View File
@@ -0,0 +1,49 @@
from flask import request, jsonify
from marshmallow import ValidationError
from app.utils.logger import logger
from app.api.schemas.repayment import RepaymentSchema
class RepaymentService:
@staticmethod
def process_request(data):
"""
Process the Repayment request.
Args:
data (dict): The request data.
Returns:
dict: A standardized response.
"""
try:
logger.info("Processing Repayment request")
# Validate input data using the Repayment schema
schema = RepaymentSchema()
validated_data = schema.load(data) # Raises ValidationError if invalid
# Simulated processing logic
response_data = {
"repayment_id": "67890",
"status": "Paid",
"amount": validated_data.get("amount", 0), # Example: Use validated field
}
# return ResponseHelper.success(
# data=response_data,
# message="Repayment processed successfully"
# )
return response_data
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return jsonify({
"message": "Validation exception"
}) , 422
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return jsonify({
"message": "Internal Server Error"
}) , 500
+106
View File
@@ -0,0 +1,106 @@
from flask import request, jsonify
from marshmallow import ValidationError
from app.utils.logger import logger
from app.api.schemas.select_offer import SelectOfferSchema
class SelectOfferService:
@staticmethod
def process_request(data):
"""
Process the SelectOffer request.
Args:
data (dict): The request data.
Returns:
dict: A standardized response.
"""
try:
logger.info("Processing SelectOffer request")
# Validate input data using the imported schema
schema = SelectOfferSchema()
validated_data = schema.load(data) # Raises ValidationError if invalid
offers = [
{
"offerId": "14451",
"productId": "2030",
"amount": 10000.0,
"upfrontPayment": 1000.0,
"interestRate": 3.0,
"managementRate": 1.0,
"managementFee": 1.0,
"insuranceRate": 1.0,
"insuranceFee": 100.0,
"VATRate": 7.5,
"VATAmount": 100.0,
"recommendedRepaymentDates": ["2022-11-30"],
"installmentAmount": 11000.0,
"totalRepaymentAmount": 11000.0
},
{
"offerId": "16645",
"productId": "2060",
"amount": 10000.0,
"upfrontPayment": 0.0,
"interestRate": 3.0,
"managementRate": 1.0,
"managementFee": 1.0,
"insuranceRate": 1.0,
"insuranceFee": 100.0,
"VATRate": 7.5,
"VATAmount": 100.0,
"recommendedRepaymentDates": ["2022-11-30", "2023-12-30"],
"installmentAmount": 5761.9,
"totalRepaymentAmount": 11523.8
},
{
"offerId": "122212",
"productId": "2090",
"amount": 10000.0,
"upfrontPayment": 0.0,
"interestRate": 10.0,
"managementRate": 1.0,
"managementFee": 1.0,
"insuranceRate": 1.0,
"insuranceFee": 100.0,
"VATRate": 7.5,
"VATAmount": 100.0,
"recommendedRepaymentDates": ["2022-11-30", "2022-12-30", "2023-01-29"],
"installmentAmount": 4021.15,
"totalRepaymentAmount": 12063.45
}
]
# Business logic - selecting an offer
response_data = {
"outstandingDebtAmount": 0,
"requestId": "202111170001371256908",
"transactionId": "1231231321232",
"customerId": "1256907",
"accountId": "5948306019",
"loan": offers,
"resultCode": "00",
"resultDescription": "Successful"
}
# return ResponseHelper.success(
# data=response_data,
# message="Offer selection completed successfully"
# )
return response_data
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return jsonify({
"message": "Validation exception"
}) , 422
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return jsonify({
"message": "Internal Server Error"
}) , 500