mirror of
https://github.com/cerbero90/json-parser.git
synced 2025-01-17 13:08:16 +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
|
protected function getJson(UriInterface|string $url): ResponseInterface
|
||||||
{
|
{
|
||||||
return (new Client())->get($url, [
|
return $this->guzzle()->get($url, [
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'Accept' => 'application/json',
|
'Accept' => 'application/json',
|
||||||
'Content-Type' => '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
|
* Retrieve the JSON response of the given request
|
||||||
*
|
*
|
||||||
@ -61,6 +71,6 @@ trait GuzzleAware
|
|||||||
*/
|
*/
|
||||||
protected function sendRequest(RequestInterface $request): ResponseInterface
|
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