setTasteProfile method
Favorites artists to see more recommendations from the artist.
Use getTasteProfile to see which artists are available to be recommended.
artists
A List with names of artists, must be contained in thetasteProfile
.tasteProfile
tasteprofile
result from getTasteProfile. Pass this if you call getTasteProfile anyway to save an extra request.
Implementation
Future<void> setTasteProfile(
List<String> artists, {
JsonMap? tasteProfile,
}) async {
tasteProfile ??= await getTasteProfile();
final formData = {
'impressionValues':
tasteProfile.keys
.map(
(k) =>
(tasteProfile!
as Map<String, JsonMap>)[k]!['impressionValue'],
)
.toList(),
'selectedValues': [],
};
for (final artist in artists) {
if (!tasteProfile.containsKey(artist)) {
throw Exception('The artist $artist was not present in taste!');
}
formData['selectedValues']!.add(
(tasteProfile[artist] as JsonMap)['selectionValue'],
);
}
await sendRequest('browse', {
'browseId': 'FEmusic_home',
'formData': formData,
});
}