<?php

declare(strict_types=1);

/*
 * PayPalRESTAPIsLib
 *
 * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
 */

namespace PayPalRESTAPIsLib\Models;

use stdClass;

/**
 * Full representation of a Bank Payment Token.
 */
class BankPaymentToken implements \JsonSerializable
{
    /**
     * @var ACHDebitResponse|null
     */
    private $achDebit;

    /**
     * @var SEPADebitResponse|null
     */
    private $sepaDebit;

    /**
     * Returns Ach Debit.
     * A Resource representing a response of vaulted a ACH Debit Account.
     */
    public function getAchDebit(): ?ACHDebitResponse
    {
        return $this->achDebit;
    }

    /**
     * Sets Ach Debit.
     * A Resource representing a response of vaulted a ACH Debit Account.
     *
     * @maps ach_debit
     */
    public function setAchDebit(?ACHDebitResponse $achDebit): void
    {
        $this->achDebit = $achDebit;
    }

    /**
     * Returns Sepa Debit.
     */
    public function getSepaDebit(): ?SEPADebitResponse
    {
        return $this->sepaDebit;
    }

    /**
     * Sets Sepa Debit.
     *
     * @maps sepa_debit
     */
    public function setSepaDebit(?SEPADebitResponse $sepaDebit): void
    {
        $this->sepaDebit = $sepaDebit;
    }

    /**
     * Encode this object to JSON
     *
     * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields
     *        are set. (default: false)
     *
     * @return array|stdClass
     */
    #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1)
    public function jsonSerialize(bool $asArrayWhenEmpty = false)
    {
        $json = [];
        if (isset($this->achDebit)) {
            $json['ach_debit']  = $this->achDebit;
        }
        if (isset($this->sepaDebit)) {
            $json['sepa_debit'] = $this->sepaDebit;
        }

        return (!$asArrayWhenEmpty && empty($json)) ? new stdClass() : $json;
    }
}
