a18767bddc
* combine methods for orders & customer * update status method for users * custom fields|dictionaries * task methods * segments * product groups list methods, * orders payments * multi-version * customers notes methods
110 lines
2.9 KiB
PHP
110 lines
2.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* PHP version 5.4
|
|
*
|
|
* TaskTrait
|
|
*
|
|
* @category RetailCrm
|
|
* @package RetailCrm
|
|
* @author RetailCrm <integration@retailcrm.ru>
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
|
*/
|
|
|
|
namespace RetailCrm\Methods\V4;
|
|
|
|
/**
|
|
* PHP version 5.4
|
|
*
|
|
* TaskTrait class
|
|
*
|
|
* @category RetailCrm
|
|
* @package RetailCrm
|
|
* @author RetailCrm <integration@retailcrm.ru>
|
|
* @license https://opensource.org/licenses/MIT MIT License
|
|
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
|
*/
|
|
trait 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');
|
|
}
|
|
|
|
return $this->client->makeRequest(
|
|
"/delivery/generic/setting/$code",
|
|
"GET"
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Edit delivery configuration
|
|
*
|
|
* @param array $configuration
|
|
*
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
* @throws \InvalidArgumentException
|
|
*
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
*/
|
|
public function deliverySettingsEdit(array $configuration)
|
|
{
|
|
if (!count($configuration) || empty($configuration['code'])) {
|
|
throw new \InvalidArgumentException(
|
|
'Parameter `configuration` must contains a data & configuration `code` must be set'
|
|
);
|
|
}
|
|
|
|
return $this->client->makeRequest(
|
|
sprintf('/delivery/generic/setting/%s/edit', $configuration['code']),
|
|
"POST",
|
|
['configuration' => json_encode($configuration)]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Delivery tracking update
|
|
*
|
|
* @param string $code
|
|
* @param array $statusUpdate
|
|
*
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
* @throws \InvalidArgumentException
|
|
*
|
|
* @return \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'
|
|
);
|
|
}
|
|
|
|
return $this->client->makeRequest(
|
|
sprintf('/delivery/generic/%s/tracking', $code),
|
|
"POST",
|
|
['statusUpdate' => json_encode($statusUpdate)]
|
|
);
|
|
}
|
|
}
|