Skip to content

Commit 8c2612e

Browse files
committed
feat: add playlist create method without userId
1 parent 38a743f commit 8c2612e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

SpotifyAPI.Web/Clients/Interfaces/IPlaylistsClient.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ public interface IPlaylistsClient
6161
[Obsolete("Use GetPlaylistItems instead, which uses the new GET /playlists/{id}/items endpoint.")]
6262
Task<Paging<PlaylistTrack<IPlayableItem>>> GetItems(string playlistId, PlaylistGetItemsRequest request, CancellationToken cancel = default);
6363

64+
/// <summary>
65+
/// Create a playlist for the current user. (The playlist will be empty until you add tracks.)
66+
/// </summary>
67+
/// <param name="request">The request-model which contains required and optional parameters.</param>
68+
/// <param name="cancel">The cancellation-token to allow to cancel the request.</param>
69+
/// <remarks>
70+
/// https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-create-playlist
71+
/// </remarks>
72+
/// <returns></returns>
73+
Task<FullPlaylist> Create(PlaylistCreateRequest request, CancellationToken cancel = default);
74+
6475
/// <summary>
6576
/// Create a playlist for a Spotify user. (The playlist will be empty until you add tracks.)
6677
/// </summary>

SpotifyAPI.Web/Clients/PlaylistsClient.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ public Task<Paging<PlaylistTrack<IPlayableItem>>> GetItems(string playlistId, Pl
4646
return API.Get<Paging<PlaylistTrack<IPlayableItem>>>(URLs.PlaylistTracks(playlistId), request.BuildQueryParams(), cancel);
4747
}
4848

49+
public Task<FullPlaylist> Create(PlaylistCreateRequest request, CancellationToken cancel = default)
50+
{
51+
Ensure.ArgumentNotNull(request, nameof(request));
52+
53+
return API.Post<FullPlaylist>(URLs.CurrentUserPlaylists(), null, request.BuildBodyParams(), cancel);
54+
}
55+
4956
[System.Obsolete("This endpoint (POST /users/{user_id}/playlists) has been removed. Use POST /me/playlists instead.")]
5057
public Task<FullPlaylist> Create(string userId, PlaylistCreateRequest request, CancellationToken cancel = default)
5158
{

0 commit comments

Comments
 (0)