<?php

namespace App\Domain\Setting\Infrastructure\ApiPlatform\Resource;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Post;
use App\Domain\Setting\Infrastructure\ApiPlatform\State\Processor\ImportContentSourceStateProcessor;
use Symfony\Component\Validator\Constraints as Assert;

#[ApiResource(
    shortName: 'ContentSource',
    operations: [
        new Post(
            uriTemplate: '/content-sources/import',
            processor: ImportContentSourceStateProcessor::class,
            input: ImportContentSourceResource::class,
            status: 201,
            description: 'Importe des sources de contenu depuis un tableau JSON'
        )
    ]
)]
class ImportContentSourceResource
{
    public function __construct(
        #[Assert\NotBlank(message: 'Les sources de contenu sont obligatoires')]
        #[Assert\Type('array', message: 'Les sources de contenu doivent être un tableau')]
        #[Assert\Count(min: 1, minMessage: 'Au moins une source de contenu doit être fournie')]
        public readonly array $contentSources = []
    ) {
    }
}
