<?php

declare(strict_types=1);

/*
 * This file is part of the VITICORE2 package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Bridge\Symfony\Bundle\Form\Site\Withdrawal\Model;

use CpCreation\VitiCore\Cart\Model\WithdrawalRequest;
use Symfony\Component\Validator\Constraints as Assert;

final class WithdrawalRequestData
{
    #[Assert\NotBlank(message: 'withdrawal.validation.firstname_required')]
    #[Assert\Length(max: 255)]
    public ?string $firstname = null;

    #[Assert\NotBlank(message: 'withdrawal.validation.lastname_required')]
    #[Assert\Length(max: 255)]
    public ?string $lastname = null;

    #[Assert\NotBlank(message: 'withdrawal.validation.reference_required')]
    #[Assert\Length(max: 255)]
    public ?string $contractReference = null;

    #[Assert\NotBlank(message: 'withdrawal.validation.email_required')]
    #[Assert\Email(message: 'withdrawal.validation.email_invalid')]
    #[Assert\Length(max: 254)]
    public ?string $receiptEmail = null;

    #[Assert\NotNull(message: 'withdrawal.validation.order_received_required')]
    public ?bool $orderReceived = null;

    #[Assert\When(
        expression: 'this.orderReceived === true',
        constraints: [new Assert\NotNull(message: 'withdrawal.validation.received_at_required')],
    )]
    #[Assert\LessThanOrEqual(value: 'today', message: 'withdrawal.validation.received_at_future')]
    public ?\DateTimeImmutable $receivedAt = null;

    #[Assert\Choice(choices: WithdrawalRequest::REASON_CODES)]
    public ?string $reasonCode = null;

    #[Assert\Length(max: WithdrawalRequest::COMMENT_MAX_LENGTH)]
    public ?string $comment = null;
}
