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
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace RetailCrm\Methods\V5;
|
|
|
|
|
|
|
|
use RetailCrm\Methods\V4\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
|
|
|
|
*/
|
|
|
|
trait References
|
|
|
|
{
|
|
|
|
use Previous;
|
2017-12-20 16:56:50 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get costs groups
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function costGroups()
|
|
|
|
{
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-12-20 16:56:50 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/cost-groups',
|
|
|
|
"GET"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit costs groups
|
|
|
|
*
|
|
|
|
* @param array $data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function costGroupsEdit(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.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!array_key_exists('color', $data)) {
|
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "color" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-12-20 16:56:50 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/cost-groups/%s/edit', $data['code']),
|
|
|
|
"POST",
|
|
|
|
['costGroup' => json_encode($data)]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get costs items
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function costItems()
|
|
|
|
{
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-12-20 16:56:50 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/cost-items',
|
|
|
|
"GET"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit costs items
|
|
|
|
*
|
|
|
|
* @param array $data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function costItemsEdit(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-12-20 16:56:50 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/cost-items/%s/edit', $data['code']),
|
|
|
|
"POST",
|
|
|
|
['costItem' => json_encode($data)]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get legal entities
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function legalEntities()
|
|
|
|
{
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-12-20 16:56:50 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/legal-entities',
|
|
|
|
"GET"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit legal entity
|
|
|
|
*
|
|
|
|
* @param array $data
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function legalEntitiesEdit(array $data)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('code', $data)) {
|
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "code" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-12-20 16:56:50 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/legal-entities/%s/edit', $data['code']),
|
|
|
|
"POST",
|
|
|
|
['legalEntity' => json_encode($data)]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get couriers
|
|
|
|
*
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function couriersList()
|
|
|
|
{
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-12-20 16:56:50 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/couriers',
|
|
|
|
"GET"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create courier
|
|
|
|
*
|
|
|
|
* @param array $courier
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function couriersCreate(array $courier)
|
|
|
|
{
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-12-20 16:56:50 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/couriers/create',
|
|
|
|
"POST",
|
|
|
|
['courier' => json_encode($courier)]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit courier
|
|
|
|
*
|
|
|
|
* @param array $courier
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function couriersEdit(array $courier)
|
|
|
|
{
|
|
|
|
if (!array_key_exists('id', $courier)) {
|
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Data must contain "id" parameter.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-12-20 16:56:50 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/couriers/%s/edit', $courier['id']),
|
|
|
|
"POST",
|
|
|
|
['courier' => json_encode($courier)]
|
|
|
|
);
|
|
|
|
}
|
2020-07-03 09:58:31 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get units
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function unitsList()
|
|
|
|
{
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/units',
|
|
|
|
"GET"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Edit unit
|
|
|
|
*
|
|
|
|
* @param array $unit
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function unitsEdit(array $unit)
|
|
|
|
{
|
|
|
|
if (empty($unit['code']) || empty($unit['name']) || empty($unit['sym'])) {
|
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'`code`, `name` and `sym` parameters must not be empty.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
sprintf('/reference/units/%s/edit', $unit['code']),
|
|
|
|
"POST",
|
|
|
|
['unit' => json_encode($unit)]
|
|
|
|
);
|
|
|
|
}
|
2023-11-27 15:06:47 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a list of currencies
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function currenciesList()
|
|
|
|
{
|
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/reference/currencies',
|
|
|
|
"GET"
|
|
|
|
);
|
|
|
|
}
|
2017-06-22 00:55:08 +03:00
|
|
|
}
|