[add]: Swagger Documentation
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
from app.api.services.rac_check import RACCheckService
|
||||
from app.api.services.disbursement import DisbursementService
|
||||
from app.api.services.collect_loan import CollectLoanService
|
||||
from app.api.services.transaction_verify import TransactionVerifyService
|
||||
from app.api.services.penal_charge import PenalChargeService
|
||||
from app.api.services.revoke_enable_consent import RevokeEnableConsentService
|
||||
from app.api.services.token_validation import TokenValidationService
|
||||
from app.api.services.lien_check import LienCheckService
|
||||
from app.api.services.new_transaction_check import NewTransactionCheckService
|
||||
@@ -0,0 +1,61 @@
|
||||
from flask import request, jsonify
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from app.api.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)
|
||||
|
||||
# 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 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
|
||||
@@ -0,0 +1,51 @@
|
||||
from flask import request, jsonify
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
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
|
||||
@@ -0,0 +1,62 @@
|
||||
from flask import request, jsonify
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from app.api.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 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
|
||||
@@ -0,0 +1,51 @@
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from app.api.schemas.lien_check import LienCheckSchema
|
||||
from flask import request, jsonify
|
||||
|
||||
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 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
|
||||
@@ -0,0 +1,58 @@
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from app.api.schemas.new_transaction_check import NewTransactionCheckSchema
|
||||
from flask import request, jsonify
|
||||
|
||||
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 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
|
||||
@@ -0,0 +1,51 @@
|
||||
from flask import request, jsonify
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from app.api.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 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
|
||||
@@ -0,0 +1,63 @@
|
||||
from flask import request, jsonify
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from app.api.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 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
|
||||
@@ -0,0 +1,54 @@
|
||||
from flask import request, jsonify
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from app.api.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 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
|
||||
@@ -0,0 +1,54 @@
|
||||
from flask import request, jsonify
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from app.api.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 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
|
||||
@@ -0,0 +1,57 @@
|
||||
from flask import request, jsonify
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from app.api.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 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
|
||||
Reference in New Issue
Block a user