using IdokladSdk.Enums;
using Idoklad.Client;

namespace Idoklad.Services;

/// <summary>Agenda statistics and summaries.</summary>
public sealed class StatisticsService
{
    private readonly IdokladApiAccessor _accessor;

    public StatisticsService(IdokladApiAccessor accessor) => _accessor = accessor;

    public async Task<object?> InvoicingForPeriodAsync(PeriodType periodType, CancellationToken ct)
        => (await _accessor.Api.StatisticsClient.InvoicingForPeriodAsync(periodType, null, ct)).Unwrap();

    public async Task<object?> InvoicingForYearAsync(YearType yearType, CancellationToken ct)
        => (await _accessor.Api.StatisticsClient.InvoicingForYearAsync(yearType, ct)).Unwrap();

    public async Task<object?> QuarterSummaryAsync(CancellationToken ct)
        => (await _accessor.Api.StatisticsClient.QuarterSummaryAsync(ct)).Unwrap();

    public async Task<object?> TopPartnersAsync(int? count, CancellationToken ct)
        => (await _accessor.Api.StatisticsClient.TopPartnersAsync(count, ct)).Unwrap();

    public async Task<object?> AgendaSummaryAsync(CancellationToken ct)
        => (await _accessor.Api.StatisticsClient.AgendaSummaryAsync(ct)).Unwrap();

    public async Task<object?> StatisticForContactAsync(int id, CancellationToken ct)
        => (await _accessor.Api.StatisticsClient.StatisticForContactAsync(id, ct)).Unwrap();

    public async Task<object?> DebtIntervalsAsync(CancellationToken ct)
        => (await _accessor.Api.StatisticsClient.DebtIntervals(ct)).Unwrap();

    public async Task<object?> TopDebtorsAsync(int? count, CancellationToken ct)
        => (await _accessor.Api.StatisticsClient.TopDebtors(count, ct)).Unwrap();

    public async Task<object?> VatPayerProgressAsync(CancellationToken ct)
        => (await _accessor.Api.StatisticsClient.VatPayerProgress(ct)).Unwrap();
}
