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 ApiPaymentRefundRequest extends DataObject |
15: | { |
16: | |
17: | |
18: | |
19: | public $amount = null; |
20: | |
21: | |
22: | |
23: | |
24: | public $captureImmediately = null; |
25: | |
26: | |
27: | |
28: | |
29: | public $dynamicCurrencyConversion = null; |
30: | |
31: | |
32: | |
33: | |
34: | public $operationId = null; |
35: | |
36: | |
37: | |
38: | |
39: | public $references = null; |
40: | |
41: | |
42: | |
43: | |
44: | public $terminalData = null; |
45: | |
46: | |
47: | |
48: | |
49: | public $transactionTimestamp = null; |
50: | |
51: | |
52: | |
53: | |
54: | public function toObject() |
55: | { |
56: | $object = parent::toObject(); |
57: | if (!is_null($this->amount)) { |
58: | $object->amount = $this->amount->toObject(); |
59: | } |
60: | if (!is_null($this->captureImmediately)) { |
61: | $object->captureImmediately = $this->captureImmediately; |
62: | } |
63: | if (!is_null($this->dynamicCurrencyConversion)) { |
64: | $object->dynamicCurrencyConversion = $this->dynamicCurrencyConversion->toObject(); |
65: | } |
66: | if (!is_null($this->operationId)) { |
67: | $object->operationId = $this->operationId; |
68: | } |
69: | if (!is_null($this->references)) { |
70: | $object->references = $this->references->toObject(); |
71: | } |
72: | if (!is_null($this->terminalData)) { |
73: | $object->terminalData = $this->terminalData->toObject(); |
74: | } |
75: | if (!is_null($this->transactionTimestamp)) { |
76: | $object->transactionTimestamp = $this->transactionTimestamp->format('Y-m-d\\TH:i:s.vP'); |
77: | } |
78: | return $object; |
79: | } |
80: | |
81: | |
82: | |
83: | |
84: | |
85: | |
86: | public function fromObject($object) |
87: | { |
88: | parent::fromObject($object); |
89: | if (property_exists($object, 'amount')) { |
90: | if (!is_object($object->amount)) { |
91: | throw new UnexpectedValueException('value \'' . print_r($object->amount, true) . '\' is not an object'); |
92: | } |
93: | $value = new AmountData(); |
94: | $this->amount = $value->fromObject($object->amount); |
95: | } |
96: | if (property_exists($object, 'captureImmediately')) { |
97: | $this->captureImmediately = $object->captureImmediately; |
98: | } |
99: | if (property_exists($object, 'dynamicCurrencyConversion')) { |
100: | if (!is_object($object->dynamicCurrencyConversion)) { |
101: | throw new UnexpectedValueException('value \'' . print_r($object->dynamicCurrencyConversion, true) . '\' is not an object'); |
102: | } |
103: | $value = new DccData(); |
104: | $this->dynamicCurrencyConversion = $value->fromObject($object->dynamicCurrencyConversion); |
105: | } |
106: | if (property_exists($object, 'operationId')) { |
107: | $this->operationId = $object->operationId; |
108: | } |
109: | if (property_exists($object, 'references')) { |
110: | if (!is_object($object->references)) { |
111: | throw new UnexpectedValueException('value \'' . print_r($object->references, true) . '\' is not an object'); |
112: | } |
113: | $value = new PaymentReferences(); |
114: | $this->references = $value->fromObject($object->references); |
115: | } |
116: | if (property_exists($object, 'terminalData')) { |
117: | if (!is_object($object->terminalData)) { |
118: | throw new UnexpectedValueException('value \'' . print_r($object->terminalData, true) . '\' is not an object'); |
119: | } |
120: | $value = new TerminalData(); |
121: | $this->terminalData = $value->fromObject($object->terminalData); |
122: | } |
123: | if (property_exists($object, 'transactionTimestamp')) { |
124: | $this->transactionTimestamp = new DateTime($object->transactionTimestamp); |
125: | } |
126: | return $this; |
127: | } |
128: | } |
129: | |