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 $transactionTimestamp = null; |
45: | |
46: | |
47: | |
48: | |
49: | public function toObject() |
50: | { |
51: | $object = parent::toObject(); |
52: | if (!is_null($this->amount)) { |
53: | $object->amount = $this->amount->toObject(); |
54: | } |
55: | if (!is_null($this->captureImmediately)) { |
56: | $object->captureImmediately = $this->captureImmediately; |
57: | } |
58: | if (!is_null($this->dynamicCurrencyConversion)) { |
59: | $object->dynamicCurrencyConversion = $this->dynamicCurrencyConversion->toObject(); |
60: | } |
61: | if (!is_null($this->operationId)) { |
62: | $object->operationId = $this->operationId; |
63: | } |
64: | if (!is_null($this->references)) { |
65: | $object->references = $this->references->toObject(); |
66: | } |
67: | if (!is_null($this->transactionTimestamp)) { |
68: | $object->transactionTimestamp = $this->transactionTimestamp->format('Y-m-d\\TH:i:s.vP'); |
69: | } |
70: | return $object; |
71: | } |
72: | |
73: | |
74: | |
75: | |
76: | |
77: | |
78: | public function fromObject($object) |
79: | { |
80: | parent::fromObject($object); |
81: | if (property_exists($object, 'amount')) { |
82: | if (!is_object($object->amount)) { |
83: | throw new UnexpectedValueException('value \'' . print_r($object->amount, true) . '\' is not an object'); |
84: | } |
85: | $value = new AmountData(); |
86: | $this->amount = $value->fromObject($object->amount); |
87: | } |
88: | if (property_exists($object, 'captureImmediately')) { |
89: | $this->captureImmediately = $object->captureImmediately; |
90: | } |
91: | if (property_exists($object, 'dynamicCurrencyConversion')) { |
92: | if (!is_object($object->dynamicCurrencyConversion)) { |
93: | throw new UnexpectedValueException('value \'' . print_r($object->dynamicCurrencyConversion, true) . '\' is not an object'); |
94: | } |
95: | $value = new DccData(); |
96: | $this->dynamicCurrencyConversion = $value->fromObject($object->dynamicCurrencyConversion); |
97: | } |
98: | if (property_exists($object, 'operationId')) { |
99: | $this->operationId = $object->operationId; |
100: | } |
101: | if (property_exists($object, 'references')) { |
102: | if (!is_object($object->references)) { |
103: | throw new UnexpectedValueException('value \'' . print_r($object->references, true) . '\' is not an object'); |
104: | } |
105: | $value = new PaymentReferences(); |
106: | $this->references = $value->fromObject($object->references); |
107: | } |
108: | if (property_exists($object, 'transactionTimestamp')) { |
109: | $this->transactionTimestamp = new DateTime($object->transactionTimestamp); |
110: | } |
111: | return $this; |
112: | } |
113: | } |
114: | |