<?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;

/**
 * The vaulted payment method details.
 */
class PaymentTokenResponsePaymentSource implements \JsonSerializable
{
    /**
     * @var CardPaymentTokenEntity|null
     */
    private $card;

    /**
     * @var PaypalPaymentToken|null
     */
    private $paypal;

    /**
     * @var VenmoPaymentToken|null
     */
    private $venmo;

    /**
     * @var ApplePayPaymentToken|null
     */
    private $applePay;

    /**
     * Returns Card.
     * Full representation of a Card Payment Token including network token.
     */
    public function getCard(): ?CardPaymentTokenEntity
    {
        return $this->card;
    }

    /**
     * Sets Card.
     * Full representation of a Card Payment Token including network token.
     *
     * @maps card
     */
    public function setCard(?CardPaymentTokenEntity $card): void
    {
        $this->card = $card;
    }

    /**
     * Returns Paypal.
     * Full representation of a PayPal Payment Token.
     */
    public function getPaypal(): ?PaypalPaymentToken
    {
        return $this->paypal;
    }

    /**
     * Sets Paypal.
     * Full representation of a PayPal Payment Token.
     *
     * @maps paypal
     */
    public function setPaypal(?PaypalPaymentToken $paypal): void
    {
        $this->paypal = $paypal;
    }

    /**
     * Returns Venmo.
     * Full representation of a Venmo Payment Token.
     */
    public function getVenmo(): ?VenmoPaymentToken
    {
        return $this->venmo;
    }

    /**
     * Sets Venmo.
     * Full representation of a Venmo Payment Token.
     *
     * @maps venmo
     */
    public function setVenmo(?VenmoPaymentToken $venmo): void
    {
        $this->venmo = $venmo;
    }

    /**
     * Returns Apple Pay.
     * A resource representing a response for Apple Pay.
     */
    public function getApplePay(): ?ApplePayPaymentToken
    {
        return $this->applePay;
    }

    /**
     * Sets Apple Pay.
     * A resource representing a response for Apple Pay.
     *
     * @maps apple_pay
     */
    public function setApplePay(?ApplePayPaymentToken $applePay): void
    {
        $this->applePay = $applePay;
    }

    /**
     * Converts the PaymentTokenResponsePaymentSource object to a human-readable string representation.
     *
     * @return string The string representation of the PaymentTokenResponsePaymentSource object.
     */
    public function __toString(): string
    {
        return ApiHelper::stringify(
            'PaymentTokenResponsePaymentSource',
            [
                'card' => $this->card,
                'paypal' => $this->paypal,
                'venmo' => $this->venmo,
                'applePay' => $this->applePay
            ]
        );
    }

    /**
     * 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->card)) {
            $json['card']      = $this->card;
        }
        if (isset($this->paypal)) {
            $json['paypal']    = $this->paypal;
        }
        if (isset($this->venmo)) {
            $json['venmo']     = $this->venmo;
        }
        if (isset($this->applePay)) {
            $json['apple_pay'] = $this->applePay;
        }

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