33 lines
1.3 KiB
C#
33 lines
1.3 KiB
C#
using IdokladSdk.Clients;
|
|
using IdokladSdk.Requests.Core;
|
|
|
|
namespace Idoklad.Client;
|
|
|
|
/// <summary>
|
|
/// Generic helpers over the SDK's list/detail request builders so the read endpoints of the many
|
|
/// agendas can be expressed in a single line. The concrete payload type is inferred by the SDK and
|
|
/// returned boxed (full data is preserved at runtime; only the Swagger schema is generic).
|
|
/// </summary>
|
|
public static class SdkRequestExtensions
|
|
{
|
|
public static async Task<object?> ToPageAsync<TList, TClient, TGetModel, TFilter, TSort>(
|
|
this BaseList<TList, TClient, TGetModel, TFilter, TSort> list,
|
|
int page,
|
|
int pageSize,
|
|
CancellationToken ct)
|
|
where TList : BaseList<TList, TClient, TGetModel, TFilter, TSort>
|
|
where TClient : BaseClient
|
|
where TFilter : new()
|
|
where TSort : new()
|
|
where TGetModel : new()
|
|
=> (await list.Page(page).PageSize(pageSize).GetAsync(ct)).Unwrap();
|
|
|
|
public static async Task<object?> ToDetailAsync<TDetail, TClient, TGetModel>(
|
|
this BaseDetail<TDetail, TClient, TGetModel> detail,
|
|
CancellationToken ct)
|
|
where TDetail : BaseDetail<TDetail, TClient, TGetModel>
|
|
where TClient : BaseClient
|
|
where TGetModel : new()
|
|
=> (await detail.GetAsync(ct)).Unwrap();
|
|
}
|