Skip to content

Commit 1dc2543

Browse files
committed
Don't wrap data for custom post / put actions
1 parent fc128e7 commit 1dc2543

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/ShopifyResource.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ public function __call($name, $arguments)
225225

226226
$url = $this->generateUrl($urlParams, $customAction);
227227

228-
return $this->$httpMethod($dataArray, $url);
228+
if ($httpMethod == 'post' || $httpMethod == 'put') {
229+
return $this->$httpMethod($dataArray, $url, false);
230+
} else {
231+
return $this->$httpMethod($dataArray, $url);
232+
}
229233
}
230234
}
231235

@@ -357,16 +361,17 @@ public function search($query)
357361
*
358362
* @param array $dataArray Check Shopify API reference of the specific resource for the list of required and optional data elements to be provided
359363
* @param string $url
364+
* @param bool $wrapData
360365
*
361366
* @uses HttpRequestJson::post() to send the HTTP request
362367
*
363368
* @return array
364369
*/
365-
public function post($dataArray, $url = null)
370+
public function post($dataArray, $url = null, $wrapData = true)
366371
{
367372
if (!$url) $url = $this->generateUrl();
368373

369-
if (!empty($dataArray)) $dataArray = $this->wrapData($dataArray);
374+
if ($wrapData && !empty($dataArray)) $dataArray = $this->wrapData($dataArray);
370375

371376
$response = HttpRequestJson::post($url, $dataArray, $this->httpHeaders);
372377

@@ -378,17 +383,18 @@ public function post($dataArray, $url = null)
378383
*
379384
* @param array $dataArray Check Shopify API reference of the specific resource for the list of required and optional data elements to be provided
380385
* @param string $url
386+
* @param bool $wrapData
381387
*
382388
* @uses HttpRequestJson::put() to send the HTTP request
383389
*
384390
* @return array
385391
*/
386-
public function put($dataArray, $url = null)
392+
public function put($dataArray, $url = null, $wrapData = true)
387393
{
388394

389395
if (!$url) $url = $this->generateUrl();
390396

391-
if (!empty($dataArray)) $dataArray = $this->wrapData($dataArray);
397+
if ($wrapData && !empty($dataArray)) $dataArray = $this->wrapData($dataArray);
392398

393399
$response = HttpRequestJson::put($url, $dataArray, $this->httpHeaders);
394400

0 commit comments

Comments
 (0)