2017-06-22 00:55:08 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 5.4
|
|
|
|
*
|
2017-06-22 16:42:42 +03:00
|
|
|
* Delivery
|
2017-06-22 00:55:08 +03:00
|
|
|
*
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm
|
|
|
|
* @author RetailCrm <integration@retailcrm.ru>
|
|
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
2019-08-30 14:10:52 +03:00
|
|
|
* @link https://help.retailcrm.ru/Developers/ApiVersion5
|
2017-06-22 00:55:08 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace RetailCrm\Methods\V4;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 5.4
|
|
|
|
*
|
2017-06-22 16:42:42 +03:00
|
|
|
* Delivery class
|
2017-06-22 00:55:08 +03:00
|
|
|
*
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm
|
|
|
|
* @author RetailCrm <integration@retailcrm.ru>
|
|
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
2019-08-30 14:10:52 +03:00
|
|
|
* @link https://help.retailcrm.ru/Developers/ApiVersion5
|
2017-06-22 00:55:08 +03:00
|
|
|
*/
|
|
|
|
trait Delivery
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Get delivery settings
|
|
|
|
*
|
|
|
|
* @param string $code
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function deliverySettingsGet($code)
|
|
|
|
{
|
|
|
|
if (empty($code)) {
|
|
|
|
throw new \InvalidArgumentException('Parameter `code` must be set');
|
|
|
|
}
|
|
|
|
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-06-22 00:55:08 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
"/delivery/generic/setting/$code",
|
|
|
|
"GET"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delivery tracking update
|
|
|
|
*
|
|
|
|
* @param string $code
|
|
|
|
* @param array $statusUpdate
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\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'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-06-22 00:55:08 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/delivery/generic/%s/tracking', $code),
|
|
|
|
"POST",
|
|
|
|
['statusUpdate' => json_encode($statusUpdate)]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|