<?php

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

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use App\Domain\Setting\Infrastructure\ApiPlatform\State\Provider\GetContentSourceStateProvider;
use Symfony\Component\Validator\Constraints as Assert;

#[ApiResource(
    shortName: 'ContentSource',
    operations: [
        new Get(
            uriTemplate: '/content-sources/{id}',
            provider: GetContentSourceStateProvider::class,
            description: 'Récupère une source de contenu par son identifiant'
        )
    ]
)]
class GetContentSourceResource
{
    public function __construct(
        #[Assert\NotBlank]
        #[Assert\Type('integer')]
        public readonly int $id,
        public readonly string $baseUrl,
        public readonly string $chapterUrlFormat,
        public readonly string $scrapingType,
        public readonly ?string $imageSelector,
        public readonly ?string $nextPageSelector,
        public readonly ?string $chapterSelector,
        public readonly string $cleanBaseUrl,
        public readonly ?string $testSlug = null,
        public readonly ?float $testChapterNumber = null,
        public readonly string $healthStatus = 'unknown',
        public readonly ?\DateTimeImmutable $healthLastTestedAt = null,
        public readonly ?string $healthLastError = null,
    ) {
    }
}
