Added overload for NextPage stuff CursorPaging

This commit is contained in:
Jonas Dellinger 2019-05-20 16:57:24 +02:00
parent 4cfda50859
commit 67427cdb72
2 changed files with 48 additions and 19 deletions

View File

@ -22,5 +22,10 @@ namespace SpotifyAPI.Web.Models
[JsonProperty("total")] [JsonProperty("total")]
public int Total { get; set; } public int Total { get; set; }
public bool HasNext()
{
return !string.IsNullOrEmpty(Next);
}
} }
} }

View File

@ -2694,11 +2694,23 @@ namespace SpotifyAPI.Web
return DownloadData<TOut>(paging.Next); return DownloadData<TOut>(paging.Next);
} }
public TOut GetNextPage<TOut, TIn>(CursorPaging<TIn> paging) where TOut : BasicModel
{
if (!paging.HasNext())
throw new InvalidOperationException("This CursorPaging-Object has no Next-Page");
return DownloadData<TOut>(paging.Next);
}
public Paging<T> GetNextPage<T>(Paging<T> paging) public Paging<T> GetNextPage<T>(Paging<T> paging)
{ {
return GetNextPage<Paging<T>, T>(paging); return GetNextPage<Paging<T>, T>(paging);
} }
public CursorPaging<T> GetNextPage<T>(CursorPaging<T> paging)
{
return GetNextPage<CursorPaging<T>, T>(paging);
}
public Task<TOut> GetNextPageAsync<TOut, TIn>(Paging<TIn> paging) where TOut : BasicModel public Task<TOut> GetNextPageAsync<TOut, TIn>(Paging<TIn> paging) where TOut : BasicModel
{ {
if (!paging.HasNextPage()) if (!paging.HasNextPage())
@ -2706,11 +2718,23 @@ namespace SpotifyAPI.Web
return DownloadDataAsync<TOut>(paging.Next); return DownloadDataAsync<TOut>(paging.Next);
} }
public Task<TOut> GetNextPageAsync<TOut, TIn>(CursorPaging<TIn> paging) where TOut : BasicModel
{
if (!paging.HasNext())
throw new InvalidOperationException("This Paging-Object has no Next-Page");
return DownloadDataAsync<TOut>(paging.Next);
}
public Task<Paging<T>> GetNextPageAsync<T>(Paging<T> paging) public Task<Paging<T>> GetNextPageAsync<T>(Paging<T> paging)
{ {
return GetNextPageAsync<Paging<T>, T>(paging); return GetNextPageAsync<Paging<T>, T>(paging);
} }
public Task<CursorPaging<T>> GetNextPageAsync<T>(CursorPaging<T> paging)
{
return GetNextPageAsync<CursorPaging<T>, T>(paging);
}
public TOut GetPreviousPage<TOut, TIn>(Paging<TIn> paging) where TOut : BasicModel public TOut GetPreviousPage<TOut, TIn>(Paging<TIn> paging) where TOut : BasicModel
{ {
if (!paging.HasPreviousPage()) if (!paging.HasPreviousPage())