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:
parent
3cfd9e4b30
commit
9f6492185b
20
src/Api.php
20
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user