From a82bbbf5b7ea227f363df57f6f7dbd22992a99f2 Mon Sep 17 00:00:00 2001 From: Gruhlum Date: Fri, 24 Aug 2018 13:22:38 +0200 Subject: [PATCH] Adds collaborative and description to UpdatePlaylist and CreatePlaylist --- SpotifyAPI.Web/SpotifyWebAPI.cs | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/SpotifyAPI.Web/SpotifyWebAPI.cs b/SpotifyAPI.Web/SpotifyWebAPI.cs index 3b68d09e..e77af261 100644 --- a/SpotifyAPI.Web/SpotifyWebAPI.cs +++ b/SpotifyAPI.Web/SpotifyWebAPI.cs @@ -1395,14 +1395,19 @@ namespace SpotifyAPI.Web /// default true. If true the playlist will be public, if false it will be private. To be able to /// create private playlists, the user must have granted the playlist-modify-private scope. /// + /// 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 FullPlaylist CreatePlaylist(string userId, string playlistName, bool isPublic = true) + public FullPlaylist CreatePlaylist(string userId, string playlistName, bool isPublic = true, bool isCollaborative = false, string playlistDescription = "") { JObject body = new JObject { {"name", playlistName}, - {"public", isPublic} + {"public", isPublic}, + {"collaborative", isCollaborative}, + {"description", playlistDescription} }; return UploadData(_builder.CreatePlaylist(userId, playlistName, isPublic), body.ToString(Formatting.None)); } @@ -1419,14 +1424,19 @@ namespace SpotifyAPI.Web /// default true. If true the playlist will be public, if false it will be private. To be able to /// create private playlists, the user must have granted the playlist-modify-private scope. /// + /// 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 Task CreatePlaylistAsync(string userId, string playlistName, bool isPublic = true) + public Task CreatePlaylistAsync(string userId, string playlistName, bool isPublic = true, bool isCollaborative = false, string playlistDescription = "") { JObject body = new JObject { {"name", playlistName}, - {"public", isPublic} + {"public", isPublic}, + {"collaborative", isCollaborative}, + {"description", playlistDescription} }; return UploadDataAsync(_builder.CreatePlaylist(userId, playlistName, isPublic), body.ToString(Formatting.None)); } @@ -1438,7 +1448,8 @@ namespace SpotifyAPI.Web /// 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. + /// 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 @@ -1463,15 +1474,21 @@ namespace SpotifyAPI.Web /// 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 userId, string playlistId, string newName = null, bool? newPublic = null) + public async Task UpdatePlaylistAsync(string userId, 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(userId, playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse(); }