From 8d5f95ed38edd7a375d1378d978818e49d6d4a60 Mon Sep 17 00:00:00 2001 From: Brad Jones Date: Mon, 31 May 2021 14:25:34 -1000 Subject: [PATCH] Fix misspellings and deprecations in HTTP API class --- src/MatrixHttpApi.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/MatrixHttpApi.php b/src/MatrixHttpApi.php index d86df7b..0a8b367 100644 --- a/src/MatrixHttpApi.php +++ b/src/MatrixHttpApi.php @@ -8,6 +8,7 @@ use Aryess\PhpMatrixSdk\Exceptions\MatrixRequestException; use Aryess\PhpMatrixSdk\Exceptions\ValidationException; use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; +use GuzzleHttp\RequestOptions; /** * Contains all raw Matrix HTTP Client-Server API calls. @@ -63,7 +64,7 @@ class MatrixHttpApi { /** * @var bool */ - private $vallidateCert; + private $validateCert; /** * @var Client @@ -94,7 +95,7 @@ class MatrixHttpApi { $this->token = $token; $this->identity = $identity; $this->txnId = 0; - $this->vallidateCert = true; + $this->validateCert = true; $this->client = new Client(); $this->default429WaitMs = $default429WaitMs; $this->useAuthorizationHeader = $useAuthorizationHeader; @@ -139,7 +140,7 @@ class MatrixHttpApi { } public function validateCertificate(bool $validity) { - $this->vallidateCert = $validity; + $this->validateCert = $validity; } /** @@ -925,18 +926,20 @@ class MatrixHttpApi { $queryParams['user_id'] = $this->identity; } - $endpoint = $this->baseUrl . $apiPath . $path; - if ($headers['Content-Type'] == "application/json" && $content != null) { - $content = json_encode($content); - } - $options = array_merge($options, [ 'headers' => $headers, 'query' => $queryParams, - 'body' => $content, - 'verify' => $this->vallidateCert, + 'verify' => $this->validateCert, ]); + $endpoint = $this->baseUrl . $apiPath . $path; + if ($headers['Content-Type'] == "application/json" && $content !== null) { + $options[RequestOptions::JSON] = $content; + } + else { + $options[RequestOptions::FORM_PARAMS] = $content; + } + $responseBody = ''; while (true) { try { @@ -1449,4 +1452,4 @@ class MatrixHttpApi { } -} \ No newline at end of file +}