using System.Text.Json.Nodes;
using Csob.Client;

namespace Csob.Services;

/// <summary>
/// Common – PSU consent lifecycle (create / detail / revoke). The consent request body varies
/// across COBS profiles, so it is accepted and forwarded as raw JSON.
/// </summary>
public sealed class ConsentsService
{
    private readonly CsobApiAccessor _accessor;

    public ConsentsService(CsobApiAccessor accessor) => _accessor = accessor;

    public Task<JsonNode?> CreateAsync(JsonNode request, CancellationToken ct)
        => _accessor.Client.PostAsync(CsobApiPaths.Consents, request, ct);

    public Task<JsonNode?> DetailAsync(string id, CancellationToken ct)
        => _accessor.Client.GetAsync(CsobApiPaths.Consent(id), null, ct);

    public Task<JsonNode?> DeleteAsync(string id, CancellationToken ct)
        => _accessor.Client.DeleteAsync(CsobApiPaths.Consent(id), ct);
}
