2020-05-31 14:56:49 +01:00
|
|
|
using System.Threading;
|
2020-05-05 04:26:37 +01:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Threading.Tasks;
|
2020-05-30 22:20:42 +01:00
|
|
|
using SpotifyAPI.Web.Http;
|
2020-05-05 04:26:37 +01:00
|
|
|
|
2020-05-01 19:05:28 +01:00
|
|
|
namespace SpotifyAPI.Web
|
|
|
|
{
|
2020-05-02 12:04:26 +01:00
|
|
|
public interface ISpotifyClient
|
2020-05-01 19:05:28 +01:00
|
|
|
{
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// The default paginator used by the Paginator methods
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-05 04:26:37 +01:00
|
|
|
IPaginator DefaultPaginator { get; }
|
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Operations related to Spotify User Profiles
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-01 19:05:28 +01:00
|
|
|
IUserProfileClient UserProfile { get; }
|
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Operations related to Spotify Browse Endpoints
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-01 19:05:28 +01:00
|
|
|
IBrowseClient Browse { get; }
|
2020-05-02 21:48:21 +01:00
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Operations related to Spotify Shows
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-02 21:48:21 +01:00
|
|
|
IShowsClient Shows { get; }
|
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Operations related to Spotify Playlists
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-02 21:48:21 +01:00
|
|
|
IPlaylistsClient Playlists { get; }
|
2020-05-03 21:34:03 +01:00
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Operations related to Spotify Search
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-03 21:34:03 +01:00
|
|
|
ISearchClient Search { get; }
|
2020-05-04 22:02:53 +01:00
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Operations related to Spotify Follows
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-04 22:02:53 +01:00
|
|
|
IFollowClient Follow { get; }
|
2020-05-04 22:04:59 +01:00
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Operations related to Spotify Tracks
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-04 22:04:59 +01:00
|
|
|
ITracksClient Tracks { get; }
|
2020-05-05 04:26:37 +01:00
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Operations related to Spotify Player Endpoints
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-07 17:03:20 +01:00
|
|
|
IPlayerClient Player { get; }
|
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Operations related to Spotify Albums
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-07 21:33:29 +01:00
|
|
|
IAlbumsClient Albums { get; }
|
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Operations related to Spotify Artists
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-08 10:10:53 +01:00
|
|
|
IArtistsClient Artists { get; }
|
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Operations related to Spotify Personalization Endpoints
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-08 11:09:59 +01:00
|
|
|
IPersonalizationClient Personalization { get; }
|
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Operations related to Spotify Podcast Episodes
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-11 17:43:52 +01:00
|
|
|
IEpisodesClient Episodes { get; }
|
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Operations related to Spotify User Library
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-20 07:48:08 +01:00
|
|
|
ILibraryClient Library { get; }
|
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the last response received by an API call.
|
|
|
|
/// </summary>
|
|
|
|
/// <value></value>
|
2020-05-30 22:20:42 +01:00
|
|
|
IResponse? LastResponse { get; }
|
2020-05-20 19:59:11 +01:00
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Fetches all pages and returns them grouped in a list.
|
|
|
|
/// The default paginator will fetch all available resources without a delay between requests.
|
|
|
|
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="firstPage">The first page, will be included in the output list!</param>
|
|
|
|
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
|
|
|
|
/// <typeparam name="T">The Paging-Type</typeparam>
|
|
|
|
/// <returns>A list containing all fetched pages</returns>
|
|
|
|
Task<IList<T>> PaginateAll<T>(Paging<T> firstPage, IPaginator? paginator = default!);
|
2020-05-30 22:20:42 +01:00
|
|
|
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Fetches all pages and returns them grouped in a list.
|
|
|
|
/// The default paginator will fetch all available resources without a delay between requests.
|
|
|
|
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="getFirstPage">A function to retrive the first page, will be included in the output list!</param>
|
|
|
|
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
|
|
|
|
/// <typeparam name="T">The Paging-Type</typeparam>
|
|
|
|
/// <returns>A list containing all fetched pages</returns>
|
|
|
|
Task<IList<T>> PaginateAll<T>(Func<Task<Paging<T>>> getFirstPage, IPaginator? paginator = default!);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Fetches all pages and returns them grouped in a list.
|
|
|
|
/// The default paginator will fetch all available resources without a delay between requests.
|
|
|
|
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="firstPageTask">A task to retrive the first page, will be included in the output list!</param>
|
|
|
|
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
|
|
|
|
/// <typeparam name="T">The Paging-Type</typeparam>
|
|
|
|
/// <returns>A list containing all fetched pages</returns>
|
|
|
|
Task<IList<T>> PaginateAll<T>(Task<Paging<T>> firstPageTask, IPaginator? paginator = default!);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Fetches all pages and returns them grouped in a list.
|
|
|
|
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
|
|
|
|
/// To workaround this limitation, the mapper is required and needs to point to the correct next pagination.
|
|
|
|
/// The default paginator will fetch all available resources without a delay between requests.
|
|
|
|
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="firstPage">A first page, will be included in the output list!</param>
|
|
|
|
/// <param name="mapper">A function which maps response objects to the next paging object</param>
|
|
|
|
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
|
|
|
|
/// <typeparam name="T">The Paging-Type</typeparam>
|
|
|
|
/// <returns>A list containing all fetched pages</returns>
|
|
|
|
Task<IList<T>> PaginateAll<T, TNext>(
|
|
|
|
Paging<T, TNext> firstPage,
|
|
|
|
Func<TNext, Paging<T, TNext>> mapper,
|
|
|
|
IPaginator? paginator = default!
|
|
|
|
);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Fetches all pages and returns them grouped in a list.
|
|
|
|
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
|
|
|
|
/// To workaround this limitation, the mapper is required and needs to point to the correct next pagination.
|
|
|
|
/// The default paginator will fetch all available resources without a delay between requests.
|
|
|
|
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="getFirstPage">A function to retrive the first page, will be included in the output list!</param>
|
|
|
|
/// <param name="mapper">A function which maps response objects to the next paging object</param>
|
|
|
|
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
|
|
|
|
/// <typeparam name="T">The Paging-Type</typeparam>
|
|
|
|
/// <typeparam name="TNext">The Response-Type</typeparam>
|
|
|
|
/// <returns></returns>
|
|
|
|
Task<IList<T>> PaginateAll<T, TNext>(
|
|
|
|
Func<Task<Paging<T, TNext>>> getFirstPage,
|
|
|
|
Func<TNext, Paging<T, TNext>> mapper,
|
|
|
|
IPaginator? paginator = default!
|
|
|
|
);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Fetches all pages and returns them grouped in a list.
|
|
|
|
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
|
|
|
|
/// To workaround this limitation, the mapper is required and needs to point to the correct next pagination.
|
|
|
|
/// The default paginator will fetch all available resources without a delay between requests.
|
|
|
|
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="firstPageTask">A Task to retrive the first page, will be included in the output list!</param>
|
|
|
|
/// <param name="mapper">A function which maps response objects to the next paging object</param>
|
|
|
|
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
|
|
|
|
/// <typeparam name="T">The Paging-Type</typeparam>
|
|
|
|
/// <typeparam name="TNext">The Response-Type</typeparam>
|
|
|
|
/// <returns></returns>
|
|
|
|
Task<IList<T>> PaginateAll<T, TNext>(
|
|
|
|
Task<Paging<T, TNext>> firstPageTask,
|
|
|
|
Func<TNext, Paging<T, TNext>> mapper,
|
|
|
|
IPaginator? paginator = default!
|
|
|
|
);
|
2020-05-20 19:59:11 +01:00
|
|
|
|
|
|
|
#if NETSTANDARD2_1
|
2020-05-31 14:56:49 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
|
|
|
|
/// The default paginator will fetch all available resources without a delay between requests.
|
|
|
|
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="firstPage">A first page, will be included in the output list!</param>
|
|
|
|
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
|
|
|
|
/// <param name="cancellationToken">An optional Cancellation Token</param>
|
|
|
|
/// <typeparam name="T">The Paging-Type</typeparam>
|
|
|
|
/// <returns>An iterable IAsyncEnumerable</returns>
|
|
|
|
IAsyncEnumerable<T> Paginate<T>(
|
|
|
|
Paging<T> firstPage,
|
|
|
|
IPaginator? paginator = default!,
|
|
|
|
CancellationToken cancellationToken = default!
|
|
|
|
);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
|
|
|
|
/// The default paginator will fetch all available resources without a delay between requests.
|
|
|
|
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="getFirstPage">A Function to retrive the first page, will be included in the output list!</param>
|
|
|
|
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
|
|
|
|
/// <param name="cancellationToken">An optional Cancellation Token</param>
|
|
|
|
/// <typeparam name="T">The Paging-Type</typeparam>
|
|
|
|
/// <returns>An iterable IAsyncEnumerable</returns>
|
|
|
|
IAsyncEnumerable<T> Paginate<T>(
|
|
|
|
Func<Task<Paging<T>>> getFirstPage,
|
|
|
|
IPaginator? paginator = default!,
|
|
|
|
CancellationToken cancellationToken = default!
|
|
|
|
);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
|
|
|
|
/// The default paginator will fetch all available resources without a delay between requests.
|
|
|
|
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="firstPageTask">A Task to retrive the first page, will be included in the output list!</param>
|
|
|
|
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
|
|
|
|
/// <param name="cancellationToken">An optional Cancellation Token</param>
|
|
|
|
/// <typeparam name="T">The Paging-Type</typeparam>
|
|
|
|
/// <returns>An iterable IAsyncEnumerable</returns>
|
|
|
|
IAsyncEnumerable<T> Paginate<T>(
|
|
|
|
Task<Paging<T>> firstPageTask,
|
|
|
|
IPaginator? paginator = default!,
|
|
|
|
CancellationToken cancellationToken = default!
|
|
|
|
);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
|
|
|
|
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
|
|
|
|
/// To workaround this limitation, the mapper is required and needs to point to the correct next pagination.
|
|
|
|
/// The default paginator will fetch all available resources without a delay between requests.
|
|
|
|
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="firstPage">A first page, will be included in the output list!</param>
|
|
|
|
/// <param name="mapper">A function which maps response objects to the next paging object</param>
|
|
|
|
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
|
|
|
|
/// <param name="cancellationToken">An optional Cancellation Token</param>
|
|
|
|
/// <typeparam name="T">The Paging-Type</typeparam>
|
|
|
|
/// <typeparam name="TNext">The Response-Type</typeparam>
|
|
|
|
/// <returns></returns>
|
|
|
|
IAsyncEnumerable<T> Paginate<T, TNext>(
|
|
|
|
Paging<T, TNext> firstPage,
|
|
|
|
Func<TNext, Paging<T, TNext>> mapper,
|
|
|
|
IPaginator? paginator = default!,
|
|
|
|
CancellationToken cancellationToken = default!
|
|
|
|
);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
|
|
|
|
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
|
|
|
|
/// To workaround this limitation, the mapper is required and needs to point to the correct next pagination.
|
|
|
|
/// The default paginator will fetch all available resources without a delay between requests.
|
|
|
|
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="getFirstPage">A Function to retrive the first page, will be included in the output list!</param>
|
|
|
|
/// <param name="mapper">A function which maps response objects to the next paging object</param>
|
|
|
|
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
|
|
|
|
/// <param name="cancellationToken">An optional Cancellation Token</param>
|
|
|
|
/// <typeparam name="T">The Paging-Type</typeparam>
|
|
|
|
/// <typeparam name="TNext">The Response-Type</typeparam>
|
|
|
|
/// <returns></returns>
|
|
|
|
IAsyncEnumerable<T> Paginate<T, TNext>(
|
|
|
|
Func<Task<Paging<T, TNext>>> getFirstPage,
|
|
|
|
Func<TNext, Paging<T, TNext>> mapper,
|
|
|
|
IPaginator? paginator = default!,
|
|
|
|
CancellationToken cancellationToken = default!
|
|
|
|
);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Paginate through pages by using IAsyncEnumerable, introduced in C# 8
|
|
|
|
/// Some responses (e.g search response) have the pagination nested in a JSON Property.
|
|
|
|
/// To workaround this limitation, the mapper is required and needs to point to the correct next pagination.
|
|
|
|
/// The default paginator will fetch all available resources without a delay between requests.
|
|
|
|
/// This can drain your request limit quite fast, so consider using a custom paginator with delays.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="firstPageTask">A Task to retrive the first page, will be included in the output list!</param>
|
|
|
|
/// <param name="mapper">A function which maps response objects to the next paging object</param>
|
|
|
|
/// <param name="paginator">Optional. If not supplied, DefaultPaginator will be used</param>
|
|
|
|
/// <param name="cancellationToken">An optional Cancellation Token</param>
|
|
|
|
/// <typeparam name="T">The Paging-Type</typeparam>
|
|
|
|
/// <typeparam name="TNext">The Response-Type</typeparam>
|
|
|
|
/// <returns></returns>
|
|
|
|
IAsyncEnumerable<T> Paginate<T, TNext>(
|
|
|
|
Task<Paging<T, TNext>> firstPageTask,
|
|
|
|
Func<TNext, Paging<T, TNext>> mapper,
|
|
|
|
IPaginator? paginator = default!,
|
|
|
|
CancellationToken cancellationToken = default!
|
|
|
|
);
|
2020-05-20 19:59:11 +01:00
|
|
|
#endif
|
2020-05-01 19:05:28 +01:00
|
|
|
}
|
|
|
|
}
|