mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-23 14:46:26 +00:00
feat: implements markets API (#787)
* feat: implements markets API * fix: use correct constructor name
This commit is contained in:
parent
7acffd96ba
commit
d363789d42
19
SpotifyAPI.Web/Clients/Interfaces/IMarketsClient.cs
Normal file
19
SpotifyAPI.Web/Clients/Interfaces/IMarketsClient.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
16
SpotifyAPI.Web/Clients/MarketsClient.cs
Normal file
16
SpotifyAPI.Web/Clients/MarketsClient.cs
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -49,6 +49,7 @@ namespace SpotifyAPI.Web
|
|||||||
Personalization = new PersonalizationClient(_apiConnector);
|
Personalization = new PersonalizationClient(_apiConnector);
|
||||||
Episodes = new EpisodesClient(_apiConnector);
|
Episodes = new EpisodesClient(_apiConnector);
|
||||||
Library = new LibraryClient(_apiConnector);
|
Library = new LibraryClient(_apiConnector);
|
||||||
|
Markets = new MarketsClient(_apiConnector);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPaginator DefaultPaginator { get; }
|
public IPaginator DefaultPaginator { get; }
|
||||||
@ -79,6 +80,8 @@ namespace SpotifyAPI.Web
|
|||||||
|
|
||||||
public ILibraryClient Library { get; }
|
public ILibraryClient Library { get; }
|
||||||
|
|
||||||
|
public IMarketsClient Markets { get; }
|
||||||
|
|
||||||
public IResponse? LastResponse { get; private set; }
|
public IResponse? LastResponse { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
10
SpotifyAPI.Web/Models/Response/AvailableMarketsResponse.cs
Normal file
10
SpotifyAPI.Web/Models/Response/AvailableMarketsResponse.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SpotifyAPI.Web
|
||||||
|
{
|
||||||
|
public class AvailableMarketsResponse
|
||||||
|
{
|
||||||
|
public List<string> Markets { get; set; } = default!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -129,6 +129,8 @@ namespace SpotifyAPI.Web
|
|||||||
|
|
||||||
public static Uri LibraryEpisodesContains() => EUri($"me/episodes/contains");
|
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);
|
private static Uri EUri(FormattableString path) => new(path.ToString(_provider), UriKind.Relative);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user