mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: start ovh API implement
This commit is contained in:
@@ -6,5 +6,10 @@ use App\Entity\Domain;
|
|||||||
|
|
||||||
interface ConnectorInterface
|
interface ConnectorInterface
|
||||||
{
|
{
|
||||||
public function orderDomain(Domain $domain, bool $acceptConditions, bool $ownerLegalAge, bool $waiveRetractationPeriod): void;
|
public function orderDomain(Domain $domain,
|
||||||
|
bool $acceptConditions,
|
||||||
|
bool $ownerLegalAge,
|
||||||
|
bool $waiveRetractationPeriod,
|
||||||
|
bool $dryRyn
|
||||||
|
): void;
|
||||||
}
|
}
|
||||||
@@ -6,4 +6,5 @@ namespace App\Config;
|
|||||||
enum TriggerAction: string
|
enum TriggerAction: string
|
||||||
{
|
{
|
||||||
case SendEmail = 'email';
|
case SendEmail = 'email';
|
||||||
|
case BuyDomain = 'buy';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,18 @@ class OVHConnector extends Connector implements ConnectorInterface
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Order a domain name with the OVH API
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function orderDomain(Domain $domain, bool $acceptConditions, bool $ownerLegalAge, bool $waiveRetractationPeriod): void
|
public function orderDomain(Domain $domain,
|
||||||
|
bool $acceptConditions,
|
||||||
|
bool $ownerLegalAge,
|
||||||
|
bool $waiveRetractationPeriod,
|
||||||
|
bool $dryRyn = false
|
||||||
|
): void
|
||||||
{
|
{
|
||||||
|
if (!$domain->getDeleted()) throw new Exception('The domain name still appears in the WHOIS database.');
|
||||||
|
|
||||||
$ldhName = $domain->getLdhName();
|
$ldhName = $domain->getLdhName();
|
||||||
if (!$ldhName) throw new Exception("Domain name cannot be null.");
|
if (!$ldhName) throw new Exception("Domain name cannot be null.");
|
||||||
|
|
||||||
@@ -83,11 +91,11 @@ class OVHConnector extends Connector implements ConnectorInterface
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$conn->get("/order/cart/{$cartId}/checkout");
|
$conn->get("/order/cart/{$cartId}/checkout");
|
||||||
/*
|
|
||||||
|
if ($dryRyn) return;
|
||||||
$conn->post("/order/cart/{$cartId}/checkout", [
|
$conn->post("/order/cart/{$cartId}/checkout", [
|
||||||
"autoPayWithPreferredPaymentMethod" => true,
|
"autoPayWithPreferredPaymentMethod" => true,
|
||||||
"waiveRetractationPeriod" => $waiveRetractationPeriod
|
"waiveRetractationPeriod" => $waiveRetractationPeriod
|
||||||
]);
|
]);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ namespace App\MessageHandler;
|
|||||||
use App\Config\TriggerAction;
|
use App\Config\TriggerAction;
|
||||||
use App\Entity\Domain;
|
use App\Entity\Domain;
|
||||||
use App\Entity\DomainEvent;
|
use App\Entity\DomainEvent;
|
||||||
|
use App\Entity\OVHConnector;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Entity\WatchList;
|
use App\Entity\WatchList;
|
||||||
use App\Entity\WatchListTrigger;
|
use App\Entity\WatchListTrigger;
|
||||||
@@ -53,6 +54,13 @@ final readonly class ProcessDomainTriggerHandler
|
|||||||
switch ($watchListTrigger->getAction()) {
|
switch ($watchListTrigger->getAction()) {
|
||||||
case TriggerAction::SendEmail:
|
case TriggerAction::SendEmail:
|
||||||
$this->sendEmailDomainUpdated($event, $watchList->getUser());
|
$this->sendEmailDomainUpdated($event, $watchList->getUser());
|
||||||
|
break;
|
||||||
|
case TriggerAction::BuyDomain :
|
||||||
|
if ($watchListTrigger->getConnector() === null) throw new Exception('Connector is missing');
|
||||||
|
$connector = $watchListTrigger->getConnector();
|
||||||
|
if ($connector::class === OVHConnector::class) {
|
||||||
|
$connector->orderDomain($domain, true, true, true, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user