using Idoklad.Client;

namespace Idoklad.Services;

/// <summary>
/// Read-only iDoklad code lists (registers): banks, countries, currencies, constant symbols,
/// exchange rates, payment options, VAT codes, VAT reverse-charge codes, sales offices and
/// sales POS equipment. Every agenda supports list + detail.
/// </summary>
public sealed class CodeListsService
{
    private readonly IdokladApiAccessor _accessor;

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

    public Task<object?> ListBanksAsync(int page, int pageSize, CancellationToken ct)
        => _accessor.Api.BankClient.List().ToPageAsync(page, pageSize, ct);

    public Task<object?> BankDetailAsync(int id, CancellationToken ct)
        => _accessor.Api.BankClient.Detail(id).ToDetailAsync(ct);

    public Task<object?> ListCountriesAsync(int page, int pageSize, CancellationToken ct)
        => _accessor.Api.CountryClient.List().ToPageAsync(page, pageSize, ct);

    public Task<object?> CountryDetailAsync(int id, CancellationToken ct)
        => _accessor.Api.CountryClient.Detail(id).ToDetailAsync(ct);

    public Task<object?> ListCurrenciesAsync(int page, int pageSize, CancellationToken ct)
        => _accessor.Api.CurrencyClient.List().ToPageAsync(page, pageSize, ct);

    public Task<object?> CurrencyDetailAsync(int id, CancellationToken ct)
        => _accessor.Api.CurrencyClient.Detail(id).ToDetailAsync(ct);

    public Task<object?> ListConstantSymbolsAsync(int page, int pageSize, CancellationToken ct)
        => _accessor.Api.ConstantSymbolClient.List().ToPageAsync(page, pageSize, ct);

    public Task<object?> ConstantSymbolDetailAsync(int id, CancellationToken ct)
        => _accessor.Api.ConstantSymbolClient.Detail(id).ToDetailAsync(ct);

    public Task<object?> ListExchangeRatesAsync(int page, int pageSize, CancellationToken ct)
        => _accessor.Api.ExchangeRateClient.List().ToPageAsync(page, pageSize, ct);

    public Task<object?> ExchangeRateDetailAsync(int id, CancellationToken ct)
        => _accessor.Api.ExchangeRateClient.Detail(id).ToDetailAsync(ct);

    public Task<object?> ListPaymentOptionsAsync(int page, int pageSize, CancellationToken ct)
        => _accessor.Api.PaymentOptionClient.List().ToPageAsync(page, pageSize, ct);

    public Task<object?> PaymentOptionDetailAsync(int id, CancellationToken ct)
        => _accessor.Api.PaymentOptionClient.Detail(id).ToDetailAsync(ct);

    public Task<object?> ListVatCodesAsync(int page, int pageSize, CancellationToken ct)
        => _accessor.Api.VatCodeClient.List().ToPageAsync(page, pageSize, ct);

    public Task<object?> VatCodeDetailAsync(int id, CancellationToken ct)
        => _accessor.Api.VatCodeClient.Detail(id).ToDetailAsync(ct);

    public Task<object?> ListVatReverseChargeCodesAsync(int page, int pageSize, CancellationToken ct)
        => _accessor.Api.VatReverseChargeCodeClient.List().ToPageAsync(page, pageSize, ct);

    public Task<object?> VatReverseChargeCodeDetailAsync(int id, CancellationToken ct)
        => _accessor.Api.VatReverseChargeCodeClient.Detail(id).ToDetailAsync(ct);

    public Task<object?> ListSalesOfficesAsync(int page, int pageSize, CancellationToken ct)
        => _accessor.Api.SalesOfficeClient.List().ToPageAsync(page, pageSize, ct);

    public Task<object?> SalesOfficeDetailAsync(int id, CancellationToken ct)
        => _accessor.Api.SalesOfficeClient.Detail(id).ToDetailAsync(ct);

    public Task<object?> ListSalesPosEquipmentAsync(int page, int pageSize, CancellationToken ct)
        => _accessor.Api.SalesPosEquipmentClient.List().ToPageAsync(page, pageSize, ct);

    public Task<object?> SalesPosEquipmentDetailAsync(int id, CancellationToken ct)
        => _accessor.Api.SalesPosEquipmentClient.Detail(id).ToDetailAsync(ct);
}
