Files
digifi-BankEmulator/app/services/revoke_enable_consent.py
T
2025-03-21 17:05:12 +01:00

55 lines
1.7 KiB
Python

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 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