Spotify.NET/SpotifyAPI.Web/Clients/UserProfileClient.cs
Noel Griffin a27c3729c8
Add Users Top Tracks / Users Top Artists to UserClient (#938)
* add top tracks & artists endpoints

* fix file extenstion

* added TODO

* Add Methods to interface

* Add Top items query class

* implement query into UserProfileClient.cs - Top Requests

* Tidy Up Naming

* Removed random json file change

* Added Tests.

* run formatter

* remove additional namespace

---------

Co-authored-by: Jonas Dellinger <jonas@dellinger.dev>
2024-01-19 19:56:07 +01:00

39 lines
1.2 KiB
C#

using System.Threading;
using System.Threading.Tasks;
using SpotifyAPI.Web.Http;
namespace SpotifyAPI.Web
{
public class UserProfileClient : APIClient, IUserProfileClient
{
public UserProfileClient(IAPIConnector apiConnector) : base(apiConnector) { }
public Task<PrivateUser> Current(CancellationToken cancel = default)
{
return API.Get<PrivateUser>(SpotifyUrls.Me(), cancel);
}
public Task<PublicUser> Get(string userId, CancellationToken cancel = default)
{
Ensure.ArgumentNotNullOrEmptyString(userId, nameof(userId));
return API.Get<PublicUser>(SpotifyUrls.User(userId), cancel);
}
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);
}
}
}