Files
csob/Controllers/ConsentsController.cs
JiriUhlir 09db30a3ca first
2026-06-18 11:05:46 +02:00

36 lines
1.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Text.Json.Nodes;
using Microsoft.AspNetCore.Mvc;
using Csob.Services;
namespace Csob.Controllers;
/// <summary>
/// Common PSU consent lifecycle. Requires the ČSOB credential headers. The consent body is
/// forwarded to ČSOB as raw JSON (COBS consent shape).
/// </summary>
[ApiController]
[Route("consents")]
[Produces("application/json")]
[Tags("Consents")]
public sealed class ConsentsController : ControllerBase
{
private readonly ConsentsService _service;
public ConsentsController(ConsentsService service) => _service = service;
/// <summary>Create a consent.</summary>
[HttpPost]
public async Task<IActionResult> Create([FromBody] JsonNode request, CancellationToken ct)
=> Ok(await _service.CreateAsync(request, ct));
/// <summary>Get a consent detail.</summary>
[HttpGet("{id}")]
public async Task<IActionResult> Detail(string id, CancellationToken ct)
=> Ok(await _service.DetailAsync(id, ct));
/// <summary>Revoke a consent.</summary>
[HttpDelete("{id}")]
public async Task<IActionResult> Delete(string id, CancellationToken ct)
=> Ok(await _service.DeleteAsync(id, ct));
}