Уведомление группе пользователей
Отправка уведомления группе пользователей в Liner.
Примечание
Уведомление с типом urgent автоматически открывается у пользователя в Liner, если он онлайн.
Адрес и метод
POST /v1/notification/group/
Параметры (Body)
groupenum
Группа получателей. Возможные значения:client,call-center,call-center-senior,arbitration,moderator,admin.
titlestring
Заголовок уведомления (строка).
textstring
Текст уведомления (строка).
typeenum
Тип уведомления. Возможные значения:default,urgent(urgent открывается автоматически).
levelenum
Уровень/стиль уведомления. Возможные значения:default,success,warning,danger.
Пример запроса
<?php
$host = 'https://YOUR_LINER_API_HOST';
$token = 'YOUR_API_TOKEN';
$payload = [
'group' => $group, // client | call-center | call-center-senior | arbitration | moderator | admin
'title' => $title,
'text' => $text,
'type' => $notification_type, // default | urgent
'level' => $notification_level, // default | success | warning | danger
];
$ch = curl_init($host . '/v1/notification/group/');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Api-Key: ' . $token,
],
CURLOPT_POSTFIELDS => json_encode($payload, JSON_UNESCAPED_UNICODE),
CURLOPT_TIMEOUT => 15,
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($response === false) {
throw new RuntimeException('cURL error: ' . curl_error($ch));
}
curl_close($ch);
echo "HTTP {$httpCode}\n";
echo $response;
const host = "https://YOUR_LINER_API_HOST";
const token = "YOUR_API_TOKEN";
const payload = {
group: group, // client | call-center | call-center-senior | arbitration | moderator | admin
title: title,
text: text,
type: notification_type, // default | urgent
level: notification_level // default | success | warning | danger
};
const res = await fetch(`${host}/v1/notification/group/`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Api-Key": token
},
body: JSON.stringify(payload)
});
const data = await res.json();
console.log("HTTP", res.status, data);