<?php

declare(strict_types=1);

namespace App\ApiResources\Export;

use ApiPlatform\Metadata\ApiProperty;
use App\Enum\Export\ExportFormatEnum;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Demande d'export d'un fichier
 * -- C'est la classe de base des ressources de type ExportRequest --.
 */
abstract class ExportRequest
{
    /**
     * Id 'bidon' ajouté par défaut pour permettre la construction
     * de l'IRI par api platform.
     */
    #[ApiProperty(identifier: true)]
    protected int $id = 0;

    /**
     * Format de sortie attendu (pdf, txt...).
     */
    #[Assert\Type(type: ExportFormatEnum::class)]
    protected ExportFormatEnum $format;

    /**
     * The id of the access requesting this export.
     */
    protected ?int $requesterId = null;

    /**
     * Should the export be asynchrone.
     */
    protected bool $async = true;

    /**
     * The id of the db record of the file.
     */
    protected ?int $fileId = null;

    public function getId(): int
    {
        return $this->id;
    }

    public function getFormat(): ExportFormatEnum
    {
        return $this->format;
    }

    public function setFormat(ExportFormatEnum $format): void
    {
        $this->format = $format;
    }

    public function getRequesterId(): ?int
    {
        return $this->requesterId;
    }

    public function setRequesterId(?int $requesterId): void
    {
        $this->requesterId = $requesterId;
    }

    public function isAsync(): bool
    {
        return $this->async;
    }

    public function setAsync(bool $async): void
    {
        $this->async = $async;
    }

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

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