feat: get supported tlds by namecheap

This commit is contained in:
Vincent
2024-09-25 14:03:16 +02:00
parent f0e708272e
commit f70ddb6b05

View File

@@ -4,6 +4,7 @@ namespace App\Service\Connector;
use App\Entity\Domain; use App\Entity\Domain;
use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\HttpClientInterface;
@@ -14,8 +15,9 @@ class NamecheapConnector extends AbstractProvider
public const SANDBOX_BASE_URL = 'http://api.sandbox.namecheap.com/xml.response'; public const SANDBOX_BASE_URL = 'http://api.sandbox.namecheap.com/xml.response';
public function __construct(private HttpClientInterface $client, private readonly string $outgoingIp) public function __construct(CacheItemPoolInterface $cacheItemPool, private HttpClientInterface $client, private readonly string $outgoingIp)
{ {
parent::__construct($cacheItemPool);
} }
public function orderDomain(Domain $domain, $dryRun): void public function orderDomain(Domain $domain, $dryRun): void
@@ -86,11 +88,19 @@ class NamecheapConnector extends AbstractProvider
protected function getCachedTldList(): CacheItemInterface protected function getCachedTldList(): CacheItemInterface
{ {
// TODO: Implement getCachedTldList() method. return $this->cacheItemPool->getItem('app.provider.namecheap.supported-tld');
} }
protected function getSupportedTldList(): array protected function getSupportedTldList(): array
{ {
// TODO: Implement getSupportedTldList() method. $supported = [];
$tlds = $this->call('namecheap.domains.gettldlist', [], false)->Tlds->Tld;
for ($i = 0; $i < $tlds->count(); ++$i) {
$supported[] = (string) $tlds[$i]['Name'];
}
return $supported;
} }
} }