mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: implement OpenProvider
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Service\Provider\EppClientProvider;
|
||||
use App\Service\Provider\GandiProvider;
|
||||
use App\Service\Provider\NamecheapProvider;
|
||||
use App\Service\Provider\NameComProvider;
|
||||
use App\Service\Provider\OpenProviderProvider;
|
||||
use App\Service\Provider\OvhProvider;
|
||||
|
||||
enum ConnectorProvider: string
|
||||
@@ -16,6 +17,7 @@ enum ConnectorProvider: string
|
||||
case AUTODNS = 'autodns';
|
||||
case NAMECHEAP = 'namecheap';
|
||||
case NAMECOM = 'namecom';
|
||||
case OPENPROVIDER = 'openprovider';
|
||||
case EPP = 'epp';
|
||||
|
||||
public function getConnectorProvider(): string
|
||||
@@ -27,6 +29,7 @@ enum ConnectorProvider: string
|
||||
ConnectorProvider::NAMECHEAP => NamecheapProvider::class,
|
||||
ConnectorProvider::NAMECOM => NameComProvider::class,
|
||||
ConnectorProvider::EPP => EppClientProvider::class,
|
||||
ConnectorProvider::OPENPROVIDER => OpenProviderProvider::class,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,4 @@ final class OpenProviderProviderDto extends DefaultProviderDto
|
||||
public int $period = 1;
|
||||
|
||||
public string $nsGroup;
|
||||
|
||||
#[Assert\Choice(['off', 'on', 'default'])]
|
||||
#[Assert\NotBlank]
|
||||
public string $autoRenew = 'default';
|
||||
}
|
||||
|
||||
@@ -5,14 +5,13 @@ namespace App\Service\Provider;
|
||||
use App\Dto\Connector\DefaultProviderDto;
|
||||
use App\Dto\Connector\OpenProviderProviderDto;
|
||||
use App\Entity\Domain;
|
||||
use App\Service\Provider\AbstractProvider;
|
||||
use App\Exception\Provider\DomainOrderFailedExeption;
|
||||
use App\Exception\Provider\InvalidLoginException;
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
|
||||
use Symfony\Component\HttpClient\HttpOptions;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
@@ -28,7 +27,7 @@ class OpenProviderProvider extends AbstractProvider
|
||||
/** @var OpenProviderProviderDto */
|
||||
protected DefaultProviderDto $authData;
|
||||
|
||||
private const string BASE_URL = 'https://api.openprovider.eu/v1beta';
|
||||
private const string BASE_URL = 'https://api.openprovider.eu';
|
||||
|
||||
public function __construct(
|
||||
CacheItemPoolInterface $cacheItemPool,
|
||||
@@ -54,49 +53,73 @@ class OpenProviderProvider extends AbstractProvider
|
||||
}
|
||||
|
||||
$payload = [
|
||||
'accept_eap_fee' => 0,
|
||||
'accept_premium_fee' => 0,
|
||||
// additional_data
|
||||
'admin_handle' => $this->authData->adminHandle,
|
||||
// application_mode
|
||||
// application_notice_id
|
||||
// application_smd
|
||||
// auth_code
|
||||
'autorenew' => 'default',
|
||||
'billing_handle' => $this->authData->billingHandle,
|
||||
'owner_handle' => $this->authData->ownerHandle,
|
||||
'tech_handle' => $this->authData->techHandle,
|
||||
'comments' => 'Ordered with Domain Watchdog',
|
||||
// dnssec_keys
|
||||
'domain' => [
|
||||
'name' => explode('.', $domain->getLdhName(), 2)[0],
|
||||
'extension' => explode('.', $domain->getLdhName(), 2)[1],
|
||||
],
|
||||
'period' => '1',
|
||||
// is_dnssec_enabled
|
||||
// is_easy_dmarc_enabled
|
||||
// is_private_whois_enabled
|
||||
// is_sectigo_dns_enabled
|
||||
// is_spamexperts_enabled
|
||||
// name_servers
|
||||
'ns_group' => $this->authData->nsGroup,
|
||||
'autorenew' => 'default',
|
||||
// ns_template_id
|
||||
// ns_template_name
|
||||
'owner_handle' => $this->authData->ownerHandle,
|
||||
'period' => $this->authData->period,
|
||||
// promo_code
|
||||
// provider
|
||||
'tech_handle' => $this->authData->techHandle,
|
||||
// unit
|
||||
// use_domicile
|
||||
];
|
||||
|
||||
if (null !== $this->authData->resellerHandle) {
|
||||
$payload['resellerHandle'] = $this->authData->resellerHandle;
|
||||
}
|
||||
|
||||
$res = $this->client->request('POST', '/domain', (new HttpOptions())
|
||||
if ($dryRun) {
|
||||
return;
|
||||
}
|
||||
|
||||
$res = $this->client->request('POST', '/v1beta/domain', (new HttpOptions())
|
||||
->setAuthBearer($this->authData->token)
|
||||
->setHeader('Accept', 'application/json')
|
||||
->setBaseUri(self::BASE_URL)
|
||||
->setJson($payload)->toArray());
|
||||
|
||||
if ((!$dryRun && Response::HTTP_ACCEPTED !== $res->getStatusCode())
|
||||
|| ($dryRun && Response::HTTP_OK !== $res->getStatusCode())) {
|
||||
throw new HttpException($res->toArray()['message']);
|
||||
if (Response::HTTP_OK !== $res->getStatusCode()) {
|
||||
throw new DomainOrderFailedExeption($res->toArray()['message']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws InvalidLoginException
|
||||
*/
|
||||
protected function assertAuthentication(): void
|
||||
{
|
||||
$response = $this->client->request('GET', '/customers', (new HttpOptions())
|
||||
$response = $this->client->request('GET', '/v1beta/customers', (new HttpOptions())
|
||||
->setAuthBearer($this->authData->token)
|
||||
->setHeader('Accept', 'application/json')
|
||||
->setBaseUri(self::BASE_URL)
|
||||
->toArray()
|
||||
);
|
||||
|
||||
if (Response::HTTP_OK !== $response->getStatusCode()) {
|
||||
throw new BadRequestHttpException('The status of these credentials is not valid');
|
||||
throw new InvalidLoginException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user