2014-11-06 02:44:52 +03:00
|
|
|
<?php
|
2016-03-09 02:31:29 +03:00
|
|
|
|
2016-04-10 00:46:08 +03:00
|
|
|
/**
|
|
|
|
* PHP version 5.3
|
|
|
|
*
|
|
|
|
* API client class
|
|
|
|
*
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm
|
|
|
|
* @author RetailCrm <integration@retailcrm.ru>
|
|
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
2016-07-22 01:34:37 +03:00
|
|
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
2016-04-10 00:46:08 +03:00
|
|
|
*/
|
|
|
|
|
2014-11-06 02:44:52 +03:00
|
|
|
namespace RetailCrm;
|
|
|
|
|
|
|
|
use RetailCrm\Http\Client;
|
|
|
|
use RetailCrm\Response\ApiResponse;
|
|
|
|
|
|
|
|
/**
|
2016-03-09 02:31:29 +03:00
|
|
|
* PHP version 5.3
|
|
|
|
*
|
|
|
|
* API client class
|
|
|
|
*
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm
|
|
|
|
* @author RetailCrm <integration@retailcrm.ru>
|
|
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
2016-07-22 01:34:37 +03:00
|
|
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
2014-11-06 02:44:52 +03:00
|
|
|
*/
|
|
|
|
class ApiClient
|
|
|
|
{
|
2016-01-09 15:23:50 +03:00
|
|
|
|
2016-06-06 17:53:05 +03:00
|
|
|
const VERSION = 'v4';
|
2014-11-06 02:44:52 +03:00
|
|
|
|
|
|
|
protected $client;
|
|
|
|
|
2014-11-27 11:23:44 +03:00
|
|
|
/**
|
|
|
|
* Site code
|
|
|
|
*/
|
|
|
|
protected $siteCode;
|
|
|
|
|
2014-11-06 02:44:52 +03:00
|
|
|
/**
|
|
|
|
* Client creating
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param string $url api url
|
|
|
|
* @param string $apiKey api key
|
|
|
|
* @param string $site site code
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*
|
2014-11-10 03:12:50 +03:00
|
|
|
* @return mixed
|
2014-11-06 02:44:52 +03:00
|
|
|
*/
|
2014-11-27 11:23:44 +03:00
|
|
|
public function __construct($url, $apiKey, $site = null)
|
2014-11-06 02:44:52 +03:00
|
|
|
{
|
2016-06-06 17:53:05 +03:00
|
|
|
if ('/' !== $url[strlen($url) - 1]) {
|
2014-11-06 02:44:52 +03:00
|
|
|
$url .= '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
$url = $url . 'api/' . self::VERSION;
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
$this->client = new Client($url, array('apiKey' => $apiKey));
|
2014-11-27 11:23:44 +03:00
|
|
|
$this->siteCode = $site;
|
2016-09-21 00:09:24 +03:00
|
|
|
|
|
|
|
return $this->client;
|
2014-11-06 02:44:52 +03:00
|
|
|
}
|
|
|
|
|
2016-06-06 17:53:05 +03:00
|
|
|
/**
|
|
|
|
* Returns users list
|
|
|
|
*
|
|
|
|
* @param array $filter
|
|
|
|
* @param null $page
|
|
|
|
* @param null $limit
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function usersList(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(
|
|
|
|
'/users',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-09-21 00:09:24 +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
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-06-06 17:53:05 +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);
|
|
|
|
}
|
|
|
|
|
2014-11-06 02:44:52 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Returns filtered orders list
|
2014-11-06 02:44:52 +03:00
|
|
|
*
|
2016-01-09 15:23:50 +03:00
|
|
|
* @param array $filter (default: array())
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
2014-11-06 02:44:52 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 02:44:52 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function ordersList(array $filter = array(), $page = null, $limit = null)
|
2014-11-06 02:44:52 +03:00
|
|
|
{
|
2016-01-09 15:23:50 +03:00
|
|
|
$parameters = array();
|
2014-11-06 02:44:52 +03:00
|
|
|
|
2016-03-12 01:54:33 +03:00
|
|
|
if (count($filter)) {
|
2016-01-09 15:23:50 +03:00
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
2014-11-06 02:44:52 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
2014-11-06 02:44:52 +03:00
|
|
|
}
|
|
|
|
|
2014-11-06 13:48:07 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Create a order
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param array $order order data
|
|
|
|
* @param string $site (default: null)
|
2014-11-06 13:48:07 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 13:48:07 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function ordersCreate(array $order, $site = null)
|
2014-11-06 13:48:07 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!count($order)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `order` must contains a data'
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
'/orders/create',
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('order' => json_encode($order)))
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
|
|
|
|
2014-11-06 02:44:52 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Save order IDs' (id and externalId) association in the CRM
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param array $ids order identificators
|
2014-11-06 02:44:52 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 02:44:52 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function ordersFixExternalIds(array $ids)
|
2014-11-06 02:44:52 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (! count($ids)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Method parameter must contains at least one IDs pair'
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
2014-11-06 02:44:52 +03:00
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
'/orders/fix-external-ids',
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
array('orders' => json_encode($ids)
|
|
|
|
)
|
|
|
|
);
|
2014-11-06 02:44:52 +03:00
|
|
|
}
|
|
|
|
|
2014-11-06 03:50:15 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Returns statuses of the orders
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param array $ids (default: array())
|
2016-01-09 15:23:50 +03:00
|
|
|
* @param array $externalIds (default: array())
|
2014-11-06 03:50:15 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 13:48:07 +03:00
|
|
|
* @return ApiResponse
|
2014-11-06 03:50:15 +03:00
|
|
|
*/
|
2016-06-06 17:53:05 +03:00
|
|
|
public function ordersStatuses(array $ids = array(), array $externalIds = array())
|
|
|
|
{
|
2014-11-06 03:50:15 +03:00
|
|
|
$parameters = array();
|
|
|
|
|
2016-03-12 01:54:33 +03:00
|
|
|
if (count($ids)) {
|
2016-01-09 15:23:50 +03:00
|
|
|
$parameters['ids'] = $ids;
|
2014-11-06 03:50:15 +03:00
|
|
|
}
|
2016-03-12 01:54:33 +03:00
|
|
|
if (count($externalIds)) {
|
2016-01-09 15:23:50 +03:00
|
|
|
$parameters['externalIds'] = $externalIds;
|
2014-11-06 03:50:15 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders/statuses',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
2014-11-06 03:50:15 +03:00
|
|
|
}
|
|
|
|
|
2014-11-13 09:37:53 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Upload array of the orders
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param array $orders array of orders
|
|
|
|
* @param string $site (default: null)
|
2014-11-13 09:37:53 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-13 09:37:53 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function ordersUpload(array $orders, $site = null)
|
2014-11-13 09:37:53 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!count($orders)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `orders` must contains array of the orders'
|
|
|
|
);
|
2014-11-13 09:37:53 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
'/orders/upload',
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('orders' => json_encode($orders)))
|
|
|
|
);
|
2014-11-13 09:37:53 +03:00
|
|
|
}
|
|
|
|
|
2014-11-06 13:48:07 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Get order by id or externalId
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param string $id order identificator
|
|
|
|
* @param string $by (default: 'externalId')
|
2016-01-09 15:23:50 +03:00
|
|
|
* @param string $site (default: null)
|
2014-11-06 13:48:07 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 13:48:07 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function ordersGet($id, $by = 'externalId', $site = null)
|
2014-11-06 13:48:07 +03:00
|
|
|
{
|
2016-01-09 15:23:50 +03:00
|
|
|
$this->checkIdParameter($by);
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/orders/$id",
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$this->fillSite($site, array('by' => $by))
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit a order
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param array $order order data
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2016-01-09 15:23:50 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function ordersEdit(array $order, $by = 'externalId', $site = null)
|
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!count($order)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `order` must contains a data'
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
|
|
|
|
2016-01-09 15:23:50 +03:00
|
|
|
$this->checkIdParameter($by);
|
|
|
|
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!array_key_exists($by, $order)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
sprintf('Order array must contain the "%s" parameter.', $by)
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/orders/%s/edit', $order[$by]),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite(
|
|
|
|
$site,
|
|
|
|
array('order' => json_encode($order), 'by' => $by)
|
|
|
|
)
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
2015-05-08 18:03:05 +03:00
|
|
|
|
2016-07-11 14:22:06 +03:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-05-04 18:47:14 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Returns filtered customers list
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
2015-05-04 18:47:14 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2015-05-04 18:47:14 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-06-06 17:53:05 +03:00
|
|
|
public function customersList(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
2015-05-04 18:47:14 +03:00
|
|
|
$parameters = array();
|
|
|
|
|
2016-03-12 01:54:33 +03:00
|
|
|
if (count($filter)) {
|
2015-05-04 18:47:14 +03:00
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/customers',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
2015-05-04 18:47:14 +03:00
|
|
|
}
|
2014-11-06 13:48:07 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a customer
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param array $customer customer data
|
|
|
|
* @param string $site (default: null)
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 13:48:07 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2014-11-27 11:23:44 +03:00
|
|
|
public function customersCreate(array $customer, $site = null)
|
2014-11-06 13:48:07 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (! count($customer)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `customer` must contains a data'
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
'/customers/create',
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('customer' => json_encode($customer)))
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Save customer IDs' (id and externalId) association in the CRM
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param array $ids ids mapping
|
2014-11-06 13:48:07 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 13:48:07 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function customersFixExternalIds(array $ids)
|
2014-11-06 13:48:07 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (! count($ids)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Method parameter must contains at least one IDs pair'
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
'/customers/fix-external-ids',
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
array('customers' => json_encode($ids))
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Upload array of the customers
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param array $customers array of customers
|
|
|
|
* @param string $site (default: null)
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 13:48:07 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2014-11-27 11:23:44 +03:00
|
|
|
public function customersUpload(array $customers, $site = null)
|
2014-11-06 13:48:07 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (! count($customers)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `customers` must contains array of the customers'
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
'/customers/upload',
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('customers' => json_encode($customers)))
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get customer by id or externalId
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param string $id customer identificator
|
|
|
|
* @param string $by (default: 'externalId')
|
2016-01-09 15:23:50 +03:00
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 13:48:07 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2014-11-27 11:23:44 +03:00
|
|
|
public function customersGet($id, $by = 'externalId', $site = null)
|
2014-11-06 13:48:07 +03:00
|
|
|
{
|
|
|
|
$this->checkIdParameter($by);
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/customers/$id",
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$this->fillSite($site, array('by' => $by))
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Edit a customer
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param array $customer customer data
|
|
|
|
* @param string $by (default: 'externalId')
|
|
|
|
* @param string $site (default: null)
|
2014-11-06 13:48:07 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 13:48:07 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function customersEdit(array $customer, $by = 'externalId', $site = null)
|
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!count($customer)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `customer` must contains a data'
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->checkIdParameter($by);
|
|
|
|
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!array_key_exists($by, $customer)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
sprintf('Customer array must contain the "%s" parameter.', $by)
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/customers/%s/edit', $customer[$by]),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite(
|
|
|
|
$site,
|
|
|
|
array('customer' => json_encode($customer), 'by' => $by)
|
|
|
|
)
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
2016-07-11 14:22:06 +03:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-01-09 15:23:50 +03:00
|
|
|
/**
|
|
|
|
* Get orders assembly list
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2016-01-09 15:23:50 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-06-06 17:53:05 +03:00
|
|
|
public function ordersPacksList(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
2014-11-06 13:48:07 +03:00
|
|
|
$parameters = array();
|
|
|
|
|
2016-03-12 01:54:33 +03:00
|
|
|
if (count($filter)) {
|
2014-11-06 13:48:07 +03:00
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders/packs',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Create orders assembly
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param array $pack pack data
|
2016-01-09 15:23:50 +03:00
|
|
|
* @param string $site (default: null)
|
2014-11-06 13:48:07 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 13:48:07 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function ordersPacksCreate(array $pack, $site = null)
|
2014-11-06 13:48:07 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!count($pack)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `pack` must contains a data'
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
'/orders/packs/create',
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('pack' => json_encode($pack)))
|
|
|
|
);
|
2014-11-06 13:48:07 +03:00
|
|
|
}
|
|
|
|
|
2015-05-04 18:47:14 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Get orders assembly history
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
2015-05-04 18:47:14 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2015-05-04 18:47:14 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-06-06 17:53:05 +03:00
|
|
|
public function ordersPacksHistory(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
2015-05-04 18:47:14 +03:00
|
|
|
$parameters = array();
|
|
|
|
|
2016-03-12 01:54:33 +03:00
|
|
|
if (count($filter)) {
|
2015-05-04 18:47:14 +03:00
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/orders/packs/history',
|
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
|
|
|
);
|
2015-05-04 18:47:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Get orders assembly by id
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param string $id pack identificator
|
2015-05-04 18:47:14 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2015-05-04 18:47:14 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function ordersPacksGet($id)
|
2015-05-04 18:47:14 +03:00
|
|
|
{
|
2016-01-09 15:23:50 +03:00
|
|
|
if (empty($id)) {
|
|
|
|
throw new \InvalidArgumentException('Parameter `id` must be set');
|
2015-05-04 18:47:14 +03:00
|
|
|
}
|
|
|
|
|
2016-03-12 01:54:33 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/orders/packs/$id",
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
2015-05-04 18:47:14 +03:00
|
|
|
}
|
|
|
|
|
2014-11-06 16:39:55 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Delete orders assembly by id
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param string $id pack identificator
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function ordersPacksDelete($id)
|
2014-11-06 16:39:55 +03:00
|
|
|
{
|
2016-01-09 15:23:50 +03:00
|
|
|
if (empty($id)) {
|
|
|
|
throw new \InvalidArgumentException('Parameter `id` must be set');
|
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/orders/packs/%s/delete', $id),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Edit orders assembly
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param array $pack pack data
|
2016-01-09 15:23:50 +03:00
|
|
|
* @param string $site (default: null)
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function ordersPacksEdit(array $pack, $site = null)
|
2014-11-06 16:39:55 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!count($pack) || empty($pack['id'])) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `pack` must contains a data & pack `id` must be set'
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/orders/packs/%s/edit', $pack['id']),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('pack' => json_encode($pack)))
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Get purchace prices & stock balance
|
|
|
|
*
|
2016-04-10 00:46:08 +03:00
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
2016-03-12 01:54:33 +03:00
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-06-06 17:53:05 +03:00
|
|
|
public function storeInventories(array $filter = array(), $page = null, $limit = null)
|
|
|
|
{
|
2016-01-09 15:23:50 +03:00
|
|
|
$parameters = array();
|
|
|
|
|
2016-03-12 01:54:33 +03:00
|
|
|
if (count($filter)) {
|
2016-01-09 15:23:50 +03:00
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/store/inventories',
|
|
|
|
Client::METHOD_GET,
|
2016-03-12 01:54:33 +03:00
|
|
|
$parameters
|
2016-03-09 02:31:29 +03:00
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
2016-06-06 17:53:05 +03:00
|
|
|
/**
|
|
|
|
* Get store settings
|
|
|
|
*
|
|
|
|
* @param string $code get settings code
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function storeSettingsGet($code)
|
|
|
|
{
|
|
|
|
if (empty($code)) {
|
|
|
|
throw new \InvalidArgumentException('Parameter `code` must be set');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2016-07-28 10:48:15 +03:00
|
|
|
"/store/setting/$code",
|
2016-06-06 17:53:05 +03:00
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit store configuration
|
|
|
|
*
|
|
|
|
* @param array $configuration
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function storeSettingsEdit(array $configuration)
|
|
|
|
{
|
|
|
|
if (!count($configuration) || empty($configuration['code'])) {
|
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `configuration` must contains a data & configuration `code` must be set'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2016-07-28 10:48:15 +03:00
|
|
|
sprintf('/store/setting/%s/edit', $configuration['code']),
|
2016-06-06 17:53:05 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
$configuration
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-11-06 16:39:55 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Upload store inventories
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param array $offers offers data
|
|
|
|
* @param string $site (default: null)
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function storeInventoriesUpload(array $offers, $site = null)
|
2014-11-06 16:39:55 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!count($offers)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `offers` must contains array of the offers'
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
'/store/inventories/upload',
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('offers' => json_encode($offers)))
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
2016-09-21 00:09:24 +03:00
|
|
|
/**
|
|
|
|
* Upload store prices
|
|
|
|
*
|
|
|
|
* @param array $prices prices data
|
|
|
|
* @param string $site default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function storePricesUpload(array $prices, $site = null)
|
|
|
|
{
|
|
|
|
if (!count($prices)) {
|
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `prices` must contains array of the prices'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/store/prices/upload',
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$this->fillSite($site, array('prices' => json_encode($prices)))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-06-06 17:53:05 +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
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-07-11 14:22:06 +03:00
|
|
|
/**
|
|
|
|
* Get delivery settings
|
|
|
|
*
|
|
|
|
* @param string $code
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function deliverySettingsGet($code)
|
|
|
|
{
|
|
|
|
if (empty($code)) {
|
|
|
|
throw new \InvalidArgumentException('Parameter `code` must be set');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/delivery/generic/setting/$code",
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit delivery configuration
|
|
|
|
*
|
|
|
|
* @param array $configuration
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function deliverySettingsEdit(array $configuration)
|
|
|
|
{
|
|
|
|
if (!count($configuration) || empty($configuration['code'])) {
|
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `configuration` must contains a data & configuration `code` must be set'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2016-08-02 16:54:50 +03:00
|
|
|
sprintf('/delivery/generic/setting/%s/edit', $configuration['code']),
|
2016-07-11 14:22:06 +03:00
|
|
|
Client::METHOD_POST,
|
2016-08-02 16:54:50 +03:00
|
|
|
array('configuration' => json_encode($configuration))
|
2016-07-11 14:22:06 +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)) {
|
|
|
|
throw new \InvalidArgumentException('Parameter `code` must be set');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!count($statusUpdate)) {
|
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `statusUpdate` must contains a data'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/delivery/generic/%s/tracking', $code),
|
|
|
|
Client::METHOD_POST,
|
|
|
|
$statusUpdate
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-11-06 16:39:55 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Returns available county list
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function countriesList()
|
2014-11-06 16:39:55 +03:00
|
|
|
{
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/countries',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Returns deliveryServices list
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function deliveryServicesList()
|
2014-11-06 16:39:55 +03:00
|
|
|
{
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/delivery-services',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Edit deliveryService
|
|
|
|
*
|
|
|
|
* @param array $data delivery service data
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function deliveryServicesEdit(array $data)
|
2014-11-06 16:39:55 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!array_key_exists('code', $data)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/reference/delivery-services/%s/edit', $data['code']),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
array('deliveryService' => json_encode($data))
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Returns deliveryTypes list
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function deliveryTypesList()
|
2014-11-06 16:39:55 +03:00
|
|
|
{
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/delivery-types',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
2014-11-27 11:23:44 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Edit deliveryType
|
|
|
|
*
|
|
|
|
* @param array $data delivery type data
|
2014-11-27 11:23:44 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-27 11:23:44 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function deliveryTypesEdit(array $data)
|
2014-11-27 11:23:44 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!array_key_exists('code', $data)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/reference/delivery-types/%s/edit', $data['code']),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
array('deliveryType' => json_encode($data))
|
|
|
|
);
|
2014-11-27 11:23:44 +03:00
|
|
|
}
|
|
|
|
|
2015-06-15 16:40:39 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Returns orderMethods list
|
2015-06-15 16:40:39 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2015-06-15 16:40:39 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function orderMethodsList()
|
2015-06-15 16:40:39 +03:00
|
|
|
{
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
'/reference/order-methods',
|
|
|
|
Client::METHOD_GET
|
2016-03-09 02:31:29 +03:00
|
|
|
);
|
2015-06-15 16:40:39 +03:00
|
|
|
}
|
2014-11-27 11:23:44 +03:00
|
|
|
|
2014-11-06 16:39:55 +03:00
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Edit orderMethod
|
|
|
|
*
|
|
|
|
* @param array $data order method data
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function orderMethodsEdit(array $data)
|
2014-11-06 16:39:55 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!array_key_exists('code', $data)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/reference/order-methods/%s/edit', $data['code']),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
array('orderMethod' => json_encode($data))
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Returns orderTypes list
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function orderTypesList()
|
2014-11-06 16:39:55 +03:00
|
|
|
{
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/order-types',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Edit orderType
|
|
|
|
*
|
|
|
|
* @param array $data order type data
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function orderTypesEdit(array $data)
|
2014-11-06 16:39:55 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!array_key_exists('code', $data)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/reference/order-types/%s/edit', $data['code']),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
array('orderType' => json_encode($data))
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Returns paymentStatuses list
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function paymentStatusesList()
|
2014-11-06 16:39:55 +03:00
|
|
|
{
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/payment-statuses',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit paymentStatus
|
|
|
|
*
|
2014-11-10 03:12:50 +03:00
|
|
|
* @param array $data payment status data
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function paymentStatusesEdit(array $data)
|
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!array_key_exists('code', $data)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/reference/payment-statuses/%s/edit', $data['code']),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
array('paymentStatus' => json_encode($data))
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns paymentTypes list
|
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2016-01-09 15:23:50 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function paymentTypesList()
|
|
|
|
{
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/payment-types',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit paymentType
|
|
|
|
*
|
2014-11-10 03:12:50 +03:00
|
|
|
* @param array $data payment type data
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function paymentTypesEdit(array $data)
|
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!array_key_exists('code', $data)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/reference/payment-types/%s/edit', $data['code']),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
array('paymentType' => json_encode($data))
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns productStatuses list
|
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2016-01-09 15:23:50 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function productStatusesList()
|
|
|
|
{
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/product-statuses',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit productStatus
|
|
|
|
*
|
2014-11-10 03:12:50 +03:00
|
|
|
* @param array $data product status data
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function productStatusesEdit(array $data)
|
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!array_key_exists('code', $data)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/reference/product-statuses/%s/edit', $data['code']),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
array('productStatus' => json_encode($data))
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-01-09 15:23:50 +03:00
|
|
|
* Returns sites list
|
2014-11-06 16:39:55 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-06 16:39:55 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-01-09 15:23:50 +03:00
|
|
|
public function sitesList()
|
2014-11-06 16:39:55 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/sites',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
2014-11-06 16:39:55 +03:00
|
|
|
}
|
|
|
|
|
2014-11-27 11:23:44 +03:00
|
|
|
/**
|
|
|
|
* Edit site
|
|
|
|
*
|
|
|
|
* @param array $data site data
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2014-11-27 11:23:44 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function sitesEdit(array $data)
|
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!array_key_exists('code', $data)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
2014-11-27 11:23:44 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/reference/sites/%s/edit', $data['code']),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
array('site' => json_encode($data))
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns statusGroups list
|
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2016-01-09 15:23:50 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function statusGroupsList()
|
|
|
|
{
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/status-groups',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns statuses list
|
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2016-01-09 15:23:50 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function statusesList()
|
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/statuses',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit order status
|
|
|
|
*
|
|
|
|
* @param array $data status data
|
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2016-01-09 15:23:50 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function statusesEdit(array $data)
|
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!array_key_exists('code', $data)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/reference/statuses/%s/edit', $data['code']),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
array('status' => json_encode($data))
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns stores list
|
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2016-01-09 15:23:50 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function storesList()
|
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/stores',
|
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
2014-11-27 11:23:44 +03:00
|
|
|
}
|
|
|
|
|
2015-06-15 16:40:39 +03:00
|
|
|
/**
|
|
|
|
* Edit store
|
|
|
|
*
|
|
|
|
* @param array $data site data
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2015-06-15 16:40:39 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function storesEdit(array $data)
|
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!array_key_exists('code', $data)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
2015-06-15 16:40:39 +03:00
|
|
|
}
|
|
|
|
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!array_key_exists('name', $data)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "name" parameter.'
|
|
|
|
);
|
2015-06-15 16:40:39 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
sprintf('/reference/stores/%s/edit', $data['code']),
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
array('store' => json_encode($data))
|
|
|
|
);
|
2015-06-15 16:40:39 +03:00
|
|
|
}
|
|
|
|
|
2016-09-21 00:09:24 +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)) {
|
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!array_key_exists('name', $data)) {
|
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'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-04-10 00:46:08 +03:00
|
|
|
/**
|
2016-06-06 17:53:05 +03:00
|
|
|
* Get telephony settings
|
|
|
|
*
|
|
|
|
* @param string $code
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function telephonySettingsGet($code)
|
|
|
|
{
|
|
|
|
if (empty($code)) {
|
|
|
|
throw new \InvalidArgumentException('Parameter `code` must be set');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->client->makeRequest(
|
2016-07-22 01:01:47 +03:00
|
|
|
"/telephony/setting/$code",
|
2016-06-06 17:53:05 +03:00
|
|
|
Client::METHOD_GET
|
|
|
|
);
|
|
|
|
}
|
2016-07-22 01:01:47 +03:00
|
|
|
|
2016-06-06 17:53:05 +03:00
|
|
|
/**
|
|
|
|
* Edit telephony settings
|
2016-04-10 00:46:08 +03:00
|
|
|
*
|
|
|
|
* @param string $code symbolic code
|
|
|
|
* @param string $clientId client id
|
|
|
|
* @param boolean $active telephony activity
|
|
|
|
* @param mixed $name service name
|
2016-07-22 01:01:47 +03:00
|
|
|
* @param mixed $makeCallUrl service init url
|
2016-04-10 00:46:08 +03:00
|
|
|
* @param mixed $image service logo url(svg file)
|
|
|
|
*
|
2016-07-22 01:01:47 +03:00
|
|
|
* @param array $additionalCodes
|
|
|
|
* @param array $externalPhones
|
|
|
|
* @param bool $allowEdit
|
|
|
|
* @param bool $inputEventSupported
|
|
|
|
* @param bool $outputEventSupported
|
|
|
|
* @param bool $hangupEventSupported
|
|
|
|
* @param bool $changeUserStatusUrl
|
2016-04-10 00:46:08 +03:00
|
|
|
*
|
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
2016-07-22 01:01:47 +03:00
|
|
|
public function telephonySettingsEdit(
|
|
|
|
$code,
|
|
|
|
$clientId,
|
|
|
|
$active = false,
|
|
|
|
$name = false,
|
|
|
|
$makeCallUrl = false,
|
|
|
|
$image = false,
|
|
|
|
$additionalCodes = array(),
|
|
|
|
$externalPhones = array(),
|
|
|
|
$allowEdit = false,
|
|
|
|
$inputEventSupported = false,
|
|
|
|
$outputEventSupported = false,
|
|
|
|
$hangupEventSupported = false,
|
|
|
|
$changeUserStatusUrl = false
|
|
|
|
)
|
2016-06-06 17:53:05 +03:00
|
|
|
{
|
2016-04-10 00:46:08 +03:00
|
|
|
if (!isset($code)) {
|
|
|
|
throw new \InvalidArgumentException('Code must be set');
|
|
|
|
}
|
|
|
|
|
|
|
|
$parameters['code'] = $code;
|
|
|
|
|
|
|
|
if (!isset($clientId)) {
|
|
|
|
throw new \InvalidArgumentException('client id must be set');
|
|
|
|
}
|
|
|
|
|
|
|
|
$parameters['clientId'] = $clientId;
|
|
|
|
|
|
|
|
if (!isset($active)) {
|
|
|
|
$parameters['active'] = false;
|
|
|
|
} else {
|
|
|
|
$parameters['active'] = $active;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($name)) {
|
|
|
|
throw new \InvalidArgumentException('name must be set');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($name)) {
|
|
|
|
$parameters['name'] = $name;
|
|
|
|
}
|
|
|
|
|
2016-07-22 01:01:47 +03:00
|
|
|
if (isset($makeCallUrl)) {
|
|
|
|
$parameters['makeCallUrl'] = $makeCallUrl;
|
|
|
|
}
|
|
|
|
|
2016-04-10 00:46:08 +03:00
|
|
|
if (isset($image)) {
|
|
|
|
$parameters['image'] = $image;
|
|
|
|
}
|
|
|
|
|
2016-07-22 01:01:47 +03:00
|
|
|
if (isset($additionalCodes)) {
|
|
|
|
$parameters['additionalCodes'] = $additionalCodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($externalPhones)) {
|
|
|
|
$parameters['externalPhones'] = $externalPhones;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($allowEdit)) {
|
|
|
|
$parameters['allowEdit'] = $allowEdit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($inputEventSupported)) {
|
|
|
|
$parameters['inputEventSupported'] = $inputEventSupported;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($outputEventSupported)) {
|
|
|
|
$parameters['outputEventSupported'] = $outputEventSupported;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($hangupEventSupported)) {
|
|
|
|
$parameters['hangupEventSupported'] = $hangupEventSupported;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($changeUserStatusUrl)) {
|
|
|
|
$parameters['changeUserStatusUrl'] = $changeUserStatusUrl;
|
|
|
|
}
|
|
|
|
|
2016-04-10 00:46:08 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-06-06 17:53:05 +03:00
|
|
|
"/telephony/setting/$code/edit",
|
2016-04-10 00:46:08 +03:00
|
|
|
Client::METHOD_POST,
|
2016-07-22 01:01:47 +03:00
|
|
|
array('configuration' => json_encode($parameters))
|
2016-04-10 00:46:08 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-01-09 15:23:50 +03:00
|
|
|
/**
|
|
|
|
* Call event
|
|
|
|
*
|
2016-07-22 01:01:47 +03:00
|
|
|
* @param string $phone phone number
|
|
|
|
* @param string $type call type
|
|
|
|
* @param array $codes
|
|
|
|
* @param string $hangupStatus
|
|
|
|
* @param string $externalPhone
|
|
|
|
* @param array $webAnalyticsData
|
2016-03-12 01:54:33 +03:00
|
|
|
*
|
2016-01-09 15:23:50 +03:00
|
|
|
* @return ApiResponse
|
2016-07-22 01:01:47 +03:00
|
|
|
* @internal param string $code additional phone code
|
|
|
|
* @internal param string $status call status
|
|
|
|
*
|
2016-01-09 15:23:50 +03:00
|
|
|
*/
|
2016-07-22 01:01:47 +03:00
|
|
|
public function telephonyCallEvent(
|
|
|
|
$phone,
|
|
|
|
$type,
|
|
|
|
$codes,
|
|
|
|
$hangupStatus,
|
|
|
|
$externalPhone = null,
|
|
|
|
$webAnalyticsData = array()
|
|
|
|
)
|
2016-01-09 15:23:50 +03:00
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!isset($phone)) {
|
2016-01-09 15:23:50 +03:00
|
|
|
throw new \InvalidArgumentException('Phone number must be set');
|
|
|
|
}
|
|
|
|
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!isset($type)) {
|
2016-01-09 15:23:50 +03:00
|
|
|
throw new \InvalidArgumentException('Type must be set (in|out|hangup)');
|
|
|
|
}
|
|
|
|
|
2016-07-22 01:01:47 +03:00
|
|
|
if (empty($codes)) {
|
|
|
|
throw new \InvalidArgumentException('Codes array must be set');
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
2016-07-22 01:01:47 +03:00
|
|
|
$parameters['phone'] = $phone;
|
|
|
|
$parameters['type'] = $type;
|
|
|
|
$parameters['codes'] = $codes;
|
|
|
|
$parameters['hangupStatus'] = $hangupStatus;
|
|
|
|
$parameters['callExternalId'] = $externalPhone;
|
|
|
|
$parameters['webAnalyticsData'] = $webAnalyticsData;
|
|
|
|
|
2016-01-09 15:23:50 +03:00
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/telephony/call/event',
|
|
|
|
Client::METHOD_POST,
|
2016-07-22 01:01:47 +03:00
|
|
|
array('event' => json_encode($parameters))
|
2016-03-09 02:31:29 +03:00
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Upload calls
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param array $calls calls data
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2016-01-09 15:23:50 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function telephonyCallsUpload(array $calls)
|
|
|
|
{
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!count($calls)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `calls` must contains array of the calls'
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
2016-03-12 01:54:33 +03:00
|
|
|
'/telephony/calls/upload',
|
2016-03-09 02:31:29 +03:00
|
|
|
Client::METHOD_POST,
|
|
|
|
array('calls' => json_encode($calls))
|
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get call manager
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param string $phone phone number
|
|
|
|
* @param bool $details detailed information
|
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
2016-01-09 15:23:50 +03:00
|
|
|
* @return ApiResponse
|
|
|
|
*/
|
|
|
|
public function telephonyCallManager($phone, $details)
|
|
|
|
{
|
|
|
|
if (!isset($phone)) {
|
|
|
|
throw new \InvalidArgumentException('Phone number must be set');
|
|
|
|
}
|
|
|
|
|
|
|
|
$parameters['phone'] = $phone;
|
|
|
|
$parameters['details'] = isset($details) ? $details : 0;
|
|
|
|
|
2016-03-09 02:31:29 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/telephony/manager',
|
2016-03-12 01:54:33 +03:00
|
|
|
Client::METHOD_GET,
|
|
|
|
$parameters
|
2016-03-09 02:31:29 +03:00
|
|
|
);
|
2016-01-09 15:23:50 +03:00
|
|
|
}
|
|
|
|
|
2016-06-06 17:53:05 +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
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-11-27 11:23:44 +03:00
|
|
|
/**
|
|
|
|
* Return current site
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getSite()
|
|
|
|
{
|
|
|
|
return $this->siteCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set site
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param string $site site code
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2014-11-27 11:23:44 +03:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setSite($site)
|
|
|
|
{
|
|
|
|
$this->siteCode = $site;
|
|
|
|
}
|
|
|
|
|
2014-11-06 02:44:52 +03:00
|
|
|
/**
|
|
|
|
* Check ID parameter
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param string $by identify by
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2016-03-12 01:54:33 +03:00
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*
|
2014-11-06 02:44:52 +03:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
protected function checkIdParameter($by)
|
|
|
|
{
|
2016-01-09 15:23:50 +03:00
|
|
|
$allowedForBy = array(
|
|
|
|
'externalId',
|
|
|
|
'id'
|
|
|
|
);
|
2016-03-09 02:31:29 +03:00
|
|
|
|
2016-03-12 01:54:33 +03:00
|
|
|
if (!in_array($by, $allowedForBy, false)) {
|
2016-03-09 02:31:29 +03:00
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
sprintf(
|
2016-04-10 00:46:08 +03:00
|
|
|
'Value "%s" for "by" param is not valid. Allowed values are %s.',
|
2016-03-09 02:31:29 +03:00
|
|
|
$by,
|
|
|
|
implode(', ', $allowedForBy)
|
|
|
|
)
|
|
|
|
);
|
2014-11-06 02:44:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2014-11-27 11:23:44 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill params by site value
|
|
|
|
*
|
2016-03-09 02:31:29 +03:00
|
|
|
* @param string $site site code
|
|
|
|
* @param array $params input parameters
|
2016-01-09 15:23:50 +03:00
|
|
|
*
|
2014-11-27 11:23:44 +03:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function fillSite($site, array $params)
|
|
|
|
{
|
|
|
|
if ($site) {
|
|
|
|
$params['site'] = $site;
|
|
|
|
} elseif ($this->siteCode) {
|
|
|
|
$params['site'] = $this->siteCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $params;
|
|
|
|
}
|
2014-11-10 03:12:50 +03:00
|
|
|
}
|