From 5f5fd55c4efd87e4bf018fabed04dc54a92c73bc Mon Sep 17 00:00:00 2001 From: Jordy Verschoor Date: Wed, 11 Jan 2023 09:46:33 +0100 Subject: [PATCH] path added to heartbeat --- src/Vies/HeartBeat.php | 28 ++++++++++++++++++++++++++-- src/Vies/Vies.php | 3 ++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/Vies/HeartBeat.php b/src/Vies/HeartBeat.php index f12c1e0..de0fcf8 100644 --- a/src/Vies/HeartBeat.php +++ b/src/Vies/HeartBeat.php @@ -38,6 +38,10 @@ class HeartBeat * @var int The port you want to verify */ protected $port; + /** + * @var string The path to append + */ + protected $path; /** * @var int The timeout in seconds @@ -59,12 +63,13 @@ class HeartBeat * @param int $port * @param int $timeout */ - public function __construct(?string $host = null, int $port = Vies::VIES_PORT, int $timeout = self::DEFAULT_TIMEOUT) + public function __construct(?string $host = null, int $port = Vies::VIES_PORT, ?string $path = null, int $timeout = self::DEFAULT_TIMEOUT) { if (null !== $host) { $this->setHost($host); } + $this->setPath($path); $this->setPort($port); $this->setTimeout($timeout); } @@ -92,6 +97,25 @@ public function setHost(string $host): self return $this; } + /** + * @return string + */ + public function getPath(): string + { + return $this->path; + } + + /** + * @param string $path + * @return self + */ + public function setPath(string $path): self + { + $this->path = $path; + + return $this; + } + /** * @return int */ @@ -177,7 +201,7 @@ private function readContents($handle): array throw new \InvalidArgumentException('Expecting a resource to be provided'); } $response = ''; - $uri = sprintf('%s://%s/', Vies::VIES_PROTO, $this->host); + $uri = sprintf('%s://%s%s', Vies::VIES_PROTO, $this->host, $this->path); $stream = [ 'GET ' . $uri . ' HTTP/1.0', 'Host: ' . $this->host, diff --git a/src/Vies/Vies.php b/src/Vies/Vies.php index 3a4b7b9..529da43 100644 --- a/src/Vies/Vies.php +++ b/src/Vies/Vies.php @@ -49,6 +49,7 @@ class Vies const VIES_PROTO = 'https'; const VIES_DOMAIN = 'ec.europa.eu'; const VIES_PORT = 443; + const VIES_PATH = '/taxation_customs/vies'; const VIES_WSDL = '/taxation_customs/vies/checkVatService.wsdl'; const VIES_TEST_WSDL = '/taxation_customs/vies/checkVatTestService.wsdl'; const VIES_EU_COUNTRY_TOTAL = 28; @@ -242,7 +243,7 @@ public function setOptions(array $options): self */ public function getHeartBeat(): HeartBeat { - $this->heartBeat = $this->heartBeat ?? new HeartBeat(self::VIES_DOMAIN, self::VIES_PORT); + $this->heartBeat = $this->heartBeat ?? new HeartBeat(self::VIES_DOMAIN, self::VIES_PORT, self::VIES_PATH); return $this->heartBeat; }