As an Admin, I can:
:: See all notifications
:: See the details of a specific notification
:: Create a notification
:: Update a notification
:: Assign a notification to one or multiple clients
:: Delete a notification
:: Delete a user_notification
As a Client, I can:
:: View all my notifications
:: View one notification
Request Headers
Content-Type: application/json
X-User-Email: [email protected]
X-User-Token: 1HJ**************BZos
[GET]
Endpoint: /v1/notifications
Host: http://localhost:3000/api
Response Body Example
[
{
"id": 1,
"date": "Sat, 21 May 2022 11:23:03 +0200",
"title": "Notification 01",
"description": "Notification 01 description"
},
{
"id": 2,
"date": "Sat, 21 May 2022 11:23:03 +0200",
"title": "Notification 02",
"description": "Notification 02 description"
}
]
[GET]
Endpoint: /v1/notifications/:id
Host: http://localhost:3000/api
Response Body Example
{
"id": 1,
"date": "Sat, 21 May 2022 11:23:03 +0200",
"title": "Notification 01",
"description": "Notification 01 description",
"user_notifications": [
{
"id": 1,
"seen": false,
"user_id": 1,
"email": "[email protected]"
},
{
"id": 2,
"seen": true,
"user_id": 2,
"email": "[email protected]"
}
]
}
[POST]
Endpoint: /v1/notifications
Host: http://localhost:3000/api
Request Body Example
{
"notification": {
"date": "Sat, 21 May 2022 11:23:03 +0200",
"title": "Creating New Notification",
"description": "Using the API to create a new notification"
}
}
Response Body Example
{
"id": 2,
"date": "2022-05-21T09:23:03.000Z",
"title": "Creating New Notification",
"description": "Using the API to create a new notification",
"users_notified": []
}
[PATCH]
Endpoint: /v1/notifications/:id
Host: http://localhost:3000/api
Request Body Example
{
"notification": {
"title": "New Title"
}
}
Response Body Example
{
"id": 2,
"date": "2022-05-21T09:23:03.000Z",
"title": "New Title",
"description": "Using the API to create a new notification",
"users_notified": []
}
[POST]
Endpoint: /v1/notifications/:notification_id/user_notifications
Host: http://localhost:3000/api
Request Body Example
{
"user_notification": {
"user_ids": [
2
]
}
}
Response Body Example
{
"id": 1,
"date": "2022-05-21T00:00:00.000Z",
"title": "New Title",
"description": "Notification 01 description",
"user_notifications": [
{
"id": 2,
"seen": false,
"user_id": 2,
"email": "[email protected]"
}
]
}
[DELETE]
Endpoint: /v1/notifications/:id
Host: http://localhost:3000/api
[DELETE]
Endpoint: /v1/notifications/:notification_id/user_notifications/:id
Host: http://localhost:3000/api
[GET]
Endpoint: /v1/user_notifications
Host: http://localhost:3000/api
[
{
"id": 4,
"seen": false,
"user_id": 2,
"notification_id": 1
},
{
"id": 5,
"seen": false,
"user_id": 2,
"notification_id": 2
}
]
The first time a Client views a notification, the seen field will be automatically updated to “true”. This does not happen if the admin views this notification.
Users who have not been assigned this notification do not have permission to visualize it.
[GET]
Endpoint: /v1/notifications/:notification_id/user_notifications/:id
Host: http://localhost:3000/api
Response Body Example
{
"id": 4,
"seen": true,
"user_id": 2,
"notification": {
"id": 1,
"title": "Testing Update",
"description": "Notification 01 description"
}
}