Spotify.NET/SpotifyAPI.Web/Clients/ArtistsClient.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

57 lines
2.1 KiB
C#

using System.Threading;
using System.Threading.Tasks;
using SpotifyAPI.Web.Http;
using URLs = SpotifyAPI.Web.SpotifyUrls;
namespace SpotifyAPI.Web
{
public class ArtistsClient : APIClient, IArtistsClient
{
public ArtistsClient(IAPIConnector apiConnector) : base(apiConnector) { }
public Task<FullArtist> Get(string artistId, CancellationToken cancel = default)
{
Ensure.ArgumentNotNullOrEmptyString(artistId, nameof(artistId));
return API.Get<FullArtist>(URLs.Artist(artistId), cancel);
}
public Task<Paging<SimpleAlbum>> GetAlbums(string artistId, CancellationToken cancel = default)
{
Ensure.ArgumentNotNullOrEmptyString(artistId, nameof(artistId));
return API.Get<Paging<SimpleAlbum>>(URLs.ArtistAlbums(artistId), cancel);
}
public Task<Paging<SimpleAlbum>> GetAlbums(string artistId, ArtistsAlbumsRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNullOrEmptyString(artistId, nameof(artistId));
Ensure.ArgumentNotNull(request, nameof(request));
return API.Get<Paging<SimpleAlbum>>(URLs.ArtistAlbums(artistId), request.BuildQueryParams(), cancel);
}
public Task<ArtistsRelatedArtistsResponse> GetRelatedArtists(string artistId, CancellationToken cancel = default)
{
Ensure.ArgumentNotNullOrEmptyString(artistId, nameof(artistId));
return API.Get<ArtistsRelatedArtistsResponse>(URLs.ArtistRelatedArtists(artistId), cancel);
}
public Task<ArtistsResponse> GetSeveral(ArtistsRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNull(request, nameof(request));
return API.Get<ArtistsResponse>(URLs.Artists(), request.BuildQueryParams(), cancel);
}
public Task<ArtistsTopTracksResponse> GetTopTracks(string artistId, ArtistsTopTracksRequest request, CancellationToken cancel = default)
{
Ensure.ArgumentNotNullOrEmptyString(artistId, nameof(artistId));
Ensure.ArgumentNotNull(request, nameof(request));
return API.Get<ArtistsTopTracksResponse>(URLs.ArtistTopTracks(artistId), request.BuildQueryParams(), cancel);
}
}
}