1
0
Fork 0
mirror of synced 2025-04-11 13:10:57 +00:00

init multiversion

This commit is contained in:
Alex Lushpai 2017-06-14 02:20:49 +03:00
parent 370736eeb5
commit aa2dcae686
46 changed files with 3420 additions and 2576 deletions

View file

@ -5,7 +5,6 @@ cache:
- $HOME/.composer/cache
php:
- '5.3'
- '5.4'
- '5.5'
- '5.6'
@ -14,6 +13,6 @@ php:
before_script:
- flags="--prefer-dist --no-dev -o"
- composer install $flags
- wget -c -O phpunit.xml https://goo.gl/yZHStN
- cp phpunit.xml.dist phpunit.xml
script: phpunit

View file

@ -8,11 +8,11 @@
"authors": [
{
"name": "retailCRM",
"email": "support@retailcrm.pro"
"email": "support@retailcrm.ru"
}
],
"require": {
"php": ">=5.3.0",
"php": ">=5.4.0",
"ext-curl": "*"
},
"require-dev": {

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,68 @@
<?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\V4;
use RetailCrm\Http\Client;
use RetailCrm\Response\ApiResponse;
use RetailCrm\Traits\CoreTrait;
use RetailCrm\Traits\StatisticTrait;
use RetailCrm\Traits\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 Loader
{
protected $siteCode;
protected $client;
/**
* Init version based client
*
* @param string $url api url
* @param string $apiKey api key
* @param string $site site code
*
*/
public function __construct($url, $apiKey, $site = null)
{
if ('/' !== $url[strlen($url) - 1]) {
$url .= '/';
}
$url = $url . 'api/v4';
$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;
}

View file

@ -0,0 +1,72 @@
<?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\V5;
use RetailCrm\Http\Client;
use RetailCrm\Response\ApiResponse;
use RetailCrm\Traits\CoreTrait;
use RetailCrm\Traits\StatisticTrait;
use RetailCrm\Traits\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 Loader
{
protected $siteCode;
protected $client;
/**
* Init version based client
*
* @param string $url api url
* @param string $apiKey api key
* @param string $site site code
*
*/
public function __construct($url, $apiKey, $site = null)
{
if ('/' !== $url[strlen($url) - 1]) {
$url .= '/';
}
$url = $url . 'api/v5';
$this->client = new Client($url, ['apiKey' => $apiKey]);
$this->siteCode = $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;
}

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* Class CurlException
*
@ -15,7 +15,7 @@
namespace RetailCrm\Exception;
/**
* PHP version 5.3
* PHP version 5.4
*
* Class CurlException
*

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* Class InvalidJsonException
*
@ -15,7 +15,7 @@
namespace RetailCrm\Exception;
/**
* PHP version 5.3
* PHP version 5.4
*
* Class InvalidJsonException
*

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* HTTP client
*
@ -19,7 +19,7 @@ use RetailCrm\Exception\InvalidJsonException;
use RetailCrm\Response\ApiResponse;
/**
* PHP version 5.3
* PHP version 5.4
*
* HTTP client
*
@ -45,7 +45,7 @@ class Client
*
* @throws \InvalidArgumentException
*/
public function __construct($url, array $defaultParameters = array())
public function __construct($url, array $defaultParameters = [])
{
if (false === stripos($url, 'https://')) {
throw new \InvalidArgumentException(
@ -75,9 +75,9 @@ class Client
public function makeRequest(
$path,
$method,
array $parameters = array()
array $parameters = []
) {
$allowedMethods = array(self::METHOD_GET, self::METHOD_POST);
$allowedMethods = [self::METHOD_GET, self::METHOD_POST];
if (!in_array($method, $allowedMethods, false)) {
throw new \InvalidArgumentException(

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* Response from retailCRM API
*
@ -17,7 +17,7 @@ namespace RetailCrm\Response;
use RetailCrm\Exception\InvalidJsonException;
/**
* PHP version 5.3
* PHP version 5.4
*
* Response from retailCRM API
*

View file

@ -0,0 +1,99 @@
<?php
/**
* PHP version 5.4
*
* CoreTrait 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\Traits;
/**
* PHP version 5.4
*
* CoreTrait 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 CoreTrait
{
/**
* Return current site
*
* @return string
*/
public function getSite()
{
return $this->siteCode;
}
/**
* Set site
*
* @param string $site site code
*
* @return void
*/
public function setSite($site)
{
$this->siteCode = $site;
}
/**
* Check ID parameter
*
* @param string $by identify by
*
* @throws \InvalidArgumentException
*
* @return bool
*/
protected function checkIdParameter($by)
{
$allowedForBy = [
'externalId',
'id'
];
if (!in_array($by, $allowedForBy, false)) {
throw new \InvalidArgumentException(
sprintf(
'Value "%s" for "by" param is not valid. Allowed values are %s.',
$by,
implode(', ', $allowedForBy)
)
);
}
return true;
}
/**
* Fill params by site value
*
* @param string $site site code
* @param array $params input parameters
*
* @return array
*/
protected function fillSite($site, array $params)
{
if ($site) {
$params['site'] = $site;
} elseif ($this->siteCode) {
$params['site'] = $this->siteCode;
}
return $params;
}
}

View file

@ -0,0 +1,48 @@
<?php
/**
* PHP version 5.4
*
* StatisticTrait 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\Traits;
use RetailCrm\Response\ApiResponse;
/**
* PHP version 5.4
*
* StatisticTrait 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 StatisticTrait
{
/**
* 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',
$this->client::METHOD_GET
);
}
}

View file

@ -0,0 +1,235 @@
<?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\Traits\V4;
/**
* 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 CustomersTrait
{
/**
* Returns filtered customers list
*
* @param array $filter (default: array())
* @param int $page (default: null)
* @param int $limit (default: null)
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function customersList(array $filter = [], $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',
$this->client::METHOD_GET,
$parameters
);
}
/**
* Create a customer
*
* @param array $customer customer data
* @param string $site (default: null)
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function customersCreate(array $customer, $site = null)
{
if (! count($customer)) {
throw new \InvalidArgumentException(
'Parameter `customer` must contains a data'
);
}
return $this->client->makeRequest(
'/customers/create',
$this->client::METHOD_POST,
$this->fillSite($site, ['customer' => json_encode($customer)])
);
}
/**
* Save customer IDs' (id and externalId) association in the CRM
*
* @param array $ids ids mapping
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function customersFixExternalIds(array $ids)
{
if (! count($ids)) {
throw new \InvalidArgumentException(
'Method parameter must contains at least one IDs pair'
);
}
return $this->client->makeRequest(
'/customers/fix-external-ids',
$this->client::METHOD_POST,
['customers' => json_encode($ids)]
);
}
/**
* Upload array of the customers
*
* @param array $customers array of customers
* @param string $site (default: null)
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function customersUpload(array $customers, $site = null)
{
if (! count($customers)) {
throw new \InvalidArgumentException(
'Parameter `customers` must contains array of the customers'
);
}
return $this->client->makeRequest(
'/customers/upload',
$this->client::METHOD_POST,
$this->fillSite($site, ['customers' => json_encode($customers)])
);
}
/**
* Get customer by id or externalId
*
* @param string $id customer identificator
* @param string $by (default: 'externalId')
* @param string $site (default: null)
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function customersGet($id, $by = 'externalId', $site = null)
{
$this->checkIdParameter($by);
return $this->client->makeRequest(
"/customers/$id",
$this->client::METHOD_GET,
$this->fillSite($site, ['by' => $by])
);
}
/**
* Edit a customer
*
* @param array $customer customer data
* @param string $by (default: 'externalId')
* @param string $site (default: null)
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function customersEdit(array $customer, $by = 'externalId', $site = null)
{
if (!count($customer)) {
throw new \InvalidArgumentException(
'Parameter `customer` must contains a data'
);
}
$this->checkIdParameter($by);
if (!array_key_exists($by, $customer)) {
throw new \InvalidArgumentException(
sprintf('Customer array must contain the "%s" parameter.', $by)
);
}
return $this->client->makeRequest(
sprintf('/customers/%s/edit', $customer[$by]),
$this->client::METHOD_POST,
$this->fillSite(
$site,
['customer' => json_encode($customer), 'by' => $by]
)
);
}
/**
* Get customers history
* @param array $filter
* @param null $page
* @param null $limit
*
* @return ApiResponse
*/
public function customersHistory(array $filter = [], $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
);
}
}

View file

@ -0,0 +1,109 @@
<?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\Traits\V4;
/**
* 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 DeliveryTrait
{
/**
* 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",
$this->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(
sprintf('/delivery/generic/setting/%s/edit', $configuration['code']),
$this->client::METHOD_POST,
['configuration' => json_encode($configuration)]
);
}
/**
* 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),
$this->client::METHOD_POST,
['statusUpdate' => json_encode($statusUpdate)]
);
}
}

View file

@ -0,0 +1,56 @@
<?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\V4;;
/**
* 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
{
/**
* Edit marketplace configuration
*
* @param array $configuration
*
* @throws \RetailCrm\Exception\InvalidJsonException
* @throws \RetailCrm\Exception\CurlException
* @throws \InvalidArgumentException
*
* @return ApiResponse
*/
public function marketplaceSettingsEdit(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(
sprintf('/marketplace/external/setting/%s/edit', $configuration['code']),
$this->client::METHOD_POST,
['configuration' => json_encode($configuration)]
);
}
}

View file

@ -0,0 +1,267 @@
<?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\Traits\V4;
/**
* 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 OrdersTrait
{
/**
* 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
);
}
}

View file

@ -0,0 +1,197 @@
<?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\Traits\V4;
/**
* 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 PacksTrait
{
/**
* Get orders assembly list
*
* @param array $filter (default: array())
* @param int $page (default: null)
* @param int $limit (default: null)
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function ordersPacksList(array $filter = [], $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/packs',
$this->client::METHOD_GET,
$parameters
);
}
/**
* Create orders assembly
*
* @param array $pack pack data
* @param string $site (default: null)
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function ordersPacksCreate(array $pack, $site = null)
{
if (!count($pack)) {
throw new \InvalidArgumentException(
'Parameter `pack` must contains a data'
);
}
return $this->client->makeRequest(
'/orders/packs/create',
$this->client::METHOD_POST,
$this->fillSite($site, ['pack' => json_encode($pack)])
);
}
/**
* Get orders assembly history
*
* @param array $filter (default: array())
* @param int $page (default: null)
* @param int $limit (default: null)
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function ordersPacksHistory(array $filter = [], $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/packs/history',
$this->client::METHOD_GET,
$parameters
);
}
/**
* Get orders assembly by id
*
* @param string $id pack identificator
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function ordersPacksGet($id)
{
if (empty($id)) {
throw new \InvalidArgumentException('Parameter `id` must be set');
}
return $this->client->makeRequest(
"/orders/packs/$id",
$this->client::METHOD_GET
);
}
/**
* Delete orders assembly by id
*
* @param string $id pack identificator
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function ordersPacksDelete($id)
{
if (empty($id)) {
throw new \InvalidArgumentException('Parameter `id` must be set');
}
return $this->client->makeRequest(
sprintf('/orders/packs/%s/delete', $id),
$this->client::METHOD_POST
);
}
/**
* Edit orders assembly
*
* @param array $pack pack data
* @param string $site (default: null)
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function ordersPacksEdit(array $pack, $site = null)
{
if (!count($pack) || empty($pack['id'])) {
throw new \InvalidArgumentException(
'Parameter `pack` must contains a data & pack `id` must be set'
);
}
return $this->client->makeRequest(
sprintf('/orders/packs/%s/edit', $pack['id']),
$this->client::METHOD_POST,
$this->fillSite($site, ['pack' => json_encode($pack)])
);
}
}

View file

@ -0,0 +1,547 @@
<?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\Traits\V4;
/**
* 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 ReferencesTrait
{
/**
* Returns available county list
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function countriesList()
{
return $this->client->makeRequest(
'/reference/countries',
$this->client::METHOD_GET
);
}
/**
* Returns deliveryServices list
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function deliveryServicesList()
{
return $this->client->makeRequest(
'/reference/delivery-services',
$this->client::METHOD_GET
);
}
/**
* Edit deliveryService
*
* @param array $data delivery service data
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function deliveryServicesEdit(array $data)
{
if (!array_key_exists('code', $data)) {
throw new \InvalidArgumentException(
'Data must contain "code" parameter.'
);
}
return $this->client->makeRequest(
sprintf('/reference/delivery-services/%s/edit', $data['code']),
$this->client::METHOD_POST,
['deliveryService' => json_encode($data)]
);
}
/**
* Returns deliveryTypes list
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function deliveryTypesList()
{
return $this->client->makeRequest(
'/reference/delivery-types',
$this->client::METHOD_GET
);
}
/**
* Edit deliveryType
*
* @param array $data delivery type data
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function deliveryTypesEdit(array $data)
{
if (!array_key_exists('code', $data)) {
throw new \InvalidArgumentException(
'Data must contain "code" parameter.'
);
}
return $this->client->makeRequest(
sprintf('/reference/delivery-types/%s/edit', $data['code']),
$this->client::METHOD_POST,
['deliveryType' => json_encode($data)]
);
}
/**
* Returns orderMethods list
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function orderMethodsList()
{
return $this->client->makeRequest(
'/reference/order-methods',
$this->client::METHOD_GET
);
}
/**
* Edit orderMethod
*
* @param array $data order method data
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function orderMethodsEdit(array $data)
{
if (!array_key_exists('code', $data)) {
throw new \InvalidArgumentException(
'Data must contain "code" parameter.'
);
}
return $this->client->makeRequest(
sprintf('/reference/order-methods/%s/edit', $data['code']),
$this->client::METHOD_POST,
['orderMethod' => json_encode($data)]
);
}
/**
* Returns orderTypes list
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function orderTypesList()
{
return $this->client->makeRequest(
'/reference/order-types',
$this->client::METHOD_GET
);
}
/**
* Edit orderType
*
* @param array $data order type data
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function orderTypesEdit(array $data)
{
if (!array_key_exists('code', $data)) {
throw new \InvalidArgumentException(
'Data must contain "code" parameter.'
);
}
return $this->client->makeRequest(
sprintf('/reference/order-types/%s/edit', $data['code']),
$this->client::METHOD_POST,
['orderType' => json_encode($data)]
);
}
/**
* Returns paymentStatuses list
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function paymentStatusesList()
{
return $this->client->makeRequest(
'/reference/payment-statuses',
$this->client::METHOD_GET
);
}
/**
* Edit paymentStatus
*
* @param array $data payment status data
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function paymentStatusesEdit(array $data)
{
if (!array_key_exists('code', $data)) {
throw new \InvalidArgumentException(
'Data must contain "code" parameter.'
);
}
return $this->client->makeRequest(
sprintf('/reference/payment-statuses/%s/edit', $data['code']),
$this->client::METHOD_POST,
['paymentStatus' => json_encode($data)]
);
}
/**
* Returns paymentTypes list
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function paymentTypesList()
{
return $this->client->makeRequest(
'/reference/payment-types',
$this->client::METHOD_GET
);
}
/**
* Edit paymentType
*
* @param array $data payment type data
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function paymentTypesEdit(array $data)
{
if (!array_key_exists('code', $data)) {
throw new \InvalidArgumentException(
'Data must contain "code" parameter.'
);
}
return $this->client->makeRequest(
sprintf('/reference/payment-types/%s/edit', $data['code']),
$this->client::METHOD_POST,
['paymentType' => json_encode($data)]
);
}
/**
* Returns productStatuses list
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function productStatusesList()
{
return $this->client->makeRequest(
'/reference/product-statuses',
$this->client::METHOD_GET
);
}
/**
* Edit productStatus
*
* @param array $data product status data
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function productStatusesEdit(array $data)
{
if (!array_key_exists('code', $data)) {
throw new \InvalidArgumentException(
'Data must contain "code" parameter.'
);
}
return $this->client->makeRequest(
sprintf('/reference/product-statuses/%s/edit', $data['code']),
$this->client::METHOD_POST,
['productStatus' => json_encode($data)]
);
}
/**
* Returns sites list
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function sitesList()
{
return $this->client->makeRequest(
'/reference/sites',
$this->client::METHOD_GET
);
}
/**
* Edit site
*
* @param array $data site data
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function sitesEdit(array $data)
{
if (!array_key_exists('code', $data)) {
throw new \InvalidArgumentException(
'Data must contain "code" parameter.'
);
}
return $this->client->makeRequest(
sprintf('/reference/sites/%s/edit', $data['code']),
$this->client::METHOD_POST,
['site' => json_encode($data)]
);
}
/**
* Returns statusGroups list
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function statusGroupsList()
{
return $this->client->makeRequest(
'/reference/status-groups',
$this->client::METHOD_GET
);
}
/**
* Returns statuses list
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function statusesList()
{
return $this->client->makeRequest(
'/reference/statuses',
$this->client::METHOD_GET
);
}
/**
* Edit order status
*
* @param array $data status data
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function statusesEdit(array $data)
{
if (!array_key_exists('code', $data)) {
throw new \InvalidArgumentException(
'Data must contain "code" parameter.'
);
}
return $this->client->makeRequest(
sprintf('/reference/statuses/%s/edit', $data['code']),
$this->client::METHOD_POST,
['status' => json_encode($data)]
);
}
/**
* Returns stores list
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function storesList()
{
return $this->client->makeRequest(
'/reference/stores',
$this->client::METHOD_GET
);
}
/**
* Edit store
*
* @param array $data site data
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function storesEdit(array $data)
{
if (!array_key_exists('code', $data)) {
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/stores/%s/edit', $data['code']),
$this->client::METHOD_POST,
['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)]
);
}
}

View file

@ -0,0 +1,201 @@
<?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\Traits\V4;
/**
* 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 StoresTrait
{
/**
* 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
);
}
/**
* 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(
"/store/setting/$code",
$this->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(
sprintf('/store/setting/%s/edit', $configuration['code']),
$this->client::METHOD_POST,
['configuration' => json_encode($configuration)]
);
}
/**
* 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
*
* @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',
$this->client::METHOD_POST,
$this->fillSite($site, ['prices' => json_encode($prices)])
);
}
/**
* 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 = [], $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/products',
$this->client::METHOD_GET,
$parameters
);
}
}

View file

@ -0,0 +1,260 @@
<?php
/**
* PHP version 5.4
*
* TelephonyTrait
*
* @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\V4;
/**
* PHP version 5.4
*
* TelephonyTrait 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 TelephonyTrait
{
/**
* 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(
"/telephony/setting/$code",
$this->client::METHOD_GET
);
}
/**
* 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
*
* @param string $phone phone number
* @param string $type call type
* @param array $codes
* @param string $hangupStatus
* @param string $externalPhone
* @param array $webAnalyticsData
*
* @return ApiResponse
* @internal param string $code additional phone code
* @internal param string $status call status
*
*/
public function telephonyCallEvent(
$phone,
$type,
$codes,
$hangupStatus,
$externalPhone = null,
$webAnalyticsData = []
) {
if (!isset($phone)) {
throw new \InvalidArgumentException('Phone number must be set');
}
if (!isset($type)) {
throw new \InvalidArgumentException('Type must be set (in|out|hangup)');
}
if (empty($codes)) {
throw new \InvalidArgumentException('Codes array must be set');
}
$parameters['phone'] = $phone;
$parameters['type'] = $type;
$parameters['codes'] = $codes;
$parameters['hangupStatus'] = $hangupStatus;
$parameters['callExternalId'] = $externalPhone;
$parameters['webAnalyticsData'] = $webAnalyticsData;
return $this->client->makeRequest(
'/telephony/call/event',
$this->client::METHOD_POST,
['event' => json_encode($parameters)]
);
}
/**
* Upload calls
*
* @param array $calls calls data
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function telephonyCallsUpload(array $calls)
{
if (!count($calls)) {
throw new \InvalidArgumentException(
'Parameter `calls` must contains array of the calls'
);
}
return $this->client->makeRequest(
'/telephony/calls/upload',
$this->client::METHOD_POST,
['calls' => json_encode($calls)]
);
}
/**
* Get call manager
*
* @param string $phone phone number
* @param bool $details detailed information
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function telephonyCallManager($phone, $details)
{
if (!isset($phone)) {
throw new \InvalidArgumentException('Phone number must be set');
}
$parameters['phone'] = $phone;
$parameters['details'] = isset($details) ? $details : 0;
return $this->client->makeRequest(
'/telephony/manager',
$this->client::METHOD_GET,
$parameters
);
}
}

View file

@ -0,0 +1,108 @@
<?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\Traits\V4;
/**
* 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 UsersTrait
{
/**
* 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 = [], $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(
'/users',
$this->client::METHOD_GET,
$parameters
);
}
/**
* 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 = [];
if (null !== $page) {
$parameters['page'] = (int)$page;
}
if (null !== $limit) {
$parameters['limit'] = (int)$limit;
}
return $this->client->makeRequest(
'/user-groups',
$this->client::METHOD_GET,
$parameters
);
}
/**
* 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", $this->client::METHOD_GET);
}
}

View file

@ -0,0 +1,250 @@
<?php
/**
* PHP version 5.4
*
* CustomFieldsTrait
*
* @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;
/**
* PHP version 5.4
*
* CustomFieldsTrait 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 CustomFieldsTrait
{
/**
* Get custom fields list
*
* @param array $filter
* @param null $limit
* @param null $page
*
* @return ApiResponse
*/
public function customFieldsList(array $filter = [], $limit = null, $page = 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(
'/custom-fields',
$this->client::METHOD_GET,
$parameters
);
}
/**
* Create custom field
*
* @param $entity
* @param $customField
*
* @return ApiResponse
*/
public function customFieldsCreate($entity, $customField)
{
if (!count($customField) ||
empty($customField['code']) ||
empty($customField['name']) ||
empty($customField['type'])
) {
throw new \InvalidArgumentException(
'Parameter `customField` must contain a data & fields `code`, `name` & `type` must be set'
);
}
if (empty($entity) || $entity != 'customer' || $entity != 'order') {
throw new \InvalidArgumentException(
'Parameter `entity` must contain a data & value must be `order` or `customer`'
);
}
return $this->client->makeRequest(
"/custom-fields/$entity/create",
$this->client::METHOD_POST,
['customField' => json_encode($customField)]
);
}
/**
* Edit custom field
*
* @param $entity
* @param $customField
*
* @return ApiResponse
*/
public function customFieldsEdit($entity, $customField)
{
if (!count($customField) || empty($customField['code'])) {
throw new \InvalidArgumentException(
'Parameter `customField` must contain a data & fields `code` must be set'
);
}
if (empty($entity) || $entity != 'customer' || $entity != 'order') {
throw new \InvalidArgumentException(
'Parameter `entity` must contain a data & value must be `order` or `customer`'
);
}
return $this->client->makeRequest(
"/custom-fields/$entity/edit/{$customField['code']}",
$this->client::METHOD_POST,
['customField' => json_encode($customField)]
);
}
/**
* Get custom field
*
* @param $entity
* @param $code
*
* @return ApiResponse
*/
public function customFieldsGet($entity, $code)
{
if (empty($code)) {
throw new \InvalidArgumentException(
'Parameter `code` must be not empty'
);
}
if (empty($entity) || $entity != 'customer' || $entity != 'order') {
throw new \InvalidArgumentException(
'Parameter `entity` must contain a data & value must be `order` or `customer`'
);
}
return $this->client->makeRequest(
"/custom-fields/$entity/$code",
$this->client::METHOD_GET
);
}
/**
* Get custom dictionaries list
*
* @param array $filter
* @param null $limit
* @param null $page
*
* @return ApiResponse
*/
public function customDictionariesList(array $filter = [], $limit = null, $page = 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(
'/custom-fields/dictionaries',
$this->client::METHOD_GET,
$parameters
);
}
/**
* Create custom dictionary
*
* @param $customDictionary
*
* @return ApiResponse
*/
public function customDictionariesCreate($customDictionary)
{
if (!count($customDictionary) ||
empty($customDictionary['code']) ||
empty($customDictionary['elements'])
) {
throw new \InvalidArgumentException(
'Parameter `dictionary` must contain a data & fields `code` & `elemets` must be set'
);
}
return $this->client->makeRequest(
"/custom-fields/dictionaries/{$customDictionary['code']}/create",
$this->client::METHOD_POST,
['customDictionary' => json_encode($customDictionary)]
);
}
/**
* Edit custom dictionary
*
* @param $customDictionary
*
* @return ApiResponse
*/
public function customDictionariesEdit($customDictionary)
{
if (!count($customDictionary) ||
empty($customDictionary['code']) ||
empty($customDictionary['elements'])
) {
throw new \InvalidArgumentException(
'Parameter `dictionary` must contain a data & fields `code` & `elemets` must be set'
);
}
return $this->client->makeRequest(
"/custom-fields/dictionaries/{$customDictionary['code']}/edit",
$this->client::METHOD_POST,
['customDictionary' => json_encode($customDictionary)]
);
}
/**
* Get custom dictionary
*
* @param $code
*
* @return ApiResponse
*/
public function customDictionariesGet($code)
{
if (empty($code)) {
throw new \InvalidArgumentException(
'Parameter `code` must be not empty'
);
}
return $this->client->makeRequest(
"/custom-fields/dictionaries/$code",
$this->client::METHOD_GET
);
}
}

View file

@ -0,0 +1,60 @@
<?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\Traits\V5;
use RetailCrm\Traits\V4\CustomersTrait 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 CustomersTrait
{
use Previous;
/**
* Combine customers
*
* @param array $customers
* @param array $resultCustomer
*
* @return ApiResponse
*/
public function customersCombine(array $customers, $resultCustomer)
{
if (!count($customers) || !count($resultCustomer)) {
throw new \InvalidArgumentException(
'Parameters `customers` & `resultCustomer` must contains a data'
);
}
return $this->client->makeRequest(
'/customers/combine',
$this->client::METHOD_POST,
[
'customers' => json_encode($customers),
'resultCustomer' => json_encode($resultCustomer)
]
);
}
}

View 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\Traits\V5;
use RetailCrm\Traits\V4\DeliveryTrait 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 DeliveryTrait
{
use Previous;
}

View file

@ -0,0 +1,33 @@
<?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;
}

View file

@ -0,0 +1,131 @@
<?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\Traits\V5;
use RetailCrm\Response\ApiResponse;
use RetailCrm\Traits\V4\OrdersTrait 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 OrdersTrait
{
use Previous;
/**
* Combine orders
*
* @param string $technique
* @param array $order
* @param array $resultOrder
*
* @return ApiResponse
*/
public function ordersCombine($order, $resultOrder, $technique = 'ours')
{
$techniques = ['ours', 'summ', 'theirs'];
if (!count($order) || !count($resultOrder)) {
throw new \InvalidArgumentException(
'Parameters `order` & `resultOrder` must contains a data'
);
}
if (!in_array($technique, $techniques)) {
throw new \InvalidArgumentException(
'Parameter `technique` must be on of ours|summ|theirs'
);
}
return $this->client->makeRequest(
'/orders/combine',
$this->client::METHOD_POST,
[
'technique' => $technique,
'order' => json_encode($order),
'resultOrder' => json_encode($resultOrder)
]
);
}
/**
* Create an order payment
*
* @param array $payment order data
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function ordersPaymentCreate(array $payment)
{
if (!count($payment)) {
throw new \InvalidArgumentException(
'Parameter `payment` must contains a data'
);
}
return $this->client->makeRequest(
'/orders/payments/create',
$this->client::METHOD_POST,
['payment' => json_encode($payment)]
);
}
/**
* Edit an order payment
*
* @param array $payment order data
* @param string $by by key
* @param null $site site code
*
* @return ApiResponse
*/
public function ordersPaymentEdit(array $payment, $by = 'id', $site = null)
{
if (!count($payment)) {
throw new \InvalidArgumentException(
'Parameter `payment` must contains a data'
);
}
$this->checkIdParameter($by);
if (!array_key_exists($by, $payment)) {
throw new \InvalidArgumentException(
sprintf('Order array must contain the "%s" parameter.', $by)
);
}
return $this->client->makeRequest(
sprintf('/orders/payments/%s/edit', $payment[$by]),
$this->client::METHOD_POST,
$this->fillSite(
$site,
['payment' => json_encode($payment), 'by' => $by]
)
);
}
}

View 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\Traits\V5;
use RetailCrm\Traits\V4\PacksTrait 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 PacksTrait
{
use Previous;
}

View 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\Traits\V5;
use RetailCrm\Traits\V4\ReferencesTrait 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 ReferencesTrait
{
use Previous;
}

View file

@ -0,0 +1,59 @@
<?php
/**
* PHP version 5.4
*
* SegmentsTrait
*
* @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;
/**
* PHP version 5.4
*
* SegmentsTrait 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 SegmentsTrait
{
/**
* Get segments list
*
* @param array $filter
* @param null $limit
* @param null $page
*
* @return ApiResponse
*/
public function segmentsList(array $filter = [], $limit = null, $page = 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(
'/segments',
$this->client::METHOD_GET,
$parameters
);
}
}

View file

@ -0,0 +1,67 @@
<?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\Traits\V5;
use RetailCrm\Traits\V4\StoresTrait 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 StoresTrait
{
use Previous;
/**
* Get products groups
*
* @param array $filter (default: array())
* @param int $page (default: null)
* @param int $limit (default: null)
*
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return ApiResponse
*/
public function storeProductsGroups(array $filter = [], $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/product-groups',
$this->client::METHOD_GET,
$parameters
);
}
}

View file

@ -0,0 +1,134 @@
<?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\Traits\V5;
/**
* 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 TasksTrait
{
/**
* Get tasks list
*
* @param array $filter
* @param null $limit
* @param null $page
*
* @return ApiResponse
*/
public function tasksList(array $filter = [], $limit = null, $page = 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(
'/tasks',
$this->client::METHOD_GET,
$parameters
);
}
/**
* Create task
*
* @param array $task
* @param null $site
*
* @return ApiResponse
*
*/
public function tasksCreate($task, $site = null)
{
if (!count($task)) {
throw new \InvalidArgumentException(
'Parameter `task` must contain a data'
);
}
return $this->client->makeRequest(
"/tasks/create",
$this->client::METHOD_POST,
$this->fillSite(
$site,
['task' => json_encode($task)]
)
);
}
/**
* Edit task
*
* @param array $task
* @param null $site
*
* @return ApiResponse
*
*/
public function tasksEdit($task, $site = null)
{
if (!count($task)) {
throw new \InvalidArgumentException(
'Parameter `task` must contain a data'
);
}
return $this->client->makeRequest(
"/tasks/{$task['id']}/edit",
$this->client::METHOD_POST,
$this->fillSite(
$site,
['task' => json_encode($task)]
)
);
}
/**
* Get custom dictionary
*
* @param $id
*
* @return ApiResponse
*/
public function tasksGet($id)
{
if (empty($id)) {
throw new \InvalidArgumentException(
'Parameter `id` must be not empty'
);
}
return $this->client->makeRequest(
"/tasks/$id",
$this->client::METHOD_GET
);
}
}

View file

@ -0,0 +1,33 @@
<?php
/**
* PHP version 5.4
*
* TelephonyTrait
*
* @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\TelephonyTrait as Previous;
/**
* PHP version 5.4
*
* TelephonyTrait 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 TelephonyTrait
{
use Previous;
}

View file

@ -0,0 +1,59 @@
<?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\Traits\V5;
use RetailCrm\Response\ApiResponse;
use RetailCrm\Traits\V4\UsersTrait 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 UsersTrait
{
use Previous;
/**
* Change user status
*
* @param integer $id user ID
* @param string $status user status
*
* @return ApiResponse
*/
public function usersStatus($id, $status)
{
$statuses = ["free", "busy", "dinner", "break"];
if (empty($status) || !in_array($status, $statuses)) {
throw new \InvalidArgumentException(
'Parameter `status` must be not empty & must be equal one of these values: free|busy|dinner|break'
);
}
return $this->client->makeRequest(
"/users/$id/status",
$this->client::METHOD_POST,
['status' => $status]
);
}
}

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* Test case class
*
@ -50,15 +50,15 @@ class TestCase extends \PHPUnit_Framework_TestCase
*
* @return Client
*/
public static function getClient($url = null, $defaultParameters = array())
public static function getClient($url = null, $defaultParameters = [])
{
return new Client(
$url ?: $_SERVER['CRM_URL'] . '/api/' . ApiClient::VERSION,
array(
[
'apiKey' => array_key_exists('apiKey', $defaultParameters)
? $defaultParameters['apiKey']
: $_SERVER['CRM_API_KEY']
)
]
);
}
}

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* API client customers test class
*
@ -39,19 +39,19 @@ class ApiClientCustomersTest extends TestCase
$externalId = 'c-create-' . time();
$response = $client->customersCreate(array(
$response = $client->customersCreate([
'firstName' => self::FIRST_NAME,
'externalId' => $externalId,
));
]);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(201, $response->getStatusCode());
static::assertTrue(is_int($response['id']));
return array(
return [
'id' => $response['id'],
'externalId' => $externalId,
);
];
}
/**
@ -61,7 +61,7 @@ class ApiClientCustomersTest extends TestCase
public function testCreateExceptionEmpty()
{
$client = static::getApiClient();
$client->customersCreate(array());
$client->customersCreate([]);
}
/**
@ -115,19 +115,19 @@ class ApiClientCustomersTest extends TestCase
$client = static::getApiClient();
$response = $client->customersEdit(
array(
[
'id' => 22342134,
'lastName' => '12345',
),
],
'id'
);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(404, $response->getStatusCode());
$response = $client->customersEdit(array(
$response = $client->customersEdit([
'externalId' => $ids['externalId'],
'lastName' => '12345',
));
]);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(200, $response->getStatusCode());
static::assertTrue($response->isSuccessful());
@ -140,7 +140,7 @@ class ApiClientCustomersTest extends TestCase
public function testCustomersEditExceptionEmpty()
{
$client = static::getApiClient();
$client->customersEdit(array(), 'asdf');
$client->customersEdit([], 'asdf');
}
/**
@ -150,7 +150,7 @@ class ApiClientCustomersTest extends TestCase
public function testCustomersEditException()
{
$client = static::getApiClient();
$client->customersEdit(array('id' => 678678678), 'asdf');
$client->customersEdit(['id' => 678678678], 'asdf');
}
/**
@ -165,14 +165,14 @@ class ApiClientCustomersTest extends TestCase
static::assertTrue($response->isSuccessful());
static::assertTrue(isset($response['customers']));
$response = $client->customersList(array(), 1, 300);
$response = $client->customersList([], 1, 300);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertFalse(
$response->isSuccessful(),
'Pagination error'
);
$response = $client->customersList(array('maxOrdersCount' => 10), 1);
$response = $client->customersList(['maxOrdersCount' => 10], 1);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertTrue(
$response->isSuccessful(),
@ -187,7 +187,7 @@ class ApiClientCustomersTest extends TestCase
public function testCustomersFixExternalIdsException()
{
$client = static::getApiClient();
$client->customersFixExternalIds(array());
$client->customersFixExternalIds([]);
}
/**
@ -197,9 +197,9 @@ class ApiClientCustomersTest extends TestCase
{
$client = static::getApiClient();
$response = $client->ordersCreate(array(
$response = $client->ordersCreate([
'firstName' => 'Aaa111',
));
]);
static::assertTrue(
$response->isSuccessful(),
@ -215,9 +215,9 @@ class ApiClientCustomersTest extends TestCase
$id = $response['order']['customer']['id'];
$externalId = 'asdf' . time();
$response = $client->customersFixExternalIds(array(
array('id' => $id, 'externalId' => $externalId)
));
$response = $client->customersFixExternalIds([
['id' => $id, 'externalId' => $externalId]
]);
static::assertTrue(
$response->isSuccessful(),
@ -248,7 +248,7 @@ class ApiClientCustomersTest extends TestCase
public function testCustomersUploadExceptionEmpty()
{
$client = static::getApiClient();
$client->customersUpload(array());
$client->customersUpload([]);
}
/**
@ -261,16 +261,16 @@ class ApiClientCustomersTest extends TestCase
$externalIdA = 'upload-a-' . time();
$externalIdB = 'upload-b-' . time();
$response = $client->customersUpload(array(
array(
$response = $client->customersUpload([
[
'externalId' => $externalIdA,
'firstName' => 'Aaa',
),
array(
],
[
'externalId' => $externalIdB,
'lastName' => 'Bbb',
),
));
],
]);
static::assertTrue(
$response->isSuccessful(),
'Got customer'
@ -292,41 +292,41 @@ class ApiClientCustomersTest extends TestCase
{
$client = static::getApiClient();
$responseCreateFirst = $client->customersCreate(array(
$responseCreateFirst = $client->customersCreate([
'firstName' => 'Aaa111',
'externalId' => 'AA-' . time(),
'phones' => array(
array(
'phones' => [
[
'number' => '+79999999990'
)
)
));
]
]
]);
static::assertTrue(
$responseCreateFirst->isSuccessful(),
'Got customer'
);
$responseCreateSecond = $client->customersCreate(array(
$responseCreateSecond = $client->customersCreate([
'firstName' => 'Aaa222',
'externalId' => 'BB-' . time(),
'phones' => array(
array(
'phones' => [
[
'number' => '+79999999991'
)
)
));
]
]
]);
static::assertTrue(
$responseCreateSecond->isSuccessful(),
'Got customer'
);
$customers = array(
array('id' => $responseCreateFirst['id'])
);
$customers = [
['id' => $responseCreateFirst['id']]
];
$resultCustomer = array('id' => $responseCreateSecond['id']);
$resultCustomer = ['id' => $responseCreateSecond['id']];
$response = $client->customersCombine($customers, $resultCustomer);

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* API client marketplace test class
*
@ -34,16 +34,16 @@ class ApiClientMarketplaceTest extends TestCase
$client = static::getApiClient();
$response = $client->marketplaceSettingsEdit(
array(
[
'name' => self::SNAME,
'code' => self::SCODE,
'logo' => 'http://download.retailcrm.pro/logos/setup.svg',
'active' => 'true'
)
]
);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertTrue(in_array($response->getStatusCode(), array(200, 201)));
static::assertTrue(in_array($response->getStatusCode(), [200, 201]));
static::assertTrue($response->isSuccessful());
}
}

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* API client orders test class
*
@ -38,18 +38,18 @@ class ApiClientOrdersTest extends TestCase
$externalId = 'o-create-' . time();
$response = $client->ordersCreate(array(
$response = $client->ordersCreate([
'firstName' => self::FIRST_NAME,
'externalId' => $externalId,
));
]);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(201, $response->getStatusCode());
static::assertTrue(is_int($response['id']));
return array(
return [
'id' => $response['id'],
'externalId' => $externalId,
);
];
}
/**
@ -59,7 +59,7 @@ class ApiClientOrdersTest extends TestCase
public function testOrdersCreateExceptionEmpty()
{
$client = static::getApiClient();
$client->ordersCreate(array());
$client->ordersCreate([]);
}
/**
@ -77,14 +77,14 @@ class ApiClientOrdersTest extends TestCase
static::assertEquals(400, $response->getStatusCode());
static::assertFalse($response->isSuccessful());
$response = $client->ordersStatuses(array(), array('asdf'));
$response = $client->ordersStatuses([], ['asdf']);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(200, $response->getStatusCode());
static::assertTrue($response->isSuccessful());
$orders = $response['orders'];
static::assertEquals(0, sizeof($orders));
$response = $client->ordersStatuses(array(), array($ids['externalId']));
$response = $client->ordersStatuses([], [$ids['externalId']]);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(200, $response->getStatusCode());
static::assertTrue($response->isSuccessful());
@ -92,14 +92,14 @@ class ApiClientOrdersTest extends TestCase
static::assertEquals(1, sizeof($orders));
static::assertEquals('new', $orders[0]['status']);
$response = $client->ordersStatuses(array($ids['id']), array($ids['externalId']));
$response = $client->ordersStatuses([$ids['id']], [$ids['externalId']]);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(200, $response->getStatusCode());
static::assertTrue($response->isSuccessful());
$orders = $response['orders'];
static::assertEquals(1, sizeof($orders));
$response = $client->ordersStatuses(array($ids['id']));
$response = $client->ordersStatuses([$ids['id']]);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(200, $response->getStatusCode());
static::assertTrue($response->isSuccessful());
@ -158,19 +158,19 @@ class ApiClientOrdersTest extends TestCase
$client = static::getApiClient();
$response = $client->ordersEdit(
array(
[
'id' => 22342134,
'lastName' => '12345',
),
],
'id'
);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(404, $response->getStatusCode());
$response = $client->ordersEdit(array(
$response = $client->ordersEdit([
'externalId' => $ids['externalId'],
'lastName' => '12345',
));
]);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(200, $response->getStatusCode());
static::assertTrue($response->isSuccessful());
@ -183,7 +183,7 @@ class ApiClientOrdersTest extends TestCase
public function testOrdersEditExceptionEmpty()
{
$client = static::getApiClient();
$client->ordersEdit(array(), 'asdf');
$client->ordersEdit([], 'asdf');
}
/**
@ -193,7 +193,7 @@ class ApiClientOrdersTest extends TestCase
public function testOrdersEditException()
{
$client = static::getApiClient();
$client->ordersEdit(array('id' => 678678678), 'asdf');
$client->ordersEdit(['id' => 678678678], 'asdf');
}
/**
@ -221,14 +221,14 @@ class ApiClientOrdersTest extends TestCase
static::assertTrue($response->isSuccessful());
static::assertTrue(isset($response['orders']));
$response = $client->ordersList(array(), 1, 300);
$response = $client->ordersList([], 1, 300);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertFalse(
$response->isSuccessful(),
'Pagination error'
);
$response = $client->ordersList(array('paymentStatus' => 'paid'), 1);
$response = $client->ordersList(['paymentStatus' => 'paid'], 1);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
}
@ -239,7 +239,7 @@ class ApiClientOrdersTest extends TestCase
public function testOrdersFixExternalIdsException()
{
$client = static::getApiClient();
$client->ordersFixExternalIds(array());
$client->ordersFixExternalIds([]);
}
/**
@ -249,9 +249,9 @@ class ApiClientOrdersTest extends TestCase
{
$client = static::getApiClient();
$response = $client->ordersCreate(array(
$response = $client->ordersCreate([
'firstName' => 'Aaa',
));
]);
static::assertTrue(
$response->isSuccessful(),
'Order created'
@ -260,9 +260,9 @@ class ApiClientOrdersTest extends TestCase
$id = $response['id'];
$externalId = 'asdf' . time();
$response = $client->ordersFixExternalIds(array(
array('id' => $id, 'externalId' => $externalId)
));
$response = $client->ordersFixExternalIds([
['id' => $id, 'externalId' => $externalId]
]);
static::assertTrue(
$response->isSuccessful(),
@ -293,7 +293,7 @@ class ApiClientOrdersTest extends TestCase
public function testOrdersUploadExceptionEmpty()
{
$client = static::getApiClient();
$client->ordersUpload(array());
$client->ordersUpload([]);
}
/**
@ -306,16 +306,16 @@ class ApiClientOrdersTest extends TestCase
$externalIdA = 'upload-a-' . time();
$externalIdB = 'upload-b-' . time();
$response = $client->ordersUpload(array(
array(
$response = $client->ordersUpload([
[
'externalId' => $externalIdA,
'firstName' => 'Aaa',
),
array(
],
[
'externalId' => $externalIdB,
'lastName' => 'Bbb',
),
));
],
]);
static::assertTrue(
$response->isSuccessful(),
'Got order'
@ -385,14 +385,14 @@ class ApiClientOrdersTest extends TestCase
'Got order'
);
$payment = array(
$payment = [
'externalId' => $externalId,
'order' => array('id' => $responseCreateFirst['id']),
'order' => ['id' => $responseCreateFirst['id']],
'amount' => 1200,
'comment' => 'test payment',
'type' => 'cash',
'status' => 'paid'
);
];
$response = $client->ordersPaymentCreate($payment);
@ -401,14 +401,14 @@ class ApiClientOrdersTest extends TestCase
'Got payment'
);
$paymentEdit = array(
$paymentEdit = [
'id' => $response['id'],
'externalId' => $externalId,
'amount' => 1500,
'comment' => 'test payment!',
'type' => 'cash',
'status' => 'paid'
);
];
$responseAgain = $client->ordersPaymentEdit($paymentEdit);

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* API client packs test class
*
@ -60,11 +60,11 @@ class ApiClientPacksTest extends TestCase
public function testPacksCreateFailed()
{
$client = static::getApiClient();
$pack = array(
$pack = [
'itemId' => 12,
'store' => 'test',
'quantity' => 2
);
];
$response = $client->ordersPacksCreate($pack);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* API client prices test class
*
@ -74,12 +74,12 @@ class ApiClientPricesTest extends TestCase
$client = static::getApiClient();
$response = $client->pricesEdit(
array(
[
'code' => $this->code,
'name' => $this->code,
'ordering' => 500,
'active' => true
)
]
);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
@ -94,7 +94,7 @@ class ApiClientPricesTest extends TestCase
public function testPricesUploadExceptionEmpty()
{
$client = static::getApiClient();
$client->storePricesUpload(array());
$client->storePricesUpload([]);
}
/**
@ -107,26 +107,26 @@ class ApiClientPricesTest extends TestCase
$xmlIdA = 'upload-a-' . time();
$xmlIdB = 'upload-b-' . time();
$response = $client->storePricesUpload(array(
array(
$response = $client->storePricesUpload([
[
'xmlId' => $xmlIdA,
'prices' => array(
array(
'prices' => [
[
'code' => $this->code,
'price' => 1700
)
)
),
array(
]
]
],
[
'xmlId' => $xmlIdB,
'prices' => array(
array(
'prices' => [
[
'code' => $this->code,
'price' => 1500
)
)
),
));
]
]
],
]);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(200, $response->getStatusCode());

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* API client references test class
*
@ -59,7 +59,7 @@ class ApiClientReferenceTest extends TestCase
$client = static::getApiClient();
$method = $name . 'Edit';
$client->$method(array());
$client->$method([]);
}
/**
@ -74,11 +74,11 @@ class ApiClientReferenceTest extends TestCase
$code = 'dict-' . strtolower($name) . '-' . time();
$method = $name . 'Edit';
$params = array(
$params = [
'code' => $code,
'name' => 'Aaa' . $code,
'active' => false
);
];
if ($name == 'statuses') {
$params['group'] = 'new';
}
@ -86,15 +86,15 @@ class ApiClientReferenceTest extends TestCase
$response = $client->$method($params);
/* @var \RetailCrm\Response\ApiResponse $response */
static::assertTrue(in_array($response->getStatusCode(), array(200, 201)));
static::assertTrue(in_array($response->getStatusCode(), [200, 201]));
$response = $client->$method(array(
$response = $client->$method([
'code' => $code,
'name' => 'Bbb' . $code,
'active' => false
));
]);
static::assertTrue(in_array($response->getStatusCode(), array(200, 201)));
static::assertTrue(in_array($response->getStatusCode(), [200, 201]));
}
/**
@ -108,11 +108,11 @@ class ApiClientReferenceTest extends TestCase
$code = 'dict-' . strtolower($name) . '-' . time();
$method = $name . 'Edit';
$params = array(
$params = [
'code' => $code,
'name' => 'Aaa',
'active' => false
);
];
$response = $client->$method($params);
/* @var \RetailCrm\Response\ApiResponse $response */
@ -121,11 +121,11 @@ class ApiClientReferenceTest extends TestCase
if ($code == $client->getSite()) {
$method = $name . 'Edit';
$params = array(
$params = [
'code' => $code,
'name' => 'Aaa' . time(),
'active' => false
);
];
$response = $client->$method($params);
static::assertEquals(200, $response->getStatusCode());
@ -137,18 +137,18 @@ class ApiClientReferenceTest extends TestCase
*/
public function getListDictionaries()
{
return array(
array('deliveryServices'),
array('deliveryTypes'),
array('orderMethods'),
array('orderTypes'),
array('paymentStatuses'),
array('paymentTypes'),
array('productStatuses'),
array('statusGroups'),
array('statuses'),
array('sites'),
);
return [
['deliveryServices'],
['deliveryTypes'],
['orderMethods'],
['orderTypes'],
['paymentStatuses'],
['paymentTypes'],
['productStatuses'],
['statusGroups'],
['statuses'],
['sites'],
];
}
/**
@ -156,15 +156,15 @@ class ApiClientReferenceTest extends TestCase
*/
public function getEditDictionaries()
{
return array(
array('deliveryServices'),
array('deliveryTypes'),
array('orderMethods'),
array('orderTypes'),
array('paymentStatuses'),
array('paymentTypes'),
array('productStatuses'),
array('statuses'),
);
return [
['deliveryServices'],
['deliveryTypes'],
['orderMethods'],
['orderTypes'],
['paymentStatuses'],
['paymentTypes'],
['productStatuses'],
['statuses'],
];
}
}

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* API client store test class
*
@ -37,9 +37,9 @@ class ApiClientStoreTest extends TestCase
{
$client = static::getApiClient();
$response = $client->storesEdit(array('name' => self::SNAME, 'code' => self::SCODE));
$response = $client->storesEdit(['name' => self::SNAME, 'code' => self::SCODE]);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertTrue(in_array($response->getStatusCode(), array(200, 201)));
static::assertTrue(in_array($response->getStatusCode(), [200, 201]));
static::assertTrue($response->isSuccessful());
}
@ -67,7 +67,7 @@ class ApiClientStoreTest extends TestCase
public function testInventoriesException()
{
$client = static::getApiClient();
$client->storeInventoriesUpload(array());
$client->storeInventoriesUpload([]);
}
/**
@ -77,28 +77,28 @@ class ApiClientStoreTest extends TestCase
{
$client = static::getApiClient();
$response = $client->storeInventoriesUpload(array(
array(
$response = $client->storeInventoriesUpload([
[
'externalId' => 'pTKIKAeghYzX21HTdzFCe1',
'stores' => array(
array(
'stores' => [
[
'code' => self::SCODE,
'available' => 10,
'purchasePrice' => 1700
)
)
),
array(
]
]
],
[
'externalId' => 'JQIvcrCtiSpOV3AAfMiQB3',
'stores' => array(
array(
'stores' => [
[
'code' => self::SCODE,
'available' => 20,
'purchasePrice' => 1500
)
)
),
));
]
]
],
]);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertTrue($response->isSuccessful());
@ -114,18 +114,18 @@ class ApiClientStoreTest extends TestCase
$externalIdA = 'upload-a-' . time();
$externalIdB = 'upload-b-' . time();
$response = $client->storeInventoriesUpload(array(
array(
$response = $client->storeInventoriesUpload([
[
'externalId' => $externalIdA,
'available' => 10,
'purchasePrice' => 1700
),
array(
],
[
'externalId' => $externalIdB,
'available' => 20,
'purchasePrice' => 1500
),
));
],
]);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertEquals(400, $response->getStatusCode());
static::assertTrue(isset($response['errorMsg']), $response['errorMsg']);

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* API client orders test class
*
@ -47,19 +47,19 @@ class ApiClientTasksTest extends TestCase
public function testTasksCreateExceptionEmpty()
{
$client = static::getApiClient();
$client->tasksCreate(array());
$client->tasksCreate([]);
}
public function testTasksCRU()
{
$client = static::getApiClient();
$task = array(
$task = [
'text' => 'test task',
'commentary' => 'test task commentary',
'performerId' => $_SERVER['CRM_USER_ID'],
'complete' => false
);
];
$responseCreate = $client->tasksCreate($task);

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* API client telephony test class
*
@ -49,12 +49,12 @@ class ApiClientTelephonyTest extends TestCase
'TestTelephony',
false,
self::TEL_IMAGE,
array(array('userId' => $_SERVER['CRM_USER_ID'], 'code' => '101')),
array(array('siteCode' => 'api-client-php', 'externalPhone' => '+74950000000'))
[['userId' => $_SERVER['CRM_USER_ID'], 'code' => '101']],
[['siteCode' => 'api-client-php', 'externalPhone' => '+74950000000']]
);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertTrue(in_array($response->getStatusCode(), array(200, 201)));
static::assertTrue(in_array($response->getStatusCode(), [200, 201]));
static::assertTrue($response->isSuccessful());
}
@ -89,7 +89,7 @@ class ApiClientTelephonyTest extends TestCase
$response = $client->telephonyCallEvent(
'+79999999999',
'in',
array('101'),
['101'],
'failed',
'+74950000000'
@ -112,8 +112,8 @@ class ApiClientTelephonyTest extends TestCase
$client = static::getApiClient();
$response = $client->telephonyCallsUpload(
array(
array(
[
[
'date' => '2016-07-22 00:18:00',
'type' => 'in',
'phone' => '+79999999999',
@ -121,8 +121,8 @@ class ApiClientTelephonyTest extends TestCase
'result' => 'answered',
'externalId' => rand(10, 100),
'recordUrl' => 'http://download.retailcrm.pro/api-client-files/beep1.mp3'
),
array(
],
[
'date' => '2016-07-22 00:24:00',
'type' => 'in',
'phone' => '+79999999999',
@ -130,8 +130,8 @@ class ApiClientTelephonyTest extends TestCase
'result' => 'answered',
'externalId' => rand(10, 100),
'recordUrl' => 'http://download.retailcrm.pro/api-client-files/beep2.mp3'
)
)
]
]
);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* API client test class
*

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* API client users test class
*
@ -36,7 +36,7 @@ class ApiClientUsersTest extends TestCase
$response = $client->usersList();
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertTrue(in_array($response->getStatusCode(), array(200, 201)));
static::assertTrue(in_array($response->getStatusCode(), [200, 201]));
static::assertTrue($response->isSuccessful());
}
@ -49,7 +49,7 @@ class ApiClientUsersTest extends TestCase
$response = $client->usersGet($_SERVER["CRM_USER_ID"]);
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertTrue(in_array($response->getStatusCode(), array(200, 201)));
static::assertTrue(in_array($response->getStatusCode(), [200, 201]));
static::assertTrue($response->isSuccessful());
}
@ -62,7 +62,7 @@ class ApiClientUsersTest extends TestCase
$response = $client->usersStatus($_SERVER["CRM_USER_ID"], 'dinner');
static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
static::assertTrue(in_array($response->getStatusCode(), array(200, 201)));
static::assertTrue(in_array($response->getStatusCode(), [200, 201]));
static::assertTrue($response->isSuccessful());
}
}

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* API client test class
*
@ -34,7 +34,7 @@ class ClientTest extends TestCase
*/
public function testConstruct()
{
$client = new Client('https://asdf.df', array());
$client = new Client('https://asdf.df', []);
static::assertInstanceOf('RetailCrm\Http\Client', $client);
}
@ -45,7 +45,7 @@ class ClientTest extends TestCase
*/
public function testHttpRequiring()
{
$client = new Client('http://demo.retailcrm.ru/api/' . ApiClient::VERSION, array('apiKey' => '123'));
$client = new Client('http://demo.retailcrm.ru/api/' . ApiClient::VERSION, ['apiKey' => '123']);
return $client;
}
@ -65,8 +65,8 @@ class ClientTest extends TestCase
*/
public function testRequestWrongUrl()
{
$client = new Client('https://asdf.df', array());
$client->makeRequest('/a', Client::METHOD_GET, array());
$client = new Client('https://asdf.df', []);
$client->makeRequest('/a', Client::METHOD_GET, []);
}
/**

View file

@ -1,7 +1,7 @@
<?php
/**
* PHP version 5.3
* PHP version 5.4
*
* API client response test class
*