using System.Text.Json.Nodes;
using Microsoft.AspNetCore.Mvc;
using Csob.Services;
namespace Csob.Controllers;
///
/// Common – PSU consent lifecycle. Requires the ČSOB credential headers. The consent body is
/// forwarded to ČSOB as raw JSON (COBS consent shape).
///
[ApiController]
[Route("consents")]
[Produces("application/json")]
[Tags("Consents")]
public sealed class ConsentsController : ControllerBase
{
private readonly ConsentsService _service;
public ConsentsController(ConsentsService service) => _service = service;
/// Create a consent.
[HttpPost]
public async Task Create([FromBody] JsonNode request, CancellationToken ct)
=> Ok(await _service.CreateAsync(request, ct));
/// Get a consent detail.
[HttpGet("{id}")]
public async Task Detail(string id, CancellationToken ct)
=> Ok(await _service.DetailAsync(id, ct));
/// Revoke a consent.
[HttpDelete("{id}")]
public async Task Delete(string id, CancellationToken ct)
=> Ok(await _service.DeleteAsync(id, ct));
}