Skip to content

Commit

Permalink
Merge pull request #288 from TransbankDevelopers/feat/upgrade-guzzle-…
Browse files Browse the repository at this point in the history
…version

feat: upgrade guzzle version
  • Loading branch information
gasspper authored Jul 9, 2024
2 parents 7a96b44 + 184978c commit bf1da94
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle":"^5.3.1|^6.5.8|^7.4.5"
"guzzlehttp/guzzle":"^7"
},
"require-dev": {
"phpunit/phpunit": "^9",
Expand Down
33 changes: 0 additions & 33 deletions src/Utils/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,9 @@ public function request(

$requestTimeout = $options['timeout'] ?? 0;

if (defined('\GuzzleHttp\Client::VERSION') && version_compare(Client::VERSION, '6', '<')) {
return $this->sendGuzzle5Request($method, $url, $headers, $payload, $requestTimeout);
}

return $this->sendGuzzleRequest($method, $url, $headers, $payload, $requestTimeout);
}

/**
* Sends a Guzzle 5 request.
*
* @param string $method
* @param string $url
* @param array $headers
* @param array|null $payload
* @param int $timeout
*
* @throws GuzzleException
*
* @return ResponseInterface
*/
protected function sendGuzzle5Request($method, $url, array $headers, $payload, int $timeout): ResponseInterface
{
$client = new Client([
'timeout' => $timeout,
'read_timeout' => $timeout,
'connect_timeout' => $timeout,
]);

$request = $client->createRequest($method, $url, [
'headers' => $headers,
'body' => $payload,
]);

return $client->send($request);
}

/**
* Sends a Guzzle request.
*
Expand Down

0 comments on commit bf1da94

Please sign in to comment.