<?php

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

use UnexpectedValueException;
/**
 * @package OnlinePayments\Sdk\Domain
 */
class CreateTokenRequest extends DataObject
{
    /**
     * @var TokenCardSpecificInput|null
     */
    public ?TokenCardSpecificInput $card = null;
    /**
     * @var string|null
     */
    public ?string $encryptedCustomerInput = null;
    /**
     * @var int|null
     */
    public ?int $paymentProductId = null;
    /**
     * @return TokenCardSpecificInput|null
     */
    public function getCard() : ?TokenCardSpecificInput
    {
        return $this->card;
    }
    /**
     * @param TokenCardSpecificInput|null $value
     */
    public function setCard(?TokenCardSpecificInput $value) : void
    {
        $this->card = $value;
    }
    /**
     * @return string|null
     */
    public function getEncryptedCustomerInput() : ?string
    {
        return $this->encryptedCustomerInput;
    }
    /**
     * @param string|null $value
     */
    public function setEncryptedCustomerInput(?string $value) : void
    {
        $this->encryptedCustomerInput = $value;
    }
    /**
     * @return int|null
     */
    public function getPaymentProductId() : ?int
    {
        return $this->paymentProductId;
    }
    /**
     * @param int|null $value
     */
    public function setPaymentProductId(?int $value) : void
    {
        $this->paymentProductId = $value;
    }
    /**
     * @return object
     */
    public function toObject() : object
    {
        $object = parent::toObject();
        if (!\is_null($this->card)) {
            $object->card = $this->card->toObject();
        }
        if (!\is_null($this->encryptedCustomerInput)) {
            $object->encryptedCustomerInput = $this->encryptedCustomerInput;
        }
        if (!\is_null($this->paymentProductId)) {
            $object->paymentProductId = $this->paymentProductId;
        }
        return $object;
    }
    /**
     * @param object $object
     * @return $this
     * @throws UnexpectedValueException
     */
    public function fromObject(object $object) : CreateTokenRequest
    {
        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 TokenCardSpecificInput();
            $this->card = $value->fromObject($object->card);
        }
        if (\property_exists($object, 'encryptedCustomerInput')) {
            $this->encryptedCustomerInput = $object->encryptedCustomerInput;
        }
        if (\property_exists($object, 'paymentProductId')) {
            $this->paymentProductId = $object->paymentProductId;
        }
        return $this;
    }
}
