1: | <?php |
2: | |
3: | |
4: | |
5: | namespace Worldline\Acquiring\Sdk\V1\Domain; |
6: | |
7: | use DateTime; |
8: | use UnexpectedValueException; |
9: | use Worldline\Acquiring\Sdk\Domain\DataObject; |
10: | |
11: | |
12: | |
13: | |
14: | class ApiIncrementRequest extends DataObject |
15: | { |
16: | |
17: | |
18: | |
19: | public $dynamicCurrencyConversion = null; |
20: | |
21: | |
22: | |
23: | |
24: | public $incrementAmount = null; |
25: | |
26: | |
27: | |
28: | |
29: | public $operationId = null; |
30: | |
31: | |
32: | |
33: | |
34: | public $terminalData = null; |
35: | |
36: | |
37: | |
38: | |
39: | public $transactionTimestamp = null; |
40: | |
41: | |
42: | |
43: | |
44: | public function toObject() |
45: | { |
46: | $object = parent::toObject(); |
47: | if (!is_null($this->dynamicCurrencyConversion)) { |
48: | $object->dynamicCurrencyConversion = $this->dynamicCurrencyConversion->toObject(); |
49: | } |
50: | if (!is_null($this->incrementAmount)) { |
51: | $object->incrementAmount = $this->incrementAmount->toObject(); |
52: | } |
53: | if (!is_null($this->operationId)) { |
54: | $object->operationId = $this->operationId; |
55: | } |
56: | if (!is_null($this->terminalData)) { |
57: | $object->terminalData = $this->terminalData->toObject(); |
58: | } |
59: | if (!is_null($this->transactionTimestamp)) { |
60: | $object->transactionTimestamp = $this->transactionTimestamp->format('Y-m-d\\TH:i:s.vP'); |
61: | } |
62: | return $object; |
63: | } |
64: | |
65: | |
66: | |
67: | |
68: | |
69: | |
70: | public function fromObject($object) |
71: | { |
72: | parent::fromObject($object); |
73: | if (property_exists($object, 'dynamicCurrencyConversion')) { |
74: | if (!is_object($object->dynamicCurrencyConversion)) { |
75: | throw new UnexpectedValueException('value \'' . print_r($object->dynamicCurrencyConversion, true) . '\' is not an object'); |
76: | } |
77: | $value = new DccData(); |
78: | $this->dynamicCurrencyConversion = $value->fromObject($object->dynamicCurrencyConversion); |
79: | } |
80: | if (property_exists($object, 'incrementAmount')) { |
81: | if (!is_object($object->incrementAmount)) { |
82: | throw new UnexpectedValueException('value \'' . print_r($object->incrementAmount, true) . '\' is not an object'); |
83: | } |
84: | $value = new AmountData(); |
85: | $this->incrementAmount = $value->fromObject($object->incrementAmount); |
86: | } |
87: | if (property_exists($object, 'operationId')) { |
88: | $this->operationId = $object->operationId; |
89: | } |
90: | if (property_exists($object, 'terminalData')) { |
91: | if (!is_object($object->terminalData)) { |
92: | throw new UnexpectedValueException('value \'' . print_r($object->terminalData, true) . '\' is not an object'); |
93: | } |
94: | $value = new TerminalData(); |
95: | $this->terminalData = $value->fromObject($object->terminalData); |
96: | } |
97: | if (property_exists($object, 'transactionTimestamp')) { |
98: | $this->transactionTimestamp = new DateTime($object->transactionTimestamp); |
99: | } |
100: | return $this; |
101: | } |
102: | } |
103: | |