mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-23 22:56:25 +00:00
* Fixing #607 + Refactoring Added me/episodes and done some refactoring * Fixing LibrarySaveEpisodesRequest #607 Fixing the remove of epsides. * Fixed some issues after review #608 * Fixing some small issues Co-authored-by: DEV-PBO-DEV <72922549+DEV-PBO-DEV@users.noreply.github.com>
This commit is contained in:
parent
8573070af7
commit
c4704abae4
@ -39,6 +39,16 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> RemoveShows(LibraryRemoveShowsRequest request);
|
Task<bool> RemoveShows(LibraryRemoveShowsRequest request);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Delete one or more episodes from current Spotify user’s library.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The request-model which contains required and optional parameters.</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// https://developer.spotify.com/documentation/web-api/reference/#endpoint-remove-episodes-user
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<bool> RemoveEpisodes(LibraryRemoveEpisodesRequest request);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Save one or more tracks to the current user’s ‘Your Music’ library.
|
/// Save one or more tracks to the current user’s ‘Your Music’ library.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -69,6 +79,16 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> SaveShows(LibrarySaveShowsRequest request);
|
Task<bool> SaveShows(LibrarySaveShowsRequest request);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Save one or more episodes to current Spotify user’s library.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The request-model which contains required and optional parameters.</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// https://developer.spotify.com/documentation/web-api/reference/#endpoint-save-episodes-user
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<bool> SaveEpisodes(LibrarySaveEpisodesRequest request);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if one or more tracks is already saved in the current Spotify user’s ‘Your Music’ library.
|
/// Check if one or more tracks is already saved in the current Spotify user’s ‘Your Music’ library.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -99,6 +119,16 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<bool>> CheckShows(LibraryCheckShowsRequest request);
|
Task<List<bool>> CheckShows(LibraryCheckShowsRequest request);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if one or more episodes is already saved in the current Spotify user’s library.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The request-model which contains required and optional parameters.</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// https://developer.spotify.com/documentation/web-api/reference/#endpoint-check-users-saved-episodes
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<bool>> CheckEpisodes(LibraryCheckEpisodesRequest request);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a list of the songs saved in the current Spotify user’s ‘Your Music’ library.
|
/// Get a list of the songs saved in the current Spotify user’s ‘Your Music’ library.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -157,5 +187,26 @@ namespace SpotifyAPI.Web
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<Paging<SavedShow>> GetShows(LibraryShowsRequest request);
|
Task<Paging<SavedShow>> GetShows(LibraryShowsRequest request);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a list of episodes saved in the current Spotify user’s library.
|
||||||
|
/// Optional parameters can be used to limit the number of shows returned.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-users-saved-episodes
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<Paging<SavedEpisodes>> GetEpisodes();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a list of episodes saved in the current Spotify user’s library.
|
||||||
|
/// Optional parameters can be used to limit the number of shows returned.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The request-model which contains required and optional parameters.</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-users-saved-episodes
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<Paging<SavedEpisodes>> GetEpisodes(LibraryEpisodesRequest request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,13 @@ namespace SpotifyAPI.Web
|
|||||||
return API.Get<List<bool>>(SpotifyUrls.LibraryTracksContains(), request.BuildQueryParams());
|
return API.Get<List<bool>>(SpotifyUrls.LibraryTracksContains(), request.BuildQueryParams());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task<List<bool>> CheckEpisodes(LibraryCheckEpisodesRequest request)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNull(request, nameof(request));
|
||||||
|
|
||||||
|
return API.Get<List<bool>>(SpotifyUrls.LibraryEpisodesContains(), request.BuildQueryParams());
|
||||||
|
}
|
||||||
|
|
||||||
public Task<Paging<SavedAlbum>> GetAlbums()
|
public Task<Paging<SavedAlbum>> GetAlbums()
|
||||||
{
|
{
|
||||||
return API.Get<Paging<SavedAlbum>>(SpotifyUrls.LibraryAlbums());
|
return API.Get<Paging<SavedAlbum>>(SpotifyUrls.LibraryAlbums());
|
||||||
@ -66,6 +73,18 @@ namespace SpotifyAPI.Web
|
|||||||
return API.Get<Paging<SavedTrack>>(SpotifyUrls.LibraryTracks(), request.BuildQueryParams());
|
return API.Get<Paging<SavedTrack>>(SpotifyUrls.LibraryTracks(), request.BuildQueryParams());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task<Paging<SavedEpisodes>> GetEpisodes()
|
||||||
|
{
|
||||||
|
return API.Get<Paging<SavedEpisodes>>(SpotifyUrls.LibraryEpisodes());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<Paging<SavedEpisodes>> GetEpisodes(LibraryEpisodesRequest request)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNull(request, nameof(request));
|
||||||
|
|
||||||
|
return API.Get<Paging<SavedEpisodes>>(SpotifyUrls.LibraryEpisodes(), request.BuildQueryParams());
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<bool> RemoveAlbums(LibraryRemoveAlbumsRequest request)
|
public async Task<bool> RemoveAlbums(LibraryRemoveAlbumsRequest request)
|
||||||
{
|
{
|
||||||
Ensure.ArgumentNotNull(request, nameof(request));
|
Ensure.ArgumentNotNull(request, nameof(request));
|
||||||
@ -90,6 +109,14 @@ namespace SpotifyAPI.Web
|
|||||||
return statusCode == HttpStatusCode.OK;
|
return statusCode == HttpStatusCode.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> RemoveEpisodes(LibraryRemoveEpisodesRequest request)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNull(request, nameof(request));
|
||||||
|
|
||||||
|
var statusCode = await API.Delete(SpotifyUrls.LibraryEpisodes(), null, request.BuildBodyParams()).ConfigureAwait(false);
|
||||||
|
return statusCode == HttpStatusCode.OK;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<bool> SaveAlbums(LibrarySaveAlbumsRequest request)
|
public async Task<bool> SaveAlbums(LibrarySaveAlbumsRequest request)
|
||||||
{
|
{
|
||||||
Ensure.ArgumentNotNull(request, nameof(request));
|
Ensure.ArgumentNotNull(request, nameof(request));
|
||||||
@ -113,5 +140,13 @@ namespace SpotifyAPI.Web
|
|||||||
var statusCode = await API.Put(SpotifyUrls.LibraryTracks(), request.BuildQueryParams(), null).ConfigureAwait(false);
|
var statusCode = await API.Put(SpotifyUrls.LibraryTracks(), request.BuildQueryParams(), null).ConfigureAwait(false);
|
||||||
return statusCode == HttpStatusCode.OK;
|
return statusCode == HttpStatusCode.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> SaveEpisodes(LibrarySaveEpisodesRequest request)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNull(request, nameof(request));
|
||||||
|
|
||||||
|
var statusCode = await API.Put(SpotifyUrls.LibraryEpisodes(), request.BuildQueryParams(), null).ConfigureAwait(false);
|
||||||
|
return statusCode == HttpStatusCode.OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
25
SpotifyAPI.Web/Models/Request/LibraryCheckEpisodesRequest.cs
Normal file
25
SpotifyAPI.Web/Models/Request/LibraryCheckEpisodesRequest.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SpotifyAPI.Web
|
||||||
|
{
|
||||||
|
public class LibraryCheckEpisodesRequest : RequestParams
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids">A comma-separated list of the Spotify IDs for the shows. Maximum: 50 ids.</param>
|
||||||
|
public LibraryCheckEpisodesRequest(IList<string> ids)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNull(ids, nameof(ids));
|
||||||
|
|
||||||
|
Ids = ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A comma-separated list of the Spotify IDs for the shows. Maximum: 50 ids.
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
[QueryParam("ids")]
|
||||||
|
public IList<string> Ids { get; }
|
||||||
|
}
|
||||||
|
}
|
28
SpotifyAPI.Web/Models/Request/LibraryEpisodesRequest.cs
Normal file
28
SpotifyAPI.Web/Models/Request/LibraryEpisodesRequest.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
namespace SpotifyAPI.Web
|
||||||
|
{
|
||||||
|
public class LibraryEpisodesRequest : RequestParams
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum number of episodes to return. Default: 20. Minimum: 1. Maximum: 50
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
[QueryParam("limit")]
|
||||||
|
public int? Limit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The index of the first episode to return. Default: 0 (the first object).
|
||||||
|
/// Use with limit to get the next set of episodes.
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
[QueryParam("offset")]
|
||||||
|
public int? Offset { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An ISO 3166-1 alpha-2 country code or the string from_token.
|
||||||
|
/// Provide this parameter if you want to apply Track Relinking.
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
[QueryParam("market")]
|
||||||
|
public string? Market { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SpotifyAPI.Web
|
||||||
|
{
|
||||||
|
public class LibraryRemoveEpisodesRequest : RequestParams
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids">
|
||||||
|
/// A comma-separated list of Spotify IDs for the shows to be deleted from the user’s library.
|
||||||
|
/// </param>
|
||||||
|
public LibraryRemoveEpisodesRequest(IList<string> ids)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyList(ids, nameof(ids));
|
||||||
|
|
||||||
|
Ids = ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A comma-separated list of Spotify IDs for the shows to be deleted from the user’s library.
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
[BodyParam("ids")]
|
||||||
|
public IList<string> Ids { get; }
|
||||||
|
}
|
||||||
|
}
|
26
SpotifyAPI.Web/Models/Request/LibrarySaveEpisodesRequest.cs
Normal file
26
SpotifyAPI.Web/Models/Request/LibrarySaveEpisodesRequest.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SpotifyAPI.Web
|
||||||
|
{
|
||||||
|
public class LibrarySaveEpisodesRequest : RequestParams
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Request for SaveEpisodes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
public LibrarySaveEpisodesRequest(IList<string> ids)
|
||||||
|
{
|
||||||
|
Ensure.ArgumentNotNullOrEmptyList(ids, nameof(ids));
|
||||||
|
|
||||||
|
Ids = ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A comma-separated list of the Spotify IDs.
|
||||||
|
/// Maximum: 50 IDs.
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
[QueryParam("ids")]
|
||||||
|
public IList<string> Ids { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace SpotifyAPI.Web
|
namespace SpotifyAPI.Web
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web
|
namespace SpotifyAPI.Web
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace SpotifyAPI.Web
|
namespace SpotifyAPI.Web
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace SpotifyAPI.Web
|
namespace SpotifyAPI.Web
|
||||||
{
|
{
|
||||||
|
10
SpotifyAPI.Web/Models/Response/SavedEpisodes.cs
Normal file
10
SpotifyAPI.Web/Models/Response/SavedEpisodes.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace SpotifyAPI.Web
|
||||||
|
{
|
||||||
|
public class SavedEpisodes
|
||||||
|
{
|
||||||
|
public DateTime AddedAt { get; set; }
|
||||||
|
public FullEpisode Episode { get; set; } = default!;
|
||||||
|
}
|
||||||
|
}
|
@ -125,6 +125,10 @@ namespace SpotifyAPI.Web
|
|||||||
|
|
||||||
public static Uri LibraryShows() => EUri($"me/shows");
|
public static Uri LibraryShows() => EUri($"me/shows");
|
||||||
|
|
||||||
|
public static Uri LibraryEpisodes() => EUri($"me/episodes");
|
||||||
|
|
||||||
|
public static Uri LibraryEpisodesContains() => EUri($"me/episodes/contains");
|
||||||
|
|
||||||
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