diff --git a/SpotifyAPI.Web/Enums/Scope.cs b/SpotifyAPI.Web/Enums/Scope.cs index 569c29e7..5b500b98 100644 --- a/SpotifyAPI.Web/Enums/Scope.cs +++ b/SpotifyAPI.Web/Enums/Scope.cs @@ -60,6 +60,9 @@ namespace SpotifyAPI.Web.Enums UserReadCurrentlyPlaying = 131072, [String("app-remote-control")] - AppRemoteControl = 262144 + AppRemoteControl = 262144, + + [String("ugc-image-upload")] + UgcImageUpload = 524288 } } diff --git a/SpotifyAPI.Web/SpotifyWebAPI.cs b/SpotifyAPI.Web/SpotifyWebAPI.cs index 2e31b33e..c7ce8512 100644 --- a/SpotifyAPI.Web/SpotifyWebAPI.cs +++ b/SpotifyAPI.Web/SpotifyWebAPI.cs @@ -1496,6 +1496,56 @@ 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. (The user must, of course, own the playlist.) + /// + /// The user's Spotify user ID. + /// The Spotify ID for the playlist. + /// The image as a base64 encoded string + /// + /// AUTH NEEDED + public ErrorResponse UploadPlaylistImage(string userId, string playlistId, string base64EncodedJpgImage) + { + return UploadData(_builder.UploadPlaylistImage(userId, playlistId), base64EncodedJpgImage, "PUT") ?? new ErrorResponse(); + } + + /// + /// Change a playlist’s name and public/private state asynchronously. (The user must, of course, own the playlist.) + /// + /// The user's Spotify user ID. + /// The Spotify ID for the playlist. + /// The image as a base64 encoded string + /// + /// AUTH NEEDED + public async Task UploadPlaylistImageAsync(string userId, string playlistId, string base64EncodedJpgImage) + { + return (await UploadDataAsync(_builder.UploadPlaylistImage(userId, playlistId), base64EncodedJpgImage, "PUT").ConfigureAwait(false)) ?? 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 image as a base64 encoded string + /// + /// AUTH NEEDED + public ErrorResponse UploadPlaylistImage(string playlistId, string base64EncodedJpgImage) + { + return UploadData(_builder.UploadPlaylistImage(playlistId), base64EncodedJpgImage, "PUT") ?? 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 image as a base64 encoded string + /// + /// AUTH NEEDED + public async Task UploadPlaylistImageAsync(string playlistId, string base64EncodedJpgImage) + { + return (await UploadDataAsync(_builder.UploadPlaylistImage(playlistId), base64EncodedJpgImage, "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. diff --git a/SpotifyAPI.Web/SpotifyWebBuilder.cs b/SpotifyAPI.Web/SpotifyWebBuilder.cs index 84a197f1..d1778285 100644 --- a/SpotifyAPI.Web/SpotifyWebBuilder.cs +++ b/SpotifyAPI.Web/SpotifyWebBuilder.cs @@ -763,6 +763,29 @@ namespace SpotifyAPI.Web return $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks"; } + /// + /// Upload an image for a playlist. + /// + /// The user's Spotify user ID. + /// The Spotify ID for the playlist. + /// + /// AUTH NEEDED + public string UploadPlaylistImage(string userId, string playlistId) + { + return $"{APIBase}/users/{userId}/playlists/{playlistId}/images"; + } + + /// + /// Upload an image for a playlist. + /// + /// The Spotify ID for the playlist. + /// + /// AUTH NEEDED + public string UploadPlaylistImage(string playlistId) + { + return $"{APIBase}/playlists/{playlistId}/images"; + } + #endregion Playlists #region Profiles