RetailCRM API Client

References extends AbstractApiResourceGroup

Class References

Tags
category

References

SuppressWarnings

(PHPMD.CouplingBetweenObjects)

SuppressWarnings

(PHPMD.ExcessiveClassLength)

SuppressWarnings

(PHPMD.TooManyMethods)

SuppressWarnings

(PHPMD.TooManyPublicMethods)

Table of Contents

Methods

costGroups()  : CostGroupsResponse
Makes GET "/api/v5/reference/cost-groups" request.
costGroupsEdit()  : SuccessResponse
Makes POST "/api/v5/reference/cost-groups/{code}/edit" request.
costItems()  : CostItemsResponse
Makes GET "/api/v5/reference/cost-items" request.
costItemsEdit()  : SuccessResponse
Makes POST "/api/v5/reference/cost-items/{code}/edit" request.
countries()  : CountriesResponse
Makes GET "/api/v5/reference/countries" request.
couriers()  : CouriersResponse
Makes GET "/api/v5/reference/couriers" request.
couriersCreate()  : IdResponse
Makes POST "/api/v5/reference/couriers/create" request.
couriersEdit()  : SuccessResponse
Makes POST "/api/v5/reference/couriers/{id}/edit" request.
currencies()  : CurrenciesResponse
Makes GET "/api/v5/reference/currencies" request.
currenciesCreate()  : IdResponse
Makes POST "/api/v5/reference/currencies/create" request.
currenciesEdit()  : SuccessResponse
Makes POST "/api/v5/reference/currencies/{id}/edit" request.
deliveryServices()  : DeliveryServicesResponse
Makes GET "/api/v5/reference/delivery-services" request.
deliveryServicesEdit()  : SuccessResponse
Makes POST "/api/v5/reference/delivery-services/{code}/edit" request.
deliveryTypes()  : DeliveryTypesResponse
Makes GET "/api/v5/reference/delivery-types" request.
deliveryTypesEdit()  : SuccessResponse
Makes POST "/api/v5/reference/delivery-types/{code}/edit" request.
legalEntities()  : LegalEntitiesResponse
Makes GET "/api/v5/reference/legal-entities" request.
legalEntitiesEdit()  : SuccessResponse
Makes POST "/api/v5/reference/legal-entities/{code}/edit" request.
mgChannels()  : MgChannelsResponse
Makes GET "/api/v5/reference/mg-channels" request.
orderMethods()  : OrderMethodsResponse
Makes GET "/api/v5/reference/order-methods" request.
orderMethodsEdit()  : SuccessResponse
Makes POST "/api/v5/reference/order-methods/{code}/edit" request.
orderTypes()  : OrderTypesResponse
Makes GET "/api/v5/reference/order-types" request.
orderTypesEdit()  : SuccessResponse
Makes POST "/api/v5/reference/order-types/{code}/edit" request.
paymentStatuses()  : PaymentStatusesResponse
Makes GET "/api/v5/reference/payment-statuses" request.
paymentStatusesEdit()  : SuccessResponse
Makes POST "/api/v5/reference/payment-statuses/{code}/edit" request.
paymentTypes()  : PaymentTypesResponse
Makes GET "/api/v5/reference/payment-types" request.
paymentTypesEdit()  : SuccessResponse
Makes POST "/api/v5/reference/payment-types/{code}/edit" request.
priceTypes()  : PriceTypesResponse
Makes GET "/api/v5/reference/price-types" request.
priceTypesEdit()  : SuccessResponse
Makes POST "/api/v5/reference/price-types/{code}/edit" request.
productStatuses()  : ProductStatusesResponse
Makes GET "/api/v5/reference/product-statuses" request.
productStatusesEdit()  : SuccessResponse
Makes POST "/api/v5/reference/product-statuses/{code}/edit" request.
sites()  : SitesResponse
Makes GET "/api/v5/reference/sites" request.
sitesEdit()  : SuccessResponse
Makes POST "/api/v5/reference/sites/{code}/edit" request.
statuses()  : StatusesResponse
Makes GET "/api/v5/reference/statuses" request.
statusesEdit()  : SuccessResponse
Makes POST "/api/v5/reference/statuses/{code}/edit" request.
statusGroups()  : StatusGroupsResponse
Makes GET "/api/v5/reference/status-groups" request.
stores()  : StoresResponse
Makes GET "/api/v5/reference/stores" request.
storesEdit()  : SuccessResponse
Makes POST "/api/v5/reference/stores/{code}/edit" request.
units()  : UnitsResponse
Makes GET "/api/v5/reference/units" request.
unitsEdit()  : SuccessResponse
Makes POST "/api/v5/reference/units/{code}/edit" request.

Methods

costGroups()

Makes GET "/api/v5/reference/cost-groups" request.

public costGroups() : CostGroupsResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->costGroups();
} 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 'Cost groups: ' . print_r($response->costGroups, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CostGroupsResponse

costGroupsEdit()

Makes POST "/api/v5/reference/cost-groups/{code}/edit" request.

public costGroupsEdit(string $code, CostGroupsEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\CostGroup;
use RetailCrm\Api\Model\Request\References\CostGroupsEditRequest;

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

$entity           = new CostGroup();
$entity->name     = 'Комиссии';
$entity->ordering = 60;
$entity->active   = true;

try {
    $response = $client->references->costGroupsEdit('commission', new CostGroupsEditRequest($entity));
} 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);
    }
}
Parameters
$code : string
$request : CostGroupsEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

costItems()

Makes GET "/api/v5/reference/cost-items" request.

public costItems() : CostItemsResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->costItems();
} 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 'Cost items: ' . print_r($response->costItems, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CostItemsResponse

costItemsEdit()

Makes POST "/api/v5/reference/cost-items/{code}/edit" request.

public costItemsEdit(string $code, CostItemsEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\CostItem;
use RetailCrm\Api\Model\Request\References\CostItemsEditRequest;

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

$entity                  = new CostItem();
$entity->name            = "Test item";
$entity->group           = "product-cost";
$entity->ordering        = 990;
$entity->active          = true;
$entity->appliesToOrders = true;
$entity->type            = "var";
$entity->appliesToUsers  = false;

try {
    $response = $client->references->costItemsEdit('test-item', new CostItemsEditRequest($entity));
} 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);
    }
}
Parameters
$code : string
$request : CostItemsEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

countries()

Makes GET "/api/v5/reference/countries" request.

public countries() : CountriesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->countries();
} 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 'Countries ISO codes: ' . print_r($response->countriesIso, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CountriesResponse

couriers()

Makes GET "/api/v5/reference/couriers" request.

public couriers() : CouriersResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->couriers();
} 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 'Couriers: ' . print_r($response->couriers, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CouriersResponse

couriersCreate()

Makes POST "/api/v5/reference/couriers/create" request.

public couriersCreate(CouriersCreateRequest $request) : IdResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Orders\Delivery\CourierPhone;
use RetailCrm\Api\Model\Entity\References\Courier;
use RetailCrm\Api\Model\Request\References\CouriersCreateRequest;

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

$entity            = new Courier();
$entity->firstName = 'Tester';
$entity->lastName  = 'Tester';
$entity->phone     = new CourierPhone('88005553125');

try {
    $response = $client->references->couriersCreate(new CouriersCreateRequest($entity));
} 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 'Created courier with ID: ' . $response->id;
Parameters
$request : CouriersCreateRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
IdResponse

couriersEdit()

Makes POST "/api/v5/reference/couriers/{id}/edit" request.

public couriersEdit(int $id, CouriersCreateRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Orders\Delivery\CourierPhone;
use RetailCrm\Api\Model\Entity\References\Courier;
use RetailCrm\Api\Model\Request\References\CouriersCreateRequest;

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

$entity            = new Courier();
$entity->firstName = 'Tester';
$entity->lastName  = 'Courier';
$entity->phone     = new CourierPhone('88005553126');

try {
    $response = $client->references->couriersEdit(1, new CouriersCreateRequest($entity));
} 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);
    }
}
Parameters
$id : int
$request : CouriersCreateRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

currencies()

Makes GET "/api/v5/reference/currencies" request.

public currencies() : CurrenciesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->currencies();
} 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 'Currencies: ' . print_r($response->currencies, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CurrenciesResponse

currenciesCreate()

Makes POST "/api/v5/reference/currencies/create" request.

public currenciesCreate(CurrenciesCreateRequest $request) : IdResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\Currency;
use RetailCrm\Api\Model\Request\References\CurrenciesCreateRequest;

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

$entity                          = new Currency();
$entity->code                    = 'USD';
$entity->isAutoConvert           = true;
$entity->autoConvertExtraPercent = 5;

try {
    $response = $client->references->currenciesCreate(new CurrenciesCreateRequest($entity));
} 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 'Created currency with ID: ' . $response->id;
Parameters
$request : CurrenciesCreateRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
IdResponse

currenciesEdit()

Makes POST "/api/v5/reference/currencies/{id}/edit" request.

public currenciesEdit(int $id, CurrenciesCreateRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\Currency;
use RetailCrm\Api\Model\Request\References\CurrenciesCreateRequest;

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

$entity                          = new Currency();
$entity->code                    = 'USD';
$entity->isAutoConvert           = true;
$entity->autoConvertExtraPercent = 10;

try {
    $response = $client->references->currenciesEdit(1, new CurrenciesCreateRequest($entity));
} 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);
    }
}
Parameters
$id : int
$request : CurrenciesCreateRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

deliveryServices()

Makes GET "/api/v5/reference/delivery-services" request.

public deliveryServices() : DeliveryServicesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->deliveryServices();
} 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 'Delivery services: ' . print_r($response->deliveryServices, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
DeliveryServicesResponse

deliveryServicesEdit()

Makes POST "/api/v5/reference/delivery-services/{code}/edit" request.

public deliveryServicesEdit(string $code, DeliveryServicesEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\DeliveryService;
use RetailCrm\Api\Model\Request\References\DeliveryServicesEditRequest;

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

$entity         = new DeliveryService();
$entity->name   = 'dict-deliveryservices-1571123786';
$entity->active = false;

try {
    $response = $client->references->deliveryServicesEdit(
        'dict-deliveryservices-1571123786',
        new DeliveryServicesEditRequest($entity)
    );
} 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);
    }
}
Parameters
$code : string
$request : DeliveryServicesEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

deliveryTypes()

Makes GET "/api/v5/reference/delivery-types" request.

public deliveryTypes() : DeliveryTypesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->deliveryTypes();
} 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 'Delivery types: ' . print_r($response->deliveryTypes, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
DeliveryTypesResponse

deliveryTypesEdit()

Makes POST "/api/v5/reference/delivery-types/{code}/edit" request.

public deliveryTypesEdit(string $code, DeliveryTypesEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\DeliveryType;
use RetailCrm\Api\Model\Request\References\DeliveryTypesEditRequest;

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

$entity                 = new DeliveryType();
$entity->name           = 'Test Type';
$entity->active         = false;
$entity->defaultCost    = 0;
$entity->defaultNetCost = 0;
$entity->paymentTypes   = [
    'bank-card',
    'bank-transfer',
    'credit',
    'cash',
    'e-money'
];

try {
    $response = $client->references->deliveryTypesEdit('test-type', new DeliveryTypesEditRequest($entity));
} 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);
    }
}
Parameters
$code : string
$request : DeliveryTypesEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

legalEntities()

Makes GET "/api/v5/reference/legal-entities" request.

public legalEntities() : LegalEntitiesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->legalEntities();
} 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 'Legal entities: ' . print_r($response->legalEntities, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
LegalEntitiesResponse

legalEntitiesEdit()

Makes POST "/api/v5/reference/legal-entities/{code}/edit" request.

public legalEntitiesEdit(string $code, LegalEntityEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Enum\CountryCodeIso3166;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\LegalEntity;
use RetailCrm\Api\Model\Request\References\LegalEntityEditRequest;

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

$entity                 = new LegalEntity();
$entity->contragentType = "legal-entity";
$entity->legalName      = "Test Entity";
$entity->countryIso     = CountryCodeIso3166::RUSSIAN_FEDERATION;
$entity->vatRate        = "20.00";

try {
    $response = $client->references->legalEntitiesEdit('test-entity', new LegalEntityEditRequest($entity));
} 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);
    }
}
Parameters
$code : string
$request : LegalEntityEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

mgChannels()

Makes GET "/api/v5/reference/mg-channels" request.

public mgChannels() : MgChannelsResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->mgChannels();
} 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 'MG Channels: ' . print_r($response->mgChannels, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
MgChannelsResponse

orderMethods()

Makes GET "/api/v5/reference/order-methods" request.

public orderMethods() : OrderMethodsResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->orderMethods();
} 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 'Order methods: ' . print_r($response->orderMethods, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
OrderMethodsResponse

orderMethodsEdit()

Makes POST "/api/v5/reference/order-methods/{code}/edit" request.

public orderMethodsEdit(string $code, OrderMethodsEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\OrderMethod;
use RetailCrm\Api\Model\Request\References\OrderMethodsEditRequest;

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

$entity         = new OrderMethod();
$entity->name   = 'Test Method';
$entity->active = true;

try {
    $response = $client->references->orderMethodsEdit('test-method', new OrderMethodsEditRequest($entity));
} 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);
    }
}
Parameters
$code : string
$request : OrderMethodsEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

orderTypes()

Makes GET "/api/v5/reference/order-types" request.

public orderTypes() : OrderTypesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->orderTypes();
} 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 'Order types: ' . print_r($response->orderTypes, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
OrderTypesResponse

orderTypesEdit()

Makes POST "/api/v5/reference/order-types/{code}/edit" request.

public orderTypesEdit(string $code, OrderTypesEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\OrderType;
use RetailCrm\Api\Model\Request\References\OrderTypesEditRequest;

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

$entity         = new OrderType();
$entity->name   = 'Test Type';
$entity->active = true;

try {
    $response = $client->references->orderTypesEdit('test-method', new OrderTypesEditRequest($entity));
} 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);
    }
}
Parameters
$code : string
$request : OrderTypesEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

paymentStatuses()

Makes GET "/api/v5/reference/payment-statuses" request.

public paymentStatuses() : PaymentStatusesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->paymentStatuses();
} 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 'Payment statuses: ' . print_r($response->paymentStatuses, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
PaymentStatusesResponse

paymentStatusesEdit()

Makes POST "/api/v5/reference/payment-statuses/{code}/edit" request.

public paymentStatusesEdit(string $code, PaymentStatusesEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\PaymentStatus;
use RetailCrm\Api\Model\Request\References\PaymentStatusesEditRequest;

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

$entity               = new PaymentStatus();
$entity->name         = 'Test Status';
$entity->active       = true;
$entity->ordering     = 990;
$entity->paymentTypes = ['cash'];

try {
    $response = $client->references->paymentStatusesEdit('test-status', new PaymentStatusesEditRequest($entity));
} 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);
    }
}
Parameters
$code : string
$request : PaymentStatusesEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

paymentTypes()

Makes GET "/api/v5/reference/payment-types" request.

public paymentTypes() : PaymentTypesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->paymentTypes();
} 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 'Payment types: ' . print_r($response->paymentTypes, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
PaymentTypesResponse

paymentTypesEdit()

Makes POST "/api/v5/reference/payment-types/{code}/edit" request.

public paymentTypesEdit(string $code, PaymentTypesEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\PaymentType;
use RetailCrm\Api\Model\Request\References\PaymentTypesEditRequest;

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

$entity                  = new PaymentType();
$entity->name            = "Test Integration Payment";
$entity->code            = "test-payment-integration";
$entity->active          = true;
$entity->defaultForCrm   = false;
$entity->defaultForApi   = false;
$entity->paymentStatuses = [
    "invoice",
    "payment-start",
    "paid",
    "check-refund",
    "check-refund-after"
];

try {
    $response = $client->references->paymentTypesEdit(
        'test-payment-integration',
        new PaymentTypesEditRequest($entity)
    );
} 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);
    }
}
Parameters
$code : string
$request : PaymentTypesEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

priceTypes()

Makes GET "/api/v5/reference/price-types" request.

public priceTypes() : PriceTypesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->priceTypes();
} 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 'Price types: ' . print_r($response->priceTypes, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
PriceTypesResponse

priceTypesEdit()

Makes POST "/api/v5/reference/price-types/{code}/edit" request.

public priceTypesEdit(string $code, PriceTypesEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\PriceType;
use RetailCrm\Api\Model\Request\References\PriceTypesEditRequest;

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

$entity           = new PriceType();
$entity->name     = "Test Price Type";
$entity->active   = true;
$entity->ordering = 980;

try {
    $response = $client->references->priceTypesEdit('test-price-type', new PriceTypesEditRequest($entity));
} 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);
    }
}
Parameters
$code : string
$request : PriceTypesEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

productStatuses()

Makes GET "/api/v5/reference/product-statuses" request.

public productStatuses() : ProductStatusesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->productStatuses();
} 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 'Product statuses: ' . print_r($response->productStatuses, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
ProductStatusesResponse

productStatusesEdit()

Makes POST "/api/v5/reference/product-statuses/{code}/edit" request.

public productStatusesEdit(string $code, ProductStatusesEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\OrderProductStatus;
use RetailCrm\Api\Model\Request\References\ProductStatusesEditRequest;

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

$entity           = new OrderProductStatus();
$entity->name     = "Test Product Status";
$entity->active   = true;
$entity->ordering = 980;

try {
    $response = $client->references->productStatusesEdit(
        'test-product-status',
        new ProductStatusesEditRequest($entity)
    );
} 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);
    }
}
Parameters
$code : string
$request : ProductStatusesEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

sites()

Makes GET "/api/v5/reference/sites" request.

public sites() : SitesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->sites();
} 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 'Sites: ' . print_r($response->sites, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SitesResponse

sitesEdit()

Makes POST "/api/v5/reference/sites/{code}/edit" request.

public sitesEdit(string $code, SitesEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Enum\CountryCodeIso3166;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\Site;
use RetailCrm\Api\Model\Request\References\SitesEditRequest;

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

$entity                   = new Site();
$entity->name             = "Test Shop";
$entity->url              = "https://example.com";
$entity->defaultForCrm    = false;
$entity->ymlUrl           = "https://example.com/test_catalog.xml";
$entity->loadFromYml      = true;
$entity->countryIso       = CountryCodeIso3166::RUSSIAN_FEDERATION;
$entity->contragentCode   = 'test-contragent';

try {
    $response = $client->references->sitesEdit('test-site', new SitesEditRequest($entity));
} 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);
    }
}
Parameters
$code : string
$request : SitesEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

statuses()

Makes GET "/api/v5/reference/statuses" request.

public statuses() : StatusesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->statuses();
} 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 'Statuses: ' . print_r($response->statuses, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
StatusesResponse

statusesEdit()

Makes POST "/api/v5/reference/statuses/{code}/edit" request.

public statusesEdit(string $code, StatusesEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\Status;
use RetailCrm\Api\Model\Request\References\StatusesEditRequest;

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

$entity           = new Status();
$entity->name     = "Test Status";
$entity->active   = true;
$entity->ordering = 990;
$entity->group    = "assembling";

try {
    $response = $client->references->statusesEdit('test', new StatusesEditRequest($entity));
} 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);
    }
}
Parameters
$code : string
$request : StatusesEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

statusGroups()

Makes GET "/api/v5/reference/status-groups" request.

public statusGroups() : StatusGroupsResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->statusGroups();
} 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 groups: ' . print_r($response->statusGroups, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
StatusGroupsResponse

stores()

Makes GET "/api/v5/reference/stores" request.

public stores() : StoresResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->stores();
} 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 'Stores: ' . print_r($response->stores, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
StoresResponse

storesEdit()

Makes POST "/api/v5/reference/stores/{code}/edit" request.

public storesEdit(string $code, StoresEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Enum\Reference\StoreInventoryType;
use RetailCrm\Api\Enum\Reference\StoreType;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Callback\Entity\Delivery\SerializedStoreWeekOpeningHours;
use RetailCrm\Api\Model\Callback\Entity\Delivery\StoreWorkTime;
use RetailCrm\Api\Model\Entity\References\Store;
use RetailCrm\Api\Model\Entity\References\StoreAddress;
use RetailCrm\Api\Model\Entity\References\StorePhone;
use RetailCrm\Api\Model\Request\References\StoresEditRequest;

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

$entity                      = new Store();
$entity->address             = new StoreAddress();
$entity->address->countryIso = "UA";
$entity->address->region     = "Винницкая область";
$entity->address->regionId   = 104;
$entity->address->city       = "Винница";
$entity->address->cityId     = 16054;
$entity->address->cityType   = "г.";
$entity->address->street     = "Аграрна";
$entity->address->streetId   = 1814071;
$entity->address->streetType = "ул.";
$entity->address->building   = "12";
$entity->address->text       = "ул. Аграрна, д. 12";
$entity->workTime            = new SerializedStoreWeekOpeningHours(
    [new StoreWorkTime('9:00', '18:00', '12:00', '13:00')],
    [new StoreWorkTime('9:00', '18:00', '12:00', '13:00')],
    [new StoreWorkTime('9:00', '18:00', '12:00', '13:00')],
    [new StoreWorkTime('9:00', '18:00', '12:00', '13:00')],
    [new StoreWorkTime('9:00', '18:00', '12:00', '13:00')]
);
$entity->type                = StoreType::STORE_TYPE_WAREHOUSE;
$entity->inventoryType       = StoreInventoryType::INTEGER;
$entity->active              = true;
$entity->phone               = new StorePhone('88005553123');
$entity->name                = 'Test Store';

try {
    $response = $client->references->storesEdit('test', new StoresEditRequest($entity));
} 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);
    }
}
Parameters
$code : string
$request : StoresEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

units()

Makes GET "/api/v5/reference/units" request.

public units() : UnitsResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;

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

try {
    $response = $client->references->units();
} 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 'Units: ' . print_r($response->units, true);
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
UnitsResponse

unitsEdit()

Makes POST "/api/v5/reference/units/{code}/edit" request.

public unitsEdit(string $code, UnitsEditRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\References\SerializedUnit;
use RetailCrm\Api\Model\Request\References\UnitsEditRequest;

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

$entity         = new SerializedUnit();
$entity->name   = "Бобина";
$entity->sym    = "боб";
$entity->active = true;

try {
    $response = $client->references->unitsEdit('nbb', new UnitsEditRequest($entity));
} 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);
    }
}
Parameters
$code : string
$request : UnitsEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

        
On this page

Search results