2016-09-15 16:42:10 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 5.3
|
|
|
|
*
|
|
|
|
* API client class
|
|
|
|
*
|
2020-12-15 12:39:38 +03:00
|
|
|
* @category RetailCRM
|
|
|
|
* @package RetailCRM
|
2016-09-15 16:42:10 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace RetailCrm;
|
|
|
|
|
2021-07-08 16:29:34 +03:00
|
|
|
use InvalidArgumentException;
|
2016-09-15 16:42:10 +03:00
|
|
|
use RetailCrm\Http\Client;
|
|
|
|
use RetailCrm\Response\ApiResponse;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 5.3
|
|
|
|
*
|
|
|
|
* API client class
|
|
|
|
*
|
2020-12-15 12:39:38 +03:00
|
|
|
* @category RetailCRM
|
|
|
|
* @package RetailCRM
|
2016-09-15 16:42:10 +03:00
|
|
|
*/
|
|
|
|
class ApiClient
|
|
|
|
{
|
|
|
|
|
2017-09-04 11:36:04 +03:00
|
|
|
const VERSION = 'v5';
|
2016-09-15 16:42:10 +03:00
|
|
|
|
|
|
|
protected $client;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Site code
|
|
|
|
*/
|
|
|
|
protected $siteCode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Client creating
|
|
|
|
*
|
|
|
|
* @param string $url api url
|
|
|
|
* @param string $apiKey api key
|
|
|
|
* @param string $site site code
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*/
|
|
|
|
public function __construct($url, $apiKey, $site = null)
|
|
|
|
{
|
|
|
|
if ('/' !== $url[strlen($url) - 1]) {
|
|
|
|
$url .= '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
$url = $url . 'api/' . self::VERSION;
|
|
|
|
|
|
|
|
$this->client = new Client($url, array('apiKey' => $apiKey));
|
|
|
|
$this->siteCode = $site;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns users list
|
|
|
|
*
|
2021-08-19 15:46:03 +03:00
|
|
|
* @param array $filter
|
|
|
|
* @param int|null $page
|
|
|
|
* @param int|null $limit
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2021-08-19 15:46:03 +03:00
|
|
|
public function usersList(array $filter = [], int $page = null, int $limit = null): ApiResponse
|
2016-09-15 16:42:10 +03:00
|
|
|
{
|
2021-08-19 15:46:03 +03:00
|
|
|
$parameters = [];
|
2016-09-15 16:42:10 +03:00
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
2021-08-19 15:46:03 +03:00
|
|
|
$parameters['page'] = $page;
|
2016-09-15 16:42:10 +03:00
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
2021-08-19 15:46:03 +03:00
|
|
|
$parameters['limit'] = $limit;
|
2016-09-15 16:42:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/users',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-09-04 11:36:04 +03:00
|
|
|
/**
|
|
|
|
* Get user groups
|
|
|
|
*
|
|
|
|
* @param null $page
|
|
|
|
* @param null $limit
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function usersGroups($page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/user-groups',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
2018-08-31 11:18:42 +03:00
|
|
|
|
2017-09-04 11:36:04 +03:00
|
|
|
/**
|
|
|
|
* Change user status
|
|
|
|
*
|
|
|
|
* @param integer $id user ID
|
|
|
|
* @param string $status user status
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function usersStatus($id, $status)
|
|
|
|
{
|
|
|
|
$statuses = array("free", "busy", "dinner", "break");
|
|
|
|
|
|
|
|
if (empty($status) || !in_array($status, $statuses)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `status` must be not empty & must be equal one of these values: free|busy|dinner|break'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/users/$id/status",
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('status' => $status)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-09-15 16:42:10 +03:00
|
|
|
/**
|
|
|
|
* Returns user data
|
|
|
|
*
|
|
|
|
* @param integer $id user ID
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function usersGet($id)
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest("/users/$id", Client::METHOD_GET);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns filtered orders list
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersList(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-04-24 13:18:18 +03:00
|
|
|
/*
|
|
|
|
* Create customers corporate
|
|
|
|
*
|
|
|
|
* @param array $customer customer corporate data
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCorporateCreate(array $customer, $site = null)
|
|
|
|
{
|
|
|
|
if (! count($customer)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2020-04-24 13:18:18 +03:00
|
|
|
'Parameter `customer` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers-corporate/create',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('customerCorporate' => json_encode($customer)))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save customer corporate IDs' (id and externalId) association in the CRM
|
|
|
|
*
|
|
|
|
* @param array $ids ids mapping
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2020-08-25 10:30:16 +03:00
|
|
|
public function customersCorporateFixExternalIds(array $ids)
|
2020-04-24 13:18:18 +03:00
|
|
|
{
|
|
|
|
if (! count($ids)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2020-04-24 13:18:18 +03:00
|
|
|
'Method parameter must contains at least one IDs pair'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers-corporate/fix-external-ids',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('customerCorporate' => json_encode($ids))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Upload array of the customers corporate
|
|
|
|
*
|
|
|
|
* @param array $customers array of customers
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCorporateUpload(array $customers, $site = null)
|
|
|
|
{
|
|
|
|
if (! count($customers)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2020-04-24 13:18:18 +03:00
|
|
|
'Parameter `customers` must contains array of the customers'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers-corporate/upload',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('customersCorporate' => json_encode($customers)))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get customer corporate by id or externalId
|
|
|
|
*
|
|
|
|
* @param string $id customers-corporate identificator
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2020-08-25 10:30:16 +03:00
|
|
|
public function customersCorporateGet($id, $by = 'externalId', $site = null)
|
2020-04-24 13:18:18 +03:00
|
|
|
{
|
|
|
|
$this->checkIdParameter($by);
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers-corporate/$id",
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$this->fillSite($site, array('by' => $by))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get corporate customer companies by id or externalId
|
|
|
|
*
|
|
|
|
* @param string $id corporate customer identifier
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCorporateCompanies(
|
|
|
|
$id,
|
|
|
|
array $filter = [],
|
|
|
|
$page = null,
|
|
|
|
$limit = null,
|
|
|
|
$by = 'externalId',
|
|
|
|
$site = null
|
|
|
|
) {
|
|
|
|
|
|
|
|
$this->checkIdParameter($by);
|
|
|
|
|
|
|
|
$parameters = ['by' => $by];
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers-corporate/$id/companies",
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$this->fillSite($site, $parameters)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get customers corporate history
|
|
|
|
*
|
|
|
|
* @param array $filter
|
|
|
|
* @param null $page
|
|
|
|
* @param null $limit
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*
|
|
|
|
*/
|
2020-08-25 10:30:16 +03:00
|
|
|
public function customersCorporateHistory(array $filter = array(), $page = null, $limit = null)
|
2020-04-24 13:18:18 +03:00
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers-corporate/history',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create corporate customer contact
|
|
|
|
*
|
|
|
|
* @param string $id corporate customer identifier
|
|
|
|
* @param array $contact (default: array())
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*/
|
|
|
|
public function customersCorporateContactsCreate($id, array $contact = [], $by = 'externalId', $site = null)
|
|
|
|
{
|
|
|
|
if (! count($contact)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2020-04-24 13:18:18 +03:00
|
|
|
'Parameter `contact` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers-corporate/$id/contacts/create",
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, ['contact' => json_encode($contact), 'by' => $by])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get corporate customer contacts by id or externalId
|
|
|
|
*
|
|
|
|
* @param string $id corporate customer identifier
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCorporateContacts(
|
|
|
|
$id,
|
|
|
|
array $filter = [],
|
|
|
|
$page = null,
|
|
|
|
$limit = null,
|
|
|
|
$by = 'externalId',
|
|
|
|
$site = null
|
|
|
|
) {
|
|
|
|
$this->checkIdParameter($by);
|
|
|
|
$parameters = ['by' => $by];
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers-corporate/$id/contacts",
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$this->fillSite($site, $parameters)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns filtered corporate customers list
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCorporateList(array $filter = [], $page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = [];
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers-corporate',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns filtered corporate customers notes list
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCorporateNotesList(array $filter = [], $page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = [];
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers-corporate/notes',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create corporate customer note
|
|
|
|
*
|
|
|
|
* @param array $note (default: array())
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCorporateNotesCreate($note, $site = null)
|
|
|
|
{
|
|
|
|
if (empty($note['customer']['id']) && empty($note['customer']['externalId'])) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2020-04-24 13:18:18 +03:00
|
|
|
'Customer identifier must be set'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers-corporate/notes/create',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, ['note' => json_encode($note)])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete corporate customer note
|
|
|
|
*
|
|
|
|
* @param integer $id
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCorporateNotesDelete($id)
|
|
|
|
{
|
|
|
|
if (empty($id)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2020-04-24 13:18:18 +03:00
|
|
|
'Note id must be set'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers-corporate/notes/$id/delete",
|
|
|
|
Client::METHOD_POST
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get corporate customer addresses by id or externalId
|
|
|
|
*
|
|
|
|
* @param string $id corporate customer identifier
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCorporateAddresses(
|
|
|
|
$id,
|
|
|
|
array $filter = [],
|
|
|
|
$page = null,
|
|
|
|
$limit = null,
|
|
|
|
$by = 'externalId',
|
|
|
|
$site = null
|
|
|
|
) {
|
|
|
|
$this->checkIdParameter($by);
|
|
|
|
$parameters = ['by' => $by];
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers-corporate/$id/addresses",
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$this->fillSite($site, $parameters)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create corporate customer address
|
|
|
|
*
|
|
|
|
* @param string $id corporate customer identifier
|
|
|
|
* @param array $address (default: array())
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCorporateAddressesCreate($id, array $address = [], $by = 'externalId', $site = null)
|
|
|
|
{
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers-corporate/$id/addresses/create",
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, ['address' => json_encode($address), 'by' => $by])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit corporate customer address
|
|
|
|
*
|
|
|
|
* @param string $customerId corporate customer identifier
|
|
|
|
* @param string $addressId corporate customer identifier
|
|
|
|
* @param array $address (default: array())
|
|
|
|
* @param string $customerBy (default: 'externalId')
|
|
|
|
* @param string $addressBy (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCorporateAddressesEdit(
|
|
|
|
$customerId,
|
|
|
|
$addressId,
|
|
|
|
array $address = [],
|
|
|
|
$customerBy = 'externalId',
|
|
|
|
$addressBy = 'externalId',
|
|
|
|
$site = null
|
|
|
|
) {
|
|
|
|
$addressFiltered = array_filter($address);
|
|
|
|
if ((count(array_keys($addressFiltered)) <= 1)
|
|
|
|
&& (!isset($addressFiltered['text'])
|
|
|
|
|| (isset($addressFiltered['text']) && empty($addressFiltered['text']))
|
|
|
|
)
|
|
|
|
) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2020-04-24 13:18:18 +03:00
|
|
|
'Parameter `address` must contain address text or all other address field'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers-corporate/$customerId/addresses/$addressId/edit",
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, [
|
|
|
|
'address' => json_encode($address),
|
|
|
|
'by' => $customerBy,
|
|
|
|
'entityBy' => $addressBy
|
|
|
|
])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create corporate customer company
|
|
|
|
*
|
|
|
|
* @param string $id corporate customer identifier
|
|
|
|
* @param array $company (default: array())
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCorporateCompaniesCreate($id, array $company = [], $by = 'externalId', $site = null)
|
|
|
|
{
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers-corporate/$id/companies/create",
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, ['company' => json_encode($company), 'by' => $by])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit corporate customer company
|
|
|
|
*
|
|
|
|
* @param string $customerId corporate customer identifier
|
|
|
|
* @param string $companyId corporate customer identifier
|
|
|
|
* @param array $company (default: array())
|
|
|
|
* @param string $customerBy (default: 'externalId')
|
|
|
|
* @param string $companyBy (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function customersCorporateCompaniesEdit(
|
|
|
|
$customerId,
|
|
|
|
$companyId,
|
|
|
|
array $company = [],
|
|
|
|
$customerBy = 'externalId',
|
|
|
|
$companyBy = 'externalId',
|
|
|
|
$site = null
|
|
|
|
) {
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers-corporate/$customerId/companies/$companyId/edit",
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, [
|
|
|
|
'company' => json_encode($company),
|
|
|
|
'by' => $customerBy,
|
|
|
|
'entityBy' => $companyBy
|
|
|
|
])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit corporate customer contact
|
|
|
|
*
|
|
|
|
* @param string $customerId corporate customer identifier
|
|
|
|
* @param string $contactId corporate customer identifier
|
|
|
|
* @param array $contact (default: array())
|
|
|
|
* @param string $customerBy (default: 'externalId')
|
|
|
|
* @param string $contactBy (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function customersCorporateContactsEdit(
|
|
|
|
$customerId,
|
|
|
|
$contactId,
|
|
|
|
array $contact = [],
|
|
|
|
$customerBy = 'externalId',
|
|
|
|
$contactBy = 'externalId',
|
|
|
|
$site = null
|
|
|
|
) {
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers-corporate/$customerId/contacts/$contactId/edit",
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, [
|
|
|
|
'contact' => json_encode($contact),
|
|
|
|
'by' => $customerBy,
|
|
|
|
'entityBy' => $contactBy
|
|
|
|
])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit a corporate customer
|
|
|
|
*
|
2021-07-08 16:29:34 +03:00
|
|
|
* @param array $params corporate customer data
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param null $site (default: null)
|
2020-04-24 13:18:18 +03:00
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
2021-07-08 16:29:34 +03:00
|
|
|
public function customersCorporateEdit(
|
|
|
|
array $params,
|
|
|
|
$by = 'externalId',
|
|
|
|
$site = null
|
|
|
|
): ApiResponse {
|
|
|
|
if (!count($params)) {
|
|
|
|
throw new InvalidArgumentException(
|
2020-04-24 13:18:18 +03:00
|
|
|
'Parameter `customerCorporate` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
2021-07-08 16:29:34 +03:00
|
|
|
|
|
|
|
if (!isset($params['urlId'])) {
|
|
|
|
throw new InvalidArgumentException(
|
|
|
|
'urlId should be in $params'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$urlId = $params['urlId'];
|
|
|
|
|
|
|
|
unset($params['urlId']);
|
2020-04-24 13:18:18 +03:00
|
|
|
$this->checkIdParameter($by);
|
2021-07-08 16:29:34 +03:00
|
|
|
|
|
|
|
if (!array_key_exists($by, $params)) {
|
|
|
|
throw new InvalidArgumentException(
|
2020-04-24 13:18:18 +03:00
|
|
|
sprintf('Corporate customer array must contain the "%s" parameter.', $by)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
2021-07-08 16:29:34 +03:00
|
|
|
sprintf('/customers-corporate/%s/edit', $urlId),
|
2020-04-24 13:18:18 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite(
|
|
|
|
$site,
|
2021-07-08 16:29:34 +03:00
|
|
|
['customerCorporate' => json_encode($params), 'by' => $by]
|
2020-04-24 13:18:18 +03:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-09-15 16:42:10 +03:00
|
|
|
/**
|
|
|
|
* Create a order
|
|
|
|
*
|
|
|
|
* @param array $order order data
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersCreate(array $order, $site = null)
|
|
|
|
{
|
|
|
|
if (!count($order)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Parameter `order` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders/create',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('order' => json_encode($order)))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save order IDs' (id and externalId) association in the CRM
|
|
|
|
*
|
|
|
|
* @param array $ids order identificators
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersFixExternalIds(array $ids)
|
|
|
|
{
|
|
|
|
if (! count($ids)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Method parameter must contains at least one IDs pair'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders/fix-external-ids',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('orders' => json_encode($ids)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns statuses of the orders
|
|
|
|
*
|
|
|
|
* @param array $ids (default: array())
|
|
|
|
* @param array $externalIds (default: array())
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersStatuses(array $ids = array(), array $externalIds = array())
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($ids)) {
|
|
|
|
$parameters['ids'] = $ids;
|
|
|
|
}
|
|
|
|
if (count($externalIds)) {
|
|
|
|
$parameters['externalIds'] = $externalIds;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders/statuses',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Upload array of the orders
|
|
|
|
*
|
|
|
|
* @param array $orders array of orders
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersUpload(array $orders, $site = null)
|
|
|
|
{
|
|
|
|
if (!count($orders)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Parameter `orders` must contains array of the orders'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders/upload',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('orders' => json_encode($orders)))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get order by id or externalId
|
|
|
|
*
|
|
|
|
* @param string $id order identificator
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersGet($id, $by = 'externalId', $site = null)
|
|
|
|
{
|
|
|
|
$this->checkIdParameter($by);
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/orders/$id",
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$this->fillSite($site, array('by' => $by))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit a order
|
|
|
|
*
|
|
|
|
* @param array $order order data
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersEdit(array $order, $by = 'externalId', $site = null)
|
|
|
|
{
|
|
|
|
if (!count($order)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Parameter `order` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->checkIdParameter($by);
|
|
|
|
|
|
|
|
if (!array_key_exists($by, $order)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
sprintf('Order array must contain the "%s" parameter.', $by)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/orders/%s/edit', $order[$by]),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite(
|
|
|
|
$site,
|
|
|
|
array('order' => json_encode($order), 'by' => $by)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get orders history
|
|
|
|
* @param array $filter
|
|
|
|
* @param null $page
|
|
|
|
* @param null $limit
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersHistory(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders/history',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-04 11:36:04 +03:00
|
|
|
* Returns filtered customers list
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersList(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a customer
|
|
|
|
*
|
|
|
|
* @param array $customer customer data
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCreate(array $customer, $site = null)
|
|
|
|
{
|
|
|
|
if (! count($customer)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `customer` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers/create',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('customer' => json_encode($customer)))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save customer IDs' (id and externalId) association in the CRM
|
|
|
|
*
|
|
|
|
* @param array $ids ids mapping
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersFixExternalIds(array $ids)
|
|
|
|
{
|
|
|
|
if (! count($ids)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Method parameter must contains at least one IDs pair'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers/fix-external-ids',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('customers' => json_encode($ids))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Upload array of the customers
|
|
|
|
*
|
|
|
|
* @param array $customers array of customers
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersUpload(array $customers, $site = null)
|
|
|
|
{
|
|
|
|
if (! count($customers)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `customers` must contains array of the customers'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers/upload',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('customers' => json_encode($customers)))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get customer by id or externalId
|
|
|
|
*
|
|
|
|
* @param string $id customer identificator
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersGet($id, $by = 'externalId', $site = null)
|
|
|
|
{
|
|
|
|
$this->checkIdParameter($by);
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers/$id",
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$this->fillSite($site, array('by' => $by))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit a customer
|
|
|
|
*
|
|
|
|
* @param array $customer customer data
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersEdit(array $customer, $by = 'externalId', $site = null)
|
|
|
|
{
|
|
|
|
if (!count($customer)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `customer` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->checkIdParameter($by);
|
|
|
|
|
|
|
|
if (!array_key_exists($by, $customer)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
sprintf('Customer array must contain the "%s" parameter.', $by)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/customers/%s/edit', $customer[$by]),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite(
|
|
|
|
$site,
|
|
|
|
array('customer' => json_encode($customer), 'by' => $by)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get customers history
|
|
|
|
* @param array $filter
|
|
|
|
* @param null $page
|
|
|
|
* @param null $limit
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersHistory(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers/history',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
2018-08-31 11:18:42 +03:00
|
|
|
|
2017-09-04 11:36:04 +03:00
|
|
|
/**
|
|
|
|
* Combine orders
|
|
|
|
*
|
|
|
|
* @param array $order
|
|
|
|
* @param array $resultOrder
|
|
|
|
* @param string $technique
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersCombine($order, $resultOrder, $technique = 'ours')
|
|
|
|
{
|
|
|
|
$techniques = array('ours', 'summ', 'theirs');
|
|
|
|
|
|
|
|
if (!count($order) || !count($resultOrder)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameters `order` & `resultOrder` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!in_array($technique, $techniques)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `technique` must be on of ours|summ|theirs'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders/combine',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array(
|
|
|
|
'technique' => $technique,
|
|
|
|
'order' => json_encode($order),
|
|
|
|
'resultOrder' => json_encode($resultOrder)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create an order payment
|
|
|
|
*
|
|
|
|
* @param array $payment order data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersPaymentCreate(array $payment, $site = null)
|
|
|
|
{
|
|
|
|
if (!count($payment)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `payment` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders/payments/create',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite(
|
|
|
|
$site,
|
|
|
|
array('payment' => json_encode($payment))
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit an order payment
|
|
|
|
*
|
|
|
|
* @param array $payment order data
|
|
|
|
* @param string $by by key
|
|
|
|
* @param null $site site code
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersPaymentEdit(array $payment, $by = 'id', $site = null)
|
|
|
|
{
|
|
|
|
if (!count($payment)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `payment` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->checkIdParameter($by);
|
|
|
|
|
|
|
|
if (!array_key_exists($by, $payment)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
sprintf('Order array must contain the "%s" parameter.', $by)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2019-05-31 15:51:40 +03:00
|
|
|
sprintf('/orders/payments/%s/edit', urlencode($payment[$by])),
|
2017-09-04 11:36:04 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite(
|
|
|
|
$site,
|
|
|
|
array('payment' => json_encode($payment), 'by' => $by)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete an order payment
|
|
|
|
*
|
|
|
|
* @param integer $id id order payment
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersPaymentDelete($id)
|
|
|
|
{
|
|
|
|
if (empty($id)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Note id must be set'
|
|
|
|
);
|
|
|
|
}
|
2018-08-31 11:18:42 +03:00
|
|
|
|
2017-09-04 11:36:04 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/orders/payments/$id/delete",
|
|
|
|
Client::METHOD_POST
|
|
|
|
);
|
|
|
|
}
|
2018-08-31 11:18:42 +03:00
|
|
|
|
2017-09-04 11:36:04 +03:00
|
|
|
/**
|
|
|
|
* Combine customers
|
|
|
|
*
|
|
|
|
* @param array $customers
|
|
|
|
* @param array $resultCustomer
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersCombine(array $customers, $resultCustomer)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!count($customers) || !count($resultCustomer)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameters `customers` & `resultCustomer` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers/combine',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array(
|
|
|
|
'customers' => json_encode($customers),
|
|
|
|
'resultCustomer' => json_encode($resultCustomer)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns filtered customers notes list
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersNotesList(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers/notes',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create customer note
|
|
|
|
*
|
|
|
|
* @param array $note (default: array())
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersNotesCreate($note, $site = null)
|
|
|
|
{
|
|
|
|
if (empty($note['customer']['id']) && empty($note['customer']['externalId'])) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Customer identifier must be set'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers/notes/create',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('note' => json_encode($note)))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete customer note
|
|
|
|
*
|
|
|
|
* @param integer $id
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customersNotesDelete($id)
|
|
|
|
{
|
|
|
|
if (empty($id)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Note id must be set'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers/notes/$id/delete",
|
|
|
|
Client::METHOD_POST
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get custom fields list
|
|
|
|
*
|
|
|
|
* @param array $filter
|
|
|
|
* @param null $limit
|
|
|
|
* @param null $page
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customFieldsList(array $filter = array(), $limit = null, $page = null)
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/custom-fields',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create custom field
|
|
|
|
*
|
|
|
|
* @param $entity
|
|
|
|
* @param $customField
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customFieldsCreate($entity, $customField)
|
|
|
|
{
|
|
|
|
if (!count($customField) ||
|
|
|
|
empty($customField['code']) ||
|
|
|
|
empty($customField['name']) ||
|
|
|
|
empty($customField['type'])
|
|
|
|
) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `customField` must contain a data & fields `code`, `name` & `type` must be set'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-10-24 11:41:11 +03:00
|
|
|
if (empty($entity) || !in_array($entity, array('customer', 'order'))) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `entity` must contain a data & value must be `order` or `customer`'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/custom-fields/$entity/create",
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('customField' => json_encode($customField))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit custom field
|
|
|
|
*
|
|
|
|
* @param $entity
|
|
|
|
* @param $customField
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customFieldsEdit($entity, $customField)
|
|
|
|
{
|
|
|
|
if (!count($customField) || empty($customField['code'])) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `customField` must contain a data & fields `code` must be set'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-10-24 11:41:11 +03:00
|
|
|
if (empty($entity) || !in_array($entity, array('customer', 'order'))) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `entity` must contain a data & value must be `order` or `customer`'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/custom-fields/$entity/edit/{$customField['code']}",
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('customField' => json_encode($customField))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get custom field
|
|
|
|
*
|
|
|
|
* @param $entity
|
|
|
|
* @param $code
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function customFieldsGet($entity, $code)
|
|
|
|
{
|
|
|
|
if (empty($code)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `code` must be not empty'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-10-24 11:41:11 +03:00
|
|
|
if (empty($entity) || !in_array($entity, array('customer', 'order'))) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `entity` must contain a data & value must be `order` or `customer`'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/custom-fields/$entity/$code",
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get custom dictionaries list
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
2017-09-04 11:36:04 +03:00
|
|
|
* @param array $filter
|
|
|
|
* @param null $limit
|
|
|
|
* @param null $page
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2017-09-04 11:36:04 +03:00
|
|
|
public function customDictionariesList(array $filter = array(), $limit = null, $page = null)
|
2016-09-15 16:42:10 +03:00
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2017-09-04 11:36:04 +03:00
|
|
|
'/custom-fields/dictionaries',
|
2016-09-15 16:42:10 +03:00
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-04 11:36:04 +03:00
|
|
|
* Create custom dictionary
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
2017-09-04 11:36:04 +03:00
|
|
|
* @param $customDictionary
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2017-09-04 11:36:04 +03:00
|
|
|
public function customDictionariesCreate($customDictionary)
|
2016-09-15 16:42:10 +03:00
|
|
|
{
|
2017-09-04 11:36:04 +03:00
|
|
|
if (!count($customDictionary) ||
|
|
|
|
empty($customDictionary['code']) ||
|
|
|
|
empty($customDictionary['elements'])
|
|
|
|
) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `dictionary` must contain a data & fields `code` & `elemets` must be set'
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2017-09-04 11:36:04 +03:00
|
|
|
"/custom-fields/dictionaries/{$customDictionary['code']}/create",
|
2016-09-15 16:42:10 +03:00
|
|
|
Client::METHOD_POST,
|
2017-09-04 11:36:04 +03:00
|
|
|
array('customDictionary' => json_encode($customDictionary))
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-04 11:36:04 +03:00
|
|
|
* Edit custom dictionary
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
2017-09-04 11:36:04 +03:00
|
|
|
* @param $customDictionary
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2017-09-04 11:36:04 +03:00
|
|
|
public function customDictionariesEdit($customDictionary)
|
2016-09-15 16:42:10 +03:00
|
|
|
{
|
2017-09-04 11:36:04 +03:00
|
|
|
if (!count($customDictionary) ||
|
|
|
|
empty($customDictionary['code']) ||
|
|
|
|
empty($customDictionary['elements'])
|
|
|
|
) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `dictionary` must contain a data & fields `code` & `elemets` must be set'
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2017-09-04 11:36:04 +03:00
|
|
|
"/custom-fields/dictionaries/{$customDictionary['code']}/edit",
|
2016-09-15 16:42:10 +03:00
|
|
|
Client::METHOD_POST,
|
2017-09-04 11:36:04 +03:00
|
|
|
array('customDictionary' => json_encode($customDictionary))
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-04 11:36:04 +03:00
|
|
|
* Get custom dictionary
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
2017-09-04 11:36:04 +03:00
|
|
|
* @param $code
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2017-09-04 11:36:04 +03:00
|
|
|
public function customDictionariesGet($code)
|
2016-09-15 16:42:10 +03:00
|
|
|
{
|
2017-09-04 11:36:04 +03:00
|
|
|
if (empty($code)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `code` must be not empty'
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2017-09-04 11:36:04 +03:00
|
|
|
"/custom-fields/dictionaries/$code",
|
|
|
|
Client::METHOD_GET
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
2018-08-31 11:18:42 +03:00
|
|
|
|
2016-09-15 16:42:10 +03:00
|
|
|
/**
|
2017-09-04 11:36:04 +03:00
|
|
|
* Get tasks list
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
2017-09-04 11:36:04 +03:00
|
|
|
* @param array $filter
|
|
|
|
* @param null $limit
|
|
|
|
* @param null $page
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2017-09-04 11:36:04 +03:00
|
|
|
public function tasksList(array $filter = array(), $limit = null, $page = null)
|
2016-09-15 16:42:10 +03:00
|
|
|
{
|
2017-09-04 11:36:04 +03:00
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
2016-09-15 16:42:10 +03:00
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2017-09-04 11:36:04 +03:00
|
|
|
'/tasks',
|
2016-09-15 16:42:10 +03:00
|
|
|
Client::METHOD_GET,
|
2017-09-04 11:36:04 +03:00
|
|
|
$parameters
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-04 11:36:04 +03:00
|
|
|
* Create task
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
2017-09-04 11:36:04 +03:00
|
|
|
* @param array $task
|
|
|
|
* @param null $site
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @return ApiResponse
|
2017-09-04 11:36:04 +03:00
|
|
|
*
|
2016-09-15 16:42:10 +03:00
|
|
|
*/
|
2017-09-04 11:36:04 +03:00
|
|
|
public function tasksCreate($task, $site = null)
|
2016-09-15 16:42:10 +03:00
|
|
|
{
|
2017-09-04 11:36:04 +03:00
|
|
|
if (!count($task)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `task` must contain a data'
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-09-04 11:36:04 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/tasks/create",
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite(
|
|
|
|
$site,
|
|
|
|
array('task' => json_encode($task))
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2016-09-15 16:42:10 +03:00
|
|
|
|
2017-09-04 11:36:04 +03:00
|
|
|
/**
|
|
|
|
* Edit task
|
|
|
|
*
|
|
|
|
* @param array $task
|
|
|
|
* @param null $site
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function tasksEdit($task, $site = null)
|
|
|
|
{
|
|
|
|
if (!count($task)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `task` must contain a data'
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2017-09-04 11:36:04 +03:00
|
|
|
"/tasks/{$task['id']}/edit",
|
2016-09-15 16:42:10 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite(
|
|
|
|
$site,
|
2017-09-04 11:36:04 +03:00
|
|
|
array('task' => json_encode($task))
|
2016-09-15 16:42:10 +03:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-04 11:36:04 +03:00
|
|
|
* Get custom dictionary
|
|
|
|
*
|
|
|
|
* @param $id
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2017-09-04 11:36:04 +03:00
|
|
|
public function tasksGet($id)
|
2016-09-15 16:42:10 +03:00
|
|
|
{
|
2017-09-04 11:36:04 +03:00
|
|
|
if (empty($id)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `id` must be not empty'
|
|
|
|
);
|
2016-09-15 16:42:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2017-09-04 11:36:04 +03:00
|
|
|
"/tasks/$id",
|
|
|
|
Client::METHOD_GET
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
2018-08-31 11:18:42 +03:00
|
|
|
|
2016-09-15 16:42:10 +03:00
|
|
|
/**
|
|
|
|
* Get orders assembly list
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersPacksList(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders/packs',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create orders assembly
|
|
|
|
*
|
|
|
|
* @param array $pack pack data
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersPacksCreate(array $pack, $site = null)
|
|
|
|
{
|
|
|
|
if (!count($pack)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Parameter `pack` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders/packs/create',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('pack' => json_encode($pack)))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get orders assembly history
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersPacksHistory(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders/packs/history',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get orders assembly by id
|
|
|
|
*
|
|
|
|
* @param string $id pack identificator
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersPacksGet($id)
|
|
|
|
{
|
|
|
|
if (empty($id)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException('Parameter `id` must be set');
|
2016-09-15 16:42:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/orders/packs/$id",
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete orders assembly by id
|
|
|
|
*
|
|
|
|
* @param string $id pack identificator
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersPacksDelete($id)
|
|
|
|
{
|
|
|
|
if (empty($id)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException('Parameter `id` must be set');
|
2016-09-15 16:42:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/orders/packs/%s/delete', $id),
|
|
|
|
Client::METHOD_POST
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit orders assembly
|
|
|
|
*
|
|
|
|
* @param array $pack pack data
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersPacksEdit(array $pack, $site = null)
|
|
|
|
{
|
|
|
|
if (!count($pack) || empty($pack['id'])) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Parameter `pack` must contains a data & pack `id` must be set'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/orders/packs/%s/edit', $pack['id']),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('pack' => json_encode($pack)))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get purchace prices & stock balance
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function storeInventories(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/store/inventories',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-04 11:36:04 +03:00
|
|
|
* Upload store inventories
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
2017-09-04 11:36:04 +03:00
|
|
|
* @param array $offers offers data
|
|
|
|
* @param string $site (default: null)
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
2017-09-04 11:36:04 +03:00
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2017-09-04 11:36:04 +03:00
|
|
|
public function storeInventoriesUpload(array $offers, $site = null)
|
2016-09-15 16:42:10 +03:00
|
|
|
{
|
2017-09-04 11:36:04 +03:00
|
|
|
if (!count($offers)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `offers` must contains array of the offers'
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2017-09-04 11:36:04 +03:00
|
|
|
'/store/inventories/upload',
|
2016-09-15 16:42:10 +03:00
|
|
|
Client::METHOD_POST,
|
2017-09-04 11:36:04 +03:00
|
|
|
$this->fillSite($site, array('offers' => json_encode($offers)))
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
2018-08-31 11:18:42 +03:00
|
|
|
|
2016-09-15 16:42:10 +03:00
|
|
|
/**
|
2017-09-04 11:36:04 +03:00
|
|
|
* Upload store prices
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
2017-09-04 11:36:04 +03:00
|
|
|
* @param array $prices prices data
|
|
|
|
* @param string $site default: null)
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2017-09-04 11:36:04 +03:00
|
|
|
public function storePricesUpload(array $prices, $site = null)
|
2016-09-15 16:42:10 +03:00
|
|
|
{
|
2017-09-04 11:36:04 +03:00
|
|
|
if (!count($prices)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Parameter `prices` must contains array of the prices'
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2017-09-04 11:36:04 +03:00
|
|
|
'/store/prices/upload',
|
2016-09-15 16:42:10 +03:00
|
|
|
Client::METHOD_POST,
|
2017-09-04 11:36:04 +03:00
|
|
|
$this->fillSite($site, array('prices' => json_encode($prices)))
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get products
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function storeProducts(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/store/products',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-07-16 16:01:19 +03:00
|
|
|
* Get module configuration
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @param string $code
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
2018-07-16 16:01:19 +03:00
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \InvalidArgumentException
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2018-07-16 16:01:19 +03:00
|
|
|
public function integrationModulesGet($code)
|
2016-09-15 16:42:10 +03:00
|
|
|
{
|
|
|
|
if (empty($code)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2018-07-16 16:01:19 +03:00
|
|
|
'Parameter `code` must be set'
|
|
|
|
);
|
2016-09-15 16:42:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2018-07-16 16:01:19 +03:00
|
|
|
sprintf('/integration-modules/%s', $code),
|
2016-09-15 16:42:10 +03:00
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
2018-08-31 11:18:42 +03:00
|
|
|
|
2016-09-15 16:42:10 +03:00
|
|
|
/**
|
2018-07-16 16:01:19 +03:00
|
|
|
* Edit module configuration
|
2016-09-15 16:42:10 +03:00
|
|
|
*
|
|
|
|
* @param array $configuration
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2018-07-16 16:01:19 +03:00
|
|
|
public function integrationModulesEdit(array $configuration)
|
2016-09-15 16:42:10 +03:00
|
|
|
{
|
|
|
|
if (!count($configuration) || empty($configuration['code'])) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Parameter `configuration` must contains a data & configuration `code` must be set'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2018-07-16 16:01:19 +03:00
|
|
|
sprintf('/integration-modules/%s/edit', $configuration['code']),
|
2016-09-15 16:42:10 +03:00
|
|
|
Client::METHOD_POST,
|
2018-07-16 16:01:19 +03:00
|
|
|
array('integrationModule' => json_encode($configuration))
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delivery tracking update
|
|
|
|
*
|
|
|
|
* @param string $code
|
|
|
|
* @param array $statusUpdate
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function deliveryTracking($code, array $statusUpdate)
|
|
|
|
{
|
|
|
|
if (empty($code)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException('Parameter `code` must be set');
|
2016-09-15 16:42:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!count($statusUpdate)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Parameter `statusUpdate` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/delivery/generic/%s/tracking', $code),
|
|
|
|
Client::METHOD_POST,
|
2017-09-04 11:36:04 +03:00
|
|
|
array('statusUpdate' => json_encode($statusUpdate))
|
2016-09-15 16:42:10 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns available county list
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function countriesList()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/countries',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns deliveryServices list
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function deliveryServicesList()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/delivery-services',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit deliveryService
|
|
|
|
*
|
|
|
|
* @param array $data delivery service data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function deliveryServicesEdit(array $data)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('code', $data)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/delivery-services/%s/edit', $data['code']),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('deliveryService' => json_encode($data))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns deliveryTypes list
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function deliveryTypesList()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/delivery-types',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit deliveryType
|
|
|
|
*
|
|
|
|
* @param array $data delivery type data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function deliveryTypesEdit(array $data)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('code', $data)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/delivery-types/%s/edit', $data['code']),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('deliveryType' => json_encode($data))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns orderMethods list
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function orderMethodsList()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/order-methods',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit orderMethod
|
|
|
|
*
|
|
|
|
* @param array $data order method data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function orderMethodsEdit(array $data)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('code', $data)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/order-methods/%s/edit', $data['code']),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('orderMethod' => json_encode($data))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns orderTypes list
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function orderTypesList()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/order-types',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit orderType
|
|
|
|
*
|
|
|
|
* @param array $data order type data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function orderTypesEdit(array $data)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('code', $data)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/order-types/%s/edit', $data['code']),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('orderType' => json_encode($data))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns paymentStatuses list
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function paymentStatusesList()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/payment-statuses',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit paymentStatus
|
|
|
|
*
|
|
|
|
* @param array $data payment status data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function paymentStatusesEdit(array $data)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('code', $data)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/payment-statuses/%s/edit', $data['code']),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('paymentStatus' => json_encode($data))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns paymentTypes list
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function paymentTypesList()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/payment-types',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit paymentType
|
|
|
|
*
|
|
|
|
* @param array $data payment type data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function paymentTypesEdit(array $data)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('code', $data)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/payment-types/%s/edit', $data['code']),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('paymentType' => json_encode($data))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns productStatuses list
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function productStatusesList()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/product-statuses',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit productStatus
|
|
|
|
*
|
|
|
|
* @param array $data product status data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function productStatusesEdit(array $data)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('code', $data)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/product-statuses/%s/edit', $data['code']),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('productStatus' => json_encode($data))
|
|
|
|
);
|
|
|
|
}
|
2018-08-31 11:18:42 +03:00
|
|
|
|
2017-09-04 11:36:04 +03:00
|
|
|
/**
|
|
|
|
* Get products groups
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function storeProductsGroups(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/store/product-groups',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
2016-09-15 16:42:10 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns sites list
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function sitesList()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/sites',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit site
|
|
|
|
*
|
|
|
|
* @param array $data site data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function sitesEdit(array $data)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('code', $data)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/sites/%s/edit', $data['code']),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('site' => json_encode($data))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns statusGroups list
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function statusGroupsList()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/status-groups',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns statuses list
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function statusesList()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/statuses',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit order status
|
|
|
|
*
|
|
|
|
* @param array $data status data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function statusesEdit(array $data)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('code', $data)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/statuses/%s/edit', $data['code']),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('status' => json_encode($data))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns stores list
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function storesList()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/stores',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit store
|
|
|
|
*
|
|
|
|
* @param array $data site data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function storesEdit(array $data)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('code', $data)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!array_key_exists('name', $data)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Data must contain "name" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/stores/%s/edit', $data['code']),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('store' => json_encode($data))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-09-04 11:36:04 +03:00
|
|
|
/**
|
|
|
|
* Get prices types
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function pricesTypes()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/price-types',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit price type
|
|
|
|
*
|
|
|
|
* @param array $data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function pricesEdit(array $data)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('code', $data)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!array_key_exists('name', $data)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2017-09-04 11:36:04 +03:00
|
|
|
'Data must contain "name" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/price-types/%s/edit', $data['code']),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('priceType' => json_encode($data))
|
|
|
|
);
|
|
|
|
}
|
2016-09-15 16:42:10 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Call event
|
|
|
|
*
|
|
|
|
* @param string $phone phone number
|
|
|
|
* @param string $type call type
|
|
|
|
* @param array $codes
|
|
|
|
* @param string $hangupStatus
|
|
|
|
* @param string $externalPhone
|
|
|
|
* @param array $webAnalyticsData
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
* @internal param string $code additional phone code
|
|
|
|
* @internal param string $status call status
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function telephonyCallEvent(
|
|
|
|
$phone,
|
|
|
|
$type,
|
|
|
|
$codes,
|
|
|
|
$hangupStatus,
|
|
|
|
$externalPhone = null,
|
|
|
|
$webAnalyticsData = array()
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (!isset($phone)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException('Phone number must be set');
|
2016-09-15 16:42:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($type)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException('Type must be set (in|out|hangup)');
|
2016-09-15 16:42:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($codes)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException('Codes array must be set');
|
2016-09-15 16:42:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$parameters['phone'] = $phone;
|
|
|
|
$parameters['type'] = $type;
|
|
|
|
$parameters['codes'] = $codes;
|
|
|
|
$parameters['hangupStatus'] = $hangupStatus;
|
|
|
|
$parameters['callExternalId'] = $externalPhone;
|
|
|
|
$parameters['webAnalyticsData'] = $webAnalyticsData;
|
|
|
|
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/telephony/call/event',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('event' => json_encode($parameters))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Upload calls
|
|
|
|
*
|
|
|
|
* @param array $calls calls data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function telephonyCallsUpload(array $calls)
|
|
|
|
{
|
|
|
|
if (!count($calls)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
'Parameter `calls` must contains array of the calls'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/telephony/calls/upload',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
array('calls' => json_encode($calls))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get call manager
|
|
|
|
*
|
|
|
|
* @param string $phone phone number
|
|
|
|
* @param bool $details detailed information
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function telephonyCallManager($phone, $details)
|
|
|
|
{
|
|
|
|
if (!isset($phone)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException('Phone number must be set');
|
2016-09-15 16:42:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$parameters['phone'] = $phone;
|
|
|
|
$parameters['details'] = isset($details) ? $details : 0;
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/telephony/manager',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
2018-08-31 11:18:42 +03:00
|
|
|
|
2017-09-04 11:36:04 +03:00
|
|
|
/**
|
|
|
|
* Get segments list
|
|
|
|
*
|
|
|
|
* @param array $filter
|
|
|
|
* @param null $limit
|
|
|
|
* @param null $page
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function segmentsList(array $filter = array(), $limit = null, $page = null)
|
|
|
|
{
|
|
|
|
$parameters = array();
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/segments',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
2016-09-15 16:42:10 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update CRM basic statistic
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function statisticUpdate()
|
|
|
|
{
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/statistic/update',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return current site
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getSite()
|
|
|
|
{
|
|
|
|
return $this->siteCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set site
|
|
|
|
*
|
|
|
|
* @param string $site site code
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setSite($site)
|
|
|
|
{
|
|
|
|
$this->siteCode = $site;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check ID parameter
|
|
|
|
*
|
|
|
|
* @param string $by identify by
|
|
|
|
*
|
2021-07-08 16:29:34 +03:00
|
|
|
* @return bool
|
2016-09-15 16:42:10 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*
|
|
|
|
*/
|
2021-07-08 16:29:34 +03:00
|
|
|
protected function checkIdParameter(string $by): bool
|
2016-09-15 16:42:10 +03:00
|
|
|
{
|
2021-07-08 16:29:34 +03:00
|
|
|
$allowedForBy = [
|
2016-09-15 16:42:10 +03:00
|
|
|
'externalId',
|
2021-07-08 16:29:34 +03:00
|
|
|
'id',
|
|
|
|
];
|
2016-09-15 16:42:10 +03:00
|
|
|
|
|
|
|
if (!in_array($by, $allowedForBy, false)) {
|
2021-07-08 16:29:34 +03:00
|
|
|
throw new InvalidArgumentException(
|
2016-09-15 16:42:10 +03:00
|
|
|
sprintf(
|
|
|
|
'Value "%s" for "by" param is not valid. Allowed values are %s.',
|
|
|
|
$by,
|
|
|
|
implode(', ', $allowedForBy)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill params by site value
|
|
|
|
*
|
|
|
|
* @param string $site site code
|
|
|
|
* @param array $params input parameters
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function fillSite($site, array $params)
|
|
|
|
{
|
|
|
|
if ($site) {
|
|
|
|
$params['site'] = $site;
|
|
|
|
} elseif ($this->siteCode) {
|
|
|
|
$params['site'] = $this->siteCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $params;
|
|
|
|
}
|
|
|
|
}
|