From 8074ff63318efcfc56cb1b1e686bd10e61afab5a Mon Sep 17 00:00:00 2001 From: Jonas Dellinger Date: Sat, 2 May 2020 13:52:01 +0200 Subject: [PATCH] Added RecommendationGenres and NewReleases --- SpotifyAPI.Web/Clients/BrowseClient.cs | 17 +++++++++++++++++ .../Clients/Interfaces/IBrowseClient.cs | 4 ++++ .../Models/Request/NewReleasesRequest.cs | 14 ++++++++++++++ .../Models/Response/NewReleasesResponse.cs | 8 ++++++++ .../Response/RecommendationGenresResponse.cs | 9 +++++++++ SpotifyAPI.Web/SpotifyUrls.cs | 4 ++++ 6 files changed, 56 insertions(+) create mode 100644 SpotifyAPI.Web/Models/Request/NewReleasesRequest.cs create mode 100644 SpotifyAPI.Web/Models/Response/NewReleasesResponse.cs create mode 100644 SpotifyAPI.Web/Models/Response/RecommendationGenresResponse.cs diff --git a/SpotifyAPI.Web/Clients/BrowseClient.cs b/SpotifyAPI.Web/Clients/BrowseClient.cs index 7d88dbe6..646d4eae 100644 --- a/SpotifyAPI.Web/Clients/BrowseClient.cs +++ b/SpotifyAPI.Web/Clients/BrowseClient.cs @@ -58,5 +58,22 @@ namespace SpotifyAPI.Web return API.Get(URLs.Recommendations(), request.BuildQueryParams()); } + + public Task GetRecommendationGenres() + { + return API.Get(URLs.Recommendations()); + } + + public Task GetNewReleases() + { + return API.Get(URLs.NewReleases()); + } + + public Task GetNewReleases(NewReleasesRequest request) + { + Ensure.ArgumentNotNull(request, nameof(request)); + + return API.Get(URLs.NewReleases(), request.BuildQueryParams()); + } } } diff --git a/SpotifyAPI.Web/Clients/Interfaces/IBrowseClient.cs b/SpotifyAPI.Web/Clients/Interfaces/IBrowseClient.cs index d010a252..f46d8858 100644 --- a/SpotifyAPI.Web/Clients/Interfaces/IBrowseClient.cs +++ b/SpotifyAPI.Web/Clients/Interfaces/IBrowseClient.cs @@ -14,5 +14,9 @@ namespace SpotifyAPI.Web Task GetCategoryPlaylists(string categoryId, CategoriesPlaylistsRequest request); Task GetRecommendations(RecommendationsRequest request); + Task GetRecommendationGenres(); + + Task GetNewReleases(); + Task GetNewReleases(NewReleasesRequest request); } } diff --git a/SpotifyAPI.Web/Models/Request/NewReleasesRequest.cs b/SpotifyAPI.Web/Models/Request/NewReleasesRequest.cs new file mode 100644 index 00000000..dc20a39b --- /dev/null +++ b/SpotifyAPI.Web/Models/Request/NewReleasesRequest.cs @@ -0,0 +1,14 @@ +namespace SpotifyAPI.Web +{ + public class NewReleasesRequest : RequestParams + { + [QueryParam("country")] + public string Country { get; set; } + + [QueryParam("limit")] + public int? Limit { get; set; } + + [QueryParam("offset")] + public int? Offset { get; set; } + } +} diff --git a/SpotifyAPI.Web/Models/Response/NewReleasesResponse.cs b/SpotifyAPI.Web/Models/Response/NewReleasesResponse.cs new file mode 100644 index 00000000..4a83a609 --- /dev/null +++ b/SpotifyAPI.Web/Models/Response/NewReleasesResponse.cs @@ -0,0 +1,8 @@ +namespace SpotifyAPI.Web +{ + public class NewReleasesResponse + { + public string Message { get; set; } + public Paging Albums { get; set; } + } +} diff --git a/SpotifyAPI.Web/Models/Response/RecommendationGenresResponse.cs b/SpotifyAPI.Web/Models/Response/RecommendationGenresResponse.cs new file mode 100644 index 00000000..9e4b2c8e --- /dev/null +++ b/SpotifyAPI.Web/Models/Response/RecommendationGenresResponse.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace SpotifyAPI.Web +{ + public class RecommendationGenresResponse + { + public List Genres { get; set; } + } +} diff --git a/SpotifyAPI.Web/SpotifyUrls.cs b/SpotifyAPI.Web/SpotifyUrls.cs index 889c5296..58c52741 100644 --- a/SpotifyAPI.Web/SpotifyUrls.cs +++ b/SpotifyAPI.Web/SpotifyUrls.cs @@ -19,6 +19,10 @@ namespace SpotifyAPI.Web public static Uri Recommendations() => EUri($"recommendations"); + public static Uri RecommendationGenres() => EUri($"recommendations/available-genre-seeds"); + + public static Uri NewReleases() => EUri($"browse/new-releases"); + private static Uri EUri(FormattableString path) => new Uri(path.ToString(_provider), UriKind.Relative); } }