Skip to content

Commit 7b0952c

Browse files
committed
fix: Use new request model for RemovePlaylistItems
Now using `items` instead of the old `tracks`. Fixes #1039
1 parent 8c2612e commit 7b0952c

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

‎SpotifyAPI.Web/Clients/Interfaces/IPlaylistsClient.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public interface IPlaylistsClient
263263
/// https://developer.spotify.com/documentation/web-api/reference/remove-items-playlist
264264
/// </remarks>
265265
/// <returns></returns>
266-
Task<SnapshotResponse> RemovePlaylistItems(string playlistId, PlaylistRemoveItemsRequest request, CancellationToken cancel = default);
266+
Task<SnapshotResponse> RemovePlaylistItems(string playlistId, PlaylistRemoveItemsRequestV2 request, CancellationToken cancel = default);
267267

268268
/// <summary>
269269
/// Either reorder or replace items in a playlist.

‎SpotifyAPI.Web/Clients/PlaylistsClient.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public Task<Paging<PlaylistTrack<IPlayableItem>>> GetPlaylistItems(string playli
172172
return API.Get<Paging<PlaylistTrack<IPlayableItem>>>(URLs.PlaylistItems(playlistId), request.BuildQueryParams(), cancel);
173173
}
174174

175-
public Task<SnapshotResponse> RemovePlaylistItems(string playlistId, PlaylistRemoveItemsRequest request, CancellationToken cancel = default)
175+
public Task<SnapshotResponse> RemovePlaylistItems(string playlistId, PlaylistRemoveItemsRequestV2 request, CancellationToken cancel = default)
176176
{
177177
Ensure.ArgumentNotNullOrEmptyString(playlistId, nameof(playlistId));
178178
Ensure.ArgumentNotNull(request, nameof(request));
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
4+
namespace SpotifyAPI.Web
5+
{
6+
public class PlaylistRemoveItemsRequestV2 : RequestParams
7+
{
8+
/// <summary>
9+
/// An array of objects containing Spotify URIs of the tracks or episodes to remove.
10+
/// For example: { "items": [{ "uri": "spotify:track:4iV5W9uYEdYUVa79Axb7Rh" },
11+
/// { "uri": "spotify:track:1301WleyT98MSxVHPZCA6M" }] }.
12+
/// A maximum of 100 objects can be sent at once.
13+
/// </summary>
14+
/// <value></value>
15+
[BodyParam("items")]
16+
public IList<Item>? Items { get; set; }
17+
18+
/// <summary>
19+
/// The playlist’s snapshot ID against which you want to make the changes.
20+
/// The API will validate that the specified items exist and in the specified positions and make the changes,
21+
/// even if more recent changes have been made to the playlist.
22+
/// </summary>
23+
/// <value></value>
24+
[BodyParam("snapshot_id")]
25+
public string? SnapshotId { get; set; }
26+
27+
public class Item
28+
{
29+
[JsonProperty("uri", NullValueHandling = NullValueHandling.Ignore)]
30+
public string? Uri { get; set; }
31+
}
32+
}
33+
}
34+

0 commit comments

Comments
 (0)