mirror of
https://github.com/cerbero90/json-parser.git
synced 2025-01-17 04:58:15 +01:00
Add method to retrieve the Guzzle client
This commit is contained in:
parent
5a65884255
commit
eee0e8bc63
@ -45,7 +45,7 @@ trait GuzzleAware
|
||||
*/
|
||||
protected function getJson(UriInterface|string $url): ResponseInterface
|
||||
{
|
||||
return (new Client())->get($url, [
|
||||
return $this->guzzle()->get($url, [
|
||||
'headers' => [
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
@ -53,6 +53,16 @@ trait GuzzleAware
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Guzzle client
|
||||
*
|
||||
* @return Client
|
||||
*/
|
||||
protected function guzzle(): Client
|
||||
{
|
||||
return new Client();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the JSON response of the given request
|
||||
*
|
||||
@ -61,6 +71,6 @@ trait GuzzleAware
|
||||
*/
|
||||
protected function sendRequest(RequestInterface $request): ResponseInterface
|
||||
{
|
||||
return (new Client())->sendRequest($request);
|
||||
return $this->guzzle()->sendRequest($request);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user