<?php

namespace App\Data\Pagarme\Recipient;

use App\Data\Pagarme\PagarmeData;
use App\Data\Pagarme\Recipient\Parts\Request\AutomaticAnticipationSettingsData;
use App\Data\Pagarme\Recipient\Parts\Request\BankAccountData;
use App\Data\Pagarme\Recipient\Parts\Request\RegisterInformationData;
use App\Data\Pagarme\Recipient\Parts\Request\TransferSettingsData;

final readonly class RecipientRequestData extends PagarmeData
{
    public function __construct(
        public string $code,

        public RegisterInformationData           $registerInformation,
        public BankAccountData                   $defaultBankAccount,
        public TransferSettingsData              $transferSettings,
        public AutomaticAnticipationSettingsData $automaticAnticipationSettings,
    ) {
        self::requireFilled($this->code, 'code');
    }

    public function toArray(): array
    {
        return $this->filterFilledRecursive([
            'code'                            => $this->code,
            'register_information'            => $this->registerInformation,
            'default_bank_account'            => $this->defaultBankAccount,
            'transfer_settings'               => $this->transferSettings,
            'automatic_anticipation_settings' => $this->automaticAnticipationSettings,
        ]);
    }
}
