<?php

namespace App\Data\Pagarme\Request\RecipientRequestData;

use App\Data\Pagarme\PagarmeData;
use App\Data\Pagarme\Request\RecipientRequestData\RecipientRegisterInformationData\RecipientRegisterInformationData;

final readonly class RecipientRequestData extends PagarmeData
{
    public function __construct(
        public string $code,
        public RecipientRegisterInformationData $registerInformation,
        public RecipientBankAccountData         $defaultBankAccount,
        public RecipientTransferSettingsData    $transferSettings,
        public RecipientAutomaticAnticipationSettingsData $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,
        ]);
    }
}
