Notifications
extends AbstractApiResourceGroup
in package
Class Notifications
Tags
Table of Contents
Methods
- send() : SuccessResponse
- Makes POST "/api/v5/notifications/send" request.
Methods
send()
Makes POST "/api/v5/notifications/send" request.
public
send(NotificationsSendRequest $request) : SuccessResponse
Example:
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Model\Entity\Notifications\Notification;
use RetailCrm\Api\Model\Request\Notifications\NotificationsSendRequest;
$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');
$notification = new Notification();
$notification->userGroups = ['superadmins'];
$notification->type = 'api.info';
$notification->message = '<p>notification text</p>';
$request = new NotificationsSendRequest();
$request->notification = $notification;
try {
$response = $client->notifications->send($request);
} catch (ApiExceptionInterface $exception) {
echo sprintf(
'Error from RetailCRM API (status code: %d): %s',
$exception->getStatusCode(),
$exception->getMessage()
);
if (count($exception->getErrorResponse()->errors) > 0) {
echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
}
return;
}
echo 'Status: ' . var_export($response->success, true);
Parameters
- $request : NotificationsSendRequest