@@ -230,16 +230,18 @@ public function get($uri)
230
230
/**
231
231
* Make POST request
232
232
*
233
+ * String type was added to parameter $param in order to support sending JSON or XML requests.
234
+ * This feature was added base on Community Pull Request https://github.com/magento/magento2/pull/8373
235
+ *
233
236
* @param string $uri
234
- * @param array $params
235
- * @param bool $json
237
+ * @param array|string $params
236
238
* @return void
237
239
*
238
240
* @see \Magento\Framework\HTTP\Client#post($uri, $params)
239
241
*/
240
- public function post ($ uri , $ params, $ json = false )
242
+ public function post ($ uri , $ params )
241
243
{
242
- $ this ->makeRequest ("POST " , $ uri , $ params, $ json = false );
244
+ $ this ->makeRequest ("POST " , $ uri , $ params );
243
245
}
244
246
245
247
/**
@@ -336,21 +338,24 @@ public function getStatus()
336
338
337
339
/**
338
340
* Make request
341
+ *
342
+ * String type was added to parameter $param in order to support sending JSON or XML requests.
343
+ * This feature was added base on Community Pull Request https://github.com/magento/magento2/pull/8373
344
+ *
339
345
* @param string $method
340
346
* @param string $uri
341
- * @param array $params
342
- * @param bool $json
347
+ * @param array|string $params - use $params as a string in case of JSON or XML POST request.
343
348
* @return void
344
349
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
345
350
* @SuppressWarnings(PHPMD.NPathComplexity)
346
351
*/
347
- protected function makeRequest ($ method , $ uri , $ params = [], $ json = false )
352
+ protected function makeRequest ($ method , $ uri , $ params = [])
348
353
{
349
354
$ this ->_ch = curl_init ();
350
355
$ this ->curlOption (CURLOPT_URL , $ uri );
351
356
if ($ method == 'POST ' ) {
352
357
$ this ->curlOption (CURLOPT_POST , 1 );
353
- $ this ->curlOption (CURLOPT_POSTFIELDS , $ json ? json_encode ($ params ) : http_build_query ( $ params) );
358
+ $ this ->curlOption (CURLOPT_POSTFIELDS , is_array ( $ params ) ? http_build_query ($ params ) : $ params );
354
359
} elseif ($ method == "GET " ) {
355
360
$ this ->curlOption (CURLOPT_HTTPGET , 1 );
356
361
} else {
0 commit comments