<?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 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.
     * 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;
    }

    /**
     * Converts the SetupTokenResponsePaymentSource object to a human-readable string representation.
     *
     * @return string The string representation of the SetupTokenResponsePaymentSource object.
     */
    public function __toString(): string
    {
        return ApiHelper::stringify(
            'SetupTokenResponsePaymentSource',
            ['card' => $this->card, 'paypal' => $this->paypal, 'venmo' => $this->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;
    }
}
