Skip to content

Commit d363789

Browse files
authored
feat: implements markets API (#787)
* feat: implements markets API * fix: use correct constructor name
1 parent 7acffd9 commit d363789

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Threading.Tasks;
2+
3+
namespace SpotifyAPI.Web
4+
{
5+
/// <summary>
6+
/// Markets Endpoints
7+
/// </summary>
8+
public interface IMarketsClient
9+
{
10+
/// <summary>
11+
/// Get the list of markets where Spotify is available.
12+
/// </summary>
13+
/// <remarks>
14+
/// https://developer.spotify.com/documentation/web-api/reference/#/operations/get-available-markets
15+
/// </remarks>
16+
/// <returns></returns>
17+
Task<AvailableMarketsResponse> AvailableMarkets();
18+
}
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Threading.Tasks;
2+
using SpotifyAPI.Web.Http;
3+
using URLs = SpotifyAPI.Web.SpotifyUrls;
4+
5+
namespace SpotifyAPI.Web
6+
{
7+
public class MarketsClient : APIClient, IMarketsClient
8+
{
9+
public MarketsClient(IAPIConnector apiConnector) : base(apiConnector) { }
10+
11+
public Task<AvailableMarketsResponse> AvailableMarkets()
12+
{
13+
return API.Get<AvailableMarketsResponse>(URLs.Markets());
14+
}
15+
}
16+
}

SpotifyAPI.Web/Clients/SpotifyClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public SpotifyClient(SpotifyClientConfig config)
4949
Personalization = new PersonalizationClient(_apiConnector);
5050
Episodes = new EpisodesClient(_apiConnector);
5151
Library = new LibraryClient(_apiConnector);
52+
Markets = new MarketsClient(_apiConnector);
5253
}
5354

5455
public IPaginator DefaultPaginator { get; }
@@ -79,6 +80,8 @@ public SpotifyClient(SpotifyClientConfig config)
7980

8081
public ILibraryClient Library { get; }
8182

83+
public IMarketsClient Markets { get; }
84+
8285
public IResponse? LastResponse { get; private set; }
8386

8487
/// <summary>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Collections.Generic;
2+
3+
namespace SpotifyAPI.Web
4+
{
5+
public class AvailableMarketsResponse
6+
{
7+
public List<string> Markets { get; set; } = default!;
8+
}
9+
}
10+

SpotifyAPI.Web/SpotifyUrls.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ public static class SpotifyUrls
129129

130130
public static Uri LibraryEpisodesContains() => EUri($"me/episodes/contains");
131131

132+
public static Uri Markets() => EUri($"markets");
133+
132134
private static Uri EUri(FormattableString path) => new(path.ToString(_provider), UriKind.Relative);
133135
}
134136
}

0 commit comments

Comments
 (0)