refactor: add DTO class to validate schema

This commit is contained in:
Maël Gangloff
2025-02-22 23:36:43 +01:00
parent 1db47dfa34
commit 5e1c84bb80
12 changed files with 186 additions and 94 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Service\Connector;
use App\Dto\Connector\GandiProviderDto;
use App\Entity\Domain;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
@@ -10,6 +11,9 @@ 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;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
@@ -20,11 +24,17 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
#[Autoconfigure(public: true)]
class GandiProvider extends AbstractProvider
{
protected string $dtoClass = GandiProviderDto::class;
private const BASE_URL = 'https://api.gandi.net';
public function __construct(CacheItemPoolInterface $cacheItemPool, private readonly HttpClientInterface $client)
{
parent::__construct($cacheItemPool);
public function __construct(
CacheItemPoolInterface $cacheItemPool,
private readonly HttpClientInterface $client,
DenormalizerInterface&NormalizerInterface $serializer,
ValidatorInterface $validator,
) {
parent::__construct($cacheItemPool, $serializer, $validator);
}
/**