1212use GuzzleHttp \TransferStats ;
1313use Psr \Http \Message \RequestInterface ;
1414use Psr \Http \Message \ResponseInterface ;
15- use Exception ;
1615use Psr \Log \LoggerInterface ;
1716use Throwable ;
1817
@@ -217,6 +216,51 @@ public function post(
217216 return $ this ->sendRequest ('POST ' , $ url , $ apiParams , $ headers , $ body , $ formParams , $ json );
218217 }
219218
219+ /**
220+ * POST request with a BODY of one of three types: raw string, fopen() resource or Psr\Http\Message\StreamInterface.
221+ *
222+ * @param string $url
223+ * @param array|null $apiParams
224+ * @param array|null $headers
225+ * @param null $body
226+ * @return ResponseInterface
227+ * @throws GuzzleException
228+ */
229+ public function postBody (string $ url , $ body = null , ?array $ apiParams = null , ?array $ headers = null ): ResponseInterface
230+ {
231+ return $ this ->post ($ url , $ apiParams , $ headers , $ body );
232+ }
233+
234+ /**
235+ * POST request with FORM payload (Content-Type: application/x-www-form-urlencoded)
236+ *
237+ * @param string $url
238+ * @param array|null $apiParams
239+ * @param array|null $headers
240+ * @param array|null $formParams
241+ * @return ResponseInterface
242+ * @throws GuzzleException
243+ */
244+ public function postForm (string $ url , ?array $ formParams = null , ?array $ apiParams = null , ?array $ headers = null ): ResponseInterface
245+ {
246+ return $ this ->post ($ url , $ apiParams , $ headers , null , $ formParams );
247+ }
248+
249+ /**
250+ * POST request with JSON payload (Content-Type: application/json)
251+ *
252+ * @param string $url
253+ * @param array|null $apiParams
254+ * @param array|null $headers
255+ * @param array|null $json
256+ * @return ResponseInterface
257+ * @throws GuzzleException
258+ */
259+ public function postJson (string $ url , ?array $ json = null , ?array $ apiParams = null , ?array $ headers = null ): ResponseInterface
260+ {
261+ return $ this ->post ($ url , $ apiParams , $ headers , null , null , $ json );
262+ }
263+
220264 /**
221265 * PUT request
222266 *
@@ -242,6 +286,52 @@ public function put(
242286 }
243287
244288
289+ /**
290+ * PUT request with a BODY of one of three types: raw string, fopen() resource or Psr\Http\Message\StreamInterface.
291+ *
292+ * @param string $url
293+ * @param array|null $apiParams
294+ * @param array|null $headers
295+ * @param null $body
296+ * @return ResponseInterface
297+ * @throws GuzzleException
298+ */
299+ public function putBody (string $ url , $ body = null , ?array $ apiParams = null , ?array $ headers = null ): ResponseInterface
300+ {
301+ return $ this ->put ($ url , $ apiParams , $ headers , $ body );
302+ }
303+
304+ /**
305+ * PUT request with FORM payload (Content-Type: application/x-www-form-urlencoded)
306+ *
307+ * @param string $url
308+ * @param array|null $apiParams
309+ * @param array|null $headers
310+ * @param array|null $formParams
311+ * @return ResponseInterface
312+ * @throws GuzzleException
313+ */
314+ public function putForm (string $ url , ?array $ formParams = null , ?array $ apiParams = null , ?array $ headers = null ): ResponseInterface
315+ {
316+ return $ this ->put ($ url , $ apiParams , $ headers , null , $ formParams );
317+ }
318+
319+ /**
320+ * PUT request with JSON payload (Content-Type: application/json)
321+ *
322+ * @param string $url
323+ * @param array|null $apiParams
324+ * @param array|null $headers
325+ * @param array|null $json
326+ * @return ResponseInterface
327+ * @throws GuzzleException
328+ */
329+ public function putJson (string $ url , ?array $ json = null , ?array $ apiParams = null , ?array $ headers = null ): ResponseInterface
330+ {
331+ return $ this ->put ($ url , $ apiParams , $ headers , null , null , $ json );
332+ }
333+
334+
245335 /**
246336 * @param string $method
247337 * @param string $url
@@ -368,6 +458,48 @@ public function postPromise(
368458 return $ this ->createPromise ('POST ' , $ url , $ apiParams , $ headers , $ body , $ formParams , $ json );
369459 }
370460
461+ /**
462+ * Create POST promise with a BODY of one of three types: raw string, fopen() resource or Psr\Http\Message\StreamInterface.
463+ *
464+ * @param string $url
465+ * @param null $body
466+ * @param array|null $apiParams
467+ * @param array|null $headers
468+ * @return PromiseInterface
469+ */
470+ public function postPromiseBody (string $ url , $ body = null , ?array $ apiParams = null , ?array $ headers = null ): PromiseInterface
471+ {
472+ return $ this ->postPromise ($ url , $ apiParams , $ headers , $ body );
473+ }
474+
475+ /**
476+ * Create POST promise with FORM payload (Content-Type: application/x-www-form-urlencoded)
477+ *
478+ * @param string $url
479+ * @param array|null $formParams
480+ * @param array|null $apiParams
481+ * @param array|null $headers
482+ * @return PromiseInterface
483+ */
484+ public function postPromiseForm (string $ url , ?array $ formParams = null , ?array $ apiParams = null , ?array $ headers = null ): PromiseInterface
485+ {
486+ return $ this ->postPromise ($ url , $ apiParams , $ headers , null , $ formParams );
487+ }
488+
489+ /**
490+ * Create POST promise with JSON payload (Content-Type: application/json)
491+ *
492+ * @param string $url
493+ * @param array|null $json
494+ * @param array|null $apiParams
495+ * @param array|null $headers
496+ * @return PromiseInterface
497+ */
498+ public function postPromiseJson (string $ url , ?array $ json = null , ?array $ apiParams = null , ?array $ headers = null ): PromiseInterface
499+ {
500+ return $ this ->postPromise ($ url , $ apiParams , $ headers , null , null , $ json );
501+ }
502+
371503 /**
372504 * Create PUT promise
373505 *
@@ -391,6 +523,48 @@ public function putPromise(
391523 return $ this ->createPromise ('PUT ' , $ url , $ apiParams , $ headers , $ body , $ formParams , $ json );
392524 }
393525
526+ /**
527+ * Create PUT promise with a BODY of one of three types: raw string, fopen() resource or Psr\Http\Message\StreamInterface.
528+ *
529+ * @param string $url
530+ * @param null $body
531+ * @param array|null $apiParams
532+ * @param array|null $headers
533+ * @return PromiseInterface
534+ */
535+ public function putPromiseBody (string $ url , $ body = null , ?array $ apiParams = null , ?array $ headers = null ): PromiseInterface
536+ {
537+ return $ this ->putPromise ($ url , $ apiParams , $ headers , $ body );
538+ }
539+
540+ /**
541+ * Create PUT promise with FORM payload (Content-Type: application/x-www-form-urlencoded)
542+ *
543+ * @param string $url
544+ * @param array|null $formParams
545+ * @param array|null $apiParams
546+ * @param array|null $headers
547+ * @return PromiseInterface
548+ */
549+ public function putPromiseForm (string $ url , ?array $ formParams = null , ?array $ apiParams = null , ?array $ headers = null ): PromiseInterface
550+ {
551+ return $ this ->putPromise ($ url , $ apiParams , $ headers , null , $ formParams );
552+ }
553+
554+ /**
555+ * Create PUT promise with JSON payload (Content-Type: application/json)
556+ *
557+ * @param string $url
558+ * @param array|null $json
559+ * @param array|null $apiParams
560+ * @param array|null $headers
561+ * @return PromiseInterface
562+ */
563+ public function putPromiseJson (string $ url , ?array $ json = null , ?array $ apiParams = null , ?array $ headers = null ): PromiseInterface
564+ {
565+ return $ this ->putPromise ($ url , $ apiParams , $ headers , null , null , $ json );
566+ }
567+
394568 /**
395569 * @param string $method
396570 * @param string $url
0 commit comments