"""Product Orchard Pricing Tier logic.""" from pricing.logic import change_detection from pricing.models import product_orchard_pricing_tier def get_by_product_id_and_pricing_family_id(product_id, pricing_family_id): """Get one product orchard pricing tier by product ID and pricing family. Args: product_id (int): the ID of the product. pricing_family_id (int): the ID of the pricing family. Returns: response.Response: containing the product orchard pricing tier dict. """ return product_orchard_pricing_tier.\ get_by_product_id_and_pricing_family_id( product_id, pricing_family_id) def update_product_with_orchard_pricing_tier( product_id, pricing_family_id, data): """Set the orchard pricing tier of a product. Args: product_id (int): the ID of the product. pricing_family_id (int): the ID of the pricing family. data (dict): the data from which to create the store pricing scheme. Returns: response.Response: containing the created store pricing scheme dict. """ if isinstance(product_id, str): product_id = int(product_id) if isinstance(pricing_family_id, str): pricing_family_id = int(pricing_family_id) result = product_orchard_pricing_tier.\ update_product_with_orchard_pricing_tier( product_id, pricing_family_id, data) if result: change_detection.write_pricing_changes(product_id, pricing_family_id) return result