mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-23 20:55:45 +00:00
refactor: connector abstraction
This commit is contained in:
parent
700e531e22
commit
2f841f0127
13
src/Service/Connector/AbstractConnector.php
Normal file
13
src/Service/Connector/AbstractConnector.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\Connector;
|
||||
|
||||
abstract class AbstractConnector implements ConnectorInterface
|
||||
{
|
||||
protected array $authData;
|
||||
|
||||
public function authenticate(array $authData)
|
||||
{
|
||||
$this->authData = $authData;
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
interface ConnectorInterface
|
||||
{
|
||||
public function __construct(array $authData, HttpClientInterface $client);
|
||||
public function authenticate(array $authData);
|
||||
|
||||
public function orderDomain(Domain $domain, bool $dryRun): void;
|
||||
|
||||
|
||||
@ -12,11 +12,11 @@ use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
readonly class GandiConnector implements ConnectorInterface
|
||||
class GandiConnector extends AbstractConnector
|
||||
{
|
||||
private const BASE_URL = 'https://api.gandi.net/v5';
|
||||
|
||||
public function __construct(private array $authData, private HttpClientInterface $client)
|
||||
public function __construct(private HttpClientInterface $client)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -5,13 +5,13 @@ namespace App\Service\Connector;
|
||||
use App\Entity\Domain;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
readonly class NamecheapConnector implements ConnectorInterface
|
||||
class NamecheapConnector extends AbstractConnector
|
||||
{
|
||||
public const BASE_URL = 'https://api.namecheap.com/xml.response';
|
||||
|
||||
public const SANDBOX_BASE_URL = 'http://api.sandbox.namecheap.com/xml.response';
|
||||
|
||||
public function __construct(private array $authData, private HttpClientInterface $client)
|
||||
public function __construct(private HttpClientInterface $client)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
readonly class OvhConnector implements ConnectorInterface
|
||||
class OvhConnector extends AbstractConnector
|
||||
{
|
||||
public const REQUIRED_ROUTES = [
|
||||
[
|
||||
@ -33,7 +33,7 @@ readonly class OvhConnector implements ConnectorInterface
|
||||
],
|
||||
];
|
||||
|
||||
public function __construct(private array $authData, private HttpClientInterface $client)
|
||||
public function __construct(private HttpClientInterface $client)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user