60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
# from flask import request, jsonify
|
|
# from app.api.helpers.response_helper import ResponseHelper
|
|
# # from app.api.services.base_service import BaseService
|
|
# from marshmallow import ValidationError
|
|
# from app.utils.logger import logger
|
|
# # from app.api.schemas.customer_consent import CustomerConsentSchema
|
|
# from app.api.services.base_service import BaseService
|
|
# from app.api.enums import TransactionType
|
|
# from app.extensions import db
|
|
#
|
|
#
|
|
# class CustomerConsentService(BaseService):
|
|
# TRANSACTION_TYPE = TransactionType.CUSTOMER_CONSENT
|
|
#
|
|
# @staticmethod
|
|
# def process_request(data):
|
|
# """
|
|
# Process the CustomerConsent request.
|
|
#
|
|
# Args:
|
|
# data (dict): The request data.
|
|
#
|
|
# Returns:
|
|
# dict: A standardized response.
|
|
# """
|
|
# try:
|
|
# with db.session.begin():
|
|
# validated_data = CustomerConsentService.validate_data(data, CustomerConsentSchema())
|
|
# account_id = validated_data.get('accountId')
|
|
# customer_id = validated_data.get('customerId')
|
|
#
|
|
# if(CustomerConsentService.validate_account_ownership(account_id = account_id, customer_id = customer_id)):
|
|
#
|
|
# transaction = CustomerConsentService.log_transaction(validated_data = validated_data)
|
|
#
|
|
# if not transaction:
|
|
# logger.error(f"Failed to log transaction")
|
|
# return ResponseHelper.error(result_description="Failed to log transaction.")
|
|
# else:
|
|
# return ResponseHelper.error(result_description="Invalid Customer or Account")
|
|
#
|
|
#
|
|
# db.session.commit()
|
|
# return ResponseHelper.success(result_description="Request is received")
|
|
#
|
|
# except ValidationError as err:
|
|
#
|
|
# logger.error(f"Validation Error: {getattr(err, 'messages', str(err))}")
|
|
# db.session.rollback()
|
|
# return ResponseHelper.unprocessable_entity(result_description="Validation exception")
|
|
#
|
|
# except ValueError as err:
|
|
# logger.error(f"{getattr(err, 'messages', str(err))}")
|
|
# db.session.rollback()
|
|
# return ResponseHelper.error(result_description=str(err))
|
|
#
|
|
# except Exception as e:
|
|
# logger.error(f"An error occurred: {str(e)}", exc_info=True)
|
|
# db.session.rollback()
|
|
# return ResponseHelper.internal_server_error() |