"""Function Logic.""" from content_utils.connectors.graphql import LambdaGraphQLConnector from kafka_utils.consumer.message.product import ProductEventMessage from kafka_utils.exceptions import IneligibleEventException from src import config from src.constants.graphql import EMAIL_NOTIFICATION_MUTATION gql_conn = LambdaGraphQLConnector( config.GRAPHQL_GATEWAY_URL, config.APPLICATION_NAME, config.app_logger ) def processing_logic(topic, value, deserializer=None): """Single event handling logic.""" review_msg = ProductEventMessage( message=value, topic=topic, value_deserializer=deserializer ) if review_msg.operation_context not in ('approve', 'reject'): raise IneligibleEventException(f'skip operations {review_msg.operation_context}') return gql_conn.execute( EMAIL_NOTIFICATION_MUTATION, {'reviewQueueId': review_msg.review_queue_id} )