<?php

declare(strict_types=1);

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

namespace PaypalServerSdkLib\Models;

use PaypalServerSdkLib\ApiHelper;
use stdClass;

/**
 * Information used to pay Bancontact.
 */
class BancontactPaymentObject implements \JsonSerializable
{
    /**
     * @var string|null
     */
    private $name;

    /**
     * @var string|null
     */
    private $countryCode;

    /**
     * @var string|null
     */
    private $bic;

    /**
     * @var string|null
     */
    private $ibanLastChars;

    /**
     * @var string|null
     */
    private $cardLastDigits;

    /**
     * Returns Name.
     * The full name representation like Mr J Smith.
     */
    public function getName(): ?string
    {
        return $this->name;
    }

    /**
     * Sets Name.
     * The full name representation like Mr J Smith.
     *
     * @maps name
     */
    public function setName(?string $name): void
    {
        $this->name = $name;
    }

    /**
     * Returns Country Code.
     * The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country
     * or region. Note: The country code for Great Britain is GB and not UK as used in the top-level domain
     * names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled
     * price (CUP) method, bank card, and cross-border transactions.
     */
    public function getCountryCode(): ?string
    {
        return $this->countryCode;
    }

    /**
     * Sets Country Code.
     * The [two-character ISO 3166-1 code](/api/rest/reference/country-codes/) that identifies the country
     * or region. Note: The country code for Great Britain is GB and not UK as used in the top-level domain
     * names for that country. Use the `C2` country code for China worldwide for comparable uncontrolled
     * price (CUP) method, bank card, and cross-border transactions.
     *
     * @maps country_code
     */
    public function setCountryCode(?string $countryCode): void
    {
        $this->countryCode = $countryCode;
    }

    /**
     * Returns Bic.
     * The business identification code (BIC). In payments systems, a BIC is used to identify a specific
     * business, most commonly a bank.
     */
    public function getBic(): ?string
    {
        return $this->bic;
    }

    /**
     * Sets Bic.
     * The business identification code (BIC). In payments systems, a BIC is used to identify a specific
     * business, most commonly a bank.
     *
     * @maps bic
     */
    public function setBic(?string $bic): void
    {
        $this->bic = $bic;
    }

    /**
     * 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 Card Last Digits.
     * The last digits of the card used to fund the Bancontact payment.
     */
    public function getCardLastDigits(): ?string
    {
        return $this->cardLastDigits;
    }

    /**
     * Sets Card Last Digits.
     * The last digits of the card used to fund the Bancontact payment.
     *
     * @maps card_last_digits
     */
    public function setCardLastDigits(?string $cardLastDigits): void
    {
        $this->cardLastDigits = $cardLastDigits;
    }

    /**
     * Converts the BancontactPaymentObject object to a human-readable string representation.
     *
     * @return string The string representation of the BancontactPaymentObject object.
     */
    public function __toString(): string
    {
        return ApiHelper::stringify(
            'BancontactPaymentObject',
            [
                'name' => $this->name,
                'countryCode' => $this->countryCode,
                'bic' => $this->bic,
                'ibanLastChars' => $this->ibanLastChars,
                'cardLastDigits' => $this->cardLastDigits
            ]
        );
    }

    /**
     * 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->name)) {
            $json['name']             = $this->name;
        }
        if (isset($this->countryCode)) {
            $json['country_code']     = $this->countryCode;
        }
        if (isset($this->bic)) {
            $json['bic']              = $this->bic;
        }
        if (isset($this->ibanLastChars)) {
            $json['iban_last_chars']  = $this->ibanLastChars;
        }
        if (isset($this->cardLastDigits)) {
            $json['card_last_digits'] = $this->cardLastDigits;
        }

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