-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define how to communicate between Front-End and Back-End #37
Comments
Discussed during August 3, 2021 Office Hours:
|
It sounds like this approach could impact any client consuming the JSON data, not just front end scripts? I'm assuming that any REST endpoints supporting WP-Notify can be accessed by any REST client and I'm thinking specifically of the WordPress, WooCommerce, and Jetpack mobile apps. |
To go along with my proposal in the data model discussion, here's a JSON schema describing the data to be expected (following the json-schema.org standard): {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://wordpress.org/feature.notification.json",
"title": "Notification",
"type": "object",
"properties": {
"id": {
"description": "The unique identifier for a notification",
"type": "integer"
},
"sender": {
"description": "The sender who originated the notification",
"type": "object",
"properties": {
"name": {
"description": "The name that identifies the sender",
"type": "string"
},
"timestamp": {
"description": "Timestamp from when the notification was originated, in milliseconds from January 1, 1970.",
"type": "integer",
},
"recipients": {
"description": "A collection of recipients who should receive the message, contains WordPress users' id only. Any recipient from a notification channel other than WordPress REST API won't be displayed here",
"type": "array",
"items": {
"type": "integer"
},
"message": {
"description": "Message to display to the recipients",
"type": "array",
"items": {
"type": "object",
"properties": {
"fieldName": {
"description": "This name will identify the field template to use for displaying this data",
"type": "string",
},
"fieldContent": {
"description": "The content of the message field will be displayed according to the template that matches the fieldName property.",
"type": "mixed"
}
}
},
"status": {
"description": "Whether the notification is read or not",
"type": "string"
},
"level": {
"description": "The level of severity of the notification",
"type": "string"
},
},
"required": [ "id", "sender", "timestamp", "recipients", "message", "status", "level" ]
} Or maybe we'd better extract sub-schemas for our object (message, recipients, sender), so we could keep a base schema that stays the same and allow ourselves to changes its parts. (For example, displaying a sender logo) |
Linked to query about testing in #15 |
In order for front-end and Back-end to be developed apart from each other, a contract between the two should be established before end.
This would then be a good idea then to document the endpoint routes before they are produced by the back-end and consumed by the front-end.
It would also be a good idea to define data schema that will be used as reference for both sides of development.
The text was updated successfully, but these errors were encountered: