From 9ab07c16bb8640acee7a5b5c289b159c436e634f Mon Sep 17 00:00:00 2001 From: bandi Date: Tue, 10 Sep 2024 15:40:43 +0330 Subject: [PATCH] prevent wrong content on GET requests --- src/Moadian.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Moadian.php b/src/Moadian.php index a336db6..af4f4e1 100644 --- a/src/Moadian.php +++ b/src/Moadian.php @@ -27,6 +27,7 @@ public function __construct($privateKey, $certificate, $baseUri ='https://tp.tax $this->client = new Client([ 'base_uri' => $baseUri, 'headers' => ['Content-Type' => 'application/json'], + 'timeout' => 60 ]); $this->signer = new SignatureService($privateKey, $certificate); $this->encryptor = new EncryptionService(); @@ -43,8 +44,9 @@ public function sendRequest(Request $request) { $request->prepare($this->signer, $this->encryptor); + $body = !empty($request->getBody()) ? json_encode($request->getBody()) : null; $httpResp = $this->client->request($request->method, $request->path, [ - 'body' => json_encode($request->getBody()), + 'body' => $body, 'headers' => $request->getHeaders(), 'query' => $request->getParams() ]);