"""Interface for the ows-pricing microservice.""" from oto import response from owsrequest import request as requests import sentry_sdk from product.constants import service_name PHYSICAL_PRICING_FAMILY_ID = 4 def copy_product_pricing(product_id, new_product_id): """Copy a product's pricing. 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. Returns: response.Response: status of copy. """ try: copy_product_pricing_response = requests.post( service_name.OWS_PRICING, "/product/{}/pricing/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-pricing." ) return response.Response(status=copy_product_pricing_response.status_code) def update_pricing_tier(product_id, pricing_family_id, orchard_pricing_tier): """Update product orchard pricing tier. Args: product_id (int): the ID of the product to set orchard pricing tier on. pricing_family_id (int): the ID of the pricing family. orchard_pricing_tier (int): pricing tier to update. Returns: response.Response: status of update. """ try: copy_product_pricing_response = requests.put( service_name.OWS_PRICING, "/product/{}/pricing-family/{}/orchard_pricing_tier".format( product_id, pricing_family_id ), json={"orchard_pricing_tier_id": orchard_pricing_tier}, ) except Exception as exception: sentry_sdk.capture_exception(exception) return response.create_fatal_response( message="Could not connect to ows-pricing." ) return response.Response(status=copy_product_pricing_response.status_code)