<?php

namespace App\Dto\Output;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\Get;
use App\Entity\HardwareType;
use Symfony\Component\Serializer\Annotation\Groups;

#[Get(shortName: 'HardwareType')]
final class HardwareTypeOutput extends AbstractOutput
{
    #[Groups(['hardware-type:read', 'hardware:read'])]
    #[ApiProperty(
        description: 'El nombre del tipo de hardware',
        example: 'Tarjeta de red'
    )]
    public string $name;

    #[Groups(['hardware-type:read', 'hardware:read'])]
    #[ApiProperty(
        description: 'La descripción del tipo de hardware',
        example: 'Dispositivo de red Ethernet'
    )]
    public ?string $description = null;

    #[Groups(['hardware-type:read', 'hardware:read'])]
    #[ApiProperty(
        description: 'El código del tipo de hardware',
        example: 'NET'
    )]
    public ?string $code = null;

    #[Groups(['hardware-type:read', 'hardware:read'])]
    #[ApiProperty(
        description: 'Fecha de creación del tipo de hardware',
        example: '2024-01-15T10:30:00+00:00'
    )]
    public \DateTime $createdAt;

    public function __construct(HardwareType $hardwareType)
    {
        parent::__construct($hardwareType);

        $this->name = $hardwareType->getName();
        $this->description = $hardwareType->getDescription();
        $this->code = $hardwareType->getCode();
        $this->createdAt = $hardwareType->getCreatedAt();
    }
}