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 ApiCaptureRequest extends DataObject |
15: | { |
16: | |
17: | |
18: | |
19: | public $amount = null; |
20: | |
21: | |
22: | |
23: | |
24: | public $captureSequenceNumber = null; |
25: | |
26: | |
27: | |
28: | |
29: | public $dynamicCurrencyConversion = null; |
30: | |
31: | |
32: | |
33: | |
34: | public $isFinal = null; |
35: | |
36: | |
37: | |
38: | |
39: | public $operationId = 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->captureSequenceNumber)) { |
56: | $object->captureSequenceNumber = $this->captureSequenceNumber; |
57: | } |
58: | if (!is_null($this->dynamicCurrencyConversion)) { |
59: | $object->dynamicCurrencyConversion = $this->dynamicCurrencyConversion->toObject(); |
60: | } |
61: | if (!is_null($this->isFinal)) { |
62: | $object->isFinal = $this->isFinal; |
63: | } |
64: | if (!is_null($this->operationId)) { |
65: | $object->operationId = $this->operationId; |
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, 'captureSequenceNumber')) { |
89: | $this->captureSequenceNumber = $object->captureSequenceNumber; |
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, 'isFinal')) { |
99: | $this->isFinal = $object->isFinal; |
100: | } |
101: | if (property_exists($object, 'operationId')) { |
102: | $this->operationId = $object->operationId; |
103: | } |
104: | if (property_exists($object, 'transactionTimestamp')) { |
105: | $this->transactionTimestamp = new DateTime($object->transactionTimestamp); |
106: | } |
107: | return $this; |
108: | } |
109: | } |
110: | |