1: | <?php |
2: | |
3: | |
4: | |
5: | namespace Worldline\Acquiring\Sdk\V1\Domain; |
6: | |
7: | use UnexpectedValueException; |
8: | use Worldline\Acquiring\Sdk\Domain\DataObject; |
9: | |
10: | |
11: | |
12: | |
13: | class DccProposal extends DataObject |
14: | { |
15: | |
16: | |
17: | |
18: | public $originalAmount = null; |
19: | |
20: | |
21: | |
22: | |
23: | public $rate = null; |
24: | |
25: | |
26: | |
27: | |
28: | public $rateReferenceId = null; |
29: | |
30: | |
31: | |
32: | |
33: | public $resultingAmount = null; |
34: | |
35: | |
36: | |
37: | |
38: | public function toObject() |
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: | |
58: | |
59: | |
60: | |
61: | public function fromObject($object) |
62: | { |
63: | parent::fromObject($object); |
64: | if (property_exists($object, 'originalAmount')) { |
65: | if (!is_object($object->originalAmount)) { |
66: | throw new UnexpectedValueException('value \'' . print_r($object->originalAmount, true) . '\' is not an object'); |
67: | } |
68: | $value = new AmountData(); |
69: | $this->originalAmount = $value->fromObject($object->originalAmount); |
70: | } |
71: | if (property_exists($object, 'rate')) { |
72: | if (!is_object($object->rate)) { |
73: | throw new UnexpectedValueException('value \'' . print_r($object->rate, true) . '\' is not an object'); |
74: | } |
75: | $value = new RateData(); |
76: | $this->rate = $value->fromObject($object->rate); |
77: | } |
78: | if (property_exists($object, 'rateReferenceId')) { |
79: | $this->rateReferenceId = $object->rateReferenceId; |
80: | } |
81: | if (property_exists($object, 'resultingAmount')) { |
82: | if (!is_object($object->resultingAmount)) { |
83: | throw new UnexpectedValueException('value \'' . print_r($object->resultingAmount, true) . '\' is not an object'); |
84: | } |
85: | $value = new AmountData(); |
86: | $this->resultingAmount = $value->fromObject($object->resultingAmount); |
87: | } |
88: | return $this; |
89: | } |
90: | } |
91: | |