namespace EventSubscriber.Application;
///
/// An inbound NRC (Open Notificaties) notification, as Open Notificaties POSTs it to an
/// abonnement callback. Only the fields the projection needs are modelled.
///
///
/// Since S-19b-2 the subscriber listens on the objecten kanaal, not zaken: the
/// register record in Objecten is what the projection is derived from (ADR-0030), so the
/// projection is a cache of the register rather than a re-derivation of the case system. An
/// Objecten notification carries no record data — only the object URL (as both
/// hoofdObject and resourceUrl) and the objecttype as a kenmerk — so the record
/// itself is read back through the ACL.
///
public sealed record Notification(
string Kanaal,
string Resource,
string Actie,
Uri ResourceUrl)
{
///
/// A register record written to Objecten — create on submit and partial_update on
/// approval, since the ACL upserts the same object for a registration (§8.6).
///
///
/// partial_update is what a PATCH actually reports: DRF routes it through the notifying
/// update() but names the action partial_update, and that is what Objecten puts in
/// the notification. update is accepted too, so a PUT-shaped write would project the same
/// way. destroy is deliberately not: removing a registration from the public register is
/// its own decision, not a side effect of this one.
///
public bool IsRegisterRecordWritten =>
Kanaal == "objecten" && Resource == "object"
&& Actie is "create" or "update" or "partial_update";
/// The object holding the register record. For a resource: object notification
/// Objecten sends the object as both hoofdObject and resourceUrl — the object is
/// the main resource — so the notification's own hoofdObject is not modelled.
public Uri ObjectUrl => ResourceUrl;
}