"""Interface for the ows-marketing microservice.""" from oto import response from owsrequest import request as requests import sentry_sdk from product.constants import error from product.constants import service_name def copy_product_highlights(product_id, new_product_id): """Copy a product's highlights. Args: product_id (int): The product_id of the product to copy from. new_product_id (int): The product_id of the product to copy to. """ try: copy_product_highlights_response = requests.post( service_name.OWS_MARKETING, "/highlights/product/{}/copy/{}".format(product_id, new_product_id), ) except Exception as exception: sentry_sdk.capture_exception(exception) return response.create_fatal_response( message="Could not connect to ows-marketing." ) return response.Response(status=copy_product_highlights_response.status_code) def delete_marketing_highlights_by_release(product_id): """Delete marketing highlights. Args: product_id (int): physical product id to delete marketing highlights for Returns: response.Response: status of deletion """ try: delete_status = requests.delete( service_name.OWS_MARKETING, "/highlights/release/{product_id}".format(product_id=product_id), ) return response.Response(status=delete_status.status_code) except Exception as exception: sentry_sdk.capture_exception(exception) return response.create_error_response( code=error.INTERNAL_ERROR, message="connection error", status=500 )