diff --git a/SpotifyAPI/Web/Models/Paging.cs b/SpotifyAPI/Web/Models/Paging.cs index d40a426e..6c37b323 100644 --- a/SpotifyAPI/Web/Models/Paging.cs +++ b/SpotifyAPI/Web/Models/Paging.cs @@ -26,5 +26,15 @@ namespace SpotifyAPI.Web.Models [JsonProperty("total")] public int Total { get; set; } + + public bool HasNextPage() + { + return Next != null; + } + + public bool HasPreviousPage() + { + return Next != null; + } } } \ No newline at end of file diff --git a/SpotifyAPI/Web/SpotifyWebAPI.cs b/SpotifyAPI/Web/SpotifyWebAPI.cs index 56dcc025..77dc8fa4 100644 --- a/SpotifyAPI/Web/SpotifyWebAPI.cs +++ b/SpotifyAPI/Web/SpotifyWebAPI.cs @@ -40,7 +40,7 @@ namespace SpotifyAPI.Web public void Dispose() { WebClient.Dispose(); - GC.SuppressFinalize(this); //TODO + GC.SuppressFinalize(this); } #region Search @@ -1450,16 +1450,34 @@ namespace SpotifyAPI.Web #region Util - public Paging Next(Paging paging) + public Paging GetNextPage(Paging paging) { + if (!paging.HasNextPage()) + throw new InvalidOperationException("This Paging-Object has no Next-Page"); return DownloadData>(paging.Next); } - public Paging Previous(Paging paging) + public async Task> GetNextPageAsync(Paging paging) { + if (!paging.HasNextPage()) + throw new InvalidOperationException("This Paging-Object has no Next-Page"); + return await DownloadDataAsync>(paging.Next); + } + + public Paging GetPreviousPage(Paging paging) + { + if (!paging.HasPreviousPage()) + throw new InvalidOperationException("This Paging-Object has no Previous-Page"); return DownloadData>(paging.Previous); } + public async Task> GetPreviousPageAsync(Paging paging) + { + if (!paging.HasPreviousPage()) + throw new InvalidOperationException("This Paging-Object has no Previous-Page"); + return await DownloadDataAsync>(paging.Previous); + } + public T UploadData(String url, String uploadData, String method = "POST") { if (!UseAuth)