@@ -96,6 +96,16 @@ abstract class ShopifyResource
96
96
protected $ customPutActions = array ();
97
97
protected $ customDeleteActions = array ();
98
98
99
+ /**
100
+ * Some actions from inventory levels do not wrap the content of the request
101
+ *
102
+ * Wrapping such request body leads to errors. This list is used to disable this wrapping
103
+ * on certain methods.
104
+ *
105
+ * @var array
106
+ */
107
+ protected $ customPostActionsNoWrap = array ();
108
+
99
109
/**
100
110
* The ID of the resource
101
111
*
@@ -225,7 +235,7 @@ public function __call($name, $arguments)
225
235
226
236
$ url = $ this ->generateUrl ($ urlParams , $ customAction );
227
237
228
- return $ this ->$ httpMethod ($ dataArray , $ url );
238
+ return $ this ->$ httpMethod ($ dataArray , $ url, ! in_array ( $ name , $ this -> customPostActionsNoWrap ) );
229
239
}
230
240
}
231
241
@@ -355,18 +365,22 @@ public function search($query)
355
365
/**
356
366
* Call POST method to create a new resource
357
367
*
358
- * @param array $dataArray Check Shopify API reference of the specific resource for the list of required and optional data elements to be provided
368
+ * @param array $dataArray Check Shopify API reference of the specific resource for the list of required and optional data elements to be provided
359
369
* @param string $url
360
370
*
361
- * @uses HttpRequestJson::post() to send the HTTP request
371
+ * @param bool $wrapBody
362
372
*
363
373
* @return array
374
+ * @throws ApiException
375
+ * @throws CurlException
376
+ * @uses HttpRequestJson::post() to send the HTTP request
377
+ *
364
378
*/
365
- public function post ($ dataArray , $ url = null )
379
+ public function post ($ dataArray , $ url = null , $ wrapBody = true )
366
380
{
367
381
if (!$ url ) $ url = $ this ->generateUrl ();
368
382
369
- if (!empty ($ dataArray )) $ dataArray = $ this ->wrapData ($ dataArray );
383
+ if ($ wrapBody && !empty ($ dataArray )) $ dataArray = $ this ->wrapData ($ dataArray );
370
384
371
385
$ response = HttpRequestJson::post ($ url , $ dataArray , $ this ->httpHeaders );
372
386
0 commit comments