<?php
declare (strict_types=1);

namespace App\ApiResources\Core\File;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use App\Enum\Core\FileSizeEnum;
use App\State\Provider\Core\ImageProvider;
use Symfony\Component\Routing\Requirement\EnumRequirement;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * A request for a file from the LocalStorage
 */
#[ApiResource(
    operations: [
        new Get(
            uriTemplate: '/image/download/{fileId}/{size}',
            requirements: ['fileId' => '\\d+', 'size' => new EnumRequirement(FileSizeEnum::class)],
            security: 'is_granted("ROLE_FILE")',
            provider: ImageProvider::class
        )
    ]
)]
class Image
{
    #[ApiProperty(identifier: true)]
    private int $fileId;

    #[Assert\Type(type: FileSizeEnum::class)]
    private string $size;

    public function getFileId() : int
    {
        return $this->fileId;
    }

    public function setFileId(int $fileId) : self
    {
        $this->fileId = $fileId;
        return $this;
    }

    public function getSize(): string
    {
        return $this->size;
    }

    public function setSize(string $size): self
    {
        $this->size = $size;
        return $this;
    }

}
