diff --git a/src/Adapter/Guzzle.php b/src/Adapter/Guzzle.php index 71e7dd75..5118d3c8 100644 --- a/src/Adapter/Guzzle.php +++ b/src/Adapter/Guzzle.php @@ -80,14 +80,31 @@ public function request(string $method, string $uri, array $data = [], array $he } try { - $response = $this->client->$method($uri, [ - 'headers' => $headers, - ($method === 'get' ? 'query' : 'json') => $data, - ]); + $methodData = $this->getMethodData($method, $data); + $response = $this->client->$method($uri, ['headers' => $headers] + $methodData); } catch (RequestException $err) { throw ResponseException::fromRequestException($err); } return $response; } + + /** + * Gets the data for the request as per the method. + * @param string $method + * @param array $data + * @return array|array[] + */ + public function getMethodData(string $method, array $data): array + { + if ($method === 'get') { + return ['query' => $data]; + } + + if (array_key_exists('multipart', $data)) { + return $data; + } + + return ['json' => $data]; + } }