2022-11-18 11:30:09 +00:00
|
|
|
using System.Threading;
|
2020-05-07 12:48:31 +01:00
|
|
|
using System.Threading.Tasks;
|
2020-05-04 22:04:59 +01:00
|
|
|
using SpotifyAPI.Web.Http;
|
2020-05-07 12:48:31 +01:00
|
|
|
using URLs = SpotifyAPI.Web.SpotifyUrls;
|
2020-05-04 22:04:59 +01:00
|
|
|
|
|
|
|
namespace SpotifyAPI.Web
|
|
|
|
{
|
|
|
|
public class TracksClient : APIClient, ITracksClient
|
|
|
|
{
|
|
|
|
public TracksClient(IAPIConnector apiConnector) : base(apiConnector) { }
|
2020-05-07 12:48:31 +01:00
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
public Task<FullTrack> Get(string trackId, CancellationToken cancel = default)
|
2020-05-07 12:48:31 +01:00
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNullOrEmptyString(trackId, nameof(trackId));
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
return API.Get<FullTrack>(URLs.Track(trackId), cancel);
|
2020-05-07 12:48:31 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
public Task<FullTrack> Get(string trackId, TrackRequest request, CancellationToken cancel = default)
|
2020-05-07 12:48:31 +01:00
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNullOrEmptyString(trackId, nameof(trackId));
|
|
|
|
Ensure.ArgumentNotNull(request, nameof(request));
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
return API.Get<FullTrack>(URLs.Track(trackId), request.BuildQueryParams(), cancel);
|
2020-05-07 12:48:31 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
public Task<TrackAudioAnalysis> GetAudioAnalysis(string trackId, CancellationToken cancel = default)
|
2020-05-07 12:48:31 +01:00
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNullOrEmptyString(trackId, nameof(trackId));
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
return API.Get<TrackAudioAnalysis>(URLs.AudioAnalysis(trackId), cancel);
|
2020-05-07 12:48:31 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
public Task<TrackAudioFeatures> GetAudioFeatures(string trackId, CancellationToken cancel = default)
|
2020-05-07 12:48:31 +01:00
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNullOrEmptyString(trackId, nameof(trackId));
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
return API.Get<TrackAudioFeatures>(URLs.AudioFeatures(trackId), cancel);
|
2020-05-07 12:48:31 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
public Task<TracksResponse> GetSeveral(TracksRequest request, CancellationToken cancel = default)
|
2020-05-07 12:48:31 +01:00
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNull(request, nameof(request));
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
return API.Get<TracksResponse>(URLs.Tracks(), request.BuildQueryParams(), cancel);
|
2020-05-07 12:48:31 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
public Task<TracksAudioFeaturesResponse> GetSeveralAudioFeatures(TracksAudioFeaturesRequest request, CancellationToken cancel = default)
|
2020-05-07 12:48:31 +01:00
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNull(request, nameof(request));
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
return API.Get<TracksAudioFeaturesResponse>(URLs.AudioFeatures(), request.BuildQueryParams(), cancel);
|
2020-05-07 12:48:31 +01:00
|
|
|
}
|
2020-05-04 22:04:59 +01:00
|
|
|
}
|
|
|
|
}
|