Add method in API V5 and delete use another version
This commit is contained in:
parent
ad15739798
commit
6d94082c22
@ -40,14 +40,14 @@ class WC_Retailcrm_Client_V5
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
*/
|
||||
public function __construct($url, $apiKey, $version = null, $site = null)
|
||||
public function __construct($url, $apiKey, $site = null)
|
||||
{
|
||||
if ('/' !== $url[strlen($url) - 1]) {
|
||||
$url .= '/';
|
||||
}
|
||||
|
||||
$unversionedUrl = $url . 'api';
|
||||
$url = $version == null ? $url . 'api' : $url . 'api/' . $version;
|
||||
$url .= 'api/v5';
|
||||
|
||||
$this->client = new WC_Retailcrm_Request($url, ['apiKey' => $apiKey]);
|
||||
$this->unversionedClient = new WC_Retailcrm_Request($unversionedUrl, ['apiKey' => $apiKey]);
|
||||
@ -2086,6 +2086,33 @@ class WC_Retailcrm_Client_V5
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload store prices
|
||||
*
|
||||
* @param array $prices prices data
|
||||
* @param string $site default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws WC_Retailcrm_Exception_Curl
|
||||
* @throws WC_Retailcrm_Exception_Json
|
||||
*
|
||||
* @return WC_Retailcrm_Response
|
||||
*/
|
||||
public function storePricesUpload(array $prices, $site = null)
|
||||
{
|
||||
if (!count($prices)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `prices` must contains array of the prices'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
'/store/prices/upload',
|
||||
WC_Retailcrm_Request::METHOD_POST,
|
||||
$this->fillSite($site, array('prices' => json_encode($prices)))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get products
|
||||
*
|
||||
|
@ -25,7 +25,7 @@ if (!class_exists('WC_Retailcrm_Proxy')) :
|
||||
include_once(WC_Integration_Retailcrm::checkCustomFile('include/api/class-wc-retailcrm-client-v5.php'));
|
||||
}
|
||||
|
||||
$this->retailcrm = new WC_Retailcrm_Client_V5($api_url, $api_key, 'v5');
|
||||
$this->retailcrm = new WC_Retailcrm_Client_V5($api_url, $api_key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user