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
|
||||
|
||||
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)
|
||||
|
||||
@ -15,7 +15,7 @@ Use [API documentation](http://retailcrm.github.io/api-client-php)
|
||||
|
||||
2) Run into your project directory:
|
||||
```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.
|
||||
|
@ -1,6 +1,6 @@
|
||||
# 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).
|
||||
|
||||
@ -15,7 +15,7 @@ PHP-клиент для работы с [retailCRM API](http://www.retailcrm.ru/
|
||||
|
||||
2) Выполните в папке проекта:
|
||||
```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/`. При отсутствии файла конфига или папки с вендорами они будут созданы.
|
||||
|
@ -15,16 +15,6 @@
|
||||
"php": ">=5.3.0",
|
||||
"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": {
|
||||
"email": "support@retailcrm.pro"
|
||||
},
|
||||
@ -33,7 +23,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0.x-dev"
|
||||
"dev-master": "4.0.x-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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;
|
||||
@ -26,12 +26,12 @@ use RetailCrm\Response\ApiResponse;
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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
|
||||
{
|
||||
|
||||
const VERSION = 'v3';
|
||||
const VERSION = 'v4';
|
||||
|
||||
protected $client;
|
||||
|
||||
@ -53,7 +53,7 @@ class ApiClient
|
||||
*/
|
||||
public function __construct($url, $apiKey, $site = null)
|
||||
{
|
||||
if ('/' !== substr($url, strlen($url) - 1, 1)) {
|
||||
if ('/' !== $url[strlen($url) - 1]) {
|
||||
$url .= '/';
|
||||
}
|
||||
|
||||
@ -63,6 +63,56 @@ class ApiClient
|
||||
$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
|
||||
*
|
||||
@ -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
|
||||
*
|
||||
@ -210,10 +213,8 @@ class ApiClient
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function ordersStatuses(
|
||||
array $ids = array(),
|
||||
array $externalIds = array()
|
||||
) {
|
||||
public function ordersStatuses(array $ids = array(), array $externalIds = array())
|
||||
{
|
||||
$parameters = array();
|
||||
|
||||
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
|
||||
*
|
||||
@ -333,11 +363,8 @@ class ApiClient
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function customersList(
|
||||
array $filter = array(),
|
||||
$page = null,
|
||||
$limit = null
|
||||
) {
|
||||
public function customersList(array $filter = array(), $page = null, $limit = null)
|
||||
{
|
||||
$parameters = array();
|
||||
|
||||
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
|
||||
*
|
||||
@ -513,11 +569,8 @@ class ApiClient
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function ordersPacksList(
|
||||
array $filter = array(),
|
||||
$page = null,
|
||||
$limit = null
|
||||
) {
|
||||
public function ordersPacksList(array $filter = array(), $page = null, $limit = null)
|
||||
{
|
||||
$parameters = array();
|
||||
|
||||
if (count($filter)) {
|
||||
@ -577,11 +630,8 @@ class ApiClient
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function ordersPacksHistory(
|
||||
array $filter = array(),
|
||||
$page = null,
|
||||
$limit = null
|
||||
) {
|
||||
public function ordersPacksHistory(array $filter = array(), $page = null, $limit = null)
|
||||
{
|
||||
$parameters = array();
|
||||
|
||||
if (count($filter)) {
|
||||
@ -687,11 +737,8 @@ class ApiClient
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function storeInventories(
|
||||
array $filter = array(),
|
||||
$page = null,
|
||||
$limit = null
|
||||
) {
|
||||
public function storeInventories(array $filter = array(), $page = null, $limit = null)
|
||||
{
|
||||
$parameters = array();
|
||||
|
||||
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
|
||||
*
|
||||
@ -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
|
||||
*
|
||||
@ -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 $clientId client id
|
||||
* @param boolean $active telephony activity
|
||||
* @param mixed $makeCallUrl service init url
|
||||
* @param mixed $name service name
|
||||
* @param mixed $makeCallUrl service init url
|
||||
* @param mixed $image service logo url(svg file)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
* @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 telephonySettings(
|
||||
public function telephonySettingsEdit(
|
||||
$code,
|
||||
$clientId,
|
||||
$active = false,
|
||||
$makeCallUrl = 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)) {
|
||||
throw new \InvalidArgumentException('Code must be set');
|
||||
}
|
||||
@ -1254,81 +1500,101 @@ class ApiClient
|
||||
throw new \InvalidArgumentException('name must be set');
|
||||
}
|
||||
|
||||
if (isset($makeCallUrl)) {
|
||||
$parameters['makeCallUrl'] = $makeCallUrl;
|
||||
}
|
||||
|
||||
if (isset($name)) {
|
||||
$parameters['name'] = $name;
|
||||
}
|
||||
|
||||
if (isset($makeCallUrl)) {
|
||||
$parameters['makeCallUrl'] = $makeCallUrl;
|
||||
}
|
||||
|
||||
if (isset($image)) {
|
||||
$parameters['image'] = $image;
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
"/telephony/setting/$code",
|
||||
Client::METHOD_POST,
|
||||
$parameters
|
||||
);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
"/telephony/setting/$code/edit",
|
||||
Client::METHOD_POST,
|
||||
array('configuration' => json_encode($parameters))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call event
|
||||
*
|
||||
* @param string $phone phone number
|
||||
* @param string $type call type
|
||||
* @param string $code additional phone code
|
||||
* @param string $status call status
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
* @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, $code, $status)
|
||||
public function telephonyCallEvent(
|
||||
$phone,
|
||||
$type,
|
||||
$codes,
|
||||
$hangupStatus,
|
||||
$externalPhone = null,
|
||||
$webAnalyticsData = array()
|
||||
)
|
||||
{
|
||||
if (!isset($phone)) {
|
||||
throw new \InvalidArgumentException('Phone number must be set');
|
||||
}
|
||||
|
||||
$parameters['phone'] = $phone;
|
||||
|
||||
if (!isset($type)) {
|
||||
throw new \InvalidArgumentException('Type must be set (in|out|hangup)');
|
||||
}
|
||||
|
||||
$parameters['type'] = $type;
|
||||
|
||||
if (!isset($code)) {
|
||||
throw new \InvalidArgumentException('Code must be set');
|
||||
if (empty($codes)) {
|
||||
throw new \InvalidArgumentException('Codes array must be set');
|
||||
}
|
||||
|
||||
$parameters['code'] = $code;
|
||||
$parameters['hangupStatus'] = $status;
|
||||
$parameters['phone'] = $phone;
|
||||
$parameters['type'] = $type;
|
||||
$parameters['codes'] = $codes;
|
||||
$parameters['hangupStatus'] = $hangupStatus;
|
||||
$parameters['callExternalId'] = $externalPhone;
|
||||
$parameters['webAnalyticsData'] = $webAnalyticsData;
|
||||
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/telephony/call/event',
|
||||
Client::METHOD_POST,
|
||||
$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
|
||||
*
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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;
|
||||
@ -23,7 +23,7 @@ namespace RetailCrm\Exception;
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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
|
||||
{
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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;
|
||||
@ -23,7 +23,7 @@ namespace RetailCrm\Exception;
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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
|
||||
{
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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;
|
||||
@ -27,7 +27,7 @@ use RetailCrm\Response\ApiResponse;
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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
|
||||
{
|
||||
|
@ -9,7 +9,7 @@
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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;
|
||||
@ -25,7 +25,7 @@ use RetailCrm\Exception\InvalidJsonException;
|
||||
* @package RetailCrm
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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
|
||||
{
|
||||
|
@ -6,16 +6,13 @@
|
||||
colors="true"
|
||||
verbose="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="true">
|
||||
stopOnFailure="false">
|
||||
|
||||
<!-- Dummy values used to provide credentials. No need to change these. -->
|
||||
<php>
|
||||
<server name="CRM_URL" value="foo" />
|
||||
<server name="CRM_API_KEY" value="bar" />
|
||||
<server name="CRM_SITE" value="zoo" />
|
||||
<server name="CRM_STORE" value="moo" />
|
||||
<server name="CRM_PACK_ITEM" value="boo" />
|
||||
<server name="CRM_PACK_QUANTITY" value="goo" />
|
||||
<server name="CRM_URL" value="https://demo.retailcrm.ru" />
|
||||
<server name="CRM_API_KEY" value="nSBFWecViONG5c96wUQQgZzHkilTnaa6" />
|
||||
<server name="CRM_USER_ID" value="1" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
|
@ -1,15 +1,36 @@
|
||||
<?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;
|
||||
|
||||
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
|
||||
{
|
||||
const FIRST_NAME = 'Иннокентий';
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group customers
|
||||
*/
|
||||
public function testCustomersCreate()
|
||||
{
|
||||
@ -32,7 +53,7 @@ class ApiClientCustomersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group customers
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testCustomersCreateExceptionEmpty()
|
||||
@ -43,7 +64,7 @@ class ApiClientCustomersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group customers
|
||||
* @depends testCustomersCreate
|
||||
*/
|
||||
public function testCustomersGet(array $ids)
|
||||
@ -53,13 +74,13 @@ class ApiClientCustomersTest extends TestCase
|
||||
$response = $client->customersGet(678678678);
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(404, $response->getStatusCode());
|
||||
$this->assertFalse($response->success);
|
||||
$this->assertFalse($response->isSuccessful());
|
||||
|
||||
$response = $client->customersGet($ids['id'], 'id');
|
||||
$customerById = $response->customer;
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
$this->assertEquals(self::FIRST_NAME, $response->customer['firstName']);
|
||||
|
||||
$response = $client->customersGet($ids['externalId'], 'externalId');
|
||||
@ -69,7 +90,7 @@ class ApiClientCustomersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group customers
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testCustomersGetException()
|
||||
@ -80,7 +101,7 @@ class ApiClientCustomersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group customers
|
||||
* @depends testCustomersGet
|
||||
*/
|
||||
public function testCustomersEdit(array $ids)
|
||||
@ -103,19 +124,11 @@ class ApiClientCustomersTest extends TestCase
|
||||
));
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
|
||||
$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);
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group customers
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testCustomersEditExceptionEmpty()
|
||||
@ -126,7 +139,7 @@ class ApiClientCustomersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group customers
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testCustomersEditException()
|
||||
@ -137,7 +150,7 @@ class ApiClientCustomersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group customers
|
||||
*/
|
||||
public function testCustomersList()
|
||||
{
|
||||
@ -164,7 +177,7 @@ class ApiClientCustomersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group customers
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testCustomersFixExternalIdsException()
|
||||
@ -175,7 +188,7 @@ class ApiClientCustomersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group customers
|
||||
*/
|
||||
public function testCustomersFixExternalIds()
|
||||
{
|
||||
@ -225,7 +238,7 @@ class ApiClientCustomersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group customers
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testCustomersUploadExceptionEmpty()
|
||||
@ -236,7 +249,7 @@ class ApiClientCustomersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group customers
|
||||
*/
|
||||
public function testCustomersUpload()
|
||||
{
|
||||
|
@ -1,15 +1,36 @@
|
||||
<?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;
|
||||
|
||||
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
|
||||
{
|
||||
const FIRST_NAME = 'Иннокентий';
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group orders
|
||||
*/
|
||||
public function testOrdersCreate()
|
||||
{
|
||||
@ -32,7 +53,7 @@ class ApiClientOrdersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group orders
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testOrdersCreateExceptionEmpty()
|
||||
@ -43,7 +64,7 @@ class ApiClientOrdersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group orders
|
||||
* @depends testOrdersCreate
|
||||
*/
|
||||
public function testOrdersStatuses(array $ids)
|
||||
@ -53,19 +74,19 @@ class ApiClientOrdersTest extends TestCase
|
||||
$response = $client->ordersStatuses();
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
$this->assertFalse($response->success);
|
||||
$this->assertFalse($response->isSuccessful());
|
||||
|
||||
$response = $client->ordersStatuses(array(), array('asdf'));
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
$orders = $response->orders;
|
||||
$this->assertEquals(0, sizeof($orders));
|
||||
|
||||
$response = $client->ordersStatuses(array(), array($ids['externalId']));
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
$orders = $response->orders;
|
||||
$this->assertEquals(1, sizeof($orders));
|
||||
$this->assertEquals('new', $orders[0]['status']);
|
||||
@ -73,20 +94,20 @@ class ApiClientOrdersTest extends TestCase
|
||||
$response = $client->ordersStatuses(array($ids['id']), array($ids['externalId']));
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
$orders = $response->orders;
|
||||
$this->assertEquals(1, sizeof($orders));
|
||||
|
||||
$response = $client->ordersStatuses(array($ids['id']));
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
$orders = $response->orders;
|
||||
$this->assertEquals(1, sizeof($orders));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group orders
|
||||
* @depends testOrdersCreate
|
||||
*/
|
||||
public function testOrdersGet(array $ids)
|
||||
@ -96,13 +117,13 @@ class ApiClientOrdersTest extends TestCase
|
||||
$response = $client->ordersGet(678678678);
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(404, $response->getStatusCode());
|
||||
$this->assertFalse($response->success);
|
||||
$this->assertFalse($response->isSuccessful());
|
||||
|
||||
$response = $client->ordersGet($ids['id'], 'id');
|
||||
$orderById = $response->order;
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
$this->assertEquals(self::FIRST_NAME, $response->order['firstName']);
|
||||
|
||||
$response = $client->ordersGet($ids['externalId'], 'externalId');
|
||||
@ -112,7 +133,7 @@ class ApiClientOrdersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group orders
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testOrdersGetException()
|
||||
@ -123,7 +144,7 @@ class ApiClientOrdersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group orders
|
||||
* @depends testOrdersGet
|
||||
*/
|
||||
public function testOrdersEdit(array $ids)
|
||||
@ -146,19 +167,11 @@ class ApiClientOrdersTest extends TestCase
|
||||
));
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
|
||||
$response = $client->ordersEdit(array(
|
||||
'externalId' => time(),
|
||||
'lastName' => '12345',
|
||||
));
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(201, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group orders
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testOrdersEditExceptionEmpty()
|
||||
@ -169,7 +182,7 @@ class ApiClientOrdersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group orders
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testOrdersEditException()
|
||||
@ -180,7 +193,7 @@ class ApiClientOrdersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group orders
|
||||
*/
|
||||
public function testOrdersHistory()
|
||||
{
|
||||
@ -189,19 +202,11 @@ class ApiClientOrdersTest extends TestCase
|
||||
$response = $client->ordersHistory();
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
$this->assertTrue(
|
||||
isset($response['orders']),
|
||||
'API returns orders history'
|
||||
);
|
||||
$this->assertTrue(
|
||||
isset($response['generatedAt']),
|
||||
'API returns generatedAt in orders history'
|
||||
);
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group orders
|
||||
*/
|
||||
public function testOrdersList()
|
||||
{
|
||||
@ -221,14 +226,10 @@ class ApiClientOrdersTest extends TestCase
|
||||
|
||||
$response = $client->ordersList(array('paymentStatus' => 'paid'), 1);
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertTrue(
|
||||
$response->isSuccessful(),
|
||||
'API returns orders list'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group orders
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testOrdersFixExternalIdsException()
|
||||
@ -239,7 +240,7 @@ class ApiClientOrdersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group orders
|
||||
] */
|
||||
public function testOrdersFixExternalIds()
|
||||
{
|
||||
@ -283,7 +284,7 @@ class ApiClientOrdersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group orders
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testOrdersUploadExceptionEmpty()
|
||||
@ -294,7 +295,7 @@ class ApiClientOrdersTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group orders
|
||||
*/
|
||||
public function testOrdersUpload()
|
||||
{
|
||||
|
@ -1,13 +1,37 @@
|
||||
<?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;
|
||||
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @group integration
|
||||
* Test packs history
|
||||
*
|
||||
* @group packs
|
||||
* @return void
|
||||
*/
|
||||
public function testOrdersPacksHistory()
|
||||
{
|
||||
@ -28,32 +52,17 @@ class ApiClientPacksTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
*/
|
||||
public function testOrdersPacksCreate()
|
||||
{
|
||||
$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
|
||||
* Test packs failed create
|
||||
*
|
||||
* @group packs
|
||||
* @return void
|
||||
*/
|
||||
public function testOrdersPacksCreateFailed()
|
||||
{
|
||||
$client = static::getApiClient();
|
||||
$pack = array(
|
||||
'itemId' => 12,
|
||||
'store' => $_SERVER['CRM_STORE'],
|
||||
'store' => 'test',
|
||||
'quantity' => 2
|
||||
);
|
||||
|
||||
@ -62,30 +71,4 @@ class ApiClientPacksTest extends TestCase
|
||||
$this->assertEquals(400, $response->getStatusCode());
|
||||
$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 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;
|
||||
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @group integration
|
||||
* @group reference
|
||||
* @dataProvider getListDictionaries
|
||||
* @param $name
|
||||
*/
|
||||
@ -25,7 +46,7 @@ class ApiClientReferenceTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group reference
|
||||
* @dataProvider getEditDictionaries
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
@ -38,7 +59,7 @@ class ApiClientReferenceTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group reference
|
||||
* @dataProvider getEditDictionaries
|
||||
*/
|
||||
public function testEditing($name)
|
||||
@ -69,7 +90,7 @@ class ApiClientReferenceTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group reference
|
||||
* @group site
|
||||
*/
|
||||
public function testSiteEditing()
|
||||
|
@ -1,17 +1,50 @@
|
||||
<?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;
|
||||
|
||||
use RetailCrm\Test\TestCase;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
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()
|
||||
{
|
||||
@ -20,7 +53,7 @@ class ApiClientStoreTest extends TestCase
|
||||
$response = $client->storeInventories();
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
$this->assertTrue($response->success);
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
$this->assertTrue(
|
||||
isset($response['offers']),
|
||||
'API returns orders assembly history'
|
||||
@ -28,7 +61,7 @@ class ApiClientStoreTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @group store
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testStoreInventoriesUploadExceptionEmpty()
|
||||
@ -38,7 +71,7 @@ class ApiClientStoreTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
* @group store
|
||||
*/
|
||||
public function testStoreInventoriesUpload()
|
||||
{
|
||||
@ -52,7 +85,7 @@ class ApiClientStoreTest extends TestCase
|
||||
'externalId' => $externalIdA,
|
||||
'stores' => array(
|
||||
array(
|
||||
'code' => $_SERVER['CRM_STORE'],
|
||||
'code' => self::SCODE,
|
||||
'available' => 10,
|
||||
'purchasePrice' => 1700
|
||||
)
|
||||
@ -62,13 +95,14 @@ class ApiClientStoreTest extends TestCase
|
||||
'externalId' => $externalIdB,
|
||||
'stores' => array(
|
||||
array(
|
||||
'code' => $_SERVER['CRM_STORE'],
|
||||
'code' => self::SCODE,
|
||||
'available' => 20,
|
||||
'purchasePrice' => 1500
|
||||
)
|
||||
)
|
||||
),
|
||||
));
|
||||
|
||||
$this->assertInstanceOf('RetailCrm\Response\ApiResponse', $response);
|
||||
$this->assertTrue($response->isSuccessful());
|
||||
}
|
||||
|
@ -1,5 +1,17 @@
|
||||
<?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;
|
||||
|
||||
use RetailCrm\Test\TestCase;
|
||||
@ -10,33 +22,138 @@ use RetailCrm\Test\TestCase;
|
||||
* @package RetailCrm\Tests
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @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
|
||||
{
|
||||
|
||||
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
|
||||
*/
|
||||
public function testTelephonySettings()
|
||||
public function testTelephonySettingsEdit()
|
||||
{
|
||||
$client = static::getApiClient();
|
||||
|
||||
$code = 'telphin';
|
||||
$clientId = '1';
|
||||
$active = true;
|
||||
$response = $client->telephonySettingsEdit(
|
||||
self::TEL_CODE,
|
||||
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->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 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;
|
||||
|
||||
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
|
||||
{
|
||||
/**
|
||||
@ -15,15 +36,4 @@ class ApiClientTest extends TestCase
|
||||
|
||||
$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 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;
|
||||
|
||||
use RetailCrm\Test\TestCase;
|
||||
use RetailCrm\ApiClient;
|
||||
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
|
||||
{
|
||||
/**
|
||||
@ -25,6 +46,7 @@ class ClientTest extends TestCase
|
||||
public function testHttpRequiring()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$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 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;
|
||||
|
||||
use RetailCrm\Test\TestCase;
|
||||
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
|
||||
{
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user