"""Function logic for ows-notifications.""" from owsrequest import request from src import config from src import service def move_target_notify_escalation(product_id, request_data): """Notify queue move target of escalation.""" _send_notification(product_id, 'escalate', request_data) def move_target_notify_de_escalation(product_id, request_data): """Notify queue move target of de-escalation.""" _send_notification(product_id, 'de-escalate', request_data) def _send_notification(product_id, escalation_type, request_data): response = request.process( config.APPLICATION_NAME, config.ENVIRONMENT, 'POST', service.OWS_NOTIFICATIONS, f'/content-review/{escalation_type}', json=request_data ) if response.status_code not in (200, 202, 204): error_message = ( f'Failed to send {escalation_type} notification for product_id ' f'{product_id}.\n' f'Status code: {response.status_code}, ' f'Error: {response.text}' ) raise Exception(error_message)