1
0
mirror of synced 2025-01-18 17:01:41 +03:00

Add method in API V5 and delete use another version

This commit is contained in:
Dima Uryvskiy 2022-05-06 17:34:51 +03:00 committed by GitHub
parent ad15739798
commit 6d94082c22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 3 deletions

View File

@ -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
*

View File

@ -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);
}
/**