RetailCRM API Client

Notifications extends AbstractApiResourceGroup

Class Notifications

Tags
category

Notifications

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
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
ApiException
throws
ClientException
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

        
On this page

Search results