From e6bf43693d956c83de2c13b92aee7b16e2a8e135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Wed, 2 Oct 2024 12:01:07 +0200 Subject: [PATCH] fix: https instead of http --- src/Service/Connector/GandiProvider.php | 6 ++-- src/Service/Connector/NamecheapProvider.php | 36 +++++++++++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/Service/Connector/GandiProvider.php b/src/Service/Connector/GandiProvider.php index da3d957..35205aa 100644 --- a/src/Service/Connector/GandiProvider.php +++ b/src/Service/Connector/GandiProvider.php @@ -86,9 +86,6 @@ public function orderDomain(Domain $domain, bool $dryRun = false): void } } - /** - * @throws TransportExceptionInterface - */ public function verifyAuthData(array $authData): array { $token = $authData['token']; @@ -123,6 +120,9 @@ public function verifyAuthData(array $authData): array return $authDataReturned; } + /** + * @throws TransportExceptionInterface + */ public function assertAuthentication(): void { $response = $this->client->request('GET', '/v5/organization/user-info', (new HttpOptions()) diff --git a/src/Service/Connector/NamecheapProvider.php b/src/Service/Connector/NamecheapProvider.php index 06168bf..e85fa44 100644 --- a/src/Service/Connector/NamecheapProvider.php +++ b/src/Service/Connector/NamecheapProvider.php @@ -3,9 +3,15 @@ namespace App\Service\Connector; use App\Entity\Domain; +use Exception; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; +use Psr\Cache\InvalidArgumentException; use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; +use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; +use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; #[Autoconfigure(public: true)] @@ -13,13 +19,17 @@ class NamecheapProvider extends AbstractProvider { public const BASE_URL = 'https://api.namecheap.com/xml.response'; - public const SANDBOX_BASE_URL = 'http://api.sandbox.namecheap.com/xml.response'; + public const SANDBOX_BASE_URL = 'https://api.sandbox.namecheap.com/xml.response'; public function __construct(CacheItemPoolInterface $cacheItemPool, private HttpClientInterface $client, private readonly string $outgoingIp) { parent::__construct($cacheItemPool); } + /** + * @throws \Exception + * @throws TransportExceptionInterface + */ public function orderDomain(Domain $domain, $dryRun): void { $addressesRes = $this->call('namecheap.users.address.getList', [], $dryRun); @@ -51,13 +61,20 @@ public function orderDomain(Domain $domain, $dryRun): void ], $domainAddresses), $dryRun); } - private static function mergePrefixKeys(string $prefix, array|object $src, array &$dest) + private static function mergePrefixKeys(string $prefix, array|object $src, array &$dest): void { foreach ($src as $key => $value) { $dest[$prefix.$key] = $value; } } + /** + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + * @throws RedirectionExceptionInterface + * @throws ClientExceptionInterface + * @throws \Exception + */ private function call(string $command, array $parameters = [], bool $dryRun = true): object { $actualParams = array_merge([ @@ -91,16 +108,31 @@ public function verifyAuthData(array $authData): array ]; } + /** + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + * @throws RedirectionExceptionInterface + * @throws ClientExceptionInterface + */ public function assertAuthentication(): void { $this->call('namecheap.domains.gettldlist', [], false); } + /** + * @throws InvalidArgumentException + */ protected function getCachedTldList(): CacheItemInterface { return $this->cacheItemPool->getItem('app.provider.namecheap.supported-tld'); } + /** + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + * @throws RedirectionExceptionInterface + * @throws ClientExceptionInterface + */ protected function getSupportedTldList(): array { $supported = [];