Spotify.NET/SpotifyAPI.Web/Clients/PersonalizationClient.cs
Sascha Kiefer b8a2190168
feat: allow to pass cancellation token to requests (#813)
* feat: implements markets API

* fix: use correct constructor name

* feat: allow to pass a cancellation token

* pass cancellation token

* pass cancellation token only >NETSTANDARD2_1

Co-authored-by: Jonas Dellinger <jonas@dellinger.dev>
2022-11-18 12:30:09 +01:00

37 lines
1.3 KiB
C#

using System.Threading;
using System.Threading.Tasks;
using SpotifyAPI.Web.Http;
using URLs = SpotifyAPI.Web.SpotifyUrls;
namespace SpotifyAPI.Web
{
public class PersonalizationClient : APIClient, IPersonalizationClient
{
public PersonalizationClient(IAPIConnector apiConnector) : base(apiConnector) { }
public Task<Paging<FullArtist>> GetTopArtists(CancellationToken cancel = default)
{
return API.Get<Paging<FullArtist>>(URLs.PersonalizationTop("artists"), cancel);
}
public Task<Paging<FullArtist>> GetTopArtists(PersonalizationTopRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNull(request, nameof(request));
return API.Get<Paging<FullArtist>>(URLs.PersonalizationTop("artists"), request.BuildQueryParams(), cancel);
}
public Task<Paging<FullTrack>> GetTopTracks(CancellationToken cancel = default)
{
return API.Get<Paging<FullTrack>>(URLs.PersonalizationTop("tracks"), cancel);
}
public Task<Paging<FullTrack>> GetTopTracks(PersonalizationTopRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNull(request, nameof(request));
return API.Get<Paging<FullTrack>>(URLs.PersonalizationTop("tracks"), request.BuildQueryParams(), cancel);
}
}
}