<?php

declare(strict_types=1);

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

namespace PayPalRESTAPIsLib\Models;

use stdClass;

/**
 * An API resource used in the response of securely storing a SEPA Debit.
 */
class VaultSEPADebitResponse implements \JsonSerializable
{
    /**
     * @var string|null
     */
    private $ibanLastChars;

    /**
     * @var mixed
     */
    private $accountHolderName;

    /**
     * @var Address|null
     */
    private $billingAddress;

    /**
     * Returns Iban Last Chars.
     * The last characters of the IBAN used to pay.
     */
    public function getIbanLastChars(): ?string
    {
        return $this->ibanLastChars;
    }

    /**
     * Sets Iban Last Chars.
     * The last characters of the IBAN used to pay.
     *
     * @maps iban_last_chars
     */
    public function setIbanLastChars(?string $ibanLastChars): void
    {
        $this->ibanLastChars = $ibanLastChars;
    }

    /**
     * Returns Account Holder Name.
     *
     * @return mixed
     */
    public function getAccountHolderName()
    {
        return $this->accountHolderName;
    }

    /**
     * Sets Account Holder Name.
     *
     * @maps account_holder_name
     *
     * @param mixed $accountHolderName
     */
    public function setAccountHolderName($accountHolderName): void
    {
        $this->accountHolderName = $accountHolderName;
    }

    /**
     * Returns Billing Address.
     * The portable international postal address. Maps to [AddressValidationMetadata](https://github.
     * com/googlei18n/libaddressinput/wiki/AddressValidationMetadata) and HTML 5.1 [Autofilling form
     * controls: the autocomplete attribute](https://www.w3.org/TR/html51/sec-forms.html#autofilling-form-
     * controls-the-autocomplete-attribute).
     */
    public function getBillingAddress(): ?Address
    {
        return $this->billingAddress;
    }

    /**
     * Sets Billing Address.
     * The portable international postal address. Maps to [AddressValidationMetadata](https://github.
     * com/googlei18n/libaddressinput/wiki/AddressValidationMetadata) and HTML 5.1 [Autofilling form
     * controls: the autocomplete attribute](https://www.w3.org/TR/html51/sec-forms.html#autofilling-form-
     * controls-the-autocomplete-attribute).
     *
     * @maps billing_address
     */
    public function setBillingAddress(?Address $billingAddress): void
    {
        $this->billingAddress = $billingAddress;
    }

    /**
     * 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->ibanLastChars)) {
            $json['iban_last_chars']     = $this->ibanLastChars;
        }
        if (isset($this->accountHolderName)) {
            $json['account_holder_name'] = $this->accountHolderName;
        }
        if (isset($this->billingAddress)) {
            $json['billing_address']     = $this->billingAddress;
        }

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