Example: Creating a notification¶
Frequency of use | Common |
---|---|
Actors |
|
Communication Flow: Kotlin
NotificationDescriptions.create.call(
CreateNotification(
notification = Notification(
id = null,
message = "Something has happened",
meta = JsonObject(mapOf("myParameter" to JsonLiteral(
coerceToInlineType = null,
content = "42",
isString = false,
)),)),
read = false,
ts = 1717663228605,
type = "MY_NOTIFICATION_TYPE",
),
user = "User#1234",
),
ucloud
).orThrow()
/*
CreateNotificationResponse(
id = FindByLongId(
id = 56123,
),
)
*/
Communication Flow: Curl
# ------------------------------------------------------------------------------------------------------
# $host is the UCloud instance to contact. Example: 'http://localhost:8080' or 'https://cloud.sdu.dk'
# $accessToken is a valid access-token issued by UCloud
# ------------------------------------------------------------------------------------------------------
# Authenticated as ucloud
curl -XPUT -H "Authorization: Bearer $accessToken" -H "Content-Type: content-type: application/json; charset=utf-8" "$host/api/notifications" -d '{
"user": "User#1234",
"notification": {
"type": "MY_NOTIFICATION_TYPE",
"message": "Something has happened",
"id": null,
"meta": {
"myParameter": 42
},
"ts": 1717663228605,
"read": false
}
}'
# {
# "id": {
# "id": 56123
# }
# }