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, update on
/// approval, since the ACL upserts the same object for a registration (§8.6).
public bool IsRegisterRecordWritten =>
Kanaal == "objecten" && Resource == "object" && Actie is "create" or "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;
}