<?php

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

use UnexpectedValueException;
/**
 * @package OnlinePayments\Sdk\Domain
 */
class CalculateSurchargeRequest extends DataObject
{
    /**
     * @var AmountOfMoney|null
     */
    public ?AmountOfMoney $amountOfMoney = null;
    /**
     * @var CardSource|null
     */
    public ?CardSource $cardSource = null;
    /**
     * @return AmountOfMoney|null
     */
    public function getAmountOfMoney() : ?AmountOfMoney
    {
        return $this->amountOfMoney;
    }
    /**
     * @param AmountOfMoney|null $value
     */
    public function setAmountOfMoney(?AmountOfMoney $value) : void
    {
        $this->amountOfMoney = $value;
    }
    /**
     * @return CardSource|null
     */
    public function getCardSource() : ?CardSource
    {
        return $this->cardSource;
    }
    /**
     * @param CardSource|null $value
     */
    public function setCardSource(?CardSource $value) : void
    {
        $this->cardSource = $value;
    }
    /**
     * @return object
     */
    public function toObject() : object
    {
        $object = parent::toObject();
        if (!\is_null($this->amountOfMoney)) {
            $object->amountOfMoney = $this->amountOfMoney->toObject();
        }
        if (!\is_null($this->cardSource)) {
            $object->cardSource = $this->cardSource->toObject();
        }
        return $object;
    }
    /**
     * @param object $object
     * @return $this
     * @throws UnexpectedValueException
     */
    public function fromObject(object $object) : CalculateSurchargeRequest
    {
        parent::fromObject($object);
        if (\property_exists($object, 'amountOfMoney')) {
            if (!\is_object($object->amountOfMoney)) {
                throw new UnexpectedValueException('value \'' . \print_r($object->amountOfMoney, \true) . '\' is not an object');
            }
            $value = new AmountOfMoney();
            $this->amountOfMoney = $value->fromObject($object->amountOfMoney);
        }
        if (\property_exists($object, 'cardSource')) {
            if (!\is_object($object->cardSource)) {
                throw new UnexpectedValueException('value \'' . \print_r($object->cardSource, \true) . '\' is not an object');
            }
            $value = new CardSource();
            $this->cardSource = $value->fromObject($object->cardSource);
        }
        return $this;
    }
}
