first commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
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
|
||||
from app.blueprints.transaction_verify import TransactionVerifyService
|
||||
from app.blueprints.penal_charge import PenalChargeService
|
||||
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,55 @@
|
||||
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)
|
||||
)
|
||||
@@ -0,0 +1,63 @@
|
||||
from flask import request
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.helpers.response_helper import ResponseHelper
|
||||
from app.schemas.collect_loan import CollectLoanSchema
|
||||
|
||||
class CollectLoanService:
|
||||
@staticmethod
|
||||
def process_request(data):
|
||||
"""
|
||||
Process the CollectLoan request.
|
||||
|
||||
Args:
|
||||
data (dict): The request data.
|
||||
|
||||
Returns:
|
||||
dict: A standardized response.
|
||||
"""
|
||||
try:
|
||||
logger.info("Processing CollectLoan request")
|
||||
|
||||
# Validate input data using CollectLoanSchema
|
||||
schema = CollectLoanSchema()
|
||||
validated_data = schema.load(data) # Raises ValidationError if invalid
|
||||
|
||||
# Simulated processing logic
|
||||
response_data = {
|
||||
"transactionId": "T002",
|
||||
"debtId": "273194670",
|
||||
"customerId": "CN621868",
|
||||
"accountId": "2017821799",
|
||||
"productId": "101",
|
||||
"collectAmount": 60000.00,
|
||||
"penalCharge": 0,
|
||||
"lienAmount": 20000,
|
||||
"countryId": "01",
|
||||
"comment": "Testing CollectionLoanRequest",
|
||||
"resultCode": "00",
|
||||
"resultDescription": "Loan Collection Successful"
|
||||
}
|
||||
|
||||
|
||||
# return ResponseHelper.success(
|
||||
# data=response_data,
|
||||
# message="Loan collection 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)
|
||||
)
|
||||
@@ -0,0 +1,55 @@
|
||||
from flask import request
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.helpers.response_helper import ResponseHelper
|
||||
from app.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 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)
|
||||
)
|
||||
@@ -0,0 +1,66 @@
|
||||
from flask import request
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.helpers.response_helper import ResponseHelper
|
||||
from app.schemas.disbursement import DisbursementSchema
|
||||
|
||||
class DisbursementService:
|
||||
@staticmethod
|
||||
def process_request(data):
|
||||
"""
|
||||
Process the Disbursement request.
|
||||
|
||||
Args:
|
||||
data (dict): The request data.
|
||||
|
||||
Returns:
|
||||
dict: A standardized response.
|
||||
"""
|
||||
try:
|
||||
logger.info("Processing Disbursement request")
|
||||
|
||||
# Validate input data using DisbursementSchema
|
||||
schema = DisbursementSchema()
|
||||
validated_data = schema.load(data) # Raises ValidationError if invalid
|
||||
|
||||
# Simulated processing logic
|
||||
response_data = {
|
||||
"transactionId": "T001",
|
||||
"TransactionId": "Tr201712RK9232P115",
|
||||
"debtId": "273194670",
|
||||
"customerId": "CN621868",
|
||||
"accountId": "2017821799",
|
||||
"productId": "101",
|
||||
"provideAmount": 100000.0,
|
||||
"collectAmountInterest": 5000,
|
||||
"collectAmountMgtFee": 1000,
|
||||
"collectAmountInsurance": 1000,
|
||||
"collectAmountVAT": 75,
|
||||
"countryId": "01",
|
||||
"resultCode": "00",
|
||||
"resultDescription": "Loan Request Completed Successfully!"
|
||||
}
|
||||
|
||||
|
||||
# return ResponseHelper.success(
|
||||
# data=response_data,
|
||||
# message="Disbursement 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)
|
||||
)
|
||||
@@ -0,0 +1,77 @@
|
||||
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)
|
||||
)
|
||||
@@ -0,0 +1,54 @@
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.helpers.response_helper import ResponseHelper
|
||||
from app.schemas.lien_check import LienCheckSchema
|
||||
|
||||
class LienCheckService:
|
||||
@staticmethod
|
||||
def process_request(data):
|
||||
"""
|
||||
Process the LienCheck request.
|
||||
|
||||
Args:
|
||||
data (dict): The request data.
|
||||
|
||||
Returns:
|
||||
dict: A standardized response.
|
||||
"""
|
||||
try:
|
||||
logger.info("Processing LienCheck request")
|
||||
|
||||
# Validate input data using LienCheckSchema
|
||||
schema = LienCheckSchema()
|
||||
validated_data = schema.load(data) # Raises ValidationError if invalid
|
||||
|
||||
# Simulated lien check logic
|
||||
response_data = {
|
||||
"lienAmount": 20000.0,
|
||||
"resultCode": "00",
|
||||
"resultDescription": "Successful"
|
||||
}
|
||||
|
||||
|
||||
# return ResponseHelper.success(
|
||||
# data=response_data,
|
||||
# message="Lien 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: {str(e)}", exc_info=True)
|
||||
return ResponseHelper.error(
|
||||
message="An internal error occurred",
|
||||
status_code=500,
|
||||
error=str(e)
|
||||
)
|
||||
@@ -0,0 +1,67 @@
|
||||
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)
|
||||
)
|
||||
@@ -0,0 +1,61 @@
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.helpers.response_helper import ResponseHelper
|
||||
from app.schemas.new_transaction_check import NewTransactionCheckSchema
|
||||
|
||||
class NewTransactionCheckService:
|
||||
@staticmethod
|
||||
def process_request(data):
|
||||
"""
|
||||
Process the NewTransactionCheck request.
|
||||
|
||||
Args:
|
||||
data (dict): The request data.
|
||||
|
||||
Returns:
|
||||
dict: A standardized response.
|
||||
"""
|
||||
try:
|
||||
logger.info("Processing NewTransactionCheck request")
|
||||
|
||||
# Validate input data using NewTransactionCheckSchema
|
||||
schema = NewTransactionCheckSchema()
|
||||
validated_data = schema.load(data) # Raises ValidationError if invalid
|
||||
|
||||
# Simulated transaction check logic
|
||||
response_data = {
|
||||
"transactionId": "24110114545374721",
|
||||
"data": {
|
||||
"transactionId": "241101",
|
||||
"providedAmount": 1000.00,
|
||||
"collectedAmount": 0.00,
|
||||
"resultCode": "00",
|
||||
"resultDescription": "Loan Provision is successful"
|
||||
},
|
||||
"resultCode": "00",
|
||||
"resultDescription": "SUCCESS"
|
||||
}
|
||||
|
||||
|
||||
# return ResponseHelper.success(
|
||||
# data=response_data,
|
||||
# message="New transaction 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: {str(e)}", exc_info=True)
|
||||
return ResponseHelper.error(
|
||||
message="An internal error occurred",
|
||||
status_code=500,
|
||||
error=str(e)
|
||||
)
|
||||
@@ -0,0 +1,54 @@
|
||||
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)
|
||||
)
|
||||
@@ -0,0 +1,55 @@
|
||||
from flask import request
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.helpers.response_helper import ResponseHelper
|
||||
from app.schemas.penal_charge import PenalChargeSchema
|
||||
|
||||
|
||||
class PenalChargeService:
|
||||
@staticmethod
|
||||
def process_request(data):
|
||||
"""
|
||||
Process the PenalCharge request.
|
||||
|
||||
Args:
|
||||
data (dict): The request data.
|
||||
|
||||
Returns:
|
||||
dict: A standardized response.
|
||||
"""
|
||||
try:
|
||||
logger.info("Processing PenalCharge request")
|
||||
|
||||
# Validate input data using PenalChargeSchema
|
||||
schema = PenalChargeSchema()
|
||||
validated_data = schema.load(data) # Raises ValidationError if invalid
|
||||
|
||||
# Simulated processing logic
|
||||
response_data = {
|
||||
"resultCode": "00",
|
||||
"resultDescription": "Penal charge debited successfully"
|
||||
}
|
||||
|
||||
|
||||
# return ResponseHelper.success(
|
||||
# data=response_data,
|
||||
# message="Penal charge applied 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)
|
||||
)
|
||||
@@ -0,0 +1,59 @@
|
||||
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)
|
||||
)
|
||||
@@ -0,0 +1,67 @@
|
||||
from flask import request
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.helpers.response_helper import ResponseHelper
|
||||
from app.schemas.rac_check import RACCheckSchema
|
||||
|
||||
class RACCheckService:
|
||||
@staticmethod
|
||||
def process_request(data):
|
||||
"""
|
||||
Process the RACCheck request.
|
||||
|
||||
Args:
|
||||
data (dict): The request data.
|
||||
|
||||
Returns:
|
||||
dict: A standardized response.
|
||||
"""
|
||||
try:
|
||||
logger.info("Processing RACCheck request")
|
||||
|
||||
# Validate input data using RACCheckSchema
|
||||
schema = RACCheckSchema()
|
||||
validated_data = schema.load(data) # Raises ValidationError if invalid
|
||||
|
||||
# Simulated processing logic
|
||||
response_data = {
|
||||
"resultCode": "00",
|
||||
"RACResponse": {
|
||||
"SalaryAccount": "1",
|
||||
"BVN": "1",
|
||||
"BVNAttachedToAccount": "1",
|
||||
"CRMS": "1",
|
||||
"CRC": "1",
|
||||
"AccountStatus": "1",
|
||||
"Lien": "1",
|
||||
"NoBouncedCheck": "1",
|
||||
"Whitelist": "1",
|
||||
"NoPastDueSalaryLoan": "1",
|
||||
"NoPastDueOtherLoan": "1"
|
||||
},
|
||||
"resultDescription": "RAC Check Successful"
|
||||
}
|
||||
|
||||
|
||||
# return ResponseHelper.success(
|
||||
# data=response_data,
|
||||
# message="RAC 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: {str(e)}", exc_info=True)
|
||||
return ResponseHelper.error(
|
||||
message="An internal error occurred",
|
||||
status_code=500,
|
||||
error=str(e)
|
||||
)
|
||||
@@ -0,0 +1,54 @@
|
||||
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)
|
||||
)
|
||||
@@ -0,0 +1,58 @@
|
||||
from flask import request
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.helpers.response_helper import ResponseHelper
|
||||
from app.schemas.revoke_enable_consent import RevokeEnableConsentSchema
|
||||
|
||||
|
||||
class RevokeEnableConsentService:
|
||||
@staticmethod
|
||||
def process_request(data):
|
||||
"""
|
||||
Process the RevokeEnableConsent request.
|
||||
|
||||
Args:
|
||||
data (dict): The request data.
|
||||
|
||||
Returns:
|
||||
dict: A standardized response.
|
||||
"""
|
||||
try:
|
||||
logger.info("Processing RevokeEnableConsent request")
|
||||
|
||||
# Validate input data using RevokeEnableConsentSchema
|
||||
schema = RevokeEnableConsentSchema()
|
||||
validated_data = schema.load(data) # Raises ValidationError if invalid
|
||||
|
||||
# Simulated processing logic
|
||||
response_data = {
|
||||
"type": "RevokeEnableConsentResponse",
|
||||
"customerId": "CN621868",
|
||||
"accountId": "2017821799",
|
||||
"resultCode": "00",
|
||||
"resultDescription": "Success"
|
||||
}
|
||||
|
||||
|
||||
# return ResponseHelper.success(
|
||||
# data=response_data,
|
||||
# message="Consent revocation 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)
|
||||
)
|
||||
@@ -0,0 +1,109 @@
|
||||
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)
|
||||
)
|
||||
@@ -0,0 +1,56 @@
|
||||
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)
|
||||
)
|
||||
@@ -0,0 +1,58 @@
|
||||
from flask import request
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.helpers.response_helper import ResponseHelper
|
||||
from app.schemas.token_validation import TokenValidationSchema
|
||||
|
||||
|
||||
class TokenValidationService:
|
||||
@staticmethod
|
||||
def process_request(data):
|
||||
"""
|
||||
Process the TokenValidation request.
|
||||
|
||||
Args:
|
||||
data (dict): The request data.
|
||||
|
||||
Returns:
|
||||
dict: A standardized response.
|
||||
"""
|
||||
try:
|
||||
logger.info("Processing TokenValidation request")
|
||||
|
||||
# Validate input data using TokenValidationSchema
|
||||
schema = TokenValidationSchema()
|
||||
validated_data = schema.load(data) # Raises ValidationError if invalid
|
||||
|
||||
# Simulated token validation logic
|
||||
response_data = {
|
||||
"Authenticated": True,
|
||||
"AuthenticatedMessage": "The user Oluwole Olusoga has successfully authenticated!",
|
||||
"ResponseCode": "00",
|
||||
"ResponseMessage": "Successful",
|
||||
"RequestId": "SMB1234567"
|
||||
}
|
||||
|
||||
|
||||
# return ResponseHelper.success(
|
||||
# data=response_data,
|
||||
# message="Token validation 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)
|
||||
)
|
||||
@@ -0,0 +1,61 @@
|
||||
from flask import request
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.helpers.response_helper import ResponseHelper
|
||||
from app.schemas.transaction_verify import TransactionVerifySchema
|
||||
|
||||
|
||||
class TransactionVerifyService:
|
||||
@staticmethod
|
||||
def process_request(data):
|
||||
"""
|
||||
Process the TransactionVerify request.
|
||||
|
||||
Args:
|
||||
data (dict): The request data.
|
||||
|
||||
Returns:
|
||||
dict: A standardized response.
|
||||
"""
|
||||
try:
|
||||
logger.info("Processing TransactionVerify request")
|
||||
|
||||
# Validate input data using TransactionVerifySchema
|
||||
schema = TransactionVerifySchema()
|
||||
validated_data = schema.load(data) # Raises ValidationError if invalid
|
||||
|
||||
# Simulated processing logic
|
||||
response_data = {
|
||||
"type": "TransactionCheckResponse",
|
||||
"nativeId": "FBN20191031104405CN621868",
|
||||
"customerId": "CN621868",
|
||||
"accountId": "2017821799",
|
||||
"providedAmount": 0.0,
|
||||
"collectedAmount": 7.50,
|
||||
"resultCode": "00",
|
||||
"resultDescription": "Collect Status retrieved successfully."
|
||||
}
|
||||
|
||||
|
||||
# return ResponseHelper.success(
|
||||
# data=response_data,
|
||||
# message="Transaction verification 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)
|
||||
)
|
||||
Reference in New Issue
Block a user