add v3 api methods
This commit is contained in:
parent
bad0c211ea
commit
a156fa0bcc
36 changed files with 936 additions and 398 deletions
|
@ -14,10 +14,11 @@
|
|||
|
||||
namespace RetailCrm;
|
||||
|
||||
use RetailCrm\Client\V4\Loader as V4;
|
||||
use RetailCrm\Client\V5\Loader as V5;
|
||||
use RetailCrm\Traits\CoreTrait;
|
||||
use RetailCrm\Traits\StatisticTrait;
|
||||
use RetailCrm\Client\ApiVersion3;
|
||||
use RetailCrm\Client\ApiVersion4;
|
||||
use RetailCrm\Client\ApiVersion5;
|
||||
use RetailCrm\Methods\Core;
|
||||
use RetailCrm\Methods\Statistic;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -47,14 +48,17 @@ class ApiClient
|
|||
{
|
||||
switch ($version) {
|
||||
case 'v5':
|
||||
$this->request = new V5($url, $apiKey, $version, $site);
|
||||
$this->request = new ApiVersion5($url, $apiKey, $version, $site);
|
||||
break;
|
||||
case 'v4':
|
||||
$this->request = new V4($url, $apiKey, $version, $site);
|
||||
$this->request = new ApiVersion4($url, $apiKey, $version, $site);
|
||||
break;
|
||||
case 'v3':
|
||||
$this->request = new ApiVersion3($url, $apiKey, $version, $site);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
use CoreTrait;
|
||||
use StatisticTrait;
|
||||
use Core;
|
||||
use Statistic;
|
||||
}
|
||||
|
|
|
@ -12,10 +12,9 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Client\V4;
|
||||
namespace RetailCrm\Client;
|
||||
|
||||
use RetailCrm\Http\Client;
|
||||
use RetailCrm\Traits\V4;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -28,7 +27,7 @@ use RetailCrm\Traits\V4;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
class Loader
|
||||
abstract class AbstractLoader
|
||||
{
|
||||
protected $siteCode;
|
||||
protected $client;
|
||||
|
@ -38,28 +37,24 @@ class Loader
|
|||
*
|
||||
* @param string $url api url
|
||||
* @param string $apiKey api key
|
||||
* @param string $version api version
|
||||
* @param string $site site code
|
||||
*
|
||||
*/
|
||||
public function __construct($url, $apiKey, $site = null)
|
||||
public function __construct($url, $apiKey, $version, $site = null)
|
||||
{
|
||||
if ('/' !== $url[strlen($url) - 1]) {
|
||||
$url .= '/';
|
||||
}
|
||||
|
||||
$url = $url . 'api/v4';
|
||||
if (empty($version) || !in_array($version, ['v3', 'v4', 'v5'])) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Version parameter must be not empty and must be equal one of v3|v4|v5'
|
||||
);
|
||||
}
|
||||
|
||||
$url = $url . 'api/' . $version;
|
||||
|
||||
$this->client = new Client($url, ['apiKey' => $apiKey]);
|
||||
$this->siteCode = $site;
|
||||
}
|
||||
|
||||
use V4\CustomersTrait;
|
||||
use V4\DeliveryTrait;
|
||||
use V4\MarketplaceTrait;
|
||||
use V4\OrdersTrait;
|
||||
use V4\PacksTrait;
|
||||
use V4\ReferencesTrait;
|
||||
use V4\StoresTrait;
|
||||
use V4\TelephonyTrait;
|
||||
use V4\UsersTrait;
|
||||
}
|
|
@ -12,10 +12,9 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Client\V5;
|
||||
namespace RetailCrm\Client;
|
||||
|
||||
use RetailCrm\Http\Client;
|
||||
use RetailCrm\Traits\V5;
|
||||
use RetailCrm\Methods\V3;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -28,42 +27,26 @@ use RetailCrm\Traits\V5;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
class Loader
|
||||
class ApiVersion3 extends AbstractLoader
|
||||
{
|
||||
protected $siteCode;
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* Init version based client
|
||||
*
|
||||
* @param string $url api url
|
||||
* @param string $apiKey api key
|
||||
* @param string $version api version
|
||||
* @param string $site site code
|
||||
*
|
||||
*/
|
||||
public function __construct($url, $apiKey, $site = null)
|
||||
public function __construct($url, $apiKey, $version, $site)
|
||||
{
|
||||
if ('/' !== $url[strlen($url) - 1]) {
|
||||
$url .= '/';
|
||||
}
|
||||
|
||||
$url = $url . 'api/v5';
|
||||
|
||||
$this->client = new Client($url, ['apiKey' => $apiKey]);
|
||||
$this->siteCode = $site;
|
||||
parent::__construct($url, $apiKey, $version, $site);
|
||||
}
|
||||
|
||||
|
||||
use V5\CustomersTrait;
|
||||
use V5\CustomFieldsTrait;
|
||||
use V5\DeliveryTrait;
|
||||
use V5\MarketplaceTrait;
|
||||
use V5\OrdersTrait;
|
||||
use V5\PacksTrait;
|
||||
use V5\ReferencesTrait;
|
||||
use V5\SegmentsTrait;
|
||||
use V5\StoresTrait;
|
||||
use V5\TasksTrait;
|
||||
use V5\TelephonyTrait;
|
||||
use V5\UsersTrait;
|
||||
use V3\Customers;
|
||||
use V3\Orders;
|
||||
use V3\Packs;
|
||||
use V3\References;
|
||||
use V3\Stores;
|
||||
use V3\Telephony;
|
||||
}
|
55
lib/RetailCrm/Client/ApiVersion4.php
Normal file
55
lib/RetailCrm/Client/ApiVersion4.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* API client class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Client;
|
||||
|
||||
use RetailCrm\Methods\V4;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* API client class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
class ApiVersion4 extends AbstractLoader
|
||||
{
|
||||
/**
|
||||
* Init version based client
|
||||
*
|
||||
* @param string $url api url
|
||||
* @param string $apiKey api key
|
||||
* @param string $version api version
|
||||
* @param string $site site code
|
||||
*
|
||||
*/
|
||||
public function __construct($url, $apiKey, $version, $site)
|
||||
{
|
||||
parent::__construct($url, $apiKey, $version, $site);
|
||||
}
|
||||
|
||||
use V4\Customers;
|
||||
use V4\Delivery;
|
||||
use V4\Marketplace;
|
||||
use V4\Orders;
|
||||
use V4\Packs;
|
||||
use V4\References;
|
||||
use V4\Stores;
|
||||
use V4\Telephony;
|
||||
use V4\Users;
|
||||
}
|
58
lib/RetailCrm/Client/ApiVersion5.php
Normal file
58
lib/RetailCrm/Client/ApiVersion5.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* API client class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Client;
|
||||
|
||||
use RetailCrm\Methods\V5;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* API client class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
class ApiVersion5 extends AbstractLoader
|
||||
{
|
||||
/**
|
||||
* Init version based client
|
||||
*
|
||||
* @param string $url api url
|
||||
* @param string $apiKey api key
|
||||
* @param string $version api version
|
||||
* @param string $site site code
|
||||
*
|
||||
*/
|
||||
public function __construct($url, $apiKey, $version, $site)
|
||||
{
|
||||
parent::__construct($url, $apiKey, $version, $site);
|
||||
}
|
||||
|
||||
use V5\Customers;
|
||||
use V5\CustomFields;
|
||||
use V5\Delivery;
|
||||
use V5\Marketplace;
|
||||
use V5\Orders;
|
||||
use V5\Packs;
|
||||
use V5\References;
|
||||
use V5\Segments;
|
||||
use V5\Stores;
|
||||
use V5\Tasks;
|
||||
use V5\Telephony;
|
||||
use V5\Users;
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* CoreTrait class
|
||||
* Core class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -12,12 +12,12 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits;
|
||||
namespace RetailCrm\Methods;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* CoreTrait class
|
||||
* Core class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -25,7 +25,7 @@ namespace RetailCrm\Traits;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait CoreTrait
|
||||
trait Core
|
||||
{
|
||||
/**
|
||||
* Return current site
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* StatisticTrait class
|
||||
* Statistic class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -12,14 +12,14 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits;
|
||||
namespace RetailCrm\Methods;
|
||||
|
||||
use RetailCrm\Response\ApiResponse;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* StatisticTrait class
|
||||
* Statistic class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -27,7 +27,7 @@ use RetailCrm\Response\ApiResponse;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait StatisticTrait
|
||||
trait Statistic
|
||||
{
|
||||
/**
|
||||
* Update CRM basic statistic
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V4;
|
||||
namespace RetailCrm\Methods\V3;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -25,7 +25,7 @@ namespace RetailCrm\Traits\V4;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait CustomersTrait
|
||||
trait Customers
|
||||
{
|
||||
/**
|
||||
* Returns filtered customers list
|
||||
|
@ -203,33 +203,4 @@ trait CustomersTrait
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get customers history
|
||||
* @param array $filter
|
||||
* @param null $page
|
||||
* @param null $limit
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function customersHistory(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;
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/customers/history',
|
||||
$this->client::METHOD_GET,
|
||||
$parameters
|
||||
);
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V4;
|
||||
namespace RetailCrm\Methods\V3;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -25,7 +25,7 @@ namespace RetailCrm\Traits\V4;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait OrdersTrait
|
||||
trait Orders
|
||||
{
|
||||
|
||||
/**
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V4;
|
||||
namespace RetailCrm\Methods\V3;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -25,7 +25,7 @@ namespace RetailCrm\Traits\V4;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait PacksTrait
|
||||
trait Packs
|
||||
{
|
||||
/**
|
||||
* Get orders assembly list
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V4;
|
||||
namespace RetailCrm\Methods\V3;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -25,7 +25,7 @@ namespace RetailCrm\Traits\V4;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait ReferencesTrait
|
||||
trait References
|
||||
{
|
||||
/**
|
||||
* Returns available county list
|
||||
|
@ -496,52 +496,4 @@ trait ReferencesTrait
|
|||
['store' => json_encode($data)]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get prices types
|
||||
*
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function pricesTypes()
|
||||
{
|
||||
return $this->client->makeRequest(
|
||||
'/reference/price-types',
|
||||
$this->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']),
|
||||
$this->client::METHOD_POST,
|
||||
['priceType' => json_encode($data)]
|
||||
);
|
||||
}
|
||||
}
|
90
lib/RetailCrm/Methods/V3/Stores.php
Normal file
90
lib/RetailCrm/Methods/V3/Stores.php
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TaskTrait
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Methods\V3;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TaskTrait class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait Stores
|
||||
{
|
||||
/**
|
||||
* 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 = [], $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;
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/store/inventories',
|
||||
$this->client::METHOD_GET,
|
||||
$parameters
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload store inventories
|
||||
*
|
||||
* @param array $offers offers data
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function storeInventoriesUpload(array $offers, $site = null)
|
||||
{
|
||||
if (!count($offers)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `offers` must contains array of the offers'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/store/inventories/upload',
|
||||
$this->client::METHOD_POST,
|
||||
$this->fillSite($site, ['offers' => json_encode($offers)])
|
||||
);
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TelephonyTrait
|
||||
* Telephony
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -12,12 +12,12 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V4;
|
||||
namespace RetailCrm\Methods\V3;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TelephonyTrait class
|
||||
* Telephony class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -25,7 +25,7 @@ namespace RetailCrm\Traits\V4;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait TelephonyTrait
|
||||
trait Telephony
|
||||
{
|
||||
/**
|
||||
* Get telephony settings
|
||||
|
@ -50,110 +50,6 @@ trait TelephonyTrait
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit telephony settings
|
||||
*
|
||||
* @param string $code symbolic code
|
||||
* @param string $clientId client id
|
||||
* @param boolean $active telephony activity
|
||||
* @param mixed $name service name
|
||||
* @param mixed $makeCallUrl service init url
|
||||
* @param mixed $image service logo url(svg file)
|
||||
*
|
||||
* @param array $additionalCodes
|
||||
* @param array $externalPhones
|
||||
* @param bool $allowEdit
|
||||
* @param bool $inputEventSupported
|
||||
* @param bool $outputEventSupported
|
||||
* @param bool $hangupEventSupported
|
||||
* @param bool $changeUserStatusUrl
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function telephonySettingsEdit(
|
||||
$code,
|
||||
$clientId,
|
||||
$active = false,
|
||||
$name = false,
|
||||
$makeCallUrl = false,
|
||||
$image = false,
|
||||
$additionalCodes = [],
|
||||
$externalPhones = [],
|
||||
$allowEdit = false,
|
||||
$inputEventSupported = false,
|
||||
$outputEventSupported = false,
|
||||
$hangupEventSupported = false,
|
||||
$changeUserStatusUrl = false
|
||||
) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (isset($makeCallUrl)) {
|
||||
$parameters['makeCallUrl'] = $makeCallUrl;
|
||||
}
|
||||
|
||||
if (isset($image)) {
|
||||
$parameters['image'] = $image;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
"/telephony/setting/$code/edit",
|
||||
$this->client::METHOD_POST,
|
||||
['configuration' => json_encode($parameters)]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call event
|
||||
*
|
62
lib/RetailCrm/Methods/V4/Customers.php
Normal file
62
lib/RetailCrm/Methods/V4/Customers.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TaskTrait
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Methods\V4;
|
||||
|
||||
use RetailCrm\Methods\V3\Customers as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TaskTrait class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait Customers
|
||||
{
|
||||
use Previous;
|
||||
|
||||
/**
|
||||
* Get customers history
|
||||
* @param array $filter
|
||||
* @param null $page
|
||||
* @param null $limit
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function customersHistory(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;
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/customers/history',
|
||||
$this->client::METHOD_GET,
|
||||
$parameters
|
||||
);
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V4;
|
||||
namespace RetailCrm\Methods\V4;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -25,7 +25,7 @@ namespace RetailCrm\Traits\V4;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait DeliveryTrait
|
||||
trait Delivery
|
||||
{
|
||||
/**
|
||||
* Get delivery settings
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* MarketplaceTrait
|
||||
* Marketplace
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -12,12 +12,12 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V4;
|
||||
namespace RetailCrm\Methods\V4;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* MarketplaceTrait class
|
||||
* Marketplace class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -25,7 +25,7 @@ namespace RetailCrm\Traits\V4;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait MarketplaceTrait
|
||||
trait Marketplace
|
||||
{
|
||||
|
||||
/**
|
271
lib/RetailCrm/Methods/V4/Orders.php
Normal file
271
lib/RetailCrm/Methods/V4/Orders.php
Normal file
|
@ -0,0 +1,271 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TaskTrait
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Methods\V4;
|
||||
|
||||
use RetailCrm\Methods\V3\Orders as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TaskTrait class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait Orders
|
||||
{
|
||||
|
||||
use Previous;
|
||||
|
||||
/**
|
||||
* 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 = [], $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;
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/orders',
|
||||
$this->client::METHOD_GET,
|
||||
$parameters
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an 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)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `order` must contains a data'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/orders/create',
|
||||
$this->client::METHOD_POST,
|
||||
$this->fillSite($site, ['order' => json_encode($order)])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save order IDs' (id and externalId) association into 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)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Method parameter must contains at least one IDs pair'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/orders/fix-external-ids',
|
||||
$this->client::METHOD_POST,
|
||||
['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 $externalIds = [])
|
||||
{
|
||||
$parameters = [];
|
||||
|
||||
if (count($ids)) {
|
||||
$parameters['ids'] = $ids;
|
||||
}
|
||||
if (count($externalIds)) {
|
||||
$parameters['externalIds'] = $externalIds;
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/orders/statuses',
|
||||
$this->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)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `orders` must contains array of the orders'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/orders/upload',
|
||||
$this->client::METHOD_POST,
|
||||
$this->fillSite($site, ['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",
|
||||
$this->client::METHOD_GET,
|
||||
$this->fillSite($site, ['by' => $by])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an 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)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `order` must contains a data'
|
||||
);
|
||||
}
|
||||
|
||||
$this->checkIdParameter($by);
|
||||
|
||||
if (!array_key_exists($by, $order)) {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf('Order array must contain the "%s" parameter.', $by)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
sprintf('/orders/%s/edit', $order[$by]),
|
||||
$this->client::METHOD_POST,
|
||||
$this->fillSite(
|
||||
$site,
|
||||
['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 = [], $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;
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/orders/history',
|
||||
$this->client::METHOD_GET,
|
||||
$parameters
|
||||
);
|
||||
}
|
||||
}
|
|
@ -12,9 +12,9 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V5;
|
||||
namespace RetailCrm\Methods\V4;
|
||||
|
||||
use RetailCrm\Traits\V4\PacksTrait as Previous;
|
||||
use RetailCrm\Methods\V3\Packs as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -27,7 +27,7 @@ use RetailCrm\Traits\V4\PacksTrait as Previous;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait PacksTrait
|
||||
trait Packs
|
||||
{
|
||||
use Previous;
|
||||
}
|
81
lib/RetailCrm/Methods/V4/References.php
Normal file
81
lib/RetailCrm/Methods/V4/References.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TaskTrait
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Methods\V4;
|
||||
|
||||
use RetailCrm\Methods\V3\References as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TaskTrait class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait References
|
||||
{
|
||||
use Previous;
|
||||
|
||||
/**
|
||||
* Get prices types
|
||||
*
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function pricesTypes()
|
||||
{
|
||||
return $this->client->makeRequest(
|
||||
'/reference/price-types',
|
||||
$this->client::METHOD_GET
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit price type
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function pricesTypesEdit(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']),
|
||||
$this->client::METHOD_POST,
|
||||
['priceType' => json_encode($data)]
|
||||
);
|
||||
}
|
||||
}
|
|
@ -12,7 +12,9 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V4;
|
||||
namespace RetailCrm\Methods\V4;
|
||||
|
||||
use RetailCrm\Methods\V3\Stores as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -25,41 +27,9 @@ namespace RetailCrm\Traits\V4;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait StoresTrait
|
||||
trait Stores
|
||||
{
|
||||
/**
|
||||
* 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 = [], $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;
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/store/inventories',
|
||||
$this->client::METHOD_GET,
|
||||
$parameters
|
||||
);
|
||||
}
|
||||
use Previous;
|
||||
|
||||
/**
|
||||
* Get store settings
|
||||
|
@ -111,33 +81,6 @@ trait StoresTrait
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload store inventories
|
||||
*
|
||||
* @param array $offers offers data
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function storeInventoriesUpload(array $offers, $site = null)
|
||||
{
|
||||
if (!count($offers)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `offers` must contains array of the offers'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/store/inventories/upload',
|
||||
$this->client::METHOD_POST,
|
||||
$this->fillSite($site, ['offers' => json_encode($offers)])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload store prices
|
||||
*
|
137
lib/RetailCrm/Methods/V4/Telephony.php
Normal file
137
lib/RetailCrm/Methods/V4/Telephony.php
Normal file
|
@ -0,0 +1,137 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* Telephony
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Methods\V4;
|
||||
|
||||
use RetailCrm\Methods\V3\Telephony as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* Telephony class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait Telephony
|
||||
{
|
||||
use Previous;
|
||||
|
||||
/**
|
||||
* Edit telephony settings
|
||||
*
|
||||
* @param string $code symbolic code
|
||||
* @param string $clientId client id
|
||||
* @param boolean $active telephony activity
|
||||
* @param mixed $name service name
|
||||
* @param mixed $makeCallUrl service init url
|
||||
* @param mixed $image service logo url(svg file)
|
||||
*
|
||||
* @param array $additionalCodes
|
||||
* @param array $externalPhones
|
||||
* @param bool $allowEdit
|
||||
* @param bool $inputEventSupported
|
||||
* @param bool $outputEventSupported
|
||||
* @param bool $hangupEventSupported
|
||||
* @param bool $changeUserStatusUrl
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function telephonySettingsEdit(
|
||||
$code,
|
||||
$clientId,
|
||||
$active = false,
|
||||
$name = false,
|
||||
$makeCallUrl = false,
|
||||
$image = false,
|
||||
$additionalCodes = [],
|
||||
$externalPhones = [],
|
||||
$allowEdit = false,
|
||||
$inputEventSupported = false,
|
||||
$outputEventSupported = false,
|
||||
$hangupEventSupported = false,
|
||||
$changeUserStatusUrl = false
|
||||
) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (isset($makeCallUrl)) {
|
||||
$parameters['makeCallUrl'] = $makeCallUrl;
|
||||
}
|
||||
|
||||
if (isset($image)) {
|
||||
$parameters['image'] = $image;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
"/telephony/setting/$code/edit",
|
||||
$this->client::METHOD_POST,
|
||||
['configuration' => json_encode($parameters)]
|
||||
);
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V4;
|
||||
namespace RetailCrm\Methods\V4;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -25,7 +25,7 @@ namespace RetailCrm\Traits\V4;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait UsersTrait
|
||||
trait Users
|
||||
{
|
||||
/**
|
||||
* Returns users list
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* CustomFieldsTrait
|
||||
* CustomFields
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -12,12 +12,12 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V5;
|
||||
namespace RetailCrm\Methods\V5;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* CustomFieldsTrait class
|
||||
* CustomFields class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -25,7 +25,7 @@ namespace RetailCrm\Traits\V5;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait CustomFieldsTrait
|
||||
trait CustomFields
|
||||
{
|
||||
/**
|
||||
* Get custom fields list
|
|
@ -12,9 +12,9 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V5;
|
||||
namespace RetailCrm\Methods\V5;
|
||||
|
||||
use RetailCrm\Traits\V4\CustomersTrait as Previous;
|
||||
use RetailCrm\Methods\V4\Customers as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -27,7 +27,7 @@ use RetailCrm\Traits\V4\CustomersTrait as Previous;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait CustomersTrait
|
||||
trait Customers
|
||||
{
|
||||
use Previous;
|
||||
|
|
@ -12,9 +12,9 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V5;
|
||||
namespace RetailCrm\Methods\V5;
|
||||
|
||||
use RetailCrm\Traits\V4\DeliveryTrait as Previous;
|
||||
use RetailCrm\Methods\V4\Delivery as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -27,7 +27,7 @@ use RetailCrm\Traits\V4\DeliveryTrait as Previous;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait DeliveryTrait
|
||||
trait Delivery
|
||||
{
|
||||
use Previous;
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TelephonyTrait
|
||||
* Marketplace
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -12,14 +12,14 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V5;
|
||||
namespace RetailCrm\Methods\V5;
|
||||
|
||||
use RetailCrm\Traits\V4\TelephonyTrait as Previous;
|
||||
use RetailCrm\Methods\V4\Marketplace as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TelephonyTrait class
|
||||
* Marketplace class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -27,7 +27,7 @@ use RetailCrm\Traits\V4\TelephonyTrait as Previous;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait TelephonyTrait
|
||||
trait Marketplace
|
||||
{
|
||||
use Previous;
|
||||
}
|
|
@ -12,10 +12,10 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V5;
|
||||
namespace RetailCrm\Methods\V5;
|
||||
|
||||
use RetailCrm\Response\ApiResponse;
|
||||
use RetailCrm\Traits\V4\OrdersTrait as Previous;
|
||||
use RetailCrm\Methods\V4\Orders as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -28,7 +28,7 @@ use RetailCrm\Traits\V4\OrdersTrait as Previous;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait OrdersTrait
|
||||
trait Orders
|
||||
{
|
||||
use Previous;
|
||||
|
|
@ -12,9 +12,9 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V5;
|
||||
namespace RetailCrm\Methods\V5;
|
||||
|
||||
use RetailCrm\Traits\V4\ReferencesTrait as Previous;
|
||||
use RetailCrm\Methods\V4\Packs as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -27,7 +27,7 @@ use RetailCrm\Traits\V4\ReferencesTrait as Previous;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait ReferencesTrait
|
||||
trait Packs
|
||||
{
|
||||
use Previous;
|
||||
}
|
33
lib/RetailCrm/Methods/V5/References.php
Normal file
33
lib/RetailCrm/Methods/V5/References.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TaskTrait
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Methods\V5;
|
||||
|
||||
use RetailCrm\Methods\V4\References as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* TaskTrait class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait References
|
||||
{
|
||||
use Previous;
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* SegmentsTrait
|
||||
* Segments
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -12,12 +12,12 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V5;
|
||||
namespace RetailCrm\Methods\V5;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* SegmentsTrait class
|
||||
* Segments class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
|
@ -25,7 +25,7 @@ namespace RetailCrm\Traits\V5;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait SegmentsTrait
|
||||
trait Segments
|
||||
{
|
||||
/**
|
||||
* Get segments list
|
|
@ -12,9 +12,9 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V5;
|
||||
namespace RetailCrm\Methods\V5;
|
||||
|
||||
use RetailCrm\Traits\V4\StoresTrait as Previous;
|
||||
use RetailCrm\Methods\V4\Stores as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -27,7 +27,7 @@ use RetailCrm\Traits\V4\StoresTrait as Previous;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait StoresTrait
|
||||
trait Stores
|
||||
{
|
||||
use Previous;
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V5;
|
||||
namespace RetailCrm\Methods\V5;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -25,7 +25,7 @@ namespace RetailCrm\Traits\V5;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait TasksTrait
|
||||
trait Tasks
|
||||
{
|
||||
/**
|
||||
* Get tasks list
|
33
lib/RetailCrm/Methods/V5/Telephony.php
Normal file
33
lib/RetailCrm/Methods/V5/Telephony.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* Telephony
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Methods\V5;
|
||||
|
||||
use RetailCrm\Methods\V4\Telephony as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* Telephony class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait Telephony
|
||||
{
|
||||
use Previous;
|
||||
}
|
|
@ -12,10 +12,10 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V5;
|
||||
namespace RetailCrm\Methods\V5;
|
||||
|
||||
use RetailCrm\Response\ApiResponse;
|
||||
use RetailCrm\Traits\V4\UsersTrait as Previous;
|
||||
use RetailCrm\Methods\V4\Users as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
|
@ -28,7 +28,7 @@ use RetailCrm\Traits\V4\UsersTrait as Previous;
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait UsersTrait
|
||||
trait Users
|
||||
{
|
||||
use Previous;
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* MarketplaceTrait
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Traits\V5;
|
||||
|
||||
use RetailCrm\Traits\V4\MarketplaceTrait as Previous;
|
||||
|
||||
/**
|
||||
* PHP version 5.4
|
||||
*
|
||||
* MarketplaceTrait class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
trait MarketplaceTrait
|
||||
{
|
||||
use Previous;
|
||||
}
|
|
@ -29,16 +29,23 @@ class TestCase extends \PHPUnit_Framework_TestCase
|
|||
*
|
||||
* @param string $url (default: null)
|
||||
* @param string $apiKey (default: null)
|
||||
* @param string $version (default: null)
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @return ApiClient
|
||||
*/
|
||||
public static function getApiClient($url = null, $apiKey = null, $site = null)
|
||||
public static function getApiClient($url = null, $apiKey = null, $version = null, $site = null)
|
||||
{
|
||||
$configUrl = getenv('CRM_API_URL') ?: $_SERVER['CRM_API_URL'];
|
||||
$configKey = getenv('CRM_API_KEY') ?: $_SERVER['CRM_API_KEY'];
|
||||
$configVersion = getenv('CRM_API_VERSION') ?: $_SERVER['CRM_API_VERSION'];
|
||||
$configSite = getenv('CRM_API_SITE') ?: $_SERVER['CRM_API_SITE'];
|
||||
|
||||
return new ApiClient(
|
||||
$url ?: $_SERVER['CRM_URL'],
|
||||
$apiKey ?: $_SERVER['CRM_API_KEY'],
|
||||
$site ?: (isset($_SERVER['CRM_SITE']) ? $_SERVER['CRM_SITE'] : null)
|
||||
$url ?: $configUrl,
|
||||
$apiKey ?: $configKey,
|
||||
$version ?: $configVersion,
|
||||
$site ?: (isset($configSite) ? $configSite: null)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -53,7 +60,7 @@ class TestCase extends \PHPUnit_Framework_TestCase
|
|||
public static function getClient($url = null, $defaultParameters = [])
|
||||
{
|
||||
return new Client(
|
||||
$url ?: $_SERVER['CRM_URL'] . '/api/' . ApiClient::VERSION,
|
||||
$url ?: $_SERVER['CRM_URL'] . '/api/' . getenv('CRM_API_VERSION') ?: $_SERVER['CRM_API_VERSION'],
|
||||
[
|
||||
'apiKey' => array_key_exists('apiKey', $defaultParameters)
|
||||
? $defaultParameters['apiKey']
|
||||
|
|
Loading…
Add table
Reference in a new issue