RetailCRM API Client

CustomersCorporate extends AbstractApiResourceGroup

Class CustomersCorporate

Tags
category

CustomersCorporate

SuppressWarnings

(PHPMD.ExcessiveClassLength)

SuppressWarnings

(PHPMD.CouplingBetweenObjects)

Table of Contents

Methods

addresses()  : CustomersCorporateAddressesResponse
Makes GET "/api/v5/customers-corporate/{externalId}/addresses" request.
addressesCreate()  : IdResponse
Makes POST "/api/v5/customers-corporate/{externalId}/addresses/create" request.
addressesEdit()  : IdResponse
Makes POST "/api/v5/customers-corporate/{externalId}/addresses/{entityExternalId}/edit" request.
combine()  : SuccessResponse
Makes POST "/api/v5/customers-corporate/combine" request.
companies()  : CustomersCorporateCompaniesResponse
Makes GET "/api/v5/customers-corporate/{externalId}/companies" request.
companiesCreate()  : IdResponse
Makes POST "/api/v5/customers-corporate/{externalId}/companies/create" request.
companiesEdit()  : IdResponse
Makes POST "/api/v5/customers-corporate/{externalId}/companies/{entityExternalId}/edit" request.
contacts()  : CustomersCorporateContactsResponse
Makes GET "/api/v5/customers-corporate/{externalId}/contacts" request.
contactsCreate()  : IdResponse
Makes POST "/api/v5/customers-corporate/{externalId}/contacts/create" request.
contactsEdit()  : IdResponse
Makes POST "/api/v5/customers-corporate/{externalId}/contacts/{entityExternalId}/edit" request.
create()  : IdResponse
Makes POST "/api/v5/customers-corporate/create" request.
edit()  : CustomersEditResponse
Makes POST "/api/v5/customers-corporate/{externalId}/edit" request.
fixExternalIds()  : SuccessResponse
Makes POST "/api/v5/customers-corporate/fix-external-ids" request.
get()  : CustomersCorporateGetResponse
Makes GET "/api/v5/customers-corporate/{externalId}" request.
history()  : CustomersCorporateHistoryResponse
Makes GET "/api/v5/customers-corporate/history" request.
list()  : CustomersCorporateResponse
Makes GET "/api/v5/customers-corporate" request.
notes()  : CustomerNotesResponse
Makes GET "/api/v5/customers-corporate/notes" request.
notesCreate()  : IdResponse
Makes POST "/api/v5/customers-corporate/notes/create" request.
notesDelete()  : SuccessResponse
Makes POST "/api/v5/customers-corporate/notes/{id}/delete" request.
upload()  : CustomersUploadResponse
Makes POST "/api/v5/customers-corporate/upload" request.

Methods

addresses()

Makes GET "/api/v5/customers-corporate/{externalId}/addresses" request.

public addresses(string|int $identifier[, CustomersCorporateAddressesRequest|null $request = null ]) : CustomersCorporateAddressesResponse

Example:

use RetailCrm\Api\Enum\ByIdentifier;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Filter\CustomersCorporate\CustomerAddressFilter;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateAddressesRequest;

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

$request              = new CustomersCorporateAddressesRequest();
$request->filter      = new CustomerAddressFilter();
$request->site        = 'aliexpress';
$request->by          = ByIdentifier::ID;
$request->filter->ids = [1];

try {
    $response = $client->customersCorporate->addresses(1, $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 'Addresses: ' . print_r($response->addresses, true);
Parameters
$identifier : string|int
$request : CustomersCorporateAddressesRequest|null = null
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CustomersCorporateAddressesResponse

addressesCreate()

Makes POST "/api/v5/customers-corporate/{externalId}/addresses/create" request.

public addressesCreate(int|string $identifier, CustomersCorporateAddressesCreateRequest $request) : IdResponse

Example:

use RetailCrm\Api\Enum\ByIdentifier;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Customers\CustomerAddress;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateAddressesCreateRequest;

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

$request                = new CustomersCorporateAddressesCreateRequest();
$request->address       = new CustomerAddress();
$request->site          = 'aliexpress';
$request->by            = ByIdentifier::ID;
$request->address->text = '(719) 395-5645 13990 W County 270 Rd Nathrop, Colorado(CO), 81236';

try {
    $response = $client->customersCorporate->addressesCreate(1, $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 'Address ID: ' . $response->id;
Parameters
$identifier : int|string
$request : CustomersCorporateAddressesCreateRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
IdResponse

addressesEdit()

Makes POST "/api/v5/customers-corporate/{externalId}/addresses/{entityExternalId}/edit" request.

public addressesEdit(int|string $customerId, int|string $addressId, CustomersCorporateAddressesEditRequest $request) : IdResponse

Example:

use RetailCrm\Api\Enum\ByIdentifier;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Customers\CustomerAddress;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateAddressesEditRequest;

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

$request                = new CustomersCorporateAddressesEditRequest();
$request->address       = new CustomerAddress();
$request->site          = 'aliexpress';
$request->by            = ByIdentifier::ID;
$request->entityBy      = ByIdentifier::ID;
$request->address->text = '(719) 395-5645 13990 W County 270 Rd Nathrop, Colorado(CO), 81236';

try {
    $response = $client->customersCorporate->addressesEdit(1, 1, $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 'Edited address ID: ' . $response->id;
Parameters
$customerId : int|string
$addressId : int|string
$request : CustomersCorporateAddressesEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
IdResponse

combine()

Makes POST "/api/v5/customers-corporate/combine" request.

public combine(CustomersCombineRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Model\Entity\Customers\SerializedCustomerReference;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Request\Customers\CustomersCombineRequest;

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

$request                = new CustomersCombineRequest();
$request->customers     = [
    new SerializedCustomerReference(2),
    new SerializedCustomerReference(3),
    new SerializedCustomerReference(4),
];
$request->resultCustomer = new SerializedCustomerReference(1);

try {
    $response = $client->customersCorporate->combine($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 'Result: ' . var_export($response->success, true);
Parameters
$request : CustomersCombineRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

companies()

Makes GET "/api/v5/customers-corporate/{externalId}/companies" request.

public companies(string|int $identifier[, CustomersCorporateCompaniesRequest|null $request = null ]) : CustomersCorporateCompaniesResponse

Example:

use RetailCrm\Api\Enum\ByIdentifier;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Filter\CustomersCorporate\CompanyFilter;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateCompaniesRequest;

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

$request              = new CustomersCorporateCompaniesRequest();
$request->filter      = new CompanyFilter();
$request->site        = 'aliexpress';
$request->by          = ByIdentifier::ID;
$request->filter->ids = [772];

try {
    $response = $client->customersCorporate->companies(1, $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 'Companies: ' . print_r($response->companies, true);
Parameters
$identifier : string|int
$request : CustomersCorporateCompaniesRequest|null = null
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CustomersCorporateCompaniesResponse

companiesCreate()

Makes POST "/api/v5/customers-corporate/{externalId}/companies/create" request.

public companiesCreate(int|string $identifier, CustomersCorporateCompaniesCreateRequest $request) : IdResponse

Example:

use RetailCrm\Api\Enum\ByIdentifier;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Customers\CustomerAddress;
use RetailCrm\Api\Model\Entity\CustomersCorporate\Company;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateCompaniesCreateRequest;

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

$request                       = new CustomersCorporateCompaniesCreateRequest();
$request->company              = new Company();
$request->company->address     = new CustomerAddress();
$request->site                 = 'aliexpress';
$request->by                   = ByIdentifier::ID;
$request->company->name        = 'Test Company';
$request->company->brand       = 'Test Brand';
$request->company->address->id = 1;
$request->company->isMain      = true;

try {
    $response = $client->customersCorporate->companiesCreate(1, $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 'Created company ID: ' . $response->id;
Parameters
$identifier : int|string
$request : CustomersCorporateCompaniesCreateRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
IdResponse

companiesEdit()

Makes POST "/api/v5/customers-corporate/{externalId}/companies/{entityExternalId}/edit" request.

public companiesEdit(int|string $customerId, int|string $companyId, CustomersCorporateCompaniesEditRequest $request) : IdResponse

Example:

use RetailCrm\Api\Enum\ByIdentifier;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Customers\CustomerAddress;
use RetailCrm\Api\Model\Entity\CustomersCorporate\Company;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateCompaniesEditRequest;

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

$request                       = new CustomersCorporateCompaniesEditRequest();
$request->company              = new Company();
$request->company->address     = new CustomerAddress();
$request->site                 = 'aliexpress';
$request->by                   = ByIdentifier::ID;
$request->entityBy             = ByIdentifier::ID;
$request->company->name        = 'Test Company';
$request->company->brand       = 'Test Brand';
$request->company->address->id = 3559;
$request->company->isMain      = true;

try {
    $response = $client->customersCorporate->companiesEdit(1, 1, $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 'Edited company ID: ' . $response->id;
Parameters
$customerId : int|string
$companyId : int|string
$request : CustomersCorporateCompaniesEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
IdResponse

contacts()

Makes GET "/api/v5/customers-corporate/{externalId}/contacts" request.

public contacts(string|int $identifier[, CustomersCorporateContactsRequest|null $request = null ]) : CustomersCorporateContactsResponse

Example:

use RetailCrm\Api\Enum\ByIdentifier;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Filter\CustomersCorporate\CustomerContactFilter;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateContactsRequest;

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

$request                             = new CustomersCorporateContactsRequest();
$request->filter                     = new CustomerContactFilter();
$request->site                       = 'aliexpress';
$request->by                         = ByIdentifier::ID;
$request->filter->contactIds         = [5039];
$request->filter->contactExternalIds = ['test_10'];

try {
    $response = $client->customersCorporate->contacts(1, $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 'Contacts: ' . print_r($response->contacts, true);
Parameters
$identifier : string|int
$request : CustomersCorporateContactsRequest|null = null
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CustomersCorporateContactsResponse

contactsCreate()

Makes POST "/api/v5/customers-corporate/{externalId}/contacts/create" request.

public contactsCreate(int|string $identifier, CustomersCorporateContactsCreateRequest $request) : IdResponse

Example:

use RetailCrm\Api\Enum\ByIdentifier;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\CustomersCorporate\CustomerContact;
use RetailCrm\Api\Model\Entity\CustomersCorporate\CustomerContactCompany;
use RetailCrm\Api\Model\Entity\CustomersCorporate\SerializedRelationAbstractCustomer;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateContactsCreateRequest;

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

$company     = new CustomerContactCompany();
$company->id = 776;

$request                        = new CustomersCorporateContactsCreateRequest();
$request->contact               = new CustomerContact();
$request->contact->customer     = new SerializedRelationAbstractCustomer();
$request->contact->customer->id = 4985;
$request->site                  = 'aliexpress';
$request->by                    = ByIdentifier::ID;
$request->contact->companies    = [$company];

try {
    $response = $client->customersCorporate->contactsCreate(1, $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 'Created contact: ' . $response->id;
Parameters
$identifier : int|string
$request : CustomersCorporateContactsCreateRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
IdResponse

contactsEdit()

Makes POST "/api/v5/customers-corporate/{externalId}/contacts/{entityExternalId}/edit" request.

public contactsEdit(int|string $customerId, int|string $contactId, CustomersCorporateContactsEditRequest $request) : IdResponse

Example:

use RetailCrm\Api\Enum\ByIdentifier;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\CustomersCorporate\CustomerContact;
use RetailCrm\Api\Model\Entity\CustomersCorporate\CustomerContactCompany;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateContactsEditRequest;

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

$company = new CustomerContactCompany();
$company->id = 776;

$request                     = new CustomersCorporateContactsEditRequest();
$request->contact            = new CustomerContact();
$request->site               = 'aliexpress';
$request->by                 = ByIdentifier::ID;
$request->entityBy           = ByIdentifier::ID;
$request->contact->companies = [$company];

try {
    $response = $client->customersCorporate->contactsEdit(1, 1, $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 'Edited contact: ' . $response->id;
Parameters
$customerId : int|string
$contactId : int|string
$request : CustomersCorporateContactsEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
IdResponse

create()

Makes POST "/api/v5/customers-corporate/create" request.

public create(CustomersCorporateCreateRequest $request) : IdResponse

Example:

use RetailCrm\Api\Model\Entity\Source;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Enum\Customers\CustomerType;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Customers\CustomerTag;
use RetailCrm\Api\Model\Entity\Customers\CustomerAddress;
use RetailCrm\Api\Model\Entity\CustomersCorporate\Company;
use RetailCrm\Api\Model\Entity\CustomersCorporate\CustomerContact;
use RetailCrm\Api\Model\Entity\CustomersCorporate\CustomerCorporate;
use RetailCrm\Api\Model\Entity\CustomersCorporate\SerializedRelationAbstractCustomer;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateCreateRequest;

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

$address       = new CustomerAddress();
$address->text = '(719) 395-5645 13990 W County 270 Rd Nathrop, Colorado(CO), 81236';

$contact                       = new CustomerContact();
$contact->customer             = new SerializedRelationAbstractCustomer();
$contact->customer->externalId = 'test_10';
$contact->customer->site       = 'aliexpress';

$company         = new Company();
$company->name   = 'Test Company';
$company->brand  = 'Test Brand';
$company->isMain = true;

$customer                   = new CustomerCorporate();
$customer->source           = new Source();
$customer->addresses        = [$address];
$customer->customerContacts = [$contact];
$customer->companies        = [$company];
$customer->source->source   = 'chats';
$customer->type             = CustomerType::CORPORATE_CUSTOMER;
$customer->externalId       = 'test_20';
$customer->managerId        = 24;
$customer->nickName         = 'Test Corp Company';
$customer->tags             = [
    new CustomerTag('first'),
    new CustomerTag('second'),
    new CustomerTag('third'),
];
$customer->customFields     = [
    'galkatrue' => true
];

$request                    = new CustomersCorporateCreateRequest();
$request->site              = 'aliexpress';
$request->customerCorporate = $customer;

try {
    $response = $client->customersCorporate->create($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 'Created new corporate customer with id: ' . $response->id;
Parameters
$request : CustomersCorporateCreateRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
IdResponse

edit()

Makes POST "/api/v5/customers-corporate/{externalId}/edit" request.

public edit(int|string $identifier, CustomersCorporateEditRequest $request) : CustomersEditResponse

Example:

use RetailCrm\Api\Enum\ByIdentifier;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\CustomersCorporate\CustomerCorporate;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateEditRequest;

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

$request                              = new CustomersCorporateEditRequest();
$request->customerCorporate           = new CustomerCorporate();
$request->customerCorporate->nickName = 'Test Edited Customer';
$request->site                        = 'aliexpress';
$request->by                          = ByIdentifier::ID;

try {
    $response = $client->customersCorporate->edit(1, $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 'Edited corporate customer with ID: ' . $response->id;
Parameters
$identifier : int|string
$request : CustomersCorporateEditRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CustomersEditResponse

fixExternalIds()

Makes POST "/api/v5/customers-corporate/fix-external-ids" request.

public fixExternalIds(CustomersCorporateFixExternalIdsRequest $request) : SuccessResponse

Example:

use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Model\Entity\Customers\FixExternalRow;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateFixExternalIdsRequest;

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

$request            = new CustomersCorporateFixExternalIdsRequest();
$request->customersCorporate = [
    new FixExternalRow(1, 'external_id_1'),
    new FixExternalRow(2, 'external_id_2'),
    new FixExternalRow(3, 'external_id_3'),
];

try {
    $response = $client->customers->fixExternalIds($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;
}
Parameters
$request : CustomersCorporateFixExternalIdsRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SuccessResponse

get()

Makes GET "/api/v5/customers-corporate/{externalId}" request.

public get(string|int $identifier[, BySiteRequest|null $request = null ]) : CustomersCorporateGetResponse

Example:

use RetailCrm\Api\Enum\ByIdentifier;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Request\BySiteRequest;

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

$request       = new CustomersGetRequest();
$request->site = 'bb_demo';
$request->by   = ByIdentifier::ID;

try {
    $response = $client->customersCorporate->get(
        4770,
        new BySiteRequest(ByIdentifier::ID, 'bb_demo')
    );
} 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 'Corporate customer: ' . print_r($response->customerCorporate);
Parameters
$identifier : string|int
$request : BySiteRequest|null = null
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CustomersCorporateGetResponse

history()

Makes GET "/api/v5/customers-corporate/history" request.

public history([CustomersHistoryRequest|null $request = null ]) : CustomersCorporateHistoryResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Filter\Customers\CustomerHistoryFilter;
use RetailCrm\Api\Model\Request\Customers\CustomersHistoryRequest;
use RetailCrm\Api\Enum\PaginationLimit;

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

$request                  = new CustomersHistoryRequest();
$request->limit           = PaginationLimit::LIMIT_20;
$request->page            = 1;
$request->filter          = new CustomerHistoryFilter();
$request->filter->sinceId = 4241;

try {
    $response = $client->customersCorporate->history($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 'History: ' . $response->history;
Parameters
$request : CustomersHistoryRequest|null = null
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CustomersCorporateHistoryResponse

list()

Makes GET "/api/v5/customers-corporate" request.

public list([CustomersCorporateRequest|null $request = null ]) : CustomersCorporateResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Filter\CustomersCorporate\CustomerCorporateFilter;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateRequest;
use RetailCrm\Api\Enum\PaginationLimit;

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

$request                        = new CustomersCorporateRequest();
$request->filter                = new CustomerCorporateFilter();
$request->limit                 = PaginationLimit::LIMIT_20;
$request->page                  = 1;
$request->filter->sites         = ['moysklad', 'aliexpress'];
$request->filter->nickName      = ['Test'];
$request->filter->contragentInn = '5921305044';

try {
    $response = $client->customersCorporate->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 'Corporate customers: ' . print_r($response->customersCorporate);
Parameters
$request : CustomersCorporateRequest|null = null
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CustomersCorporateResponse

notes()

Makes GET "/api/v5/customers-corporate/notes" request.

public notes([CustomersNotesRequest|null $request = null ]) : CustomerNotesResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Filter\Customers\CustomerNoteFilter;
use RetailCrm\Api\Model\Request\Customers\CustomersNotesRequest;
use RetailCrm\Api\Enum\PaginationLimit;

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

$request                              = new CustomersNotesRequest();
$request->limit                       = PaginationLimit::LIMIT_20;
$request->page                        = 1;
$request->filter                      = new CustomerNoteFilter();
$request->filter->customerExternalIds = ['10'];
$request->filter->createdAtFrom       = '2019-08-06 12:00:00';
$request->filter->text                = 'note';

try {
    $response = $client->customersCorporate->notes($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 'Notes: ' . print_r($response->notes, true);
Parameters
$request : CustomersNotesRequest|null = null
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CustomerNotesResponse

notesCreate()

Makes POST "/api/v5/customers-corporate/notes/create" request.

public notesCreate(CustomersNotesCreateRequest $request) : IdResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Customers\Customer;
use RetailCrm\Api\Model\Entity\Customers\CustomerNote;
use RetailCrm\Api\Model\Request\Customers\CustomersNotesCreateRequest;

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

$request                             = new CustomersNotesCreateRequest();
$request->site                       = 'moysklad';
$request->note                       = new CustomerNote();
$request->note->customer             = new Customer();
$request->note->customer->externalId = '10';
$request->note->managerId            = 21;
$request->note->text                 = 'Text';

try {
    $response = $client->customersCorporate->notesCreate($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 'Created note with id: ' . $response->id;
Parameters
$request : CustomersNotesCreateRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
IdResponse

notesDelete()

Makes POST "/api/v5/customers-corporate/notes/{id}/delete" request.

public notesDelete(int $id) : SuccessResponse

Example:

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

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

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

upload()

Makes POST "/api/v5/customers-corporate/upload" request.

public upload(CustomersCorporateUploadRequest $request) : CustomersUploadResponse

Example:

use RetailCrm\Api\Enum\Customers\CustomerType;
use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\Customers\CustomerAddress;
use RetailCrm\Api\Model\Entity\Customers\CustomerTag;
use RetailCrm\Api\Model\Entity\Customers\FixExternalRow;
use RetailCrm\Api\Model\Entity\CustomersCorporate\Company;
use RetailCrm\Api\Model\Entity\CustomersCorporate\CustomerContact;
use RetailCrm\Api\Model\Entity\CustomersCorporate\CustomerCorporate;
use RetailCrm\Api\Model\Entity\CustomersCorporate\SerializedRelationAbstractCustomer;
use RetailCrm\Api\Model\Entity\Source;
use RetailCrm\Api\Model\Request\CustomersCorporate\CustomersCorporateUploadRequest;

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

$address       = new CustomerAddress();
$address->text = '(719) 395-5645 13990 W County 270 Rd Nathrop, Colorado(CO), 81236';

$contact                       = new CustomerContact();
$contact->customer             = new SerializedRelationAbstractCustomer();
$contact->customer->externalId = 'test_10';
$contact->customer->site       = 'aliexpress';

$company         = new Company();
$company->name   = 'Test Company';
$company->brand  = 'Test Brand';
$company->isMain = true;

$customer                   = new CustomerCorporate();
$customer->source           = new Source();
$customer->addresses        = [$address];
$customer->customerContacts = [$contact];
$customer->companies        = [$company];
$customer->source->source   = 'chats';
$customer->type             = CustomerType::CORPORATE_CUSTOMER;
$customer->externalId       = 'test_20';
$customer->managerId        = 24;
$customer->nickName         = 'Test Corp Company';
$customer->tags             = [
    new CustomerTag('first'),
    new CustomerTag('second'),
    new CustomerTag('third'),
];
$customer->customFields     = [
    'galkatrue' => true
];

$request                     = new CustomersCorporateUploadRequest();
$request->site               = 'aliexpress';
$request->customersCorporate = [$customer];

try {
    $response = $client->customersCorporate->upload($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 'Uploaded customers: ' . implode(', ', array_map(static function (FixExternalRow $row) {
        return $row->id;
}, $response->uploadedCustomers));
Parameters
$request : CustomersCorporateUploadRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
CustomersUploadResponse

        
On this page

Search results