<?php

namespace App\Data\Pagarme\Recipient\Parts\Request;

use App\Data\Pagarme\PagarmeData;

final readonly class PhoneData extends PagarmeData
{
    public function __construct(
        public string $ddd,
        public string $number,
        public string $type,
    ) {
        self::requireFilled($this->ddd, 'phone.ddd');
        self::requireFilled($this->number, 'phone.number');
        self::requireIn($this->type, ['home', 'mobile'], 'phone.type');
    }

    public function toArray(): array
    {
        return $this->filterFilledRecursive([
            'ddd'    => $this->ddd,
            'number' => $this->number,
            'type'   => $this->type,
        ]);
    }
}
