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