OpenZaakWorker forwards registration.Id to IAclClient.OpenZaakAsync so the zaak's identificatie equals the reference the citizen sees on the submit confirmation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
42 lines
1.7 KiB
C#
42 lines
1.7 KiB
C#
using System.Net.Http.Json;
|
|
using System.Text.Json.Serialization;
|
|
using Big.Application;
|
|
|
|
namespace Big.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// HTTP client to the ACL service — the boundary the domain crosses to open a zaak (§8.1). It POSTs
|
|
/// the bsn to the ACL's <c>/zaken</c> endpoint and returns the created zaak URL; it never constructs
|
|
/// ZGW URLs or talks to OpenZaak itself.
|
|
/// </summary>
|
|
public sealed class AclHttpClient(HttpClient http, AclOptions options) : IAclClient
|
|
{
|
|
public async Task<Uri> OpenZaakAsync(string bsn, string reference, CancellationToken ct = default)
|
|
{
|
|
using var response = await http.PostAsJsonAsync(
|
|
new Uri(options.BaseUrl, "zaken"), new OpenZaakRequest(bsn, reference), ct);
|
|
response.EnsureSuccessStatusCode();
|
|
|
|
var opened = await response.Content.ReadFromJsonAsync<OpenZaakResponse>(ct)
|
|
?? throw new InvalidOperationException("The ACL returned an empty zaak response.");
|
|
return new Uri(opened.ZaakUrl);
|
|
}
|
|
|
|
public async Task ApproveZaakAsync(Uri zaakUrl, CancellationToken ct = default)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(zaakUrl);
|
|
|
|
using var response = await http.PostAsJsonAsync(
|
|
new Uri(options.BaseUrl, "statussen"), new SetStatusRequest(zaakUrl.ToString()), ct);
|
|
response.EnsureSuccessStatusCode();
|
|
}
|
|
|
|
private sealed record OpenZaakRequest(
|
|
[property: JsonPropertyName("bsn")] string Bsn,
|
|
[property: JsonPropertyName("reference")] string Reference);
|
|
|
|
private sealed record OpenZaakResponse([property: JsonPropertyName("zaakUrl")] string ZaakUrl);
|
|
|
|
private sealed record SetStatusRequest([property: JsonPropertyName("zaakUrl")] string ZaakUrl);
|
|
}
|