diff --git a/src/Client.php b/src/Client.php index 2e818a5..6877e4f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -232,7 +232,7 @@ public function addProductPart($idproduct, $params) public function updateProductPartAmount($idproduct, $idproductpart, $amount) { $params = ['amount' => $amount]; - + return $this->sendRequest('/products/' . $idproduct . '/parts/'.$idproductpart, $params, self::METHOD_PUT); } @@ -497,7 +497,7 @@ public function getSuppliers($filters = []) { return $this->sendRequest('/suppliers', null, null, $filters); } - + public function getAllSuppliers($filters = []) { return $this->getAllResults('supplier', $filters); @@ -699,7 +699,7 @@ public function getTags($filters = []) { return $this->sendRequest('/tags', [], self::METHOD_GET, $filters); } - + public function getAllTags($filters = []) { return $this->getAllResults('tag', $filters); @@ -763,7 +763,7 @@ public function processBackorders() { return $this->sendRequest('/backorders/process', null, self::METHOD_POST); } - + public function deleteBackorder($idbackorder) { return $this->sendRequest('/backorders/' . $idbackorder, null, self::METHOD_DELETE); @@ -807,7 +807,7 @@ public function getShippingProviders() { return $this->sendRequest('/shippingproviders'); } - + /* * Product fields */ @@ -820,7 +820,7 @@ public function getProductField($idproductfield) { return $this->sendRequest('/productfields/' . $idproductfield); } - + /* * Order fields */ @@ -833,7 +833,7 @@ public function getOrderField($idorderfield) { return $this->sendRequest('/orderfields/' . $idorderfield); } - + /* * Customer fields */ @@ -953,7 +953,7 @@ public function getAllResults($entity, $filters = []) return ['success' => true, 'data' => $collection]; } - + /* * Yield all results from the API */ @@ -1051,6 +1051,7 @@ public function enableRetryOnRateLimitHit() public function sendRequest($endpoint, $params = [], $method = self::METHOD_GET, $filters = []) { $endpoint = $this->getEndpoint($endpoint, $filters); + $this->debug('URL: ' . $this->getUrl($endpoint)); $curlSession = curl_init(); @@ -1081,6 +1082,7 @@ public function sendRequest($endpoint, $params = [], $method = self::METHOD_GET, $apiResultJson = json_decode($apiResult, true); $apiResultHeaders = $this->parseRawHeaders(); + $this->resetRawHeaders(); $result = []; $result['success'] = false; @@ -1171,6 +1173,11 @@ protected function parseRawHeaders() return $parsedHeaders; } + protected function resetRawHeaders() + { + $this->rawResponseHeaders = []; + } + protected function getRemainingRateLimit(array $apiResultHeaders) { return (array_key_exists('x-ratelimit-remaining', $apiResultHeaders)) ? $apiResultHeaders['x-ratelimit-remaining'] : null;