Health Analytics Dashboard
Custom REST Endpoint
This feature utilizes a custom WP_REST_Controller-like class (it’s not exactly the same, but its general shape should be familiar). It accepts 2 methods: GET
and POST
. Authorized users are given a WordPress application password and each User/Pass combo must be defined manually in the wp-config.php
file of each environment (see the wp-config-sample.php
for implementation).
At a glance:
- Version: 1
- Namespace:
cno
- Base:
health-data
- Endpoint:
site_url/wp-json/cno/v1/health-data
- Authorization: Basic Authentication
Class: Health Data Rest Route
Based on the WP_Rest_Controller, this class handles the initialization and extension of a new rest route at site_url() . /wp-json/cno/v1/health-data
.
The class constructor
method is the big thing to note here, as it sets up the endpoint and the page + meta_key the route POSTS to.
Data Schema:
Following the REST API Handbook Schema guides, this endpoint conforms to JSON Schema Draft 4 spec. The general shape is as follows:
{"data": [
{
"WeekOfYr": {
"start": "YYYY-MM-DD",
"end": "YYYY-MM-DD"
},
"diseases": {
"COVID": {
"PositivityRate":15.7,
"Comparison":"Plateauing"|"Increasing"|"Decreasing"|"NOVALUE"
}
}
}
]}
Where diseases
can be easily extended with other properties that have the same 2 values (PositivityRate
and Comparison
to add further data.
Class: Email Generator
(re)Charts
Powered by Recharts