(** JMAP Push Notification Types Push notifications allow servers to notify clients of state changes. Reference: RFC 8620 Section 7.1-7.2 Test files: - test/data/core/push_state_change.json - test/data/core/push_subscription.json *) (** StateChange notification object *) module StateChange = struct (** Map of type name to state string *) type type_state = (string * string) list type t = { at_type : string; (** Always "StateChange" *) changed : (Jmap_id.t * type_state) list; (** accountId -> type -> state *) } (** Accessors *) let at_type t = t.at_type let changed t = t.changed (** Constructor *) let v ~at_type ~changed = { at_type; changed } (** Parse from JSON. Test files: test/data/core/push_state_change.json Expected structure: { "@type": "StateChange", "changed": { "account-id-1": { "Email": "d35ecb040aab", "Mailbox": "0af7a512ce70" }, "account-id-2": { "CalendarEvent": "7a4297cecd76" } } } *) let of_json _json = (* TODO: Implement JSON parsing *) raise (Jmap_error.Parse_error "StateChange.of_json not yet implemented") end (** PushSubscription object *) module PushSubscription = struct type t = { id : Jmap_id.t; device_client_id : string; url : string; keys : Ezjsonm.value option; verification_code : string option; expires : Jmap_primitives.UTCDate.t option; types : string list option; } (** Accessors *) let id t = t.id let device_client_id t = t.device_client_id let url t = t.url let keys t = t.keys let verification_code t = t.verification_code let expires t = t.expires let types t = t.types (** Constructor *) let v ~id ~device_client_id ~url ?keys ?verification_code ?expires ?types () = { id; device_client_id; url; keys; verification_code; expires; types } (** Parse from JSON. Test files: test/data/core/push_subscription.json Expected structure: { "id": "push-sub-id", "deviceClientId": "device-hash", "url": "https://push.example.com/push", "keys": { "p256dh": "base64-encoded-key", "auth": "base64-encoded-secret" }, "verificationCode": "verification-code", "expires": "2024-12-31T23:59:59Z", "types": ["Email", "Mailbox"] } *) let of_json _json = (* TODO: Implement JSON parsing *) raise (Jmap_error.Parse_error "PushSubscription.of_json not yet implemented") end (** PushVerification object (sent to push endpoint) *) module PushVerification = struct type t = { at_type : string; (** Always "PushVerification" *) push_subscription_id : string; verification_code : string; } (** Accessors *) let at_type t = t.at_type let push_subscription_id t = t.push_subscription_id let verification_code t = t.verification_code (** Constructor *) let v ~at_type ~push_subscription_id ~verification_code = { at_type; push_subscription_id; verification_code } let of_json _json = (* TODO: Implement JSON parsing *) raise (Jmap_error.Parse_error "PushVerification.of_json not yet implemented") end