using System.Net.Http;
using AyCode.Services.Nav.Ekaer.Models;

namespace AyCode.Services.Nav.Ekaer;

/// <summary>
/// EKÁER bejelentés-kezelés (create / modify / delete / finalize / correction) a <c>/manageTradeCards</c>
/// műveleten keresztül. A send-flow-t és az auth-ot a <see cref="NavReportServiceBase{TRequest,TResponse}"/>
/// adja; itt csak az EKÁER endpoint (namespace) és a típuspár konkretizálódik.
/// </summary>
/// <remarks>
/// Részletek: <c>Nav/docs/EKAER_INTERFACE.md</c> (transport/auth), <c>EKAER_TRADECARD.md</c> (payload),
/// <c>EKAER_OPERATIONS.md</c> (műveletek). A <see cref="INavCredentials.BaseUrl"/> a környezet báziscíme
/// (PROD: <c>https://import.ekaer.nav.gov.hu</c>, TEST: <c>https://import-test-b.ekaer.nav.gov.hu</c>).
/// </remarks>
public sealed class EkaerManageService : NavReportServiceBase<ManageTradeCardsRequest, ManageTradeCardsResponse>
{
    public EkaerManageService(HttpClient httpClient, INavCredentials credentials)
        : base(httpClient, credentials)
    {
    }

    protected override string OperationPath => "TradeCardManagementService/customer/manageTradeCards";

    /// <summary>Elküldi a bejelentés-kezelő kérést a NAV-nak. Hibánál <see cref="NavReportException"/>.</summary>
    public Task<ManageTradeCardsResponse> ManageAsync(ManageTradeCardsRequest request, CancellationToken cancellationToken = default)
        => SendAsync(request, cancellationToken);
}

/// <summary>
/// EKÁER bejelentés-lekérdezés a <c>/queryTradeCards</c> műveleten keresztül.
/// </summary>
public sealed class EkaerQueryService : NavReportServiceBase<QueryTradeCardsRequest, QueryTradeCardsResponse>
{
    public EkaerQueryService(HttpClient httpClient, INavCredentials credentials)
        : base(httpClient, credentials)
    {
    }

    protected override string OperationPath => "TradeCardManagementService/customer/queryTradeCards";

    /// <summary>Lekérdezi a bejelentéseket a megadott paraméterekkel.</summary>
    public Task<QueryTradeCardsResponse> QueryAsync(QueryTradeCardsRequest request, CancellationToken cancellationToken = default)
        => SendAsync(request, cancellationToken);
}
