2017-06-22 00:55:08 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 5.4
|
|
|
|
*
|
2017-06-22 16:42:42 +03:00
|
|
|
* Stores
|
2017-06-22 00:55:08 +03:00
|
|
|
*
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace RetailCrm\Methods\V3;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PHP version 5.4
|
|
|
|
*
|
2017-06-22 16:42:42 +03:00
|
|
|
* Stores class
|
2017-06-22 00:55:08 +03:00
|
|
|
*
|
|
|
|
* @category RetailCrm
|
|
|
|
* @package RetailCrm
|
|
|
|
*/
|
|
|
|
trait Stores
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Get purchace prices & stock balance
|
|
|
|
*
|
|
|
|
* @param array $filter (default: array())
|
|
|
|
* @param int $page (default: null)
|
|
|
|
* @param int $limit (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function storeInventories(array $filter = [], $page = null, $limit = null)
|
|
|
|
{
|
|
|
|
$parameters = [];
|
|
|
|
|
|
|
|
if (count($filter)) {
|
|
|
|
$parameters['filter'] = $filter;
|
|
|
|
}
|
|
|
|
if (null !== $page) {
|
|
|
|
$parameters['page'] = (int) $page;
|
|
|
|
}
|
|
|
|
if (null !== $limit) {
|
|
|
|
$parameters['limit'] = (int) $limit;
|
|
|
|
}
|
|
|
|
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-06-22 00:55:08 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/store/inventories',
|
|
|
|
"GET",
|
|
|
|
$parameters
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Upload store inventories
|
|
|
|
*
|
|
|
|
* @param array $offers offers data
|
|
|
|
* @param string $site (default: null)
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
* @throws \RetailCrm\Exception\CurlException
|
|
|
|
* @throws \RetailCrm\Exception\InvalidJsonException
|
|
|
|
*
|
|
|
|
* @return \RetailCrm\Response\ApiResponse
|
|
|
|
*/
|
|
|
|
public function storeInventoriesUpload(array $offers, $site = null)
|
|
|
|
{
|
|
|
|
if (!count($offers)) {
|
|
|
|
throw new \InvalidArgumentException(
|
|
|
|
'Parameter `offers` must contains array of the offers'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-02-20 17:50:45 +03:00
|
|
|
/* @noinspection PhpUndefinedMethodInspection */
|
2017-06-22 00:55:08 +03:00
|
|
|
return $this->client->makeRequest(
|
|
|
|
'/store/inventories/upload',
|
|
|
|
"POST",
|
|
|
|
$this->fillSite($site, ['offers' => json_encode($offers)])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|