<?php

namespace App\Data\Pagarme\Card;

use App\Data\Pagarme\PagarmeData;
use App\Data\Pagarme\Card\Parts\Request\BillingAddressData;

final readonly class CardRequestData extends PagarmeData
{
    public function __construct(
        public string  $token,
        public ?string $label = null,

        public ?BillingAddressData $billingAddress = null,
    ) {
        self::requireFilled($this->token, 'token');
    }

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