prepare for playlist change

This commit is contained in:
Jonas Dellinger 2019-02-19 22:53:36 +01:00
parent f31af2395c
commit ea5d5248d3
2 changed files with 460 additions and 3 deletions

View File

@ -1319,6 +1319,7 @@ namespace SpotifyAPI.Web
/// <param name="market">An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[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<FullPlaylist>(_builder.GetPlaylist(userId, playlistId, fields, market));
}
/// <summary>
/// Get a playlist owned by a Spotify user.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="fields">
/// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are
/// returned.
/// </param>
/// <param name="market">An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public FullPlaylist GetPlaylist(string playlistId, string fields = "", string market = "")
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetPlaylist");
return DownloadData<FullPlaylist>(_builder.GetPlaylist(playlistId, fields, market));
}
/// <summary>
/// Get a playlist owned by a Spotify user asynchronously.
/// </summary>
@ -1338,6 +1357,7 @@ namespace SpotifyAPI.Web
/// <param name="market">An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling GetPlaylist with a userId is deprecated, remove the parameter")]
public Task<FullPlaylist> GetPlaylistAsync(string userId, string playlistId, string fields = "", string market = "")
{
if (!UseAuth)
@ -1345,6 +1365,24 @@ namespace SpotifyAPI.Web
return DownloadDataAsync<FullPlaylist>(_builder.GetPlaylist(userId, playlistId, fields, market));
}
/// <summary>
/// Get a playlist owned by a Spotify user asynchronously.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="fields">
/// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are
/// returned.
/// </param>
/// <param name="market">An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public Task<FullPlaylist> GetPlaylistAsync(string playlistId, string fields = "", string market = "")
{
if (!UseAuth)
throw new InvalidOperationException("Auth is required for GetPlaylist");
return DownloadDataAsync<FullPlaylist>(_builder.GetPlaylist(playlistId, fields, market));
}
/// <summary>
/// Get full details of the tracks of a playlist owned by a Spotify user.
/// </summary>
@ -1359,6 +1397,7 @@ namespace SpotifyAPI.Web
/// <param name="market">An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling GetPlaylistTracks with a userId is deprecated, remove the parameter")]
public Paging<PlaylistTrack> 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<Paging<PlaylistTrack>>(_builder.GetPlaylistTracks(userId, playlistId, fields, limit, offset, market));
}
/// <summary>
/// Get full details of the tracks of a playlist owned by a Spotify user.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="fields">
/// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are
/// returned.
/// </param>
/// <param name="limit">The maximum number of tracks to return. Default: 100. Minimum: 1. Maximum: 100.</param>
/// <param name="offset">The index of the first object to return. Default: 0 (i.e., the first object)</param>
/// <param name="market">An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public Paging<PlaylistTrack> 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<Paging<PlaylistTrack>>(_builder.GetPlaylistTracks(playlistId, fields, limit, offset, market));
}
/// <summary>
/// Get full details of the tracks of a playlist owned by a Spotify user asyncronously.
/// </summary>
@ -1380,6 +1439,7 @@ namespace SpotifyAPI.Web
/// <param name="market">An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling GetPlaylistTracks with a userId is deprecated, remove the parameter")]
public Task<Paging<PlaylistTrack>> 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<Paging<PlaylistTrack>>(_builder.GetPlaylistTracks(userId, playlistId, fields, limit, offset, market));
}
/// <summary>
/// Get full details of the tracks of a playlist owned by a Spotify user asyncronously.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="fields">
/// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are
/// returned.
/// </param>
/// <param name="limit">The maximum number of tracks to return. Default: 100. Minimum: 1. Maximum: 100.</param>
/// <param name="offset">The index of the first object to return. Default: 0 (i.e., the first object)</param>
/// <param name="market">An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling GetPlaylistTracks with a userId is deprecated, remove the parameter")]
public Task<Paging<PlaylistTrack>> 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<Paging<PlaylistTrack>>(_builder.GetPlaylistTracks(playlistId, fields, limit, offset, market));
}
/// <summary>
/// Create a playlist for a Spotify user. (The playlist will be empty until you add tracks.)
/// </summary>
@ -1457,6 +1538,7 @@ namespace SpotifyAPI.Web
/// <param name="newDescription">Value for playlist description as displayed in Spotify Clients and in the Web API.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[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<ErrorResponse>(_builder.UpdatePlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
}
/// <summary>
/// Change a playlists name and public/private state. (The user must, of course, own the playlist.)
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="newName">The new name for the playlist, for example "My New Playlist Title".</param>
/// <param name="newPublic">If true the playlist will be public, if false it will be private.</param>
/// <param name="newCollaborative">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.</param>
/// <param name="newDescription">Value for playlist description as displayed in Spotify Clients and in the Web API.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
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<ErrorResponse>(_builder.UpdatePlaylist(playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
}
/// <summary>
/// Change a playlists name and public/private state asynchronously. (The user must, of course, own the playlist.)
/// </summary>
@ -1482,6 +1589,7 @@ namespace SpotifyAPI.Web
/// <param name="newDescription">Value for playlist description as displayed in Spotify Clients and in the Web API.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling UpdatePlaylist with a userId is deprecated, remove the parameter")]
public async Task<ErrorResponse> 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<ErrorResponse>(_builder.UpdatePlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
}
/// <summary>
/// Change a playlists name and public/private state asynchronously. (The user must, of course, own the playlist.)
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="newName">The new name for the playlist, for example "My New Playlist Title".</param>
/// <param name="newPublic">If true the playlist will be public, if false it will be private.</param>
/// <param name="newCollaborative">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.</param>
/// <param name="newDescription">Value for playlist description as displayed in Spotify Clients and in the Web API.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public async Task<ErrorResponse> 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<ErrorResponse>(_builder.UpdatePlaylist(playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
}
/// <summary>
/// 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
/// <param name="uris">A list of Spotify track URIs to set. A maximum of 100 tracks can be set in one request.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling ReplacePlaylistTracks with a userId is deprecated, remove the parameter")]
public ErrorResponse ReplacePlaylistTracks(string userId, string playlistId, List<string> uris)
{
JObject body = new JObject
@ -1514,6 +1647,23 @@ namespace SpotifyAPI.Web
return UploadData<ErrorResponse>(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
}
/// <summary>
/// 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.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="uris">A list of Spotify track URIs to set. A maximum of 100 tracks can be set in one request.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public ErrorResponse ReplacePlaylistTracks(string playlistId, List<string> uris)
{
JObject body = new JObject
{
{"uris", new JArray(uris.Take(100))}
};
return UploadData<ErrorResponse>(_builder.ReplacePlaylistTracks(playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
}
/// <summary>
/// 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
/// <param name="uris">A list of Spotify track URIs to set. A maximum of 100 tracks can be set in one request.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling ReplacePlaylistTracks with a userId is deprecated, remove the parameter")]
public async Task<ErrorResponse> ReplacePlaylistTracksAsync(string userId, string playlistId, List<string> uris)
{
JObject body = new JObject
@ -1532,6 +1683,23 @@ namespace SpotifyAPI.Web
return await (UploadDataAsync<ErrorResponse>(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
}
/// <summary>
/// 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.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="uris">A list of Spotify track URIs to set. A maximum of 100 tracks can be set in one request.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public async Task<ErrorResponse> ReplacePlaylistTracksAsync(string playlistId, List<string> uris)
{
JObject body = new JObject
{
{"uris", new JArray(uris.Take(100))}
};
return await (UploadDataAsync<ErrorResponse>(_builder.ReplacePlaylistTracks(playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse();
}
/// <summary>
/// Remove one or more tracks from a users playlist.
/// </summary>
@ -1543,6 +1711,7 @@ namespace SpotifyAPI.Web
/// </param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling RemovePlaylistTracks with a userId is deprecated, remove the parameter")]
public ErrorResponse RemovePlaylistTracks(string userId, string playlistId, List<DeleteTrackUri> uris)
{
JObject body = new JObject
@ -1552,6 +1721,25 @@ namespace SpotifyAPI.Web
return UploadData<ErrorResponse>(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
}
/// <summary>
/// Remove one or more tracks from a users playlist.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="uris">
/// array of objects containing Spotify URI strings (and their position in the playlist). A maximum of
/// 100 objects can be sent at once.
/// </param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public ErrorResponse RemovePlaylistTracks(string playlistId, List<DeleteTrackUri> uris)
{
JObject body = new JObject
{
{"tracks", JArray.FromObject(uris.Take(100))}
};
return UploadData<ErrorResponse>(_builder.RemovePlaylistTracks(playlistId, uris), body.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
}
/// <summary>
/// Remove one or more tracks from a users playlist asynchronously.
/// </summary>
@ -1563,6 +1751,7 @@ namespace SpotifyAPI.Web
/// </param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling RemovePlaylistTracks with a userId is deprecated, remove the parameter")]
public async Task<ErrorResponse> RemovePlaylistTracksAsync(string userId, string playlistId, List<DeleteTrackUri> uris)
{
JObject body = new JObject
@ -1572,6 +1761,25 @@ namespace SpotifyAPI.Web
return await (UploadDataAsync<ErrorResponse>(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE").ConfigureAwait(false)) ?? new ErrorResponse();
}
/// <summary>
/// Remove one or more tracks from a users playlist asynchronously.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="uris">
/// array of objects containing Spotify URI strings (and their position in the playlist). A maximum of
/// 100 objects can be sent at once.
/// </param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public async Task<ErrorResponse> RemovePlaylistTracksAsync(string playlistId, List<DeleteTrackUri> uris)
{
JObject body = new JObject
{
{"tracks", JArray.FromObject(uris.Take(100))}
};
return await (UploadDataAsync<ErrorResponse>(_builder.RemovePlaylistTracks(playlistId, uris), body.ToString(Formatting.None), "DELETE").ConfigureAwait(false)) ?? new ErrorResponse();
}
/// <summary>
/// Remove a track from a users playlist.
/// </summary>
@ -1580,9 +1788,22 @@ namespace SpotifyAPI.Web
/// <param name="uri">Spotify URI</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[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<DeleteTrackUri> { uri });
return RemovePlaylistTracks(playlistId, new List<DeleteTrackUri> { uri });
}
/// <summary>
/// Remove a track from a users playlist.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="uri">Spotify URI</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public ErrorResponse RemovePlaylistTrack(string playlistId, DeleteTrackUri uri)
{
return RemovePlaylistTracks(playlistId, new List<DeleteTrackUri> { uri });
}
/// <summary>
@ -1593,9 +1814,22 @@ namespace SpotifyAPI.Web
/// <param name="uri">Spotify URI</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling RemovePlaylistTrack with a userId is deprecated, remove the parameter")]
public Task<ErrorResponse> RemovePlaylistTrackAsync(string userId, string playlistId, DeleteTrackUri uri)
{
return RemovePlaylistTracksAsync(userId, playlistId, new List<DeleteTrackUri> { uri });
return RemovePlaylistTracksAsync(playlistId, new List<DeleteTrackUri> { uri });
}
/// <summary>
/// Remove a track from a users playlist asynchronously.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="uri">Spotify URI</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public Task<ErrorResponse> RemovePlaylistTrackAsync(string playlistId, DeleteTrackUri uri)
{
return RemovePlaylistTracksAsync(playlistId, new List<DeleteTrackUri> { uri });
}
/// <summary>
@ -1607,6 +1841,7 @@ namespace SpotifyAPI.Web
/// <param name="position">The position to insert the tracks, a zero-based index</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling AddPlaylistTracks with a userId is deprecated, remove the parameter")]
public ErrorResponse AddPlaylistTracks(string userId, string playlistId, List<string> uris, int? position = null)
{
JObject body = new JObject
@ -1616,6 +1851,23 @@ namespace SpotifyAPI.Web
return UploadData<ErrorResponse>(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)) ?? new ErrorResponse();
}
/// <summary>
/// Add one or more tracks to a users playlist.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="uris">A list of Spotify track URIs to add</param>
/// <param name="position">The position to insert the tracks, a zero-based index</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public ErrorResponse AddPlaylistTracks(string playlistId, List<string> uris, int? position = null)
{
JObject body = new JObject
{
{"uris", JArray.FromObject(uris.Take(100))}
};
return UploadData<ErrorResponse>(_builder.AddPlaylistTracks(playlistId, uris, position), body.ToString(Formatting.None)) ?? new ErrorResponse();
}
/// <summary>
/// Add one or more tracks to a users playlist asynchronously.
/// </summary>
@ -1625,6 +1877,7 @@ namespace SpotifyAPI.Web
/// <param name="position">The position to insert the tracks, a zero-based index</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling AddPlaylistTracks with a userId is deprecated, remove the parameter")]
public async Task<ErrorResponse> AddPlaylistTracksAsync(string userId, string playlistId, List<string> uris, int? position = null)
{
JObject body = new JObject
@ -1634,6 +1887,23 @@ namespace SpotifyAPI.Web
return await (UploadDataAsync<ErrorResponse>(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)).ConfigureAwait(false)) ?? new ErrorResponse();
}
/// <summary>
/// Add one or more tracks to a users playlist asynchronously.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="uris">A list of Spotify track URIs to add</param>
/// <param name="position">The position to insert the tracks, a zero-based index</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public async Task<ErrorResponse> AddPlaylistTracksAsync(string playlistId, List<string> uris, int? position = null)
{
JObject body = new JObject
{
{"uris", JArray.FromObject(uris.Take(100))}
};
return await (UploadDataAsync<ErrorResponse>(_builder.AddPlaylistTracks(playlistId, uris, position), body.ToString(Formatting.None)).ConfigureAwait(false)) ?? new ErrorResponse();
}
/// <summary>
/// Add a track to a users playlist.
/// </summary>
@ -1643,9 +1913,24 @@ namespace SpotifyAPI.Web
/// <param name="position">The position to insert the tracks, a zero-based index</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[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<string> { uri }, position);
return AddPlaylistTracks(playlistId, new List<string> { uri }, position);
}
/// <summary>
/// Add a track to a users playlist.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="uri">A Spotify Track URI</param>
/// <param name="position">The position to insert the tracks, a zero-based index</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public ErrorResponse AddPlaylistTrack(string playlistId, string uri, int? position = null)
{
return AddPlaylistTracks(playlistId, new List<string> { uri }, position);
}
/// <summary>
@ -1657,11 +1942,25 @@ namespace SpotifyAPI.Web
/// <param name="position">The position to insert the tracks, a zero-based index</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling AddPlaylistTrack with a userId is deprecated, remove the parameter")]
public Task<ErrorResponse> AddPlaylistTrackAsync(string userId, string playlistId, string uri, int? position = null)
{
return AddPlaylistTracksAsync(userId, playlistId, new List<string> { uri }, position);
}
/// <summary>
/// Add a track to a users playlist asynchronously.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="uri">A Spotify Track URI</param>
/// <param name="position">The position to insert the tracks, a zero-based index</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public Task<ErrorResponse> AddPlaylistTrackAsync(string playlistId, string uri, int? position = null)
{
return AddPlaylistTracksAsync(playlistId, new List<string> { uri }, position);
}
/// <summary>
/// Reorder a track or a group of tracks in a playlist.
/// </summary>
@ -1673,6 +1972,7 @@ namespace SpotifyAPI.Web
/// <param name="snapshotId">The playlist's snapshot ID against which you want to make the changes.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[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<Snapshot>(_builder.ReorderPlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT");
}
/// <summary>
/// Reorder a track or a group of tracks in a playlist.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="rangeStart">The position of the first track to be reordered.</param>
/// <param name="insertBefore">The position where the tracks should be inserted. </param>
/// <param name="rangeLength">The amount of tracks to be reordered. Defaults to 1 if not set.</param>
/// <param name="snapshotId">The playlist's snapshot ID against which you want to make the changes.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
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<Snapshot>(_builder.ReorderPlaylist(playlistId), body.ToString(Formatting.None), "PUT");
}
/// <summary>
/// Reorder a track or a group of tracks in a playlist asynchronously.
/// </summary>
@ -1697,6 +2020,7 @@ namespace SpotifyAPI.Web
/// <param name="snapshotId">The playlist's snapshot ID against which you want to make the changes.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
[Obsolete("Calling ReorderPlaylist with a userId is deprecated, remove the parameter")]
public Task<Snapshot> 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<Snapshot>(_builder.ReorderPlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT");
}
/// <summary>
/// Reorder a track or a group of tracks in a playlist asynchronously.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="rangeStart">The position of the first track to be reordered.</param>
/// <param name="insertBefore">The position where the tracks should be inserted. </param>
/// <param name="rangeLength">The amount of tracks to be reordered. Defaults to 1 if not set.</param>
/// <param name="snapshotId">The playlist's snapshot ID against which you want to make the changes.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public Task<Snapshot> 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<Snapshot>(_builder.ReorderPlaylist(playlistId), body.ToString(Formatting.None), "PUT");
}
#endregion Playlists
#region Profiles

View File

@ -649,6 +649,26 @@ namespace SpotifyAPI.Web
return builder.ToString();
}
/// <summary>
/// Get a playlist owned by a Spotify user.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="fields">
/// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are
/// returned.
/// </param>
/// <param name="market">An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
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();
}
/// <summary>
/// Get full details of the tracks of a playlist owned by a Spotify user.
/// </summary>
@ -675,6 +695,31 @@ namespace SpotifyAPI.Web
return builder.ToString();
}
/// <summary>
/// Get full details of the tracks of a playlist owned by a Spotify user.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="fields">
/// Filters for the query: a comma-separated list of the fields to return. If omitted, all fields are
/// returned.
/// </param>
/// <param name="limit">The maximum number of tracks to return. Default: 100. Minimum: 1. Maximum: 100.</param>
/// <param name="offset">The index of the first object to return. Default: 0 (i.e., the first object)</param>
/// <param name="market">An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
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();
}
/// <summary>
/// Create a playlist for a Spotify user. (The playlist will be empty until you add tracks.)
/// </summary>
@ -706,6 +751,17 @@ namespace SpotifyAPI.Web
return $"{APIBase}/users/{userId}/playlists/{playlistId}";
}
/// <summary>
/// Change a playlists name and public/private state. (The user must, of course, own the playlist.)
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public string UpdatePlaylist(string playlistId)
{
return $"{APIBase}/playlists/{playlistId}";
}
/// <summary>
/// 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";
}
/// <summary>
/// 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.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public string ReplacePlaylistTracks(string playlistId)
{
return $"{APIBase}/playlists/{playlistId}/tracks";
}
/// <summary>
/// Remove one or more tracks from a users playlist.
/// </summary>
@ -735,6 +803,21 @@ namespace SpotifyAPI.Web
return $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks";
}
/// <summary>
/// Remove one or more tracks from a users playlist.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="uris">
/// array of objects containing Spotify URI strings (and their position in the playlist). A maximum of
/// 100 objects can be sent at once.
/// </param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public string RemovePlaylistTracks(string playlistId, List<DeleteTrackUri> uris)
{
return $"{APIBase}/playlists/{playlistId}/tracks";
}
/// <summary>
/// Add one or more tracks to a users playlist.
/// </summary>
@ -751,6 +834,21 @@ namespace SpotifyAPI.Web
return $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks?position={position}";
}
/// <summary>
/// Add one or more tracks to a users playlist.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <param name="uris">A list of Spotify track URIs to add</param>
/// <param name="position">The position to insert the tracks, a zero-based index</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public string AddPlaylistTracks(string playlistId, List<string> uris, int? position = null)
{
if (position == null)
return $"{APIBase}/playlists/{playlistId}/tracks";
return $"{APIBase}/playlists/{playlistId}/tracks?position={position}";
}
/// <summary>
/// Reorder a track or a group of tracks in a playlist.
/// </summary>
@ -763,6 +861,17 @@ namespace SpotifyAPI.Web
return $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks";
}
/// <summary>
/// Reorder a track or a group of tracks in a playlist.
/// </summary>
/// <param name="playlistId">The Spotify ID for the playlist.</param>
/// <returns></returns>
/// <remarks>AUTH NEEDED</remarks>
public string ReorderPlaylist(string playlistId)
{
return $"{APIBase}/playlists/{playlistId}/tracks";
}
#endregion Playlists
#region Profiles