from flask import request, jsonify 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 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