<?php

declare(strict_types=1);

namespace App\Scolarite\Infrastructure\Api\Resource;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use App\Scolarite\Application\Query\GetBlockedDates\BlockedDateDto;
use App\Scolarite\Infrastructure\Api\Provider\BlockedDateCollectionProvider;

#[ApiResource(
    shortName: 'BlockedDate',
    operations: [
        new GetCollection(
            uriTemplate: '/schedule/blocked-dates',
            provider: BlockedDateCollectionProvider::class,
            name: 'get_blocked_dates',
        ),
    ],
)]
final class BlockedDateResource
{
    #[ApiProperty(identifier: true)]
    public ?string $date = null;

    public ?string $reason = null;

    public ?string $type = null;

    public static function fromDto(BlockedDateDto $dto): self
    {
        $resource = new self();
        $resource->date = $dto->date;
        $resource->reason = $dto->reason;
        $resource->type = $dto->type;

        return $resource;
    }
}
