<?php

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

use App\Data\Pagarme\PagarmeData;

final readonly class PixData extends PagarmeData
{
    /**
     * @param  PixAdditionalInformationData[]|null  $additionalInformation
     */

    public function __construct(
        public ?int   $expiresIn             = null,
        public ?array $additionalInformation = null,
    ) {
        if ($this->expiresIn === null) {
            throw new \InvalidArgumentException(
                'pix.expires_in e obrigatorio.'
            );
        }
    }

    public function toArray(): array
    {
        return $this->filterFilledRecursive([
            'expires_in'             => $this->expiresIn,
            'additional_information' => $this->additionalInformation,
        ]);
    }
}
