/// <summary> /// Change a playlist’s name and public/private state. (The user must, of course, own the playlist.) /// </summary> /// <param name="playlistId">Required. The Spotify ID for the playlist.</param> /// <param name="details">Required. A <see cref="PlaylistDetails"/> objects containing Playlist details to change.</param> /// <param name="accessToken">The bearer token which is gotten during the authentication/authorization process.</param> /// <remarks> /// At least one optional parameter must be supplied. /// https://developer.spotify.com/documentation/web-api/reference/playlists/change-playlist-details/ /// </remarks> public async Task ChangePlaylistDetails( string playlistId, PlaylistDetails details, string accessToken = null) { if (string.IsNullOrWhiteSpace(playlistId)) { throw new ArgumentException("A valid Spotify playlist id must be specified."); } if (details == null) { throw new ArgumentNullException(nameof(details)); } var builder = new UriBuilder($"{BaseUrl}/playlists/{playlistId}"); await Put(builder.Uri, details, accessToken); }
/// <summary> /// Create a playlist for a Spotify user. (The playlist will be empty until you add tracks.) /// </summary> /// <param name="userId">Required. The user’s Spotify user ID.</param> /// <param name="details">Required. A <see cref="PlaylistDetails"/> objects containing the new Playlist details.</param> /// <param name="accessToken">The bearer token which is gotten during the authentication/authorization process.</param> /// <returns>A Task that, once successfully completed, returns the response deserialized as T.</returns> /// <remarks> /// https://developer.spotify.com/documentation/web-api/reference/playlists/create-playlist/ /// </remarks> public async Task <T> CreatePlaylist <T>( string userId, PlaylistDetails details, string accessToken = null) { if (string.IsNullOrWhiteSpace(userId)) { throw new ArgumentException("A valid Spotify user id must be specified."); } if (details == null || string.IsNullOrWhiteSpace(details.Name)) { throw new ArgumentException("A PlaylistDetails object param with new playlist name must be provided."); } var builder = new UriBuilder($"{BaseUrl}/users/{userId}/playlists"); return((await Post <T>(builder.Uri, details, accessToken)).Data); }
/// <summary> /// Create a playlist for a Spotify user. (The playlist will be empty until you add tracks.) /// </summary> /// <param name="userId">Required. The user’s Spotify user ID.</param> /// <param name="details">Required. A <see cref="PlaylistDetails"/> objects containing the new Playlist details.</param> /// <param name="accessToken">The bearer token which is gotten during the authentication/authorization process.</param> /// <returns>A Task that, once successfully completed, returns a full <see cref="Playlist"/> object.</returns> /// <remarks> /// https://developer.spotify.com/documentation/web-api/reference/playlists/create-playlist/ /// </remarks> public Task <Playlist> CreatePlaylist( string userId, PlaylistDetails details, string accessToken = null ) => CreatePlaylist <Playlist>(userId, details, accessToken: accessToken);