<?php

/*
 * This file was automatically generated.
 */
namespace Worldline\Vendor\OnlinePayments\Sdk\Domain;

use UnexpectedValueException;
/**
 * @package OnlinePayments\Sdk\Domain
 */
class TokenData extends DataObject
{
    /**
     * @var Card|null
     */
    public ?Card $card = null;
    /**
     * @var string|null
     */
    public ?string $cobrandSelectionIndicator = null;
    /**
     * @return Card|null
     */
    public function getCard() : ?Card
    {
        return $this->card;
    }
    /**
     * @param Card|null $value
     */
    public function setCard(?Card $value) : void
    {
        $this->card = $value;
    }
    /**
     * @return string|null
     */
    public function getCobrandSelectionIndicator() : ?string
    {
        return $this->cobrandSelectionIndicator;
    }
    /**
     * @param string|null $value
     */
    public function setCobrandSelectionIndicator(?string $value) : void
    {
        $this->cobrandSelectionIndicator = $value;
    }
    /**
     * @return object
     */
    public function toObject() : object
    {
        $object = parent::toObject();
        if (!\is_null($this->card)) {
            $object->card = $this->card->toObject();
        }
        if (!\is_null($this->cobrandSelectionIndicator)) {
            $object->cobrandSelectionIndicator = $this->cobrandSelectionIndicator;
        }
        return $object;
    }
    /**
     * @param object $object
     * @return $this
     * @throws UnexpectedValueException
     */
    public function fromObject(object $object) : TokenData
    {
        parent::fromObject($object);
        if (\property_exists($object, 'card')) {
            if (!\is_object($object->card)) {
                throw new UnexpectedValueException('value \'' . \print_r($object->card, \true) . '\' is not an object');
            }
            $value = new Card();
            $this->card = $value->fromObject($object->card);
        }
        if (\property_exists($object, 'cobrandSelectionIndicator')) {
            $this->cobrandSelectionIndicator = $object->cobrandSelectionIndicator;
        }
        return $this;
    }
}
