<?php
declare(strict_types=1);

namespace App\Core\DTO;

final class PaymentRequest
{
    public function __construct(
        public readonly ?int $memberId,
        public readonly string $amount,
        public readonly string $paymentType,
        public readonly string $paymentMethod = 'cash',
        public readonly ?string $description = null,
        public readonly ?string $checkNumber = null,
        public readonly ?string $checkBank = null,
        public readonly ?string $checkDate = null,
        public readonly ?string $visaReference = null,
        public readonly ?string $transferReference = null,
        public readonly ?string $relatedEntityType = null,
        public readonly ?int $relatedEntityId = null,
        public readonly ?string $notes = null,
        public readonly ?string $guestName = null,
    ) {}

    public function toArray(): array
    {
        return array_filter([
            'member_id' => $this->memberId,
            'amount' => $this->amount,
            'payment_type' => $this->paymentType,
            'payment_method' => $this->paymentMethod,
            'description' => $this->description,
            'check_number' => $this->checkNumber,
            'check_bank' => $this->checkBank,
            'check_date' => $this->checkDate,
            'visa_reference' => $this->visaReference,
            'transfer_reference' => $this->transferReference,
            'related_entity_type' => $this->relatedEntityType,
            'related_entity_id' => $this->relatedEntityId,
            'notes' => $this->notes,
            'guest_name' => $this->guestName,
        ], fn($v) => $v !== null);
    }
}
