From 5ee567b4347dcf48889d7827431ef4e7ec6fbb44 Mon Sep 17 00:00:00 2001 From: John Hooks Date: Sun, 26 Mar 2023 05:58:44 -0700 Subject: [PATCH] feature: add severity to the notification item schema --- .../restapi/class-notification-controller.php | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/includes/restapi/class-notification-controller.php b/includes/restapi/class-notification-controller.php index 9eedb7a7..1c307dc2 100644 --- a/includes/restapi/class-notification-controller.php +++ b/includes/restapi/class-notification-controller.php @@ -127,13 +127,13 @@ public function get_item_schema() { ), 'dismissed_at' => array( 'description' => __( "The datetime the notification was dismissed, in the site's timezone." ), - 'type' => 'string', + 'type' => array( 'string', 'null' ), 'format' => 'date-time', 'context' => array( 'view', 'edit', 'embed' ), ), 'displayed_at' => array( 'description' => __( "The datetime the notification was displayed, in the site's timezone." ), - 'type' => 'string', + 'type' => array( 'string', 'null' ), 'format' => 'date-time', 'context' => array( 'view', 'edit', 'embed' ), ), @@ -144,25 +144,56 @@ public function get_item_schema() { 'context' => array( 'view', 'edit', 'embed' ), ), 'context' => array( - 'description' => __( 'The context the notification.' ), + 'description' => __( 'The view context the notification.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), + 'default' => 'hub', + 'enum' => array( + 'adminbar', + 'dashboard', + 'hub', + ), ), - 'priority' => array( - 'description' => __( 'The priority of the notification.' ), - 'type' => 'string', + 'severity' => array( + 'description' => __( 'The severity of the notification.' ), + 'type' => array( 'string', 'null' ), 'context' => array( 'view', 'edit', 'embed' ), + 'enum' => array( + 'alert', + 'warning', + 'success', + ), + ), + 'status' => array( + 'description' => __( 'The status of the notification.' ), + 'type' => 'string', + 'default' => 'undisplayed', + 'enum' => array( + 'undisplayed', + 'displayed', + 'dismissed', + ), ), 'title' => array( 'description' => __( 'The title of the notification.' ), 'type' => 'string', 'context' => array( 'view', 'embed' ), ), + 'title_key' => array( + 'description' => __( 'The translation title key of the notification.' ), + 'type' => 'string', + 'context' => array( 'edit' ), + ), 'message' => array( 'description' => __( 'The message content of the notification.' ), 'type' => 'string', 'context' => array( 'view', 'embed' ), ), + 'message_key' => array( + 'description' => __( 'The translation message key of the notification.' ), + 'type' => 'string', + 'context' => array( 'edit' ), + ), 'meta' => array( 'description' => __( 'The metadata of the notification.' ), 'type' => 'string',