"""Track logic.""" from oto import response from owsrequest import request as requests from promo_player.constants import service_name from promo_player.logic import product def is_owner(track_id, account_type, account_id): """Get ownership of a track for account type and account ID. Args: track_id (int): the track ID. account_type (str): the account type (vendor or subaccount). account_id (str): the account ID. Returns: response.Response: Indicates whether the account owns the track. """ path = '/track/{track_id}'.format(track_id=track_id) track_result = requests.get(service_name.OWS_TRACK, path) if track_result.status_code != 200: return response.Response(status=track_result.status_code) product_id = track_result.json()['product_id'] return product.is_owner(product_id, account_type, account_id)