<?php

namespace App\Dto\Output;

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

#[Get(shortName: 'RemoteCalendarRule')]
final class RemoteCalendarRuleOutput extends AbstractOutput
{
    #[Groups(['remote-calendar-rule:read', 'remote-calendar:read'])]
    #[ApiProperty(
        description: 'Los días de la semana ocupados',
        example: ['monday', 'wednesday', 'friday']
    )]
    public ?array $busyWeekDays = null;

    #[Groups(['remote-calendar-rule:read', 'remote-calendar:read'])]
    #[ApiProperty(
        description: 'Hora de inicio del periodo ocupado',
        example: '08:00'
    )]
    public ?string $busyFromHour =  null;

    #[Groups(['remote-calendar-rule:read', 'remote-calendar:read'])]
    #[ApiProperty(
        description: 'Hora de fin del periodo ocupado',
        example: '14:00'
    )]
    public ?string $busyToHour = null;

    #[Groups(['remote-calendar-rule:read', 'remote-calendar:read'])]
    #[ApiProperty(
        description: 'Indica si está disponible para acceso remoto',
        example: true
    )]
    public ?bool $isRemoteAvailable = false;

    #[Groups(['remote-calendar-rule:read', 'remote-calendar:read'])]
    #[ApiProperty(
        description: 'Fecha desde la que está disponible',
        example: '2024-01-15T00:00:00+00:00'
    )]
    public ?\DateTimeInterface $availableFromDate = null;

    #[Groups(['remote-calendar-rule:read', 'remote-calendar:read'])]
    #[ApiProperty(
        description: 'Fecha hasta la que está disponible',
        example: '2024-06-30T23:59:59+00:00'
    )]
    public ?\DateTimeInterface $availableToDate = null;

    #[Groups(['remote-calendar-rule:read', 'remote-calendar:read'])]
    #[ApiProperty(
        description: 'El motivo de la disponibilidad',
        example: 'Periodo lectivo'
    )]
    public ?string $availableReason = null;

    public function __construct(RemoteCalendarRule $remoteCalendarRule)
    {
        parent::__construct($remoteCalendarRule);

        $this->busyWeekDays = $remoteCalendarRule->getBusyWeekDays();
        $this->busyFromHour = $remoteCalendarRule->getBusyFromHour();
        $this->busyToHour = $remoteCalendarRule->getBusyToHour();
        $this->isRemoteAvailable = $remoteCalendarRule->isRemoteAvailable();
        $this->availableFromDate = $remoteCalendarRule->getAvailableFromDate();
        $this->availableToDate = $remoteCalendarRule->getAvailableToDate();
        $this->availableReason = $remoteCalendarRule->getAvailableReason();
    }
}