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 ApiPaymentReversalRequest extends DataObject |
15: | { |
16: | |
17: | |
18: | |
19: | public $dynamicCurrencyConversion = null; |
20: | |
21: | |
22: | |
23: | |
24: | public $operationId = null; |
25: | |
26: | |
27: | |
28: | |
29: | public $reversalAmount = null; |
30: | |
31: | |
32: | |
33: | |
34: | public $transactionTimestamp = null; |
35: | |
36: | |
37: | |
38: | |
39: | public function toObject() |
40: | { |
41: | $object = parent::toObject(); |
42: | if (!is_null($this->dynamicCurrencyConversion)) { |
43: | $object->dynamicCurrencyConversion = $this->dynamicCurrencyConversion->toObject(); |
44: | } |
45: | if (!is_null($this->operationId)) { |
46: | $object->operationId = $this->operationId; |
47: | } |
48: | if (!is_null($this->reversalAmount)) { |
49: | $object->reversalAmount = $this->reversalAmount->toObject(); |
50: | } |
51: | if (!is_null($this->transactionTimestamp)) { |
52: | $object->transactionTimestamp = $this->transactionTimestamp->format('Y-m-d\\TH:i:s.vP'); |
53: | } |
54: | return $object; |
55: | } |
56: | |
57: | |
58: | |
59: | |
60: | |
61: | |
62: | public function fromObject($object) |
63: | { |
64: | parent::fromObject($object); |
65: | if (property_exists($object, 'dynamicCurrencyConversion')) { |
66: | if (!is_object($object->dynamicCurrencyConversion)) { |
67: | throw new UnexpectedValueException('value \'' . print_r($object->dynamicCurrencyConversion, true) . '\' is not an object'); |
68: | } |
69: | $value = new DccData(); |
70: | $this->dynamicCurrencyConversion = $value->fromObject($object->dynamicCurrencyConversion); |
71: | } |
72: | if (property_exists($object, 'operationId')) { |
73: | $this->operationId = $object->operationId; |
74: | } |
75: | if (property_exists($object, 'reversalAmount')) { |
76: | if (!is_object($object->reversalAmount)) { |
77: | throw new UnexpectedValueException('value \'' . print_r($object->reversalAmount, true) . '\' is not an object'); |
78: | } |
79: | $value = new AmountData(); |
80: | $this->reversalAmount = $value->fromObject($object->reversalAmount); |
81: | } |
82: | if (property_exists($object, 'transactionTimestamp')) { |
83: | $this->transactionTimestamp = new DateTime($object->transactionTimestamp); |
84: | } |
85: | return $this; |
86: | } |
87: | } |
88: | |