1
0
mirror of https://github.com/ovh/php-ovh.git synced 2023-11-05 03:20:26 +01:00

Create a central method to send the Request

All the calls go through that method, it'll allow extensibility.
This commit is contained in:
Stéphane HULARD 2016-04-04 19:06:37 +02:00
parent 3cfd9e4b30
commit 9f6492185b

View File

@ -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);
}
}