2022-11-18 11:30:09 +00:00
|
|
|
using System.Threading;
|
2020-05-07 21:33:29 +01:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using SpotifyAPI.Web.Http;
|
|
|
|
using URLs = SpotifyAPI.Web.SpotifyUrls;
|
|
|
|
|
|
|
|
namespace SpotifyAPI.Web
|
|
|
|
{
|
|
|
|
public class AlbumsClient : APIClient, IAlbumsClient
|
|
|
|
{
|
|
|
|
public AlbumsClient(IAPIConnector apiConnector) : base(apiConnector) { }
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
public Task<FullAlbum> Get(string albumId, CancellationToken cancel = default)
|
2020-05-07 21:33:29 +01:00
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNullOrEmptyString(albumId, nameof(albumId));
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
return API.Get<FullAlbum>(URLs.Album(albumId),cancel);
|
2020-05-07 21:33:29 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
public Task<FullAlbum> Get(string albumId, AlbumRequest request, CancellationToken cancel = default)
|
2020-05-07 21:33:29 +01:00
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNullOrEmptyString(albumId, nameof(albumId));
|
|
|
|
Ensure.ArgumentNotNull(request, nameof(request));
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
return API.Get<FullAlbum>(URLs.Album(albumId), request.BuildQueryParams(), cancel);
|
2020-05-07 21:33:29 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
public Task<AlbumsResponse> GetSeveral(AlbumsRequest request, CancellationToken cancel = default)
|
2020-05-07 21:33:29 +01:00
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNull(request, nameof(request));
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
return API.Get<AlbumsResponse>(URLs.Albums(), request.BuildQueryParams(), cancel);
|
2020-05-07 21:33:29 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
public Task<Paging<SimpleTrack>> GetTracks(string albumId, CancellationToken cancel = default)
|
2020-05-07 21:33:29 +01:00
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNullOrEmptyString(albumId, nameof(albumId));
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
return API.Get<Paging<SimpleTrack>>(URLs.AlbumTracks(albumId), cancel);
|
2020-05-07 21:33:29 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
public Task<Paging<SimpleTrack>> GetTracks(string albumId, AlbumTracksRequest request, CancellationToken cancel = default)
|
2020-05-07 21:33:29 +01:00
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNullOrEmptyString(albumId, nameof(albumId));
|
|
|
|
Ensure.ArgumentNotNull(request, nameof(request));
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
return API.Get<Paging<SimpleTrack>>(URLs.AlbumTracks(albumId), request.BuildQueryParams(), cancel);
|
2020-05-07 21:33:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|