Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: implements markets API #787

Merged
merged 2 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions SpotifyAPI.Web/Clients/Interfaces/IMarketsClient.cs
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions SpotifyAPI.Web/Clients/MarketsClient.cs
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
3 changes: 3 additions & 0 deletions SpotifyAPI.Web/Clients/SpotifyClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public SpotifyClient(SpotifyClientConfig config)
Personalization = new PersonalizationClient(_apiConnector);
Episodes = new EpisodesClient(_apiConnector);
Library = new LibraryClient(_apiConnector);
Markets = new MarketsClient(_apiConnector);
}

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

public ILibraryClient Library { get; }

public IMarketsClient Markets { get; }

public IResponse? LastResponse { get; private set; }

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions SpotifyAPI.Web/Models/Response/AvailableMarketsResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;

namespace SpotifyAPI.Web
{
public class AvailableMarketsResponse
{
public List<string> Markets { get; set; } = default!;
}
}

2 changes: 2 additions & 0 deletions SpotifyAPI.Web/SpotifyUrls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public static class SpotifyUrls

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);
}
}