diff --git a/composer.json b/composer.json index 154b492..4f0434b 100644 --- a/composer.json +++ b/composer.json @@ -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/"} diff --git a/src/Foxy/FoxyClient/FoxyClient.php b/src/Foxy/FoxyClient/FoxyClient.php index cc3f884..69c2ad3 100644 --- a/src/Foxy/FoxyClient/FoxyClient.php +++ b/src/Foxy/FoxyClient/FoxyClient.php @@ -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); @@ -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) { @@ -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) {