mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: ovh API implement
This commit is contained in:
@@ -2,10 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Config\TriggerAction;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Entity\WatchList;
|
use App\Entity\WatchList;
|
||||||
|
use App\Entity\WatchListTrigger;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Exception;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
@@ -36,6 +39,9 @@ class WatchListController extends AbstractController
|
|||||||
return $user->getWatchLists();
|
return $user->getWatchLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
#[Route(
|
#[Route(
|
||||||
path: '/api/watchlists',
|
path: '/api/watchlists',
|
||||||
name: 'watchlist_create',
|
name: 'watchlist_create',
|
||||||
@@ -49,6 +55,14 @@ class WatchListController extends AbstractController
|
|||||||
{
|
{
|
||||||
$watchList = $this->serializer->deserialize($request->getContent(), WatchList::class, 'json', ['groups' => 'watchlist:create']);
|
$watchList = $this->serializer->deserialize($request->getContent(), WatchList::class, 'json', ['groups' => 'watchlist:create']);
|
||||||
$watchList->setUser($this->getUser());
|
$watchList->setUser($this->getUser());
|
||||||
|
/** @var WatchListTrigger $trigger */
|
||||||
|
foreach ($watchList->getWatchListTriggers()->toArray() as $trigger) {
|
||||||
|
if ($trigger->getAction() === TriggerAction::SendEmail && $trigger->getConnector() !== null)
|
||||||
|
throw new Exception('No connector needed to send email');
|
||||||
|
if ($trigger->getAction() === TriggerAction::BuyDomain && $trigger->getConnector() === null)
|
||||||
|
throw new Exception('Unable to order a domain name without a Connector');
|
||||||
|
}
|
||||||
|
|
||||||
$this->em->persist($watchList);
|
$this->em->persist($watchList);
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user