RetailCRM API Client

Segments extends AbstractApiResourceGroup

Class Segments

Tags
category

Segments

Table of Contents

Methods

list()  : SegmentsResponse
Makes GET "/api/v5/segments" request.

Methods

list()

Makes GET "/api/v5/segments" request.

public list([SegmentsRequest|null $request = null ]) : SegmentsResponse

Example:

use RetailCrm\Api\Enum\NumericBoolean;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Filter\Segments\SegmentApiFilter;
use RetailCrm\Api\Model\Request\Segments\SegmentsRequest;

$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');

$request                            = new SegmentsRequest();
$request->filter                    = new SegmentApiFilter();
$request->filter->active            = NumericBoolean::TRUE;
$request->filter->minCustomersCount = 700;

try {
    $response = $client->segments->list($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 'Received segments: ' . print_r($response->segments, true);
Parameters
$request : SegmentsRequest|null = null
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SegmentsResponse

        
On this page

Search results