diff --git a/SpotifyAPI.Web/SpotifyWebAPI.cs b/SpotifyAPI.Web/SpotifyWebAPI.cs index 2e31b33e..53a967d7 100644 --- a/SpotifyAPI.Web/SpotifyWebAPI.cs +++ b/SpotifyAPI.Web/SpotifyWebAPI.cs @@ -1319,6 +1319,7 @@ namespace SpotifyAPI.Web /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. /// /// AUTH NEEDED + [Obsolete("Calling GetPlaylist with a userId is deprecated, remove the parameter")] public FullPlaylist GetPlaylist(string userId, string playlistId, string fields = "", string market = "") { if (!UseAuth) @@ -1326,6 +1327,24 @@ namespace SpotifyAPI.Web return DownloadData(_builder.GetPlaylist(userId, playlistId, fields, market)); } + /// + /// Get a playlist owned by a Spotify user. + /// + /// The Spotify ID for the playlist. + /// + /// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are + /// returned. + /// + /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. + /// + /// AUTH NEEDED + public FullPlaylist GetPlaylist(string playlistId, string fields = "", string market = "") + { + if (!UseAuth) + throw new InvalidOperationException("Auth is required for GetPlaylist"); + return DownloadData(_builder.GetPlaylist(playlistId, fields, market)); + } + /// /// Get a playlist owned by a Spotify user asynchronously. /// @@ -1338,6 +1357,7 @@ namespace SpotifyAPI.Web /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. /// /// AUTH NEEDED + [Obsolete("Calling GetPlaylist with a userId is deprecated, remove the parameter")] public Task GetPlaylistAsync(string userId, string playlistId, string fields = "", string market = "") { if (!UseAuth) @@ -1345,6 +1365,24 @@ namespace SpotifyAPI.Web return DownloadDataAsync(_builder.GetPlaylist(userId, playlistId, fields, market)); } + /// + /// Get a playlist owned by a Spotify user asynchronously. + /// + /// The Spotify ID for the playlist. + /// + /// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are + /// returned. + /// + /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. + /// + /// AUTH NEEDED + public Task GetPlaylistAsync(string playlistId, string fields = "", string market = "") + { + if (!UseAuth) + throw new InvalidOperationException("Auth is required for GetPlaylist"); + return DownloadDataAsync(_builder.GetPlaylist(playlistId, fields, market)); + } + /// /// Get full details of the tracks of a playlist owned by a Spotify user. /// @@ -1359,6 +1397,7 @@ namespace SpotifyAPI.Web /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. /// /// AUTH NEEDED + [Obsolete("Calling GetPlaylistTracks with a userId is deprecated, remove the parameter")] public Paging GetPlaylistTracks(string userId, string playlistId, string fields = "", int limit = 100, int offset = 0, string market = "") { if (!UseAuth) @@ -1366,6 +1405,26 @@ namespace SpotifyAPI.Web return DownloadData>(_builder.GetPlaylistTracks(userId, playlistId, fields, limit, offset, market)); } + /// + /// Get full details of the tracks of a playlist owned by a Spotify user. + /// + /// The Spotify ID for the playlist. + /// + /// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are + /// returned. + /// + /// The maximum number of tracks to return. Default: 100. Minimum: 1. Maximum: 100. + /// The index of the first object to return. Default: 0 (i.e., the first object) + /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. + /// + /// AUTH NEEDED + public Paging GetPlaylistTracks(string playlistId, string fields = "", int limit = 100, int offset = 0, string market = "") + { + if (!UseAuth) + throw new InvalidOperationException("Auth is required for GetPlaylistTracks"); + return DownloadData>(_builder.GetPlaylistTracks(playlistId, fields, limit, offset, market)); + } + /// /// Get full details of the tracks of a playlist owned by a Spotify user asyncronously. /// @@ -1380,6 +1439,7 @@ namespace SpotifyAPI.Web /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. /// /// AUTH NEEDED + [Obsolete("Calling GetPlaylistTracks with a userId is deprecated, remove the parameter")] public Task> GetPlaylistTracksAsync(string userId, string playlistId, string fields = "", int limit = 100, int offset = 0, string market = "") { if (!UseAuth) @@ -1387,6 +1447,27 @@ namespace SpotifyAPI.Web return DownloadDataAsync>(_builder.GetPlaylistTracks(userId, playlistId, fields, limit, offset, market)); } + /// + /// Get full details of the tracks of a playlist owned by a Spotify user asyncronously. + /// + /// The Spotify ID for the playlist. + /// + /// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are + /// returned. + /// + /// The maximum number of tracks to return. Default: 100. Minimum: 1. Maximum: 100. + /// The index of the first object to return. Default: 0 (i.e., the first object) + /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. + /// + /// AUTH NEEDED + [Obsolete("Calling GetPlaylistTracks with a userId is deprecated, remove the parameter")] + public Task> GetPlaylistTracksAsync(string playlistId, string fields = "", int limit = 100, int offset = 0, string market = "") + { + if (!UseAuth) + throw new InvalidOperationException("Auth is required for GetPlaylistTracks"); + return DownloadDataAsync>(_builder.GetPlaylistTracks(playlistId, fields, limit, offset, market)); + } + /// /// Create a playlist for a Spotify user. (The playlist will be empty until you add tracks.) /// @@ -1457,6 +1538,7 @@ namespace SpotifyAPI.Web /// Value for playlist description as displayed in Spotify Clients and in the Web API. /// /// AUTH NEEDED + [Obsolete("Calling UpdatePlaylist with a userId is deprecated, remove the parameter")] public ErrorResponse UpdatePlaylist(string userId, string playlistId, string newName = null, bool? newPublic = null, bool? newCollaborative = null, string newDescription = null) { JObject body = new JObject(); @@ -1471,6 +1553,31 @@ namespace SpotifyAPI.Web return UploadData(_builder.UpdatePlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse(); } + /// + /// Change a playlist’s name and public/private state. (The user must, of course, own the playlist.) + /// + /// The Spotify ID for the playlist. + /// The new name for the playlist, for example "My New Playlist Title". + /// If true the playlist will be public, if false it will be private. + /// If true the playlist will become collaborative and other users will be able to modify the playlist in their Spotify client. + /// Note: You can only set collaborative to true on non-public playlists. + /// Value for playlist description as displayed in Spotify Clients and in the Web API. + /// + /// AUTH NEEDED + public ErrorResponse UpdatePlaylist(string playlistId, string newName = null, bool? newPublic = null, bool? newCollaborative = null, string newDescription = null) + { + JObject body = new JObject(); + if (newName != null) + body.Add("name", newName); + if (newPublic != null) + body.Add("public", newPublic); + if (newCollaborative != null) + body.Add("collaborative", newCollaborative); + if (newDescription != null) + body.Add("description", newDescription); + return UploadData(_builder.UpdatePlaylist(playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse(); + } + /// /// Change a playlist’s name and public/private state asynchronously. (The user must, of course, own the playlist.) /// @@ -1482,6 +1589,7 @@ namespace SpotifyAPI.Web /// Value for playlist description as displayed in Spotify Clients and in the Web API. /// /// AUTH NEEDED + [Obsolete("Calling UpdatePlaylist with a userId is deprecated, remove the parameter")] public async Task UpdatePlaylistAsync(string userId, string playlistId, string newName = null, bool? newPublic = null, bool? newCollaborative = null, string newDescription = null) { JObject body = new JObject(); @@ -1496,6 +1604,30 @@ namespace SpotifyAPI.Web return (await UploadDataAsync(_builder.UpdatePlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse(); } + /// + /// Change a playlist’s name and public/private state asynchronously. (The user must, of course, own the playlist.) + /// + /// The Spotify ID for the playlist. + /// The new name for the playlist, for example "My New Playlist Title". + /// If true the playlist will be public, if false it will be private. + /// If true the playlist will become collaborative and other users will be able to modify the playlist in their Spotify client. Note: You can only set collaborative to true on non-public playlists. + /// Value for playlist description as displayed in Spotify Clients and in the Web API. + /// + /// AUTH NEEDED + public async Task UpdatePlaylistAsync(string playlistId, string newName = null, bool? newPublic = null, bool? newCollaborative = null, string newDescription = null) + { + JObject body = new JObject(); + if (newName != null) + body.Add("name", newName); + if (newPublic != null) + body.Add("public", newPublic); + if (newCollaborative != null) + body.Add("collaborative", newCollaborative); + if (newDescription != null) + body.Add("description", newDescription); + return (await UploadDataAsync(_builder.UpdatePlaylist(playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse(); + } + /// /// Replace all the tracks in a playlist, overwriting its existing tracks. This powerful request can be useful for /// replacing tracks, re-ordering existing tracks, or clearing the playlist. @@ -1505,6 +1637,7 @@ namespace SpotifyAPI.Web /// A list of Spotify track URIs to set. A maximum of 100 tracks can be set in one request. /// /// AUTH NEEDED + [Obsolete("Calling ReplacePlaylistTracks with a userId is deprecated, remove the parameter")] public ErrorResponse ReplacePlaylistTracks(string userId, string playlistId, List uris) { JObject body = new JObject @@ -1514,6 +1647,23 @@ namespace SpotifyAPI.Web return UploadData(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse(); } + /// + /// Replace all the tracks in a playlist, overwriting its existing tracks. This powerful request can be useful for + /// replacing tracks, re-ordering existing tracks, or clearing the playlist. + /// + /// The Spotify ID for the playlist. + /// A list of Spotify track URIs to set. A maximum of 100 tracks can be set in one request. + /// + /// AUTH NEEDED + public ErrorResponse ReplacePlaylistTracks(string playlistId, List uris) + { + JObject body = new JObject + { + {"uris", new JArray(uris.Take(100))} + }; + return UploadData(_builder.ReplacePlaylistTracks(playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse(); + } + /// /// Replace all the tracks in a playlist asynchronously, overwriting its existing tracks. This powerful request can be useful for /// replacing tracks, re-ordering existing tracks, or clearing the playlist. @@ -1523,6 +1673,7 @@ namespace SpotifyAPI.Web /// A list of Spotify track URIs to set. A maximum of 100 tracks can be set in one request. /// /// AUTH NEEDED + [Obsolete("Calling ReplacePlaylistTracks with a userId is deprecated, remove the parameter")] public async Task ReplacePlaylistTracksAsync(string userId, string playlistId, List uris) { JObject body = new JObject @@ -1532,6 +1683,23 @@ namespace SpotifyAPI.Web return await (UploadDataAsync(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse(); } + /// + /// Replace all the tracks in a playlist asynchronously, overwriting its existing tracks. This powerful request can be useful for + /// replacing tracks, re-ordering existing tracks, or clearing the playlist. + /// + /// The Spotify ID for the playlist. + /// A list of Spotify track URIs to set. A maximum of 100 tracks can be set in one request. + /// + /// AUTH NEEDED + public async Task ReplacePlaylistTracksAsync(string playlistId, List uris) + { + JObject body = new JObject + { + {"uris", new JArray(uris.Take(100))} + }; + return await (UploadDataAsync(_builder.ReplacePlaylistTracks(playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse(); + } + /// /// Remove one or more tracks from a user’s playlist. /// @@ -1543,6 +1711,7 @@ namespace SpotifyAPI.Web /// /// /// AUTH NEEDED + [Obsolete("Calling RemovePlaylistTracks with a userId is deprecated, remove the parameter")] public ErrorResponse RemovePlaylistTracks(string userId, string playlistId, List uris) { JObject body = new JObject @@ -1552,6 +1721,25 @@ namespace SpotifyAPI.Web return UploadData(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE") ?? new ErrorResponse(); } + /// + /// Remove one or more tracks from a user’s playlist. + /// + /// The Spotify ID for the playlist. + /// + /// array of objects containing Spotify URI strings (and their position in the playlist). A maximum of + /// 100 objects can be sent at once. + /// + /// + /// AUTH NEEDED + public ErrorResponse RemovePlaylistTracks(string playlistId, List uris) + { + JObject body = new JObject + { + {"tracks", JArray.FromObject(uris.Take(100))} + }; + return UploadData(_builder.RemovePlaylistTracks(playlistId, uris), body.ToString(Formatting.None), "DELETE") ?? new ErrorResponse(); + } + /// /// Remove one or more tracks from a user’s playlist asynchronously. /// @@ -1563,6 +1751,7 @@ namespace SpotifyAPI.Web /// /// /// AUTH NEEDED + [Obsolete("Calling RemovePlaylistTracks with a userId is deprecated, remove the parameter")] public async Task RemovePlaylistTracksAsync(string userId, string playlistId, List uris) { JObject body = new JObject @@ -1572,6 +1761,25 @@ namespace SpotifyAPI.Web return await (UploadDataAsync(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE").ConfigureAwait(false)) ?? new ErrorResponse(); } + /// + /// Remove one or more tracks from a user’s playlist asynchronously. + /// + /// The Spotify ID for the playlist. + /// + /// array of objects containing Spotify URI strings (and their position in the playlist). A maximum of + /// 100 objects can be sent at once. + /// + /// + /// AUTH NEEDED + public async Task RemovePlaylistTracksAsync(string playlistId, List uris) + { + JObject body = new JObject + { + {"tracks", JArray.FromObject(uris.Take(100))} + }; + return await (UploadDataAsync(_builder.RemovePlaylistTracks(playlistId, uris), body.ToString(Formatting.None), "DELETE").ConfigureAwait(false)) ?? new ErrorResponse(); + } + /// /// Remove a track from a user’s playlist. /// @@ -1580,9 +1788,22 @@ namespace SpotifyAPI.Web /// Spotify URI /// /// AUTH NEEDED + [Obsolete("Calling RemovePlaylistTrack with a userId is deprecated, remove the parameter")] public ErrorResponse RemovePlaylistTrack(string userId, string playlistId, DeleteTrackUri uri) { - return RemovePlaylistTracks(userId, playlistId, new List { uri }); + return RemovePlaylistTracks(playlistId, new List { uri }); + } + + /// + /// Remove a track from a user’s playlist. + /// + /// The Spotify ID for the playlist. + /// Spotify URI + /// + /// AUTH NEEDED + public ErrorResponse RemovePlaylistTrack(string playlistId, DeleteTrackUri uri) + { + return RemovePlaylistTracks(playlistId, new List { uri }); } /// @@ -1593,9 +1814,22 @@ namespace SpotifyAPI.Web /// Spotify URI /// /// AUTH NEEDED + [Obsolete("Calling RemovePlaylistTrack with a userId is deprecated, remove the parameter")] public Task RemovePlaylistTrackAsync(string userId, string playlistId, DeleteTrackUri uri) { - return RemovePlaylistTracksAsync(userId, playlistId, new List { uri }); + return RemovePlaylistTracksAsync(playlistId, new List { uri }); + } + + /// + /// Remove a track from a user’s playlist asynchronously. + /// + /// The Spotify ID for the playlist. + /// Spotify URI + /// + /// AUTH NEEDED + public Task RemovePlaylistTrackAsync(string playlistId, DeleteTrackUri uri) + { + return RemovePlaylistTracksAsync(playlistId, new List { uri }); } /// @@ -1607,6 +1841,7 @@ namespace SpotifyAPI.Web /// The position to insert the tracks, a zero-based index /// /// AUTH NEEDED + [Obsolete("Calling AddPlaylistTracks with a userId is deprecated, remove the parameter")] public ErrorResponse AddPlaylistTracks(string userId, string playlistId, List uris, int? position = null) { JObject body = new JObject @@ -1616,6 +1851,23 @@ namespace SpotifyAPI.Web return UploadData(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)) ?? new ErrorResponse(); } + /// + /// Add one or more tracks to a user’s playlist. + /// + /// The Spotify ID for the playlist. + /// A list of Spotify track URIs to add + /// The position to insert the tracks, a zero-based index + /// + /// AUTH NEEDED + public ErrorResponse AddPlaylistTracks(string playlistId, List uris, int? position = null) + { + JObject body = new JObject + { + {"uris", JArray.FromObject(uris.Take(100))} + }; + return UploadData(_builder.AddPlaylistTracks(playlistId, uris, position), body.ToString(Formatting.None)) ?? new ErrorResponse(); + } + /// /// Add one or more tracks to a user’s playlist asynchronously. /// @@ -1625,6 +1877,7 @@ namespace SpotifyAPI.Web /// The position to insert the tracks, a zero-based index /// /// AUTH NEEDED + [Obsolete("Calling AddPlaylistTracks with a userId is deprecated, remove the parameter")] public async Task AddPlaylistTracksAsync(string userId, string playlistId, List uris, int? position = null) { JObject body = new JObject @@ -1634,6 +1887,23 @@ namespace SpotifyAPI.Web return await (UploadDataAsync(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)).ConfigureAwait(false)) ?? new ErrorResponse(); } + /// + /// Add one or more tracks to a user’s playlist asynchronously. + /// + /// The Spotify ID for the playlist. + /// A list of Spotify track URIs to add + /// The position to insert the tracks, a zero-based index + /// + /// AUTH NEEDED + public async Task AddPlaylistTracksAsync(string playlistId, List uris, int? position = null) + { + JObject body = new JObject + { + {"uris", JArray.FromObject(uris.Take(100))} + }; + return await (UploadDataAsync(_builder.AddPlaylistTracks(playlistId, uris, position), body.ToString(Formatting.None)).ConfigureAwait(false)) ?? new ErrorResponse(); + } + /// /// Add a track to a user’s playlist. /// @@ -1643,9 +1913,24 @@ namespace SpotifyAPI.Web /// The position to insert the tracks, a zero-based index /// /// AUTH NEEDED + [Obsolete("Calling AddPlaylistTrack with a userId is deprecated, remove the parameter")] public ErrorResponse AddPlaylistTrack(string userId, string playlistId, string uri, int? position = null) { - return AddPlaylistTracks(userId, playlistId, new List { uri }, position); + return AddPlaylistTracks(playlistId, new List { uri }, position); + } + + + /// + /// Add a track to a user’s playlist. + /// + /// The Spotify ID for the playlist. + /// A Spotify Track URI + /// The position to insert the tracks, a zero-based index + /// + /// AUTH NEEDED + public ErrorResponse AddPlaylistTrack(string playlistId, string uri, int? position = null) + { + return AddPlaylistTracks(playlistId, new List { uri }, position); } /// @@ -1657,11 +1942,25 @@ namespace SpotifyAPI.Web /// The position to insert the tracks, a zero-based index /// /// AUTH NEEDED + [Obsolete("Calling AddPlaylistTrack with a userId is deprecated, remove the parameter")] public Task AddPlaylistTrackAsync(string userId, string playlistId, string uri, int? position = null) { return AddPlaylistTracksAsync(userId, playlistId, new List { uri }, position); } + /// + /// Add a track to a user’s playlist asynchronously. + /// + /// The Spotify ID for the playlist. + /// A Spotify Track URI + /// The position to insert the tracks, a zero-based index + /// + /// AUTH NEEDED + public Task AddPlaylistTrackAsync(string playlistId, string uri, int? position = null) + { + return AddPlaylistTracksAsync(playlistId, new List { uri }, position); + } + /// /// Reorder a track or a group of tracks in a playlist. /// @@ -1673,6 +1972,7 @@ namespace SpotifyAPI.Web /// The playlist's snapshot ID against which you want to make the changes. /// /// AUTH NEEDED + [Obsolete("Calling ReorderPlaylist with a userId is deprecated, remove the parameter")] public Snapshot ReorderPlaylist(string userId, string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "") { JObject body = new JObject @@ -1686,6 +1986,29 @@ namespace SpotifyAPI.Web return UploadData(_builder.ReorderPlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT"); } + /// + /// Reorder a track or a group of tracks in a playlist. + /// + /// The Spotify ID for the playlist. + /// The position of the first track to be reordered. + /// The position where the tracks should be inserted. + /// The amount of tracks to be reordered. Defaults to 1 if not set. + /// The playlist's snapshot ID against which you want to make the changes. + /// + /// AUTH NEEDED + public Snapshot ReorderPlaylist(string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "") + { + JObject body = new JObject + { + {"range_start", rangeStart}, + {"range_length", rangeLength}, + {"insert_before", insertBefore} + }; + if (!string.IsNullOrEmpty(snapshotId)) + body.Add("snapshot_id", snapshotId); + return UploadData(_builder.ReorderPlaylist(playlistId), body.ToString(Formatting.None), "PUT"); + } + /// /// Reorder a track or a group of tracks in a playlist asynchronously. /// @@ -1697,6 +2020,7 @@ namespace SpotifyAPI.Web /// The playlist's snapshot ID against which you want to make the changes. /// /// AUTH NEEDED + [Obsolete("Calling ReorderPlaylist with a userId is deprecated, remove the parameter")] public Task ReorderPlaylistAsync(string userId, string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "") { JObject body = new JObject @@ -1711,6 +2035,30 @@ namespace SpotifyAPI.Web return UploadDataAsync(_builder.ReorderPlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT"); } + /// + /// Reorder a track or a group of tracks in a playlist asynchronously. + /// + /// The Spotify ID for the playlist. + /// The position of the first track to be reordered. + /// The position where the tracks should be inserted. + /// The amount of tracks to be reordered. Defaults to 1 if not set. + /// The playlist's snapshot ID against which you want to make the changes. + /// + /// AUTH NEEDED + public Task ReorderPlaylistAsync(string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "") + { + JObject body = new JObject + { + {"range_start", rangeStart}, + {"range_length", rangeLength}, + {"insert_before", insertBefore}, + {"snapshot_id", snapshotId} + }; + if (!string.IsNullOrEmpty(snapshotId)) + body.Add("snapshot_id", snapshotId); + return UploadDataAsync(_builder.ReorderPlaylist(playlistId), body.ToString(Formatting.None), "PUT"); + } + #endregion Playlists #region Profiles diff --git a/SpotifyAPI.Web/SpotifyWebBuilder.cs b/SpotifyAPI.Web/SpotifyWebBuilder.cs index 84a197f1..e30a6dad 100644 --- a/SpotifyAPI.Web/SpotifyWebBuilder.cs +++ b/SpotifyAPI.Web/SpotifyWebBuilder.cs @@ -649,6 +649,26 @@ namespace SpotifyAPI.Web return builder.ToString(); } + /// + /// Get a playlist owned by a Spotify user. + /// + /// The Spotify ID for the playlist. + /// + /// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are + /// returned. + /// + /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. + /// + /// AUTH NEEDED + public string GetPlaylist(string playlistId, string fields = "", string market = "") + { + StringBuilder builder = new StringBuilder(APIBase + "/playlists/" + playlistId); + builder.Append("?fields=" + fields); + if (!string.IsNullOrEmpty(market)) + builder.Append("&market=" + market); + return builder.ToString(); + } + /// /// Get full details of the tracks of a playlist owned by a Spotify user. /// @@ -675,6 +695,31 @@ namespace SpotifyAPI.Web return builder.ToString(); } + /// + /// Get full details of the tracks of a playlist owned by a Spotify user. + /// + /// The Spotify ID for the playlist. + /// + /// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are + /// returned. + /// + /// The maximum number of tracks to return. Default: 100. Minimum: 1. Maximum: 100. + /// The index of the first object to return. Default: 0 (i.e., the first object) + /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. + /// + /// AUTH NEEDED + public string GetPlaylistTracks(string playlistId, string fields = "", int limit = 100, int offset = 0, string market = "") + { + limit = Math.Min(limit, 100); + StringBuilder builder = new StringBuilder(APIBase + "/playlists/" + playlistId + "/tracks"); + builder.Append("?fields=" + fields); + builder.Append("&limit=" + limit); + builder.Append("&offset=" + offset); + if (!string.IsNullOrEmpty(market)) + builder.Append("&market=" + market); + return builder.ToString(); + } + /// /// Create a playlist for a Spotify user. (The playlist will be empty until you add tracks.) /// @@ -706,6 +751,17 @@ namespace SpotifyAPI.Web return $"{APIBase}/users/{userId}/playlists/{playlistId}"; } + /// + /// Change a playlist’s name and public/private state. (The user must, of course, own the playlist.) + /// + /// The Spotify ID for the playlist. + /// + /// AUTH NEEDED + public string UpdatePlaylist(string playlistId) + { + return $"{APIBase}/playlists/{playlistId}"; + } + /// /// Replace all the tracks in a playlist, overwriting its existing tracks. This powerful request can be useful for /// replacing tracks, re-ordering existing tracks, or clearing the playlist. @@ -719,6 +775,18 @@ namespace SpotifyAPI.Web return $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks"; } + /// + /// Replace all the tracks in a playlist, overwriting its existing tracks. This powerful request can be useful for + /// replacing tracks, re-ordering existing tracks, or clearing the playlist. + /// + /// The Spotify ID for the playlist. + /// + /// AUTH NEEDED + public string ReplacePlaylistTracks(string playlistId) + { + return $"{APIBase}/playlists/{playlistId}/tracks"; + } + /// /// Remove one or more tracks from a user’s playlist. /// @@ -735,6 +803,21 @@ namespace SpotifyAPI.Web return $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks"; } + /// + /// Remove one or more tracks from a user’s playlist. + /// + /// The Spotify ID for the playlist. + /// + /// array of objects containing Spotify URI strings (and their position in the playlist). A maximum of + /// 100 objects can be sent at once. + /// + /// + /// AUTH NEEDED + public string RemovePlaylistTracks(string playlistId, List uris) + { + return $"{APIBase}/playlists/{playlistId}/tracks"; + } + /// /// Add one or more tracks to a user’s playlist. /// @@ -751,6 +834,21 @@ namespace SpotifyAPI.Web return $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks?position={position}"; } + /// + /// Add one or more tracks to a user’s playlist. + /// + /// The Spotify ID for the playlist. + /// A list of Spotify track URIs to add + /// The position to insert the tracks, a zero-based index + /// + /// AUTH NEEDED + public string AddPlaylistTracks(string playlistId, List uris, int? position = null) + { + if (position == null) + return $"{APIBase}/playlists/{playlistId}/tracks"; + return $"{APIBase}/playlists/{playlistId}/tracks?position={position}"; + } + /// /// Reorder a track or a group of tracks in a playlist. /// @@ -763,6 +861,17 @@ namespace SpotifyAPI.Web return $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks"; } + /// + /// Reorder a track or a group of tracks in a playlist. + /// + /// The Spotify ID for the playlist. + /// + /// AUTH NEEDED + public string ReorderPlaylist(string playlistId) + { + return $"{APIBase}/playlists/{playlistId}/tracks"; + } + #endregion Playlists #region Profiles