Skip to content

Commit

Permalink
refactor(guzzle): upgrade to version 7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
filipcujanovic committed Jan 23, 2023
1 parent 592fb81 commit b768574
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
}
],
"require": {
"guzzlehttp/guzzle": "~5.2",
"guzzlehttp/cache-subscriber": "0.1.*@dev",
"php": ">=5.3.3"
"guzzlehttp/guzzle": "^7.5",
"php": "^7.2.5 || ^8.0"
},
"autoload": {
"psr-0": {"Foxy\\FoxyClient": "src/"}
Expand Down
14 changes: 4 additions & 10 deletions src/Foxy/FoxyClient/FoxyClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,6 @@ public function get($uri = "", $post = null)
return $this->go('GET', $uri, $post);
}

public function put($uri, $post = null)
{
return $this->go('PUT', $uri, $post);
}

public function post($uri, $post = null)
{
return $this->go('POST', $uri, $post);
Expand Down Expand Up @@ -241,7 +236,7 @@ private function go($method, $uri, $post, $is_retry = false)
if ($method === "GET" && $post !== null) {
$guzzle_args['query'] = $post;
} elseif ($post !== null) {
$guzzle_args['body'] = $post;
$guzzle_args['form_params'] = $post;
}

if (!$this->handle_exceptions) {
Expand All @@ -262,14 +257,13 @@ private function go($method, $uri, $post, $is_retry = false)
private function processRequest($method, $uri, $post, $guzzle_args, $is_retry = false)
{
// special case for PATCHing a Downloadable File
if ($post !== null && is_array($post) && array_key_exists('file', $post) && $method == 'PATCH') {
if ($post !== null && array_key_exists('file', $post) && $method == 'PATCH') {
$method = 'POST';
$guzzle_args['headers']['X-HTTP-Method-Override'] = 'PATCH';
}

$api_request = $this->guzzle->createRequest($method, $uri, $guzzle_args);
$this->last_response = $this->guzzle->send($api_request);
$data = $this->last_response->json();
$this->last_response = $this->guzzle->request($method, $uri, $guzzle_args);
$data = json_decode($this->last_response->getBody()->getContents(),true);
$this->saveLinks($data);
if ($this->hasExpiredAccessTokenError($data) && !$this->shouldRefreshToken()) {
if (!$is_retry) {
Expand Down

0 comments on commit b768574

Please sign in to comment.