1: <?php
2: /*
3: * This file was automatically generated.
4: */
5: namespace Worldline\Acquiring\Sdk\V1\Domain;
6:
7: use UnexpectedValueException;
8: use Worldline\Acquiring\Sdk\Domain\DataObject;
9:
10: /**
11: * @package Worldline\Acquiring\Sdk\V1\Domain
12: */
13: class DccProposal extends DataObject
14: {
15: /**
16: * @var AmountData|null
17: */
18: public ?AmountData $originalAmount = null;
19:
20: /**
21: * @var RateData|null
22: */
23: public ?RateData $rate = null;
24:
25: /**
26: * @var string|null
27: */
28: public ?string $rateReferenceId = null;
29:
30: /**
31: * @var AmountData|null
32: */
33: public ?AmountData $resultingAmount = null;
34:
35: /**
36: * @return object
37: */
38: public function toObject(): object
39: {
40: $object = parent::toObject();
41: if (!is_null($this->originalAmount)) {
42: $object->originalAmount = $this->originalAmount->toObject();
43: }
44: if (!is_null($this->rate)) {
45: $object->rate = $this->rate->toObject();
46: }
47: if (!is_null($this->rateReferenceId)) {
48: $object->rateReferenceId = $this->rateReferenceId;
49: }
50: if (!is_null($this->resultingAmount)) {
51: $object->resultingAmount = $this->resultingAmount->toObject();
52: }
53: return $object;
54: }
55:
56: /**
57: * @param object $object
58: *
59: * @return $this
60: * @throws UnexpectedValueException
61: */
62: public function fromObject(object $object): DccProposal
63: {
64: parent::fromObject($object);
65: if (property_exists($object, 'originalAmount')) {
66: if (!is_object($object->originalAmount)) {
67: throw new UnexpectedValueException('value \'' . print_r($object->originalAmount, true) . '\' is not an object');
68: }
69: $value = new AmountData();
70: $this->originalAmount = $value->fromObject($object->originalAmount);
71: }
72: if (property_exists($object, 'rate')) {
73: if (!is_object($object->rate)) {
74: throw new UnexpectedValueException('value \'' . print_r($object->rate, true) . '\' is not an object');
75: }
76: $value = new RateData();
77: $this->rate = $value->fromObject($object->rate);
78: }
79: if (property_exists($object, 'rateReferenceId')) {
80: $this->rateReferenceId = $object->rateReferenceId;
81: }
82: if (property_exists($object, 'resultingAmount')) {
83: if (!is_object($object->resultingAmount)) {
84: throw new UnexpectedValueException('value \'' . print_r($object->resultingAmount, true) . '\' is not an object');
85: }
86: $value = new AmountData();
87: $this->resultingAmount = $value->fromObject($object->resultingAmount);
88: }
89: return $this;
90: }
91: }
92: