feat: implements markets API (#787)

* feat: implements markets API

* fix: use correct constructor name
This commit is contained in:
Sascha Kiefer 2022-08-11 08:54:09 +02:00 committed by GitHub
parent 7acffd96ba
commit d363789d42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,19 @@
using System.Threading.Tasks;
namespace SpotifyAPI.Web
{
/// <summary>
/// Markets Endpoints
/// </summary>
public interface IMarketsClient
{
/// <summary>
/// Get the list of markets where Spotify is available.
/// </summary>
/// <remarks>
/// https://developer.spotify.com/documentation/web-api/reference/#/operations/get-available-markets
/// </remarks>
/// <returns></returns>
Task<AvailableMarketsResponse> AvailableMarkets();
}
}

View File

@ -0,0 +1,16 @@
using System.Threading.Tasks;
using SpotifyAPI.Web.Http;
using URLs = SpotifyAPI.Web.SpotifyUrls;
namespace SpotifyAPI.Web
{
public class MarketsClient : APIClient, IMarketsClient
{
public MarketsClient(IAPIConnector apiConnector) : base(apiConnector) { }
public Task<AvailableMarketsResponse> AvailableMarkets()
{
return API.Get<AvailableMarketsResponse>(URLs.Markets());
}
}
}

View File

@ -49,6 +49,7 @@ namespace SpotifyAPI.Web
Personalization = new PersonalizationClient(_apiConnector);
Episodes = new EpisodesClient(_apiConnector);
Library = new LibraryClient(_apiConnector);
Markets = new MarketsClient(_apiConnector);
}
public IPaginator DefaultPaginator { get; }
@ -79,6 +80,8 @@ namespace SpotifyAPI.Web
public ILibraryClient Library { get; }
public IMarketsClient Markets { get; }
public IResponse? LastResponse { get; private set; }
/// <summary>

View File

@ -0,0 +1,10 @@
using System.Collections.Generic;
namespace SpotifyAPI.Web
{
public class AvailableMarketsResponse
{
public List<string> Markets { get; set; } = default!;
}
}

View File

@ -129,6 +129,8 @@ namespace SpotifyAPI.Web
public static Uri LibraryEpisodesContains() => EUri($"me/episodes/contains");
public static Uri Markets() => EUri($"markets");
private static Uri EUri(FormattableString path) => new(path.ToString(_provider), UriKind.Relative);
}
}