2017-06-22 00:55:08 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 5.4
|
|
|
|
*
|
2017-06-22 16:42:42 +03:00
|
|
|
* References
|
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;
|
|
|
|
|
|
|
|
use RetailCrm\Methods\V3\References as Previous;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 5.4
|
|
|
|
*
|
2017-06-22 16:42:42 +03:00
|
|
|
* References 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 References
|
|
|
|
{
|
|
|
|
use Previous;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get prices types
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function pricesTypes()
|
|
|
|
{
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-06-22 00:55:08 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/price-types',
|
|
|
|
"GET"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit price type
|
|
|
|
*
|
|
|
|
* @param array $data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function pricesTypesEdit(array $data)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('code', $data)) {
|
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!array_key_exists('name', $data)) {
|
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "name" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-06-22 00:55:08 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/price-types/%s/edit', $data['code']),
|
|
|
|
"POST",
|
|
|
|
['priceType' => json_encode($data)]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|