<?php

namespace App\Data\Pagarme\Request\CardRequestData;

use App\Data\Pagarme\PagarmeData;

final readonly class CardRequestData extends PagarmeData
{
    public function __construct(
        public string  $token,
        public ?string $label = null,
        public ?CardBillingAddressData $billingAddress = null,
    ) {
        self::requireFilled($this->token, 'token');
    }

    public function toArray(): array
    {
        return $this->filterFilledRecursive([
            'token'           => $this->token,
            'label'           => $this->label,
            'billing_address' => $this->billingAddress,
        ]);
    }
}
