Files
idoklad/Client/SdkRequestExtensions.cs
2026-07-14 06:21:37 +02:00

36 lines
1.4 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,
string? filter = null,
string? filterType = null,
string? sort = null)
where TList : BaseList<TList, TClient, TGetModel, TFilter, TSort>
where TClient : BaseClient
where TFilter : new()
where TSort : new()
where TGetModel : new()
=> await list.GetPageAsync(page, pageSize, filter, filterType, sort, ct);
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();
}