Skip to content

Commit

Permalink
fix: https instead of http
Browse files Browse the repository at this point in the history
  • Loading branch information
maelgangloff committed Oct 2, 2024
1 parent 81512be commit e6bf436
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Service/Connector/GandiProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ public function orderDomain(Domain $domain, bool $dryRun = false): void
}
}

/**
* @throws TransportExceptionInterface
*/
public function verifyAuthData(array $authData): array
{
$token = $authData['token'];
Expand Down Expand Up @@ -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())
Expand Down
36 changes: 34 additions & 2 deletions src/Service/Connector/NamecheapProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,33 @@
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)]
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);
Expand Down Expand Up @@ -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([
Expand Down Expand Up @@ -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 = [];
Expand Down

0 comments on commit e6bf436

Please sign in to comment.