<?php

namespace App\Dto\Output;

use ApiPlatform\Metadata\Get;
use App\Entity\Menu;
use App\Entity\Trace;
use Symfony\Component\Serializer\Annotation\Groups;

#[Get(shortName: 'Trace')]
final class TraceOutput extends AbstractOutput
{
    #[Groups(['trace:read'])]
    public ?string $command;

    #[Groups(['trace:read'])]
    public ?ClientOutput $client = null;

    #[Groups(['trace:read'])]
    public string $status;

    #[Groups(['trace:read'])]
    public ?string $jobId = null;

    #[Groups(['trace:read'])]
    public ?\DateTimeInterface $executedAt = null;

    #[Groups(['trace:read'])]
    public ?string $output = null;

    #[Groups(['trace:read'])]
    public ?array $input = null;

    #[Groups(['trace:read'])]
    public ?\DateTimeInterface $finishedAt = null;

    #[Groups(['trace:read'])]
    public ?float $progress = null;

    #[Groups(['trace:read'])]
    public \DateTime $createdAt;

    #[Groups(['trace:read'])]
    public ?string $createdBy = null;

    public function __construct(Trace $trace)
    {
        parent::__construct($trace);

        $this->command = $trace->getCommand();

        if ($trace->getClient() !== null) {
            $this->client = new ClientOutput($trace->getClient());
        }

        $this->status = $trace->getStatus();
        $this->jobId = $trace->getJobId();
        $this->executedAt = $trace->getExecutedAt();
        $this->output = $trace->getOutput();
        $this->input = $trace->getInput();
        $this->finishedAt = $trace->getFinishedAt();
        $this->progress = $trace->getProgress();
        $this->createdAt = $trace->getCreatedAt();
        $this->createdBy = $trace->getCreatedBy();
    }
}