[chore]: Separated Simbrella to bank calls

This commit is contained in:
VivianDee
2025-03-21 10:22:09 +01:00
parent a5940969ee
commit d2f403ed59
65 changed files with 201 additions and 1004 deletions
-9
View File
@@ -1,10 +1,3 @@
from app.blueprints.eligibility_check import EligibilityCheckService
from app.blueprints.select_offer import SelectOfferService
from app.blueprints.provide_loan import ProvideLoanService
from app.blueprints.loan_information import LoanInformationService
from app.blueprints.repayment import RepaymentService
from app.blueprints.customer_consent import CustomerConsentService
from app.blueprints.notification_callback import NotificationCallbackService
from app.blueprints.rac_check import RACCheckService
from app.blueprints.disbursement import DisbursementService
from app.blueprints.collect_loan import CollectLoanService
@@ -14,5 +7,3 @@ from app.blueprints.revoke_enable_consent import RevokeEnableConsentService
from app.blueprints.token_validation import TokenValidationService
from app.blueprints.lien_check import LienCheckService
from app.blueprints.new_transaction_check import NewTransactionCheckService
from app.blueprints.sms import SMSService
from app.blueprints.bulk_sms import BulkSMSService
Binary file not shown.
Binary file not shown.
Binary file not shown.
-55
View File
@@ -1,55 +0,0 @@
from marshmallow import ValidationError
from app.utils.logger import logger
from app.helpers.response_helper import ResponseHelper
from app.schemas.bulk_sms import BulkSMSSchema
class BulkSMSService:
@staticmethod
def process_request(data):
"""
Process the Bulk SMS request.
Args:
data (dict): The request data.
Returns:
dict: A standardized response.
"""
try:
logger.info("Processing BulkSMS request")
# Validate input data using BulkSMSSchema
schema = BulkSMSSchema()
validated_data = schema.load(data) # Raises ValidationError if invalid
# Simulated Bulk SMS sending logic
response_data = {
"data": "",
"statusCode": 200,
"isSuccessful": True,
"errorMessage": None
}
# return ResponseHelper.success(
# data=response_data,
# message="Bulk SMS sent successfully"
# )
return response_data
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return ResponseHelper.error(
message="Invalid input data",
status_code=400,
error=err.messages
)
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
error=str(e)
)
+2 -4
View File
@@ -21,7 +21,7 @@ class CollectLoanService:
# Validate input data using CollectLoanSchema
schema = CollectLoanSchema()
validated_data = schema.load(data) # Raises ValidationError if invalid
validated_data = schema.load(data)
# Simulated processing logic
response_data = {
@@ -56,8 +56,6 @@ class CollectLoanService:
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
return ResponseHelper.internal_server_error(
error=str(e)
)
+1 -3
View File
@@ -48,8 +48,6 @@ class CustomerConsentService:
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
return ResponseHelper.internal_server_error(
error=str(e)
)
+1 -3
View File
@@ -59,8 +59,6 @@ class DisbursementService:
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
return ResponseHelper.internal_server_error(
error=str(e)
)
-77
View File
@@ -1,77 +0,0 @@
from flask import session
from app.utils.logger import logger
from app.helpers.response_helper import ResponseHelper
from app.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
# Example: Validate data, perform calculations, etc.
if not data:
return ResponseHelper.error("Invalid input data", status_code=400)
# 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 ResponseHelper.error(
message="Invalid input data",
status_code=400,
error=err.messages
)
except Exception as e:
logger.error(f"An error occurred during EligibilityCheck processing: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
error=str(e)
)
+1 -3
View File
@@ -47,8 +47,6 @@ class LienCheckService:
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
return ResponseHelper.internal_server_error(
error=str(e)
)
-67
View File
@@ -1,67 +0,0 @@
from flask import request
from marshmallow import ValidationError
from app.utils.logger import logger
from app.helpers.response_helper import ResponseHelper
from app.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 ResponseHelper.error(
message="Invalid input data",
status_code=400,
error=err.messages
)
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
error=str(e)
)
+1 -3
View File
@@ -54,8 +54,6 @@ class NewTransactionCheckService:
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
return ResponseHelper.internal_server_error(
error=str(e)
)
-54
View File
@@ -1,54 +0,0 @@
from flask import request
from marshmallow import ValidationError
from app.utils.logger import logger
from app.helpers.response_helper import ResponseHelper
from app.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 ResponseHelper.error(
message="Invalid input data",
status_code=400,
error=err.messages
)
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
error=str(e)
)
+1 -3
View File
@@ -48,8 +48,6 @@ class PenalChargeService:
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
return ResponseHelper.internal_server_error(
error=str(e)
)
-59
View File
@@ -1,59 +0,0 @@
from flask import request
from marshmallow import ValidationError
from app.utils.logger import logger
from app.helpers.response_helper import ResponseHelper
from app.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 ResponseHelper.error(
message="Invalid input data",
status_code=400,
error=err.messages
)
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
error=str(e)
)
+1 -3
View File
@@ -60,8 +60,6 @@ class RACCheckService:
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
return ResponseHelper.internal_server_error(
error=str(e)
)
-54
View File
@@ -1,54 +0,0 @@
from flask import request
from marshmallow import ValidationError
from app.utils.logger import logger
from app.helpers.response_helper import ResponseHelper
from app.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 ResponseHelper.error(
message="Invalid input data",
status_code=400,
error=err.messages
)
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
error=str(e)
)
+1 -3
View File
@@ -51,8 +51,6 @@ class RevokeEnableConsentService:
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
return ResponseHelper.internal_server_error(
error=str(e)
)
-109
View File
@@ -1,109 +0,0 @@
from flask import request
from marshmallow import ValidationError
from app.utils.logger import logger
from app.helpers.response_helper import ResponseHelper
from app.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
# Business logic - selecting an offer
response_data = {
"outstandingDebtAmount": 0,
"requestId": "202111170001371256908",
"transactionId": "1231231321232",
"customerId": "1256907",
"accountId": "5948306019",
"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
}
],
"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 ResponseHelper.error(
message="Invalid input data",
status_code=400,
error=err.messages
)
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
error=str(e)
)
-56
View File
@@ -1,56 +0,0 @@
from marshmallow import ValidationError
from app.utils.logger import logger
from app.helpers.response_helper import ResponseHelper
from app.schemas.sms import SMSSchema
class SMSService:
@staticmethod
def process_request(data):
"""
Process the SMS request.
Args:
data (dict): The request data.
Returns:
dict: A standardized response.
"""
try:
logger.info("Processing SMS request")
# Validate input data using SMSSchema
schema = SMSSchema()
validated_data = schema.load(data) # Raises ValidationError if invalid
# Simulated SMS sending logic
response_data = {
"data": "",
"statusCode": 200,
"isSuccessful": True,
"errorMessage": None
}
# return ResponseHelper.success(
# data=response_data,
# message="SMS sent successfully"
# )
return response_data
except ValidationError as err:
logger.error(f"Validation Error: {err.messages}")
return ResponseHelper.error(
message="Invalid input data",
status_code=400,
error=err.messages
)
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
error=str(e)
)
+1 -3
View File
@@ -51,8 +51,6 @@ class TokenValidationService:
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
return ResponseHelper.internal_server_error(
error=str(e)
)
+1 -3
View File
@@ -54,8 +54,6 @@ class TransactionVerifyService:
except Exception as e:
logger.error(f"An error occurred: {str(e)}", exc_info=True)
return ResponseHelper.error(
message="An internal error occurred",
status_code=500,
return ResponseHelper.internal_server_error(
error=str(e)
)