@@ -96,6 +96,16 @@ abstract class ShopifyResource
9696 protected $ customPutActions = array ();
9797 protected $ customDeleteActions = array ();
9898
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+
99109 /**
100110 * The ID of the resource
101111 *
@@ -225,7 +235,7 @@ public function __call($name, $arguments)
225235
226236 $ url = $ this ->generateUrl ($ urlParams , $ customAction );
227237
228- return $ this ->$ httpMethod ($ dataArray , $ url );
238+ return $ this ->$ httpMethod ($ dataArray , $ url, ! in_array ( $ name , $ this -> customPostActionsNoWrap ) );
229239 }
230240 }
231241
@@ -355,18 +365,22 @@ public function search($query)
355365 /**
356366 * Call POST method to create a new resource
357367 *
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
359369 * @param string $url
360370 *
361- * @uses HttpRequestJson::post() to send the HTTP request
371+ * @param bool $wrapBody
362372 *
363373 * @return array
374+ * @throws ApiException
375+ * @throws CurlException
376+ * @uses HttpRequestJson::post() to send the HTTP request
377+ *
364378 */
365- public function post ($ dataArray , $ url = null )
379+ public function post ($ dataArray , $ url = null , $ wrapBody = true )
366380 {
367381 if (!$ url ) $ url = $ this ->generateUrl ();
368382
369- if (!empty ($ dataArray )) $ dataArray = $ this ->wrapData ($ dataArray );
383+ if ($ wrapBody && !empty ($ dataArray )) $ dataArray = $ this ->wrapData ($ dataArray );
370384
371385 $ response = HttpRequestJson::post ($ url , $ dataArray , $ this ->httpHeaders );
372386
0 commit comments