"""Format create product.""" from switchboard_consumer.constants.id_prefixes import AIID from switchboard_consumer.constants.system import ORCHARD def format_get_artist_id(local_id): """Split out the clean int id element of prefixed ids.""" try: return int(local_id.split(':')[1]) except (IndexError, AttributeError): return int(local_id) def format_get_artist_input(artist_id): """Format payload for get artist query.""" return { 'artistId': format_get_artist_id(artist_id) } def format_create_artist_input(artist_name, vendor_id): """Format payload for create artist query.""" return { 'artistName': artist_name, 'vendorId': int(vendor_id) } def format_filter_artists_input(artist_name, vendor_id): """Format payload for filter artists query.""" return { 'artistName': artist_name, 'vendorId': int(vendor_id) } def format_artist_local_id(insert_id): return f'{AIID}:{insert_id}' def format_artist_result(insert_id): """Format create artist result.""" return [{ 'localId': format_artist_local_id(insert_id), 'system': ORCHARD, }] def format_participant(artist_id, name, role): """Format participant data into acceptable format.""" return { 'artistInfoId': format_get_artist_id(artist_id), 'artistName': name, 'artistType': role } def format_performer(performer_name, performer_role_id, performer_type): """Format a performer.""" return { 'name': performer_name, 'roleId': performer_role_id, 'type': performer_type }