infrastructure/PayboxDirect/src/HttpClient/GuzzleHttpClient.php line 27

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the Nexylan packages.
  5. *
  6. * (c) Nexylan SAS <contact@nexylan.com>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Nexy\PayboxDirect\HttpClient;
  12. use GuzzleHttp\Client;
  13. /**
  14. * @author Sullivan Senechal <soullivaneuh@gmail.com>
  15. */
  16. final class GuzzleHttpClient extends AbstractHttpClient
  17. {
  18. private Client $client;
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public function init(): void
  23. {
  24. $this->client = new Client(
  25. [
  26. 'base_uri' => $this->baseUrl,
  27. 'timeout' => $this->timeout,
  28. ]
  29. );
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. protected function request(array $parameters): string
  35. {
  36. $response = $this->client->request('post', '', [
  37. 'form_params' => $parameters,
  38. ]);
  39. return (string) $response->getBody();
  40. }
  41. }