<?php

declare(strict_types=1);

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

namespace PaypalServerSdkLib\Models;

use stdClass;

/**
 * The setup payment method details.
 */
class SetupTokenResponsePaymentSource implements \JsonSerializable
{
    /**
     * @var SetupTokenResponseCard|null
     */
    private $card;

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

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

    /**
     * Returns Card.
     */
    public function getCard(): ?SetupTokenResponseCard
    {
        return $this->card;
    }

    /**
     * Sets Card.
     *
     * @maps card
     */
    public function setCard(?SetupTokenResponseCard $card): void
    {
        $this->card = $card;
    }

    /**
     * Returns Paypal.
     */
    public function getPaypal(): ?PaypalPaymentToken
    {
        return $this->paypal;
    }

    /**
     * Sets Paypal.
     *
     * @maps paypal
     */
    public function setPaypal(?PaypalPaymentToken $paypal): void
    {
        $this->paypal = $paypal;
    }

    /**
     * Returns Venmo.
     */
    public function getVenmo(): ?VenmoPaymentToken
    {
        return $this->venmo;
    }

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

    /**
     * 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;
        }

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