1
0
mirror of synced 2024-11-22 13:26:08 +03:00
api-client-php/lib/RetailCrm/Methods/V4/References.php
2017-06-22 16:42:42 +03:00

82 lines
1.9 KiB
PHP

<?php
/**
* PHP version 5.4
*
* References
*
* @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;
use RetailCrm\Methods\V3\References as Previous;
/**
* PHP version 5.4
*
* References 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 References
{
use Previous;
/**
* Get prices types
*
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException
*
* @return \RetailCrm\Response\ApiResponse
*/
public function pricesTypes()
{
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.'
);
}
return $this->client->makeRequest(
sprintf('/reference/price-types/%s/edit', $data['code']),
"POST",
['priceType' => json_encode($data)]
);
}
}