diff --git a/README.md b/README.md index afaa14c..d8bab15 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/README.ru.md b/README.ru.md index 5652dc6..369d52f 100644 --- a/README.ru.md +++ b/README.ru.md @@ -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). diff --git a/composer.json b/composer.json index 11898b4..a12d81c 100644 --- a/composer.json +++ b/composer.json @@ -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" }, diff --git a/lib/RetailCrm/ApiClient.php b/lib/RetailCrm/ApiClient.php index 74fece3..f1c3f8b 100644 --- a/lib/RetailCrm/ApiClient.php +++ b/lib/RetailCrm/ApiClient.php @@ -321,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 * @@ -498,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 * @@ -811,6 +869,86 @@ class ApiClient ); } + /** + * 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 *