2020-05-02 12:04:26 +01:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace SpotifyAPI.Web
|
|
|
|
{
|
|
|
|
public class RecommendationsRequest : RequestParams
|
|
|
|
{
|
|
|
|
public RecommendationsRequest()
|
|
|
|
{
|
|
|
|
Min = new Dictionary<string, string>();
|
|
|
|
Max = new Dictionary<string, string>();
|
|
|
|
Target = new Dictionary<string, string>();
|
2020-05-05 14:30:00 +01:00
|
|
|
SeedArtists = new List<string>();
|
|
|
|
SeedGenres = new List<string>();
|
|
|
|
SeedTracks = new List<string>();
|
2020-05-02 12:04:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
[QueryParam("seed_artists")]
|
2020-05-05 14:30:00 +01:00
|
|
|
public IList<string> SeedArtists { get; }
|
2020-05-02 12:04:26 +01:00
|
|
|
|
|
|
|
[QueryParam("seed_genres")]
|
2020-05-05 14:30:00 +01:00
|
|
|
public IList<string> SeedGenres { get; }
|
2020-05-02 12:04:26 +01:00
|
|
|
|
|
|
|
[QueryParam("seed_tracks")]
|
2020-05-05 14:30:00 +01:00
|
|
|
public IList<string> SeedTracks { get; }
|
2020-05-02 12:04:26 +01:00
|
|
|
|
|
|
|
[QueryParam("limit")]
|
|
|
|
public int? Limit { get; set; }
|
|
|
|
|
|
|
|
[QueryParam("market")]
|
|
|
|
public string Market { get; set; }
|
|
|
|
|
2020-05-05 14:30:00 +01:00
|
|
|
public Dictionary<string, string> Min { get; }
|
|
|
|
public Dictionary<string, string> Max { get; }
|
|
|
|
public Dictionary<string, string> Target { get; }
|
2020-05-02 12:04:26 +01:00
|
|
|
|
2020-05-02 21:48:21 +01:00
|
|
|
protected override void CustomEnsure()
|
2020-05-02 12:04:26 +01:00
|
|
|
{
|
2020-05-05 14:30:00 +01:00
|
|
|
if (SeedArtists.Count == 0 && SeedGenres.Count == 0 && SeedTracks.Count == 0)
|
2020-05-02 12:04:26 +01:00
|
|
|
{
|
|
|
|
throw new ArgumentException("At least one of the seeds has to be non-empty");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-05 14:30:00 +01:00
|
|
|
protected override void AddCustomQueryParams(Dictionary<string, string> queryParams)
|
2020-05-02 12:04:26 +01:00
|
|
|
{
|
2020-05-05 14:30:00 +01:00
|
|
|
Ensure.ArgumentNotNull(queryParams, nameof(queryParams));
|
|
|
|
|
2020-05-02 12:04:26 +01:00
|
|
|
foreach (KeyValuePair<string, string> pair in Min)
|
|
|
|
{
|
|
|
|
queryParams.Add($"min_{pair.Key}", pair.Value);
|
|
|
|
}
|
|
|
|
foreach (KeyValuePair<string, string> pair in Min)
|
|
|
|
{
|
|
|
|
queryParams.Add($"max_{pair.Key}", pair.Value);
|
|
|
|
}
|
|
|
|
foreach (KeyValuePair<string, string> pair in Min)
|
|
|
|
{
|
|
|
|
queryParams.Add($"target_{pair.Key}", pair.Value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|