diff --git a/src/Api.php b/src/Api.php index 8ac13db..111a06d 100644 --- a/src/Api.php +++ b/src/Api.php @@ -30,6 +30,8 @@ namespace Ovh; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; use GuzzleHttp\Psr7\Uri; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; @@ -276,15 +278,13 @@ class Api } } - $request = new Request( + /** @var ResponseInterface $response */ + return $this->sendRequest(new Request( $method, $uri, $headers, $body - ); - - /** @var Response $response */ - return $this->getHttpClient()->sendRequest($request); + )); } /** @@ -378,4 +378,14 @@ class Api { return $this->http_client; } + + /** + * Send the Request through the HttpClient + * @param RequestInterface $request + * @return ResponseInterface + */ + private function sendRequest(RequestInterface $request) + { + return $this->getHttpClient()->sendRequest($request); + } }