"""Logic for Track. This is for retrieving a track from the store mapping. """ import json from owsresponse import response from product_store_mapping.models import productstoremapping def get_track(track_unique_id, dms_id): """Logic handlers. Args: track_unique_id (int): The track_unique_id for the product store mapping dms_id (int): The dms_id for the product store mapping Returns: Response: dictionary of results """ result = productstoremapping.get_track(track_unique_id, dms_id) if result.status == 404: return result mapping_data = json.loads(result.message.mapping_data) return response.Response( { "store_unique_id": result.message.store_unique_id, "custom_id": mapping_data["custom_id"], } )