<?php

namespace App\Dto\Output;

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

#[Get(shortName: 'Software')]
final class SoftwareOutput extends AbstractOutput
{
    #[Groups(['software:read', 'software-profile:read'])]
    #[ApiProperty(
        description: 'El nombre del software',
        example: 'Microsoft Office 2019'
    )]
    public string $name;

    #[Groups(['software:read'])]
    #[ApiProperty(
        description: 'La descripción del software',
        example: 'Suite de oficina completa'
    )]
    public ?string $description = '';

    #[Groups(['software:read', 'software-profile:read'])]
    #[ApiProperty(
        description: 'El tipo de software',
        example: 'productivity'
    )]
    public ?string $type = '';

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

    #[Groups(['software:read'])]
    #[ApiProperty(
        description: 'Usuario que creó este registro',
        example: 'admin'
    )]
    public ?string $createdBy = null;

    public function __construct(Software $software)
    {
        parent::__construct($software);

        $this->name = $software->getName();
        $this->description = $software->getDescription();
        $this->type = $software->getType();
        $this->createdAt = $software->getCreatedAt();
        $this->createdBy = $software->getCreatedBy();
    }
}