2022-11-18 11:30:09 +00:00
|
|
|
using System.Threading;
|
2020-05-01 19:05:28 +01:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using SpotifyAPI.Web.Http;
|
|
|
|
|
|
|
|
namespace SpotifyAPI.Web
|
|
|
|
{
|
|
|
|
public class UserProfileClient : APIClient, IUserProfileClient
|
|
|
|
{
|
|
|
|
public UserProfileClient(IAPIConnector apiConnector) : base(apiConnector) { }
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
public Task<PrivateUser> Current(CancellationToken cancel = default)
|
2020-05-01 19:05:28 +01:00
|
|
|
{
|
2022-11-18 11:30:09 +00:00
|
|
|
return API.Get<PrivateUser>(SpotifyUrls.Me(), cancel);
|
2020-05-01 19:05:28 +01:00
|
|
|
}
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
public Task<PublicUser> Get(string userId, CancellationToken cancel = default)
|
2020-05-01 19:05:28 +01:00
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNullOrEmptyString(userId, nameof(userId));
|
|
|
|
|
2022-11-18 11:30:09 +00:00
|
|
|
return API.Get<PublicUser>(SpotifyUrls.User(userId), cancel);
|
2020-05-01 19:05:28 +01:00
|
|
|
}
|
2024-01-19 18:56:07 +00:00
|
|
|
|
|
|
|
public Task<UsersTopTracksResponse> GetTopTracks(UsersTopItemsRequest request, CancellationToken cancel = default)
|
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNull(request, nameof(request));
|
|
|
|
|
|
|
|
return API.Get<UsersTopTracksResponse>(SpotifyUrls.TopTracks(), request.BuildQueryParams(), cancel);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public Task<UsersTopArtistsResponse> GetTopArtists(UsersTopItemsRequest request, CancellationToken cancel = default)
|
|
|
|
{
|
|
|
|
Ensure.ArgumentNotNull(request, nameof(request));
|
|
|
|
|
|
|
|
return API.Get<UsersTopArtistsResponse>(SpotifyUrls.TopArtists(), request.BuildQueryParams(), cancel);
|
|
|
|
}
|
2020-05-01 19:05:28 +01:00
|
|
|
}
|
|
|
|
}
|