"""Logic for checking features.""" from owsfeatures.models import ows_features as features_model from promo_player import config from promo_player.constants import features def is_promo_player_product_delivered_version_enabled_for_label( vendor_id, subaccount_id, ): """Check if the promo_player_product_delivered_version feature state.""" headers = { 'Grass-Account-Type': 'vendor', 'Grass-Account-Id': f'{vendor_id}', } if subaccount_id is not None: headers = { 'Grass-Account-Type': 'subaccount', 'Grass-Account-Id': f'{subaccount_id}', } response = features_model.get_active_variant_with_headers( features.PROMO_PLAYER_PRODUCT_DELIVERED_VERSION, 'bff-promo-player', headers, config.ENVIRONMENT, ) if not response: return False return response == 'enabled'