commit
49f253c228
19
.travis.yml
Normal file
19
.travis.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
language: php
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.composer/cache
|
||||||
|
|
||||||
|
php:
|
||||||
|
- '5.3'
|
||||||
|
- '5.4'
|
||||||
|
- '5.5'
|
||||||
|
- '5.6'
|
||||||
|
- '7.0'
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- flags="--prefer-dist --no-dev"
|
||||||
|
- composer install $flags
|
||||||
|
- wget -c -O phpunit.xml https://db.tt/uMin8U9t
|
||||||
|
|
||||||
|
script: phpunit
|
@ -1,6 +1,6 @@
|
|||||||
# retailCRM API PHP client
|
# retailCRM API PHP client
|
||||||
|
|
||||||
PHP-client for [retailCRM API](http://www.retailcrm.pro/docs/Developers/ApiVersion3).
|
PHP-client for [retailCRM API](http://www.retailcrm.pro/docs/Developers/ApiVersion4).
|
||||||
|
|
||||||
Use [API documentation](http://retailcrm.github.io/api-client-php)
|
Use [API documentation](http://retailcrm.github.io/api-client-php)
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ Use [API documentation](http://retailcrm.github.io/api-client-php)
|
|||||||
|
|
||||||
2) Run into your project directory:
|
2) Run into your project directory:
|
||||||
```bash
|
```bash
|
||||||
composer require retailcrm/api-client-php ~3.0.0 --no-dev
|
composer require retailcrm/api-client-php ~4.0.0 --no-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
If you have not used `composer` before, include autoloader into your project.
|
If you have not used `composer` before, include autoloader into your project.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# PHP-клиент для retailCRM API
|
# PHP-клиент для retailCRM API
|
||||||
|
|
||||||
PHP-клиент для работы с [retailCRM API](http://www.retailcrm.ru/docs/Developers/ApiVersion3).
|
PHP-клиент для работы с [retailCRM API](http://www.retailcrm.ru/docs/Developers/ApiVersion4).
|
||||||
|
|
||||||
Рекомендуем обращаться к [документации](http://retailcrm.github.io/api-client-php) по библиотеке, в частности по классу [RetailCrm\ApiClient](http://retailcrm.github.io/api-client-php/class-RetailCrm.ApiClient.html).
|
Рекомендуем обращаться к [документации](http://retailcrm.github.io/api-client-php) по библиотеке, в частности по классу [RetailCrm\ApiClient](http://retailcrm.github.io/api-client-php/class-RetailCrm.ApiClient.html).
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ PHP-клиент для работы с [retailCRM API](http://www.retailcrm.ru/
|
|||||||
|
|
||||||
2) Выполните в папке проекта:
|
2) Выполните в папке проекта:
|
||||||
```bash
|
```bash
|
||||||
composer require retailcrm/api-client-php ~3.0.0 --no-dev
|
composer require retailcrm/api-client-php ~4.0.0 --no-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
В конфиг `composer.json` вашего проекта будет добавлена библиотека `retailcrm/api-client-php`, которая установится в папку `vendor/`. При отсутствии файла конфига или папки с вендорами они будут созданы.
|
В конфиг `composer.json` вашего проекта будет добавлена библиотека `retailcrm/api-client-php`, которая установится в папку `vendor/`. При отсутствии файла конфига или папки с вендорами они будут созданы.
|
||||||
|
@ -15,16 +15,6 @@
|
|||||||
"php": ">=5.3.0",
|
"php": ">=5.3.0",
|
||||||
"ext-curl": "*"
|
"ext-curl": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "5.2.*",
|
|
||||||
"phpunit/php-code-coverage": "3.3.0",
|
|
||||||
"phpunit/php-invoker": "1.1.4",
|
|
||||||
"phpmd/phpmd": "2.4.*",
|
|
||||||
"sebastian/phpcpd": "2.0.*",
|
|
||||||
"sebastian/phpdcd": "1.0.*",
|
|
||||||
"squizlabs/php_codesniffer": "2.5.*",
|
|
||||||
"apigen/apigen": "4.1.*"
|
|
||||||
},
|
|
||||||
"support": {
|
"support": {
|
||||||
"email": "support@retailcrm.pro"
|
"email": "support@retailcrm.pro"
|
||||||
},
|
},
|
||||||
@ -33,7 +23,7 @@
|
|||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "3.0.x-dev"
|
"dev-master": "4.0.x-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace RetailCrm;
|
namespace RetailCrm;
|
||||||
@ -26,12 +26,12 @@ use RetailCrm\Response\ApiResponse;
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
*/
|
*/
|
||||||
class ApiClient
|
class ApiClient
|
||||||
{
|
{
|
||||||
|
|
||||||
const VERSION = 'v3';
|
const VERSION = 'v4';
|
||||||
|
|
||||||
protected $client;
|
protected $client;
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class ApiClient
|
|||||||
*/
|
*/
|
||||||
public function __construct($url, $apiKey, $site = null)
|
public function __construct($url, $apiKey, $site = null)
|
||||||
{
|
{
|
||||||
if ('/' !== substr($url, strlen($url) - 1, 1)) {
|
if ('/' !== $url[strlen($url) - 1]) {
|
||||||
$url .= '/';
|
$url .= '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +63,56 @@ class ApiClient
|
|||||||
$this->siteCode = $site;
|
$this->siteCode = $site;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns users list
|
||||||
|
*
|
||||||
|
* @param array $filter
|
||||||
|
* @param null $page
|
||||||
|
* @param null $limit
|
||||||
|
*
|
||||||
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||||
|
* @throws \RetailCrm\Exception\CurlException
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function usersList(array $filter = array(), $page = null, $limit = null)
|
||||||
|
{
|
||||||
|
$parameters = array();
|
||||||
|
|
||||||
|
if (count($filter)) {
|
||||||
|
$parameters['filter'] = $filter;
|
||||||
|
}
|
||||||
|
if (null !== $page) {
|
||||||
|
$parameters['page'] = (int) $page;
|
||||||
|
}
|
||||||
|
if (null !== $limit) {
|
||||||
|
$parameters['limit'] = (int) $limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
'/users',
|
||||||
|
Client::METHOD_GET,
|
||||||
|
$parameters
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns user data
|
||||||
|
*
|
||||||
|
* @param integer $id user ID
|
||||||
|
*
|
||||||
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||||
|
* @throws \RetailCrm\Exception\CurlException
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function usersGet($id)
|
||||||
|
{
|
||||||
|
return $this->client->makeRequest("/users/$id", Client::METHOD_GET);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns filtered orders list
|
* Returns filtered orders list
|
||||||
*
|
*
|
||||||
@ -151,53 +201,6 @@ class ApiClient
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a orders history
|
|
||||||
*
|
|
||||||
* @param \DateTime $startDate (default: null)
|
|
||||||
* @param \DateTime $endDate (default: null)
|
|
||||||
* @param int $limit (default: 100)
|
|
||||||
* @param int $offset (default: 0)
|
|
||||||
* @param bool $skipMyChanges (default: true)
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
* @throws \RetailCrm\Exception\CurlException
|
|
||||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
||||||
*
|
|
||||||
* @return ApiResponse
|
|
||||||
*/
|
|
||||||
public function ordersHistory(
|
|
||||||
\DateTime $startDate = null,
|
|
||||||
\DateTime $endDate = null,
|
|
||||||
$limit = 100,
|
|
||||||
$offset = 0,
|
|
||||||
$skipMyChanges = true
|
|
||||||
) {
|
|
||||||
$parameters = array();
|
|
||||||
|
|
||||||
if ($startDate) {
|
|
||||||
$parameters['startDate'] = $startDate->format('Y-m-d H:i:s');
|
|
||||||
}
|
|
||||||
if ($endDate) {
|
|
||||||
$parameters['endDate'] = $endDate->format('Y-m-d H:i:s');
|
|
||||||
}
|
|
||||||
if ($limit) {
|
|
||||||
$parameters['limit'] = (int) $limit;
|
|
||||||
}
|
|
||||||
if ($offset) {
|
|
||||||
$parameters['offset'] = (int) $offset;
|
|
||||||
}
|
|
||||||
if ($skipMyChanges) {
|
|
||||||
$parameters['skipMyChanges'] = (bool) $skipMyChanges;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->client->makeRequest(
|
|
||||||
'/orders/history',
|
|
||||||
Client::METHOD_GET,
|
|
||||||
$parameters
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns statuses of the orders
|
* Returns statuses of the orders
|
||||||
*
|
*
|
||||||
@ -210,10 +213,8 @@ class ApiClient
|
|||||||
*
|
*
|
||||||
* @return ApiResponse
|
* @return ApiResponse
|
||||||
*/
|
*/
|
||||||
public function ordersStatuses(
|
public function ordersStatuses(array $ids = array(), array $externalIds = array())
|
||||||
array $ids = array(),
|
{
|
||||||
array $externalIds = array()
|
|
||||||
) {
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
|
|
||||||
if (count($ids)) {
|
if (count($ids)) {
|
||||||
@ -320,6 +321,35 @@ class ApiClient
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get orders history
|
||||||
|
* @param array $filter
|
||||||
|
* @param null $page
|
||||||
|
* @param null $limit
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function ordersHistory(array $filter = array(), $page = null, $limit = null)
|
||||||
|
{
|
||||||
|
$parameters = array();
|
||||||
|
|
||||||
|
if (count($filter)) {
|
||||||
|
$parameters['filter'] = $filter;
|
||||||
|
}
|
||||||
|
if (null !== $page) {
|
||||||
|
$parameters['page'] = (int) $page;
|
||||||
|
}
|
||||||
|
if (null !== $limit) {
|
||||||
|
$parameters['limit'] = (int) $limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
'/orders/history',
|
||||||
|
Client::METHOD_GET,
|
||||||
|
$parameters
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns filtered customers list
|
* Returns filtered customers list
|
||||||
*
|
*
|
||||||
@ -333,11 +363,8 @@ class ApiClient
|
|||||||
*
|
*
|
||||||
* @return ApiResponse
|
* @return ApiResponse
|
||||||
*/
|
*/
|
||||||
public function customersList(
|
public function customersList(array $filter = array(), $page = null, $limit = null)
|
||||||
array $filter = array(),
|
{
|
||||||
$page = null,
|
|
||||||
$limit = null
|
|
||||||
) {
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
|
|
||||||
if (count($filter)) {
|
if (count($filter)) {
|
||||||
@ -500,6 +527,35 @@ class ApiClient
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get customers history
|
||||||
|
* @param array $filter
|
||||||
|
* @param null $page
|
||||||
|
* @param null $limit
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function customersHistory(array $filter = array(), $page = null, $limit = null)
|
||||||
|
{
|
||||||
|
$parameters = array();
|
||||||
|
|
||||||
|
if (count($filter)) {
|
||||||
|
$parameters['filter'] = $filter;
|
||||||
|
}
|
||||||
|
if (null !== $page) {
|
||||||
|
$parameters['page'] = (int) $page;
|
||||||
|
}
|
||||||
|
if (null !== $limit) {
|
||||||
|
$parameters['limit'] = (int) $limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
'/customers/history',
|
||||||
|
Client::METHOD_GET,
|
||||||
|
$parameters
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get orders assembly list
|
* Get orders assembly list
|
||||||
*
|
*
|
||||||
@ -513,11 +569,8 @@ class ApiClient
|
|||||||
*
|
*
|
||||||
* @return ApiResponse
|
* @return ApiResponse
|
||||||
*/
|
*/
|
||||||
public function ordersPacksList(
|
public function ordersPacksList(array $filter = array(), $page = null, $limit = null)
|
||||||
array $filter = array(),
|
{
|
||||||
$page = null,
|
|
||||||
$limit = null
|
|
||||||
) {
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
|
|
||||||
if (count($filter)) {
|
if (count($filter)) {
|
||||||
@ -577,11 +630,8 @@ class ApiClient
|
|||||||
*
|
*
|
||||||
* @return ApiResponse
|
* @return ApiResponse
|
||||||
*/
|
*/
|
||||||
public function ordersPacksHistory(
|
public function ordersPacksHistory(array $filter = array(), $page = null, $limit = null)
|
||||||
array $filter = array(),
|
{
|
||||||
$page = null,
|
|
||||||
$limit = null
|
|
||||||
) {
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
|
|
||||||
if (count($filter)) {
|
if (count($filter)) {
|
||||||
@ -687,11 +737,8 @@ class ApiClient
|
|||||||
*
|
*
|
||||||
* @return ApiResponse
|
* @return ApiResponse
|
||||||
*/
|
*/
|
||||||
public function storeInventories(
|
public function storeInventories(array $filter = array(), $page = null, $limit = null)
|
||||||
array $filter = array(),
|
{
|
||||||
$page = null,
|
|
||||||
$limit = null
|
|
||||||
) {
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
|
|
||||||
if (count($filter)) {
|
if (count($filter)) {
|
||||||
@ -711,6 +758,56 @@ class ApiClient
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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/settings/$code",
|
||||||
|
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/settings/%s/edit', $configuration['code']),
|
||||||
|
Client::METHOD_POST,
|
||||||
|
$configuration
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload store inventories
|
* Upload store inventories
|
||||||
*
|
*
|
||||||
@ -738,6 +835,120 @@ class ApiClient
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get products
|
||||||
|
*
|
||||||
|
* @param array $filter (default: array())
|
||||||
|
* @param int $page (default: null)
|
||||||
|
* @param int $limit (default: null)
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
* @throws \RetailCrm\Exception\CurlException
|
||||||
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function storeProducts(array $filter = array(), $page = null, $limit = null)
|
||||||
|
{
|
||||||
|
$parameters = array();
|
||||||
|
|
||||||
|
if (count($filter)) {
|
||||||
|
$parameters['filter'] = $filter;
|
||||||
|
}
|
||||||
|
if (null !== $page) {
|
||||||
|
$parameters['page'] = (int) $page;
|
||||||
|
}
|
||||||
|
if (null !== $limit) {
|
||||||
|
$parameters['limit'] = (int) $limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
'/store/products',
|
||||||
|
Client::METHOD_GET,
|
||||||
|
$parameters
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get delivery settings
|
||||||
|
*
|
||||||
|
* @param string $code
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
* @throws \RetailCrm\Exception\CurlException
|
||||||
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function deliverySettingsGet($code)
|
||||||
|
{
|
||||||
|
if (empty($code)) {
|
||||||
|
throw new \InvalidArgumentException('Parameter `code` must be set');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
"/delivery/generic/setting/$code",
|
||||||
|
Client::METHOD_GET
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit delivery configuration
|
||||||
|
*
|
||||||
|
* @param array $configuration
|
||||||
|
*
|
||||||
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||||
|
* @throws \RetailCrm\Exception\CurlException
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function deliverySettingsEdit(array $configuration)
|
||||||
|
{
|
||||||
|
if (!count($configuration) || empty($configuration['code'])) {
|
||||||
|
throw new \InvalidArgumentException(
|
||||||
|
'Parameter `configuration` must contains a data & configuration `code` must be set'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
sprintf('/delivery/generic/settings/%s/edit', $configuration['code']),
|
||||||
|
Client::METHOD_POST,
|
||||||
|
$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),
|
||||||
|
Client::METHOD_POST,
|
||||||
|
$statusUpdate
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns available county list
|
* Returns available county list
|
||||||
*
|
*
|
||||||
@ -1209,29 +1420,64 @@ class ApiClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Telephony settings
|
* 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",
|
||||||
|
Client::METHOD_GET
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit telephony settings
|
||||||
*
|
*
|
||||||
* @param string $code symbolic code
|
* @param string $code symbolic code
|
||||||
* @param string $clientId client id
|
* @param string $clientId client id
|
||||||
* @param boolean $active telephony activity
|
* @param boolean $active telephony activity
|
||||||
* @param mixed $makeCallUrl service init url
|
|
||||||
* @param mixed $name service name
|
* @param mixed $name service name
|
||||||
|
* @param mixed $makeCallUrl service init url
|
||||||
* @param mixed $image service logo url(svg file)
|
* @param mixed $image service logo url(svg file)
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @param array $additionalCodes
|
||||||
* @throws \RetailCrm\Exception\CurlException
|
* @param array $externalPhones
|
||||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
* @param bool $allowEdit
|
||||||
|
* @param bool $inputEventSupported
|
||||||
|
* @param bool $outputEventSupported
|
||||||
|
* @param bool $hangupEventSupported
|
||||||
|
* @param bool $changeUserStatusUrl
|
||||||
*
|
*
|
||||||
* @return ApiResponse
|
* @return ApiResponse
|
||||||
*/
|
*/
|
||||||
public function telephonySettings(
|
public function telephonySettingsEdit(
|
||||||
$code,
|
$code,
|
||||||
$clientId,
|
$clientId,
|
||||||
$active = false,
|
$active = false,
|
||||||
$makeCallUrl = false,
|
|
||||||
$name = false,
|
$name = false,
|
||||||
$image = false
|
$makeCallUrl = false,
|
||||||
) {
|
$image = false,
|
||||||
|
$additionalCodes = array(),
|
||||||
|
$externalPhones = array(),
|
||||||
|
$allowEdit = false,
|
||||||
|
$inputEventSupported = false,
|
||||||
|
$outputEventSupported = false,
|
||||||
|
$hangupEventSupported = false,
|
||||||
|
$changeUserStatusUrl = false
|
||||||
|
)
|
||||||
|
{
|
||||||
if (!isset($code)) {
|
if (!isset($code)) {
|
||||||
throw new \InvalidArgumentException('Code must be set');
|
throw new \InvalidArgumentException('Code must be set');
|
||||||
}
|
}
|
||||||
@ -1254,39 +1500,50 @@ class ApiClient
|
|||||||
throw new \InvalidArgumentException('name must be set');
|
throw new \InvalidArgumentException('name must be set');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($makeCallUrl)) {
|
|
||||||
$parameters['makeCallUrl'] = $makeCallUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($name)) {
|
if (isset($name)) {
|
||||||
$parameters['name'] = $name;
|
$parameters['name'] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($makeCallUrl)) {
|
||||||
|
$parameters['makeCallUrl'] = $makeCallUrl;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($image)) {
|
if (isset($image)) {
|
||||||
$parameters['image'] = $image;
|
$parameters['image'] = $image;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->client->makeRequest(
|
if (isset($additionalCodes)) {
|
||||||
"/telephony/setting/$code",
|
$parameters['additionalCodes'] = $additionalCodes;
|
||||||
Client::METHOD_POST,
|
}
|
||||||
$parameters
|
|
||||||
);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update CRM basic statistic
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
* @throws \RetailCrm\Exception\CurlException
|
|
||||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
||||||
*
|
|
||||||
* @return ApiResponse
|
|
||||||
*/
|
|
||||||
public function statisticUpdate()
|
|
||||||
{
|
|
||||||
return $this->client->makeRequest(
|
return $this->client->makeRequest(
|
||||||
'/statistic/update',
|
"/telephony/setting/$code/edit",
|
||||||
Client::METHOD_GET
|
Client::METHOD_POST,
|
||||||
|
array('configuration' => json_encode($parameters))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1295,40 +1552,49 @@ class ApiClient
|
|||||||
*
|
*
|
||||||
* @param string $phone phone number
|
* @param string $phone phone number
|
||||||
* @param string $type call type
|
* @param string $type call type
|
||||||
* @param string $code additional phone code
|
* @param array $codes
|
||||||
* @param string $status call status
|
* @param string $hangupStatus
|
||||||
*
|
* @param string $externalPhone
|
||||||
* @throws \InvalidArgumentException
|
* @param array $webAnalyticsData
|
||||||
* @throws \RetailCrm\Exception\CurlException
|
|
||||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
||||||
*
|
*
|
||||||
* @return ApiResponse
|
* @return ApiResponse
|
||||||
|
* @internal param string $code additional phone code
|
||||||
|
* @internal param string $status call status
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public function telephonyCallEvent($phone, $type, $code, $status)
|
public function telephonyCallEvent(
|
||||||
|
$phone,
|
||||||
|
$type,
|
||||||
|
$codes,
|
||||||
|
$hangupStatus,
|
||||||
|
$externalPhone = null,
|
||||||
|
$webAnalyticsData = array()
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!isset($phone)) {
|
if (!isset($phone)) {
|
||||||
throw new \InvalidArgumentException('Phone number must be set');
|
throw new \InvalidArgumentException('Phone number must be set');
|
||||||
}
|
}
|
||||||
|
|
||||||
$parameters['phone'] = $phone;
|
|
||||||
|
|
||||||
if (!isset($type)) {
|
if (!isset($type)) {
|
||||||
throw new \InvalidArgumentException('Type must be set (in|out|hangup)');
|
throw new \InvalidArgumentException('Type must be set (in|out|hangup)');
|
||||||
}
|
}
|
||||||
|
|
||||||
$parameters['type'] = $type;
|
if (empty($codes)) {
|
||||||
|
throw new \InvalidArgumentException('Codes array must be set');
|
||||||
if (!isset($code)) {
|
|
||||||
throw new \InvalidArgumentException('Code must be set');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$parameters['code'] = $code;
|
$parameters['phone'] = $phone;
|
||||||
$parameters['hangupStatus'] = $status;
|
$parameters['type'] = $type;
|
||||||
|
$parameters['codes'] = $codes;
|
||||||
|
$parameters['hangupStatus'] = $hangupStatus;
|
||||||
|
$parameters['callExternalId'] = $externalPhone;
|
||||||
|
$parameters['webAnalyticsData'] = $webAnalyticsData;
|
||||||
|
|
||||||
|
|
||||||
return $this->client->makeRequest(
|
return $this->client->makeRequest(
|
||||||
'/telephony/call/event',
|
'/telephony/call/event',
|
||||||
Client::METHOD_POST,
|
Client::METHOD_POST,
|
||||||
$parameters
|
array('event' => json_encode($parameters))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1386,6 +1652,23 @@ class ApiClient
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update CRM basic statistic
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
* @throws \RetailCrm\Exception\CurlException
|
||||||
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||||
|
*
|
||||||
|
* @return ApiResponse
|
||||||
|
*/
|
||||||
|
public function statisticUpdate()
|
||||||
|
{
|
||||||
|
return $this->client->makeRequest(
|
||||||
|
'/statistic/update',
|
||||||
|
Client::METHOD_GET
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return current site
|
* Return current site
|
||||||
*
|
*
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace RetailCrm\Exception;
|
namespace RetailCrm\Exception;
|
||||||
@ -23,7 +23,7 @@ namespace RetailCrm\Exception;
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
*/
|
*/
|
||||||
class CurlException extends \RuntimeException
|
class CurlException extends \RuntimeException
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace RetailCrm\Exception;
|
namespace RetailCrm\Exception;
|
||||||
@ -23,7 +23,7 @@ namespace RetailCrm\Exception;
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
*/
|
*/
|
||||||
class InvalidJsonException extends \DomainException
|
class InvalidJsonException extends \DomainException
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace RetailCrm\Http;
|
namespace RetailCrm\Http;
|
||||||
@ -27,7 +27,7 @@ use RetailCrm\Response\ApiResponse;
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
*/
|
*/
|
||||||
class Client
|
class Client
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace RetailCrm\Response;
|
namespace RetailCrm\Response;
|
||||||
@ -25,7 +25,7 @@ use RetailCrm\Exception\InvalidJsonException;
|
|||||||
* @package RetailCrm
|
* @package RetailCrm
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
*/
|
*/
|
||||||
class ApiResponse implements \ArrayAccess
|
class ApiResponse implements \ArrayAccess
|
||||||
{
|
{
|
||||||
|
@ -6,16 +6,13 @@
|
|||||||
colors="true"
|
colors="true"
|
||||||
verbose="true"
|
verbose="true"
|
||||||
processIsolation="false"
|
processIsolation="false"
|
||||||
stopOnFailure="true">
|
stopOnFailure="false">
|
||||||
|
|
||||||
<!-- Dummy values used to provide credentials. No need to change these. -->
|
<!-- Dummy values used to provide credentials. No need to change these. -->
|
||||||
<php>
|
<php>
|
||||||
<server name="CRM_URL" value="foo" />
|
<server name="CRM_URL" value="https://demo.retailcrm.ru" />
|
||||||
<server name="CRM_API_KEY" value="bar" />
|
<server name="CRM_API_KEY" value="nSBFWecViONG5c96wUQQgZzHkilTnaa6" />
|
||||||
<server name="CRM_SITE" value="zoo" />
|
<server name="CRM_USER_ID" value="1" />
|
||||||
<server name="CRM_STORE" value="moo" />
|
|
||||||
<server name="CRM_PACK_ITEM" value="boo" />
|
|
||||||
<server name="CRM_PACK_QUANTITY" value="goo" />
|
|
||||||
</php>
|
</php>
|
||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
|
@ -1,15 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* API client customers test 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/ApiVersion4
|
||||||
|
*/
|
||||||
|
|
||||||
namespace RetailCrm\Tests;
|
namespace RetailCrm\Tests;
|
||||||
|
|
||||||
use RetailCrm\Test\TestCase;
|
use RetailCrm\Test\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ApiClientCustomersTest
|
||||||
|
*
|
||||||
|
* @category RetailCrm
|
||||||
|
* @package RetailCrm
|
||||||
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
|
*/
|
||||||
class ApiClientCustomersTest extends TestCase
|
class ApiClientCustomersTest extends TestCase
|
||||||
{
|
{
|
||||||
const FIRST_NAME = 'Иннокентий';
|
const FIRST_NAME = 'Иннокентий';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group customers
|
||||||
*/
|
*/
|
||||||
public function testCustomersCreate()
|
public function testCustomersCreate()
|
||||||
{
|
{
|
||||||
@ -32,7 +53,7 @@ class ApiClientCustomersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group unit
|
* @group customers
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testCustomersCreateExceptionEmpty()
|
public function testCustomersCreateExceptionEmpty()
|
||||||
@ -43,7 +64,7 @@ class ApiClientCustomersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group customers
|
||||||
* @depends testCustomersCreate
|
* @depends testCustomersCreate
|
||||||
*/
|
*/
|
||||||
public function testCustomersGet(array $ids)
|
public function testCustomersGet(array $ids)
|
||||||
@ -53,13 +74,13 @@ class ApiClientCustomersTest extends TestCase
|
|||||||
$response = $client->customersGet(678678678);
|
$response = $client->customersGet(678678678);
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(404, $response->getStatusCode());
|
$this->assertEquals(404, $response->getStatusCode());
|
||||||
$this->assertFalse($response->success);
|
$this->assertFalse($response->isSuccessful());
|
||||||
|
|
||||||
$response = $client->customersGet($ids['id'], 'id');
|
$response = $client->customersGet($ids['id'], 'id');
|
||||||
$customerById = $response->customer;
|
$customerById = $response->customer;
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertTrue($response->success);
|
$this->assertTrue($response->isSuccessful());
|
||||||
$this->assertEquals(self::FIRST_NAME, $response->customer['firstName']);
|
$this->assertEquals(self::FIRST_NAME, $response->customer['firstName']);
|
||||||
|
|
||||||
$response = $client->customersGet($ids['externalId'], 'externalId');
|
$response = $client->customersGet($ids['externalId'], 'externalId');
|
||||||
@ -69,7 +90,7 @@ class ApiClientCustomersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group unit
|
* @group customers
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testCustomersGetException()
|
public function testCustomersGetException()
|
||||||
@ -80,7 +101,7 @@ class ApiClientCustomersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group customers
|
||||||
* @depends testCustomersGet
|
* @depends testCustomersGet
|
||||||
*/
|
*/
|
||||||
public function testCustomersEdit(array $ids)
|
public function testCustomersEdit(array $ids)
|
||||||
@ -103,19 +124,11 @@ class ApiClientCustomersTest extends TestCase
|
|||||||
));
|
));
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertTrue($response->success);
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
|
||||||
$response = $client->customersEdit(array(
|
|
||||||
'externalId' => 'c-edit-' . time(),
|
|
||||||
'lastName' => '12345',
|
|
||||||
));
|
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
|
||||||
$this->assertTrue($response->success);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group unit
|
* @group customers
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testCustomersEditExceptionEmpty()
|
public function testCustomersEditExceptionEmpty()
|
||||||
@ -126,7 +139,7 @@ class ApiClientCustomersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group unit
|
* @group customers
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testCustomersEditException()
|
public function testCustomersEditException()
|
||||||
@ -137,7 +150,7 @@ class ApiClientCustomersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group customers
|
||||||
*/
|
*/
|
||||||
public function testCustomersList()
|
public function testCustomersList()
|
||||||
{
|
{
|
||||||
@ -164,7 +177,7 @@ class ApiClientCustomersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group unit
|
* @group customers
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testCustomersFixExternalIdsException()
|
public function testCustomersFixExternalIdsException()
|
||||||
@ -175,7 +188,7 @@ class ApiClientCustomersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group customers
|
||||||
*/
|
*/
|
||||||
public function testCustomersFixExternalIds()
|
public function testCustomersFixExternalIds()
|
||||||
{
|
{
|
||||||
@ -225,7 +238,7 @@ class ApiClientCustomersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group unit
|
* @group customers
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testCustomersUploadExceptionEmpty()
|
public function testCustomersUploadExceptionEmpty()
|
||||||
@ -236,7 +249,7 @@ class ApiClientCustomersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group customers
|
||||||
*/
|
*/
|
||||||
public function testCustomersUpload()
|
public function testCustomersUpload()
|
||||||
{
|
{
|
||||||
|
@ -1,15 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* API client orders test 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/ApiVersion4
|
||||||
|
*/
|
||||||
|
|
||||||
namespace RetailCrm\Tests;
|
namespace RetailCrm\Tests;
|
||||||
|
|
||||||
use RetailCrm\Test\TestCase;
|
use RetailCrm\Test\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ApiClientOrdersTest
|
||||||
|
*
|
||||||
|
* @category RetailCrm
|
||||||
|
* @package RetailCrm
|
||||||
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
|
*/
|
||||||
class ApiClientOrdersTest extends TestCase
|
class ApiClientOrdersTest extends TestCase
|
||||||
{
|
{
|
||||||
const FIRST_NAME = 'Иннокентий';
|
const FIRST_NAME = 'Иннокентий';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group orders
|
||||||
*/
|
*/
|
||||||
public function testOrdersCreate()
|
public function testOrdersCreate()
|
||||||
{
|
{
|
||||||
@ -32,7 +53,7 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group unit
|
* @group orders
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testOrdersCreateExceptionEmpty()
|
public function testOrdersCreateExceptionEmpty()
|
||||||
@ -43,7 +64,7 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group orders
|
||||||
* @depends testOrdersCreate
|
* @depends testOrdersCreate
|
||||||
*/
|
*/
|
||||||
public function testOrdersStatuses(array $ids)
|
public function testOrdersStatuses(array $ids)
|
||||||
@ -53,19 +74,19 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
$response = $client->ordersStatuses();
|
$response = $client->ordersStatuses();
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(400, $response->getStatusCode());
|
$this->assertEquals(400, $response->getStatusCode());
|
||||||
$this->assertFalse($response->success);
|
$this->assertFalse($response->isSuccessful());
|
||||||
|
|
||||||
$response = $client->ordersStatuses(array(), array('asdf'));
|
$response = $client->ordersStatuses(array(), array('asdf'));
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertTrue($response->success);
|
$this->assertTrue($response->isSuccessful());
|
||||||
$orders = $response->orders;
|
$orders = $response->orders;
|
||||||
$this->assertEquals(0, sizeof($orders));
|
$this->assertEquals(0, sizeof($orders));
|
||||||
|
|
||||||
$response = $client->ordersStatuses(array(), array($ids['externalId']));
|
$response = $client->ordersStatuses(array(), array($ids['externalId']));
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertTrue($response->success);
|
$this->assertTrue($response->isSuccessful());
|
||||||
$orders = $response->orders;
|
$orders = $response->orders;
|
||||||
$this->assertEquals(1, sizeof($orders));
|
$this->assertEquals(1, sizeof($orders));
|
||||||
$this->assertEquals('new', $orders[0]['status']);
|
$this->assertEquals('new', $orders[0]['status']);
|
||||||
@ -73,20 +94,20 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
$response = $client->ordersStatuses(array($ids['id']), array($ids['externalId']));
|
$response = $client->ordersStatuses(array($ids['id']), array($ids['externalId']));
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertTrue($response->success);
|
$this->assertTrue($response->isSuccessful());
|
||||||
$orders = $response->orders;
|
$orders = $response->orders;
|
||||||
$this->assertEquals(1, sizeof($orders));
|
$this->assertEquals(1, sizeof($orders));
|
||||||
|
|
||||||
$response = $client->ordersStatuses(array($ids['id']));
|
$response = $client->ordersStatuses(array($ids['id']));
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertTrue($response->success);
|
$this->assertTrue($response->isSuccessful());
|
||||||
$orders = $response->orders;
|
$orders = $response->orders;
|
||||||
$this->assertEquals(1, sizeof($orders));
|
$this->assertEquals(1, sizeof($orders));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group orders
|
||||||
* @depends testOrdersCreate
|
* @depends testOrdersCreate
|
||||||
*/
|
*/
|
||||||
public function testOrdersGet(array $ids)
|
public function testOrdersGet(array $ids)
|
||||||
@ -96,13 +117,13 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
$response = $client->ordersGet(678678678);
|
$response = $client->ordersGet(678678678);
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(404, $response->getStatusCode());
|
$this->assertEquals(404, $response->getStatusCode());
|
||||||
$this->assertFalse($response->success);
|
$this->assertFalse($response->isSuccessful());
|
||||||
|
|
||||||
$response = $client->ordersGet($ids['id'], 'id');
|
$response = $client->ordersGet($ids['id'], 'id');
|
||||||
$orderById = $response->order;
|
$orderById = $response->order;
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertTrue($response->success);
|
$this->assertTrue($response->isSuccessful());
|
||||||
$this->assertEquals(self::FIRST_NAME, $response->order['firstName']);
|
$this->assertEquals(self::FIRST_NAME, $response->order['firstName']);
|
||||||
|
|
||||||
$response = $client->ordersGet($ids['externalId'], 'externalId');
|
$response = $client->ordersGet($ids['externalId'], 'externalId');
|
||||||
@ -112,7 +133,7 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group unit
|
* @group orders
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testOrdersGetException()
|
public function testOrdersGetException()
|
||||||
@ -123,7 +144,7 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group orders
|
||||||
* @depends testOrdersGet
|
* @depends testOrdersGet
|
||||||
*/
|
*/
|
||||||
public function testOrdersEdit(array $ids)
|
public function testOrdersEdit(array $ids)
|
||||||
@ -146,19 +167,11 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
));
|
));
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertTrue($response->success);
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
|
||||||
$response = $client->ordersEdit(array(
|
|
||||||
'externalId' => time(),
|
|
||||||
'lastName' => '12345',
|
|
||||||
));
|
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
|
||||||
$this->assertTrue($response->success);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group unit
|
* @group orders
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testOrdersEditExceptionEmpty()
|
public function testOrdersEditExceptionEmpty()
|
||||||
@ -169,7 +182,7 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group unit
|
* @group orders
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testOrdersEditException()
|
public function testOrdersEditException()
|
||||||
@ -180,7 +193,7 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group orders
|
||||||
*/
|
*/
|
||||||
public function testOrdersHistory()
|
public function testOrdersHistory()
|
||||||
{
|
{
|
||||||
@ -189,19 +202,11 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
$response = $client->ordersHistory();
|
$response = $client->ordersHistory();
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertTrue($response->success);
|
$this->assertTrue($response->isSuccessful());
|
||||||
$this->assertTrue(
|
|
||||||
isset($response['orders']),
|
|
||||||
'API returns orders history'
|
|
||||||
);
|
|
||||||
$this->assertTrue(
|
|
||||||
isset($response['generatedAt']),
|
|
||||||
'API returns generatedAt in orders history'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group orders
|
||||||
*/
|
*/
|
||||||
public function testOrdersList()
|
public function testOrdersList()
|
||||||
{
|
{
|
||||||
@ -221,14 +226,10 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
|
|
||||||
$response = $client->ordersList(array('paymentStatus' => 'paid'), 1);
|
$response = $client->ordersList(array('paymentStatus' => 'paid'), 1);
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertTrue(
|
|
||||||
$response->isSuccessful(),
|
|
||||||
'API returns orders list'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group unit
|
* @group orders
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testOrdersFixExternalIdsException()
|
public function testOrdersFixExternalIdsException()
|
||||||
@ -239,7 +240,7 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group orders
|
||||||
] */
|
] */
|
||||||
public function testOrdersFixExternalIds()
|
public function testOrdersFixExternalIds()
|
||||||
{
|
{
|
||||||
@ -283,7 +284,7 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group unit
|
* @group orders
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testOrdersUploadExceptionEmpty()
|
public function testOrdersUploadExceptionEmpty()
|
||||||
@ -294,7 +295,7 @@ class ApiClientOrdersTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group orders
|
||||||
*/
|
*/
|
||||||
public function testOrdersUpload()
|
public function testOrdersUpload()
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* API client packs test 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/ApiVersion4
|
||||||
|
*/
|
||||||
|
|
||||||
namespace RetailCrm\Tests;
|
namespace RetailCrm\Tests;
|
||||||
|
|
||||||
use RetailCrm\Test\TestCase;
|
use RetailCrm\Test\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ApiClientPacksTest
|
||||||
|
*
|
||||||
|
* @category RetailCrm
|
||||||
|
* @package RetailCrm
|
||||||
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
|
*/
|
||||||
class ApiClientPacksTest extends TestCase
|
class ApiClientPacksTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* Test packs history
|
||||||
|
*
|
||||||
|
* @group packs
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testOrdersPacksHistory()
|
public function testOrdersPacksHistory()
|
||||||
{
|
{
|
||||||
@ -28,32 +52,17 @@ class ApiClientPacksTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* Test packs failed create
|
||||||
*/
|
*
|
||||||
public function testOrdersPacksCreate()
|
* @group packs
|
||||||
{
|
* @return void
|
||||||
$client = static::getApiClient();
|
|
||||||
$pack = array(
|
|
||||||
'itemId' => $_SERVER['CRM_PACK_ITEM'],
|
|
||||||
'quantity' => $_SERVER['CRM_PACK_QUANTITY'],
|
|
||||||
'store' => $_SERVER['CRM_STORE']
|
|
||||||
);
|
|
||||||
|
|
||||||
$response = $client->ordersPacksCreate($pack);
|
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
|
||||||
$this->assertTrue($response->success);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group integration
|
|
||||||
*/
|
*/
|
||||||
public function testOrdersPacksCreateFailed()
|
public function testOrdersPacksCreateFailed()
|
||||||
{
|
{
|
||||||
$client = static::getApiClient();
|
$client = static::getApiClient();
|
||||||
$pack = array(
|
$pack = array(
|
||||||
'itemId' => 12,
|
'itemId' => 12,
|
||||||
'store' => $_SERVER['CRM_STORE'],
|
'store' => 'test',
|
||||||
'quantity' => 2
|
'quantity' => 2
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -62,30 +71,4 @@ class ApiClientPacksTest extends TestCase
|
|||||||
$this->assertEquals(400, $response->getStatusCode());
|
$this->assertEquals(400, $response->getStatusCode());
|
||||||
$this->assertFalse($response->success);
|
$this->assertFalse($response->success);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @group integration
|
|
||||||
*/
|
|
||||||
public function testOrdersPacksGet()
|
|
||||||
{
|
|
||||||
$client = static::getApiClient();
|
|
||||||
|
|
||||||
$response = $client->ordersPacksGet(1);
|
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
|
||||||
$this->assertTrue($response->success);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @group integration
|
|
||||||
*/
|
|
||||||
public function testOrdersPacksDelete()
|
|
||||||
{
|
|
||||||
$client = static::getApiClient();
|
|
||||||
|
|
||||||
$response = $client->ordersPacksDelete(1);
|
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
|
||||||
$this->assertTrue($response->success);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,34 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* API client references test 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/ApiVersion4
|
||||||
|
*/
|
||||||
|
|
||||||
namespace RetailCrm\Tests;
|
namespace RetailCrm\Tests;
|
||||||
|
|
||||||
use RetailCrm\Test\TestCase;
|
use RetailCrm\Test\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ApiClientReferenceTest
|
||||||
|
*
|
||||||
|
* @category RetailCrm
|
||||||
|
* @package RetailCrm
|
||||||
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
|
*/
|
||||||
class ApiClientReferenceTest extends TestCase
|
class ApiClientReferenceTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group reference
|
||||||
* @dataProvider getListDictionaries
|
* @dataProvider getListDictionaries
|
||||||
* @param $name
|
* @param $name
|
||||||
*/
|
*/
|
||||||
@ -25,7 +46,7 @@ class ApiClientReferenceTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group reference
|
||||||
* @dataProvider getEditDictionaries
|
* @dataProvider getEditDictionaries
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
@ -38,7 +59,7 @@ class ApiClientReferenceTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group reference
|
||||||
* @dataProvider getEditDictionaries
|
* @dataProvider getEditDictionaries
|
||||||
*/
|
*/
|
||||||
public function testEditing($name)
|
public function testEditing($name)
|
||||||
@ -69,7 +90,7 @@ class ApiClientReferenceTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group reference
|
||||||
* @group site
|
* @group site
|
||||||
*/
|
*/
|
||||||
public function testSiteEditing()
|
public function testSiteEditing()
|
||||||
|
@ -1,17 +1,50 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* API client store test 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/ApiVersion4
|
||||||
|
*/
|
||||||
|
|
||||||
namespace RetailCrm\Tests;
|
namespace RetailCrm\Tests;
|
||||||
|
|
||||||
use RetailCrm\Test\TestCase;
|
use RetailCrm\Test\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ApiClientStoreTest
|
* Class ApiClientStoreTest
|
||||||
* @package RetailCrm\Tests
|
*
|
||||||
|
* @category RetailCrm
|
||||||
|
* @package RetailCrm
|
||||||
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
*/
|
*/
|
||||||
class ApiClientStoreTest extends TestCase
|
class ApiClientStoreTest extends TestCase
|
||||||
{
|
{
|
||||||
|
const SNAME = 'Test Store';
|
||||||
|
const SCODE = 'test-store';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group store
|
||||||
|
*/
|
||||||
|
public function testStoreCreate()
|
||||||
|
{
|
||||||
|
$client = static::getApiClient();
|
||||||
|
|
||||||
|
$response = $client->storesEdit(array('name' => self::SNAME, 'code' => self::SCODE));
|
||||||
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
|
$this->assertTrue(in_array($response->getStatusCode(), array(200, 201)));
|
||||||
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group store
|
||||||
*/
|
*/
|
||||||
public function testStoreInventories()
|
public function testStoreInventories()
|
||||||
{
|
{
|
||||||
@ -20,7 +53,7 @@ class ApiClientStoreTest extends TestCase
|
|||||||
$response = $client->storeInventories();
|
$response = $client->storeInventories();
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertTrue($response->success);
|
$this->assertTrue($response->isSuccessful());
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
isset($response['offers']),
|
isset($response['offers']),
|
||||||
'API returns orders assembly history'
|
'API returns orders assembly history'
|
||||||
@ -28,7 +61,7 @@ class ApiClientStoreTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group unit
|
* @group store
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function testStoreInventoriesUploadExceptionEmpty()
|
public function testStoreInventoriesUploadExceptionEmpty()
|
||||||
@ -38,7 +71,7 @@ class ApiClientStoreTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group integration
|
* @group store
|
||||||
*/
|
*/
|
||||||
public function testStoreInventoriesUpload()
|
public function testStoreInventoriesUpload()
|
||||||
{
|
{
|
||||||
@ -52,7 +85,7 @@ class ApiClientStoreTest extends TestCase
|
|||||||
'externalId' => $externalIdA,
|
'externalId' => $externalIdA,
|
||||||
'stores' => array(
|
'stores' => array(
|
||||||
array(
|
array(
|
||||||
'code' => $_SERVER['CRM_STORE'],
|
'code' => self::SCODE,
|
||||||
'available' => 10,
|
'available' => 10,
|
||||||
'purchasePrice' => 1700
|
'purchasePrice' => 1700
|
||||||
)
|
)
|
||||||
@ -62,13 +95,14 @@ class ApiClientStoreTest extends TestCase
|
|||||||
'externalId' => $externalIdB,
|
'externalId' => $externalIdB,
|
||||||
'stores' => array(
|
'stores' => array(
|
||||||
array(
|
array(
|
||||||
'code' => $_SERVER['CRM_STORE'],
|
'code' => self::SCODE,
|
||||||
'available' => 20,
|
'available' => 20,
|
||||||
'purchasePrice' => 1500
|
'purchasePrice' => 1500
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertTrue($response->isSuccessful());
|
$this->assertTrue($response->isSuccessful());
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* API client telephony test 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/ApiVersion4
|
||||||
|
*/
|
||||||
|
|
||||||
namespace RetailCrm\Tests;
|
namespace RetailCrm\Tests;
|
||||||
|
|
||||||
use RetailCrm\Test\TestCase;
|
use RetailCrm\Test\TestCase;
|
||||||
@ -10,33 +22,138 @@ use RetailCrm\Test\TestCase;
|
|||||||
* @package RetailCrm\Tests
|
* @package RetailCrm\Tests
|
||||||
* @author RetailCrm <integration@retailcrm.ru>
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
* @license https://opensource.org/licenses/MIT MIT License
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion3
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
*/
|
*/
|
||||||
class ApiClientTelephonyTest extends TestCase
|
class ApiClientTelephonyTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const TEL_CODE = 'telephony-code';
|
||||||
|
const TEL_CLIENT = '123';
|
||||||
|
const TEL_IMAGE = 'http://www.mec.ph/horizon/wp-content/uploads/2011/11/telephony.svg';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings test
|
* Settings Edit test
|
||||||
*
|
*
|
||||||
* @group integration
|
* @group telephony
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testTelephonySettings()
|
public function testTelephonySettingsEdit()
|
||||||
{
|
{
|
||||||
$client = static::getApiClient();
|
$client = static::getApiClient();
|
||||||
|
|
||||||
$code = 'telphin';
|
$response = $client->telephonySettingsEdit(
|
||||||
$clientId = '1';
|
self::TEL_CODE,
|
||||||
$active = true;
|
self::TEL_CLIENT,
|
||||||
|
true,
|
||||||
|
'TestTelephony',
|
||||||
|
false,
|
||||||
|
self::TEL_IMAGE,
|
||||||
|
array(array('userId' => $_SERVER['CRM_USER_ID'], 'code' => '101')),
|
||||||
|
array(array('siteCode' => 'api-client-php', 'externalPhone' => '+74950000000'))
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
|
$this->assertTrue(in_array($response->getStatusCode(), array(200, 201)));
|
||||||
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings Get test
|
||||||
|
*
|
||||||
|
* @group telephony
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testTelephonySettingsGet()
|
||||||
|
{
|
||||||
|
$client = static::getApiClient();
|
||||||
|
|
||||||
|
$response = $client->telephonySettingsGet(self::TEL_CODE);
|
||||||
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event test
|
||||||
|
*
|
||||||
|
* @group telephony
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testTelephonyEvent()
|
||||||
|
{
|
||||||
|
$client = static::getApiClient();
|
||||||
|
|
||||||
|
$response = $client->telephonyCallEvent(
|
||||||
|
'+79999999999',
|
||||||
|
'in',
|
||||||
|
array('101'),
|
||||||
|
'failed',
|
||||||
|
'+74950000000'
|
||||||
|
|
||||||
$response = $client->telephonySettings(
|
|
||||||
$code,
|
|
||||||
$clientId,
|
|
||||||
$active
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
$this->assertTrue($response->success);
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload test
|
||||||
|
*
|
||||||
|
* @group telephony
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testTelephonyUpload()
|
||||||
|
{
|
||||||
|
$client = static::getApiClient();
|
||||||
|
|
||||||
|
$response = $client->telephonyCallsUpload(
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'date' => '2016-07-22 00:18:00',
|
||||||
|
'type' => 'in',
|
||||||
|
'phone' => '+79999999999',
|
||||||
|
'code' => '101',
|
||||||
|
'result' => 'answered',
|
||||||
|
'externalId' => rand(10,100),
|
||||||
|
'recordUrl' => 'https://dl.dropboxusercontent.com/u/15492750/dontry2bfunny.mp3'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'date' => '2016-07-22 00:24:00',
|
||||||
|
'type' => 'in',
|
||||||
|
'phone' => '+79999999999',
|
||||||
|
'code' => '101',
|
||||||
|
'result' => 'answered',
|
||||||
|
'externalId' => rand(10,100),
|
||||||
|
'recordUrl' => 'https://dl.dropboxusercontent.com/u/15492750/donttytobefunny.mp3'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manager test
|
||||||
|
*
|
||||||
|
* @group telephony
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testTelephonyManager()
|
||||||
|
{
|
||||||
|
$client = static::getApiClient();
|
||||||
|
|
||||||
|
$response = $client->telephonyCallManager('+79999999999', 1);
|
||||||
|
|
||||||
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
$this->assertTrue($response->isSuccessful());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* API client test 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/ApiVersion4
|
||||||
|
*/
|
||||||
|
|
||||||
namespace RetailCrm\Tests;
|
namespace RetailCrm\Tests;
|
||||||
|
|
||||||
use RetailCrm\Test\TestCase;
|
use RetailCrm\Test\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ApiClientTest
|
||||||
|
*
|
||||||
|
* @category RetailCrm
|
||||||
|
* @package RetailCrm
|
||||||
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
|
*/
|
||||||
class ApiClientTest extends TestCase
|
class ApiClientTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -15,15 +36,4 @@ class ApiClientTest extends TestCase
|
|||||||
|
|
||||||
$this->assertInstanceOf('RetailCrm\ApiClient', $client);
|
$this->assertInstanceOf('RetailCrm\ApiClient', $client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @group integration
|
|
||||||
*/
|
|
||||||
public function testStatisticUpdate()
|
|
||||||
{
|
|
||||||
$client = static::getApiClient();
|
|
||||||
|
|
||||||
$response = $client->statisticUpdate();
|
|
||||||
$this->assertTrue($response->isSuccessful());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
55
tests/RetailCrm/Tests/ApiClientUsersTest.php
Normal file
55
tests/RetailCrm/Tests/ApiClientUsersTest.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* API client users test 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/ApiVersion4
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace RetailCrm\Tests;
|
||||||
|
|
||||||
|
use RetailCrm\Test\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ApiClientUsersTest
|
||||||
|
*
|
||||||
|
* @category RetailCrm
|
||||||
|
* @package RetailCrm
|
||||||
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
|
*/
|
||||||
|
class ApiClientUsersTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @group users
|
||||||
|
*/
|
||||||
|
public function testUsersList()
|
||||||
|
{
|
||||||
|
$client = static::getApiClient();
|
||||||
|
|
||||||
|
$response = $client->usersList();
|
||||||
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
|
$this->assertTrue(in_array($response->getStatusCode(), array(200, 201)));
|
||||||
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group users
|
||||||
|
*/
|
||||||
|
public function testUsersGet()
|
||||||
|
{
|
||||||
|
$client = static::getApiClient();
|
||||||
|
|
||||||
|
$response = $client->usersGet($_SERVER["CRM_USER_ID"]);
|
||||||
|
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||||
|
$this->assertTrue(in_array($response->getStatusCode(), array(200, 201)));
|
||||||
|
$this->assertTrue($response->isSuccessful());
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* API client test 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/ApiVersion4
|
||||||
|
*/
|
||||||
|
|
||||||
namespace RetailCrm\Tests\Http;
|
namespace RetailCrm\Tests\Http;
|
||||||
|
|
||||||
use RetailCrm\Test\TestCase;
|
use RetailCrm\Test\TestCase;
|
||||||
use RetailCrm\ApiClient;
|
use RetailCrm\ApiClient;
|
||||||
use RetailCrm\Http\Client;
|
use RetailCrm\Http\Client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ClientTest
|
||||||
|
*
|
||||||
|
* @category RetailCrm
|
||||||
|
* @package RetailCrm
|
||||||
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
|
*/
|
||||||
class ClientTest extends TestCase
|
class ClientTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -25,6 +46,7 @@ class ClientTest extends TestCase
|
|||||||
public function testHttpRequiring()
|
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, array('apiKey' => '123'));
|
||||||
|
return $client;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +66,7 @@ class ClientTest extends TestCase
|
|||||||
public function testMakeRequestWrongUrl()
|
public function testMakeRequestWrongUrl()
|
||||||
{
|
{
|
||||||
$client = new Client('https://asdf.df', array());
|
$client = new Client('https://asdf.df', array());
|
||||||
$client->makeRequest('/a', Client::METHOD_GET, array(), 1);
|
$client->makeRequest('/a', Client::METHOD_GET, array());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,10 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP version 5.3
|
||||||
|
*
|
||||||
|
* API client response test 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/ApiVersion4
|
||||||
|
*/
|
||||||
|
|
||||||
namespace RetailCrm\Tests\Response;
|
namespace RetailCrm\Tests\Response;
|
||||||
|
|
||||||
use RetailCrm\Test\TestCase;
|
use RetailCrm\Test\TestCase;
|
||||||
use RetailCrm\Response\ApiResponse;
|
use RetailCrm\Response\ApiResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ApiResponseTest
|
||||||
|
*
|
||||||
|
* @category RetailCrm
|
||||||
|
* @package RetailCrm
|
||||||
|
* @author RetailCrm <integration@retailcrm.ru>
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||||
|
*/
|
||||||
class ApiResponseTest extends TestCase
|
class ApiResponseTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user