diff --git a/SpotifyAPI/Web/SpotifyWebAPI.cs b/SpotifyAPI/Web/SpotifyWebAPI.cs index 5892641a..16f617d1 100644 --- a/SpotifyAPI/Web/SpotifyWebAPI.cs +++ b/SpotifyAPI/Web/SpotifyWebAPI.cs @@ -110,9 +110,9 @@ namespace SpotifyAPI.Web /// The index of the first result to return. Default: 0 /// An ISO 3166-1 alpha-2 country code or the string from_token. /// - public async Task SearchItemsAsync(string q, SearchType type, int limit = 20, int offset = 0, string market = "") + public Task SearchItemsAsync(string q, SearchType type, int limit = 20, int offset = 0, string market = "") { - return await DownloadDataAsync(_builder.SearchItems(q, type, limit, offset, market)); + return DownloadDataAsync(_builder.SearchItems(q, type, limit, offset, market)); } #endregion Search @@ -142,9 +142,9 @@ namespace SpotifyAPI.Web /// The index of the first track to return. Default: 0 (the first object). /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. /// - public async Task> GetAlbumTracksAsync(string id, int limit = 20, int offset = 0, string market = "") + public Task> GetAlbumTracksAsync(string id, int limit = 20, int offset = 0, string market = "") { - return await DownloadDataAsync>(_builder.GetAlbumTracks(id, limit, offset, market)); + return DownloadDataAsync>(_builder.GetAlbumTracks(id, limit, offset, market)); } /// @@ -164,9 +164,9 @@ namespace SpotifyAPI.Web /// The Spotify ID for the album. /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. /// - public async Task GetAlbumAsync(string id, string market = "") + public Task GetAlbumAsync(string id, string market = "") { - return await DownloadDataAsync(_builder.GetAlbum(id, market)); + return DownloadDataAsync(_builder.GetAlbum(id, market)); } /// @@ -186,9 +186,9 @@ namespace SpotifyAPI.Web /// A list of the Spotify IDs for the albums. Maximum: 20 IDs. /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. /// - public async Task GetSeveralAlbumsAsync(List ids, string market = "") + public Task GetSeveralAlbumsAsync(List ids, string market = "") { - return await DownloadDataAsync(_builder.GetSeveralAlbums(ids, market)); + return DownloadDataAsync(_builder.GetSeveralAlbums(ids, market)); } #endregion Albums @@ -210,9 +210,9 @@ namespace SpotifyAPI.Web /// /// The Spotify ID for the artist. /// - public async Task GetArtistAsync(string id) + public Task GetArtistAsync(string id) { - return await DownloadDataAsync(_builder.GetArtist(id)); + return DownloadDataAsync(_builder.GetArtist(id)); } /// @@ -232,9 +232,9 @@ namespace SpotifyAPI.Web /// /// The Spotify ID for the artist. /// - public async Task GetRelatedArtistsAsync(string id) + public Task GetRelatedArtistsAsync(string id) { - return await DownloadDataAsync(_builder.GetRelatedArtists(id)); + return DownloadDataAsync(_builder.GetRelatedArtists(id)); } /// @@ -254,9 +254,9 @@ namespace SpotifyAPI.Web /// The Spotify ID for the artist. /// The country: an ISO 3166-1 alpha-2 country code. /// - public async Task GetArtistsTopTracksAsync(string id, string country) + public Task GetArtistsTopTracksAsync(string id, string country) { - return await DownloadDataAsync(_builder.GetArtistsTopTracks(id, country)); + return DownloadDataAsync(_builder.GetArtistsTopTracks(id, country)); } /// @@ -296,9 +296,9 @@ namespace SpotifyAPI.Web /// geographical market /// /// - public async Task> GetArtistsAlbumsAsync(string id, AlbumType type = AlbumType.All, int limit = 20, int offset = 0, string market = "") + public Task> GetArtistsAlbumsAsync(string id, AlbumType type = AlbumType.All, int limit = 20, int offset = 0, string market = "") { - return await DownloadDataAsync>(_builder.GetArtistsAlbums(id, type, limit, offset, market)); + return DownloadDataAsync>(_builder.GetArtistsAlbums(id, type, limit, offset, market)); } /// @@ -316,9 +316,9 @@ namespace SpotifyAPI.Web /// /// A list of the Spotify IDs for the artists. Maximum: 50 IDs. /// - public async Task GetSeveralArtistsAsync(List ids) + public Task GetSeveralArtistsAsync(List ids) { - return await DownloadDataAsync(_builder.GetSeveralArtists(ids)); + return DownloadDataAsync(_builder.GetSeveralArtists(ids)); } #endregion Artists @@ -356,11 +356,11 @@ namespace SpotifyAPI.Web /// The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50. /// The index of the first item to return. Default: 0 /// AUTH NEEDED - public async Task GetFeaturedPlaylistsAsync(string locale = "", string country = "", DateTime timestamp = default(DateTime), int limit = 20, int offset = 0) + public Task GetFeaturedPlaylistsAsync(string locale = "", string country = "", DateTime timestamp = default(DateTime), int limit = 20, int offset = 0) { if (!UseAuth) throw new InvalidOperationException("Auth is required for GetFeaturedPlaylists"); - return await DownloadDataAsync(_builder.GetFeaturedPlaylists(locale, country, timestamp, limit, offset)); + return DownloadDataAsync(_builder.GetFeaturedPlaylists(locale, country, timestamp, limit, offset)); } /// @@ -386,11 +386,11 @@ namespace SpotifyAPI.Web /// The index of the first item to return. Default: 0 /// /// AUTH NEEDED - public async Task GetNewAlbumReleasesAsync(string country = "", int limit = 20, int offset = 0) + public Task GetNewAlbumReleasesAsync(string country = "", int limit = 20, int offset = 0) { if (!UseAuth) throw new InvalidOperationException("Auth is required for GetNewAlbumReleases"); - return await DownloadDataAsync(_builder.GetNewAlbumReleases(country, limit, offset)); + return DownloadDataAsync(_builder.GetNewAlbumReleases(country, limit, offset)); } /// @@ -430,11 +430,11 @@ namespace SpotifyAPI.Web /// The index of the first item to return. Default: 0 (the first object). /// /// AUTH NEEDED - public async Task GetCategoriesAsync(string country = "", string locale = "", int limit = 20, int offset = 0) + public Task GetCategoriesAsync(string country = "", string locale = "", int limit = 20, int offset = 0) { if (!UseAuth) throw new InvalidOperationException("Auth is required for GetCategories"); - return await DownloadDataAsync(_builder.GetCategories(country, locale, limit, offset)); + return DownloadDataAsync(_builder.GetCategories(country, locale, limit, offset)); } /// @@ -470,9 +470,9 @@ namespace SpotifyAPI.Web /// /// /// AUTH NEEDED - public async Task GetCategoryAsync(string categoryId, string country = "", string locale = "") + public Task GetCategoryAsync(string categoryId, string country = "", string locale = "") { - return await DownloadDataAsync(_builder.GetCategory(categoryId, country, locale)); + return DownloadDataAsync(_builder.GetCategory(categoryId, country, locale)); } /// @@ -498,9 +498,9 @@ namespace SpotifyAPI.Web /// The index of the first item to return. Default: 0 /// /// AUTH NEEDED - public async Task GetCategoryPlaylistsAsync(string categoryId, string country = "", int limit = 20, int offset = 0) + public Task GetCategoryPlaylistsAsync(string categoryId, string country = "", int limit = 20, int offset = 0) { - return await DownloadDataAsync(_builder.GetCategoryPlaylists(categoryId, country, limit, offset)); + return DownloadDataAsync(_builder.GetCategoryPlaylists(categoryId, country, limit, offset)); } /// @@ -553,10 +553,10 @@ namespace SpotifyAPI.Web /// Because min_*, max_* and target_* are applied to pools before relinking, the generated results may not precisely match the filters applied. /// /// AUTH NEEDED - public async Task GetRecommendationsAsync(List artistSeed = null, List genreSeed = null, List trackSeed = null, + public Task GetRecommendationsAsync(List artistSeed = null, List genreSeed = null, List trackSeed = null, TuneableTrack target = null, TuneableTrack min = null, TuneableTrack max = null, int limit = 20, string market = "") { - return await DownloadDataAsync(_builder.GetRecommendations(artistSeed, genreSeed, trackSeed, target, min, max, limit, market)); + return DownloadDataAsync(_builder.GetRecommendations(artistSeed, genreSeed, trackSeed, target, min, max, limit, market)); } /// @@ -574,9 +574,9 @@ namespace SpotifyAPI.Web /// /// /// AUTH NEEDED - public async Task GetRecommendationSeedsGenresAsync() + public Task GetRecommendationSeedsGenresAsync() { - return await DownloadDataAsync(_builder.GetRecommendationSeedsGenres()); + return DownloadDataAsync(_builder.GetRecommendationSeedsGenres()); } #endregion Browse @@ -606,11 +606,11 @@ namespace SpotifyAPI.Web /// The last artist ID retrieved from the previous request. /// /// AUTH NEEDED - public async Task GetFollowedArtistsAsync(FollowType followType, int limit = 20, string after = "") + public Task GetFollowedArtistsAsync(FollowType followType, int limit = 20, string after = "") { if (!UseAuth) throw new InvalidOperationException("Auth is required for GetFollowedArtists"); - return await DownloadDataAsync(_builder.GetFollowedArtists(limit, after)); + return DownloadDataAsync(_builder.GetFollowedArtists(limit, after)); } /// @@ -642,9 +642,8 @@ namespace SpotifyAPI.Web { {"ids", new JArray(ids)} }; - return await - UploadDataAsync(_builder.Follow(followType), - ob.ToString(Formatting.None), "PUT") ?? new ErrorResponse(); + return (await UploadDataAsync(_builder.Follow(followType), + ob.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse(); } /// @@ -666,9 +665,9 @@ namespace SpotifyAPI.Web /// Artists or the Users Spotify ID /// /// AUTH NEEDED - public async Task FollowAsync(FollowType followType, string id) + public Task FollowAsync(FollowType followType, string id) { - return await FollowAsync(followType, new List { id }); + return FollowAsync(followType, new List { id }); } /// @@ -700,7 +699,7 @@ namespace SpotifyAPI.Web { {"ids", new JArray(ids)} }; - return await UploadDataAsync(_builder.Unfollow(followType), ob.ToString(Formatting.None), "DELETE") ?? new ErrorResponse(); + return (await UploadDataAsync(_builder.Unfollow(followType), ob.ToString(Formatting.None), "DELETE").ConfigureAwait(false)) ?? new ErrorResponse(); } /// @@ -722,9 +721,9 @@ namespace SpotifyAPI.Web /// Artists or the Users Spotify ID /// /// AUTH NEEDED - public async Task UnfollowAsync(FollowType followType, string id) + public Task UnfollowAsync(FollowType followType, string id) { - return await UnfollowAsync(followType, new List { id }); + return UnfollowAsync(followType, new List { id }); } /// @@ -752,13 +751,13 @@ namespace SpotifyAPI.Web /// A list of the artist or the user Spotify IDs to check /// /// AUTH NEEDED - public async Task> IsFollowingAsync(FollowType followType, List ids) + public Task> IsFollowingAsync(FollowType followType, List ids) { if (!UseAuth) throw new InvalidOperationException("Auth is required for IsFollowing"); var url = _builder.IsFollowing(followType, ids); - return await DownloadListAsync(url); + return DownloadListAsync(url); } /// @@ -780,9 +779,9 @@ namespace SpotifyAPI.Web /// Artists or the Users Spotify ID /// /// AUTH NEEDED - public async Task> IsFollowingAsync(FollowType followType, string id) + public Task> IsFollowingAsync(FollowType followType, string id) { - return await IsFollowingAsync(followType, new List { id }); + return IsFollowingAsync(followType, new List { id }); } /// @@ -822,13 +821,13 @@ namespace SpotifyAPI.Web /// /// /// AUTH NEEDED - public async Task FollowPlaylistAsync(string ownerId, string playlistId, bool showPublic = true) + public Task FollowPlaylistAsync(string ownerId, string playlistId, bool showPublic = true) { JObject body = new JObject { {"public", showPublic} }; - return await UploadDataAsync(_builder.FollowPlaylist(ownerId, playlistId, showPublic), body.ToString(Formatting.None), "PUT"); + return UploadDataAsync(_builder.FollowPlaylist(ownerId, playlistId, showPublic), body.ToString(Formatting.None), "PUT"); } /// @@ -850,9 +849,9 @@ namespace SpotifyAPI.Web /// The Spotify ID of the playlist that is to be no longer followed. /// /// AUTH NEEDED - public async Task UnfollowPlaylistAsync(string ownerId, string playlistId) + public Task UnfollowPlaylistAsync(string ownerId, string playlistId) { - return await UploadDataAsync(_builder.UnfollowPlaylist(ownerId, playlistId), "", "DELETE"); + return UploadDataAsync(_builder.UnfollowPlaylist(ownerId, playlistId), "", "DELETE"); } /// @@ -880,13 +879,13 @@ namespace SpotifyAPI.Web /// A list of Spotify User IDs /// /// AUTH NEEDED - public async Task> IsFollowingPlaylistAsync(string ownerId, string playlistId, List ids) + public Task> IsFollowingPlaylistAsync(string ownerId, string playlistId, List ids) { if (!UseAuth) throw new InvalidOperationException("Auth is required for IsFollowingPlaylist"); var url = _builder.IsFollowingPlaylist(ownerId, playlistId, ids); - return await DownloadListAsync(url); + return DownloadListAsync(url); } /// @@ -910,9 +909,9 @@ namespace SpotifyAPI.Web /// A Spotify User ID /// /// AUTH NEEDED - public async Task> IsFollowingPlaylistAsync(string ownerId, string playlistId, string id) + public Task> IsFollowingPlaylistAsync(string ownerId, string playlistId, string id) { - return await IsFollowingPlaylistAsync(ownerId, playlistId, new List { id }); + return IsFollowingPlaylistAsync(ownerId, playlistId, new List { id }); } #endregion Follow @@ -940,7 +939,7 @@ namespace SpotifyAPI.Web public async Task SaveTracksAsync(List ids) { JArray array = new JArray(ids); - return await UploadDataAsync(_builder.SaveTracks(), array.ToString(Formatting.None), "PUT") ?? new ErrorResponse(); + return (await UploadDataAsync(_builder.SaveTracks(), array.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse(); } /// @@ -960,9 +959,9 @@ namespace SpotifyAPI.Web /// A Spotify ID /// /// AUTH NEEDED - public async Task SaveTrackAsync(string id) + public Task SaveTrackAsync(string id) { - return await SaveTracksAsync(new List { id }); + return SaveTracksAsync(new List { id }); } /// @@ -988,11 +987,11 @@ namespace SpotifyAPI.Web /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. /// /// AUTH NEEDED - public async Task> GetSavedTracksAsync(int limit = 20, int offset = 0, string market = "") + public Task> GetSavedTracksAsync(int limit = 20, int offset = 0, string market = "") { if (!UseAuth) throw new InvalidOperationException("Auth is required for GetSavedTracks"); - return await DownloadDataAsync>(_builder.GetSavedTracks(limit, offset, market)); + return DownloadDataAsync>(_builder.GetSavedTracks(limit, offset, market)); } /// @@ -1016,7 +1015,7 @@ namespace SpotifyAPI.Web public async Task RemoveSavedTracksAsync(List ids) { JArray array = new JArray(ids); - return await UploadDataAsync(_builder.RemoveSavedTracks(), array.ToString(Formatting.None), "DELETE") ?? new ErrorResponse(); + return (await UploadDataAsync(_builder.RemoveSavedTracks(), array.ToString(Formatting.None), "DELETE").ConfigureAwait(false)) ?? new ErrorResponse(); } /// @@ -1040,12 +1039,12 @@ namespace SpotifyAPI.Web /// A list of the Spotify IDs. /// /// AUTH NEEDED - public async Task> CheckSavedTracksAsync(List ids) + public Task> CheckSavedTracksAsync(List ids) { if (!UseAuth) throw new InvalidOperationException("Auth is required for CheckSavedTracks"); var url = _builder.CheckSavedTracks(ids); - return await DownloadListAsync(url); + return DownloadListAsync(url); } /// @@ -1069,7 +1068,7 @@ namespace SpotifyAPI.Web public async Task SaveAlbumsAsync(List ids) { JArray array = new JArray(ids); - return await UploadDataAsync(_builder.SaveAlbums(), array.ToString(Formatting.None), "PUT") ?? new ErrorResponse(); + return (await UploadDataAsync(_builder.SaveAlbums(), array.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse(); } /// @@ -1089,9 +1088,9 @@ namespace SpotifyAPI.Web /// A Spotify ID /// /// AUTH NEEDED - public async Task SaveAlbumAsync(string id) + public Task SaveAlbumAsync(string id) { - return await SaveAlbumsAsync(new List { id }); + return SaveAlbumsAsync(new List { id }); } /// @@ -1117,11 +1116,11 @@ namespace SpotifyAPI.Web /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. /// /// AUTH NEEDED - public async Task> GetSavedAlbumsAsync(int limit = 20, int offset = 0, string market = "") + public Task> GetSavedAlbumsAsync(int limit = 20, int offset = 0, string market = "") { if (!UseAuth) throw new InvalidOperationException("Auth is required for GetSavedAlbumsAsync"); - return await DownloadDataAsync>(_builder.GetSavedAlbums(limit, offset, market)); + return DownloadDataAsync>(_builder.GetSavedAlbums(limit, offset, market)); } /// @@ -1145,7 +1144,7 @@ namespace SpotifyAPI.Web public async Task RemoveSavedAlbumsAsync(List ids) { JArray array = new JArray(ids); - return await UploadDataAsync(_builder.RemoveSavedAlbums(), array.ToString(Formatting.None), "DELETE") ?? new ErrorResponse(); + return (await UploadDataAsync(_builder.RemoveSavedAlbums(), array.ToString(Formatting.None), "DELETE").ConfigureAwait(false)) ?? new ErrorResponse(); } /// @@ -1169,12 +1168,12 @@ namespace SpotifyAPI.Web /// A list of the Spotify IDs. /// /// AUTH NEEDED - public async Task> CheckSavedAlbumsAsync(List ids) + public Task> CheckSavedAlbumsAsync(List ids) { if (!UseAuth) throw new InvalidOperationException("Auth is required for CheckSavedAlbumsAsync"); var url = _builder.CheckSavedAlbums(ids); - return await DownloadListAsync(url); + return DownloadListAsync(url); } #endregion Library @@ -1206,9 +1205,9 @@ namespace SpotifyAPI.Web /// The index of the first entity to return. Default: 0 (i.e., the first track). Use with limit to get the next set of entities. /// /// AUTH NEEDED - public async Task> GetUsersTopTracksAsync(TimeRangeType timeRange = TimeRangeType.MediumTerm, int limit = 20, int offest = 0) + public Task> GetUsersTopTracksAsync(TimeRangeType timeRange = TimeRangeType.MediumTerm, int limit = 20, int offest = 0) { - return await DownloadDataAsync>(_builder.GetUsersTopTracks(timeRange, limit, offest)); + return DownloadDataAsync>(_builder.GetUsersTopTracks(timeRange, limit, offest)); } /// @@ -1236,9 +1235,9 @@ namespace SpotifyAPI.Web /// The index of the first entity to return. Default: 0 (i.e., the first track). Use with limit to get the next set of entities. /// /// AUTH NEEDED - public async Task> GetUsersTopArtistsAsync(TimeRangeType timeRange = TimeRangeType.MediumTerm, int limit = 20, int offest = 0) + public Task> GetUsersTopArtistsAsync(TimeRangeType timeRange = TimeRangeType.MediumTerm, int limit = 20, int offest = 0) { - return await DownloadDataAsync>(_builder.GetUsersTopArtists(timeRange, limit, offest)); + return DownloadDataAsync>(_builder.GetUsersTopArtists(timeRange, limit, offest)); } #endregion @@ -1268,11 +1267,11 @@ namespace SpotifyAPI.Web /// The index of the first playlist to return. Default: 0 (the first object) /// /// AUTH NEEDED - public async Task> GetUserPlaylistsAsync(string userId, int limit = 20, int offset = 0) + public Task> GetUserPlaylistsAsync(string userId, int limit = 20, int offset = 0) { if (!UseAuth) throw new InvalidOperationException("Auth is required for GetUserPlaylists"); - return await DownloadDataAsync>(_builder.GetUserPlaylists(userId, limit, offset)); + return DownloadDataAsync>(_builder.GetUserPlaylists(userId, limit, offset)); } /// @@ -1306,11 +1305,11 @@ namespace SpotifyAPI.Web /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. /// /// AUTH NEEDED - public async Task GetPlaylistAsync(string userId, string playlistId, string fields = "", string market = "") + public Task GetPlaylistAsync(string userId, string playlistId, string fields = "", string market = "") { if (!UseAuth) throw new InvalidOperationException("Auth is required for GetPlaylist"); - return await DownloadDataAsync(_builder.GetPlaylist(userId, playlistId, fields, market)); + return DownloadDataAsync(_builder.GetPlaylist(userId, playlistId, fields, market)); } /// @@ -1348,11 +1347,11 @@ namespace SpotifyAPI.Web /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. /// /// AUTH NEEDED - public async Task> GetPlaylistTracksAsync(string userId, string playlistId, string fields = "", int limit = 100, int offset = 0, string market = "") + public Task> GetPlaylistTracksAsync(string userId, string playlistId, string fields = "", int limit = 100, int offset = 0, string market = "") { if (!UseAuth) throw new InvalidOperationException("Auth is required for GetPlaylistTracks"); - return await DownloadDataAsync>(_builder.GetPlaylistTracks(userId, playlistId, fields, limit, offset, market)); + return DownloadDataAsync>(_builder.GetPlaylistTracks(userId, playlistId, fields, limit, offset, market)); } /// @@ -1393,14 +1392,14 @@ namespace SpotifyAPI.Web /// /// /// AUTH NEEDED - public async Task CreatePlaylistAsync(string userId, string playlistName, bool isPublic = true) + public Task CreatePlaylistAsync(string userId, string playlistName, bool isPublic = true) { JObject body = new JObject { {"name", playlistName}, {"public", isPublic} }; - return await UploadDataAsync(_builder.CreatePlaylist(userId, playlistName, isPublic), body.ToString(Formatting.None)); + return UploadDataAsync(_builder.CreatePlaylist(userId, playlistName, isPublic), body.ToString(Formatting.None)); } /// @@ -1438,7 +1437,7 @@ namespace SpotifyAPI.Web body.Add("name", newName); if (newPublic != null) body.Add("public", newPublic); - return await UploadDataAsync(_builder.UpdatePlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse(); + return (await UploadDataAsync(_builder.UpdatePlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse(); } /// @@ -1474,7 +1473,7 @@ namespace SpotifyAPI.Web { {"uris", new JArray(uris.Take(100))} }; - return await UploadDataAsync(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse(); + return await (UploadDataAsync(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false)) ?? new ErrorResponse(); } /// @@ -1514,7 +1513,7 @@ namespace SpotifyAPI.Web { {"tracks", JArray.FromObject(uris.Take(100))} }; - return await UploadDataAsync(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE") ?? new ErrorResponse(); + return await (UploadDataAsync(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE").ConfigureAwait(false)) ?? new ErrorResponse(); } /// @@ -1538,9 +1537,9 @@ namespace SpotifyAPI.Web /// Spotify URI /// /// AUTH NEEDED - public async Task RemovePlaylistTrackAsync(string userId, string playlistId, DeleteTrackUri uri) + public Task RemovePlaylistTrackAsync(string userId, string playlistId, DeleteTrackUri uri) { - return await RemovePlaylistTracksAsync(userId, playlistId, new List { uri }); + return RemovePlaylistTracksAsync(userId, playlistId, new List { uri }); } /// @@ -1576,7 +1575,7 @@ namespace SpotifyAPI.Web { {"uris", JArray.FromObject(uris.Take(100))} }; - return await UploadDataAsync(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)) ?? new ErrorResponse(); + return await (UploadDataAsync(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)).ConfigureAwait(false)) ?? new ErrorResponse(); } /// @@ -1602,9 +1601,9 @@ namespace SpotifyAPI.Web /// The position to insert the tracks, a zero-based index /// /// AUTH NEEDED - public async Task AddPlaylistTrackAsync(string userId, string playlistId, string uri, int? position = null) + public Task AddPlaylistTrackAsync(string userId, string playlistId, string uri, int? position = null) { - return await AddPlaylistTracksAsync(userId, playlistId, new List { uri }, position); + return AddPlaylistTracksAsync(userId, playlistId, new List { uri }, position); } /// @@ -1642,7 +1641,7 @@ namespace SpotifyAPI.Web /// The playlist's snapshot ID against which you want to make the changes. /// /// AUTH NEEDED - public async Task ReorderPlaylistAsync(string userId, string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "") + public Task ReorderPlaylistAsync(string userId, string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "") { JObject body = new JObject { @@ -1653,7 +1652,7 @@ namespace SpotifyAPI.Web }; if (!string.IsNullOrEmpty(snapshotId)) body.Add("snapshot_id", snapshotId); - return await UploadDataAsync(_builder.ReorderPlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT"); + return UploadDataAsync(_builder.ReorderPlaylist(userId, playlistId), body.ToString(Formatting.None), "PUT"); } #endregion Playlists @@ -1677,11 +1676,11 @@ namespace SpotifyAPI.Web /// /// /// AUTH NEEDED - public async Task GetPrivateProfileAsync() + public Task GetPrivateProfileAsync() { if (!UseAuth) throw new InvalidOperationException("Auth is required for GetPrivateProfile"); - return await DownloadDataAsync(_builder.GetPrivateProfile()); + return DownloadDataAsync(_builder.GetPrivateProfile()); } /// @@ -1699,9 +1698,9 @@ namespace SpotifyAPI.Web /// /// The user's Spotify user ID. /// - public async Task GetPublicProfileAsync(string userId) + public Task GetPublicProfileAsync(string userId) { - return await DownloadDataAsync(_builder.GetPublicProfile(userId)); + return DownloadDataAsync(_builder.GetPublicProfile(userId)); } #endregion Profiles @@ -1725,9 +1724,9 @@ namespace SpotifyAPI.Web /// A list of the Spotify IDs for the tracks. Maximum: 50 IDs. /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. /// - public async Task GetSeveralTracksAsync(List ids, string market = "") + public Task GetSeveralTracksAsync(List ids, string market = "") { - return await DownloadDataAsync(_builder.GetSeveralTracks(ids, market)); + return DownloadDataAsync(_builder.GetSeveralTracks(ids, market)); } /// @@ -1747,9 +1746,9 @@ namespace SpotifyAPI.Web /// The Spotify ID for the track. /// An ISO 3166-1 alpha-2 country code. Provide this parameter if you want to apply Track Relinking. /// - public async Task GetTrackAsync(string id, string market = "") + public Task GetTrackAsync(string id, string market = "") { - return await DownloadDataAsync(_builder.GetTrack(id, market)); + return DownloadDataAsync(_builder.GetTrack(id, market)); } /// @@ -1769,9 +1768,9 @@ namespace SpotifyAPI.Web /// The Spotify ID for the track. /// /// AUTH NEEDED - public async Task GetAudioFeaturesAsync(string id) + public Task GetAudioFeaturesAsync(string id) { - return await DownloadDataAsync(_builder.GetAudioFeatures(id)); + return DownloadDataAsync(_builder.GetAudioFeatures(id)); } /// @@ -1791,9 +1790,9 @@ namespace SpotifyAPI.Web /// A list of Spotify Track-IDs. Maximum: 100 IDs. /// /// AUTH NEEDED - public async Task GetSeveralAudioFeaturesAsync(List ids) + public Task GetSeveralAudioFeaturesAsync(List ids) { - return await DownloadDataAsync(_builder.GetSeveralAudioFeatures(ids)); + return DownloadDataAsync(_builder.GetSeveralAudioFeatures(ids)); } #endregion Tracks @@ -1812,16 +1811,16 @@ namespace SpotifyAPI.Web return GetNextPage, T>(paging); } - public async Task GetNextPageAsync(Paging paging) where TOut : BasicModel + public Task GetNextPageAsync(Paging paging) where TOut : BasicModel { if (!paging.HasNextPage()) throw new InvalidOperationException("This Paging-Object has no Next-Page"); - return await DownloadDataAsync(paging.Next); + return DownloadDataAsync(paging.Next); } - public async Task> GetNextPageAsync(Paging paging) + public Task> GetNextPageAsync(Paging paging) { - return await GetNextPageAsync, T>(paging); + return GetNextPageAsync, T>(paging); } public TOut GetPreviousPage(Paging paging) where TOut : BasicModel @@ -1836,16 +1835,16 @@ namespace SpotifyAPI.Web return GetPreviousPage, T>(paging); } - public async Task GetPreviousPageAsync(Paging paging) where TOut : BasicModel + public Task GetPreviousPageAsync(Paging paging) where TOut : BasicModel { if (!paging.HasPreviousPage()) throw new InvalidOperationException("This Paging-Object has no Previous-Page"); - return await DownloadDataAsync(paging.Previous); + return DownloadDataAsync(paging.Previous); } - public async Task> GetPreviousPageAsync(Paging paging) + public Task> GetPreviousPageAsync(Paging paging) { - return await GetPreviousPageAsync, T>(paging); + return GetPreviousPageAsync, T>(paging); } private ListResponse DownloadList(string url) @@ -1877,8 +1876,8 @@ namespace SpotifyAPI.Web ListResponse data = null; do { - if (data != null) { await Task.Delay(RetryAfter); } - Tuple res = await DownloadDataAltAsync(url); + if (data != null) { await Task.Delay(RetryAfter).ConfigureAwait(false); } + Tuple res = await DownloadDataAltAsync(url).ConfigureAwait(false); data = ExtractDataToListResponse(res); lastError = data.Error; @@ -1953,8 +1952,8 @@ namespace SpotifyAPI.Web WebClient.SetHeader("Authorization", TokenType + " " + AccessToken); WebClient.SetHeader("Content-Type", "application/json"); - if (response != null) { await Task.Delay(RetryAfter); } - response = await WebClient.UploadJsonAsync(url, uploadData, method); + if (response != null) { await Task.Delay(RetryAfter).ConfigureAwait(false); } + response = await WebClient.UploadJsonAsync(url, uploadData, method).ConfigureAwait(false); response.Item2.AddResponseInfo(response.Item1); lastError = response.Item2.Error; @@ -1996,8 +1995,8 @@ namespace SpotifyAPI.Web Tuple response = null; do { - if (response != null) { await Task.Delay(RetryAfter); } - response = await DownloadDataAltAsync(url); + if (response != null) { await Task.Delay(RetryAfter).ConfigureAwait(false); } + response = await DownloadDataAltAsync(url).ConfigureAwait(false); response.Item2.AddResponseInfo(response.Item1); lastError = response.Item2.Error;