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 ApiPaymentResource extends DataObject |
15: | { |
16: | |
17: | |
18: | |
19: | public $cardPaymentData = null; |
20: | |
21: | |
22: | |
23: | |
24: | public $initialAuthorizationCode = null; |
25: | |
26: | |
27: | |
28: | |
29: | public $operations = null; |
30: | |
31: | |
32: | |
33: | |
34: | public $paymentId = null; |
35: | |
36: | |
37: | |
38: | |
39: | public $references = null; |
40: | |
41: | |
42: | |
43: | |
44: | public $retryAfter = null; |
45: | |
46: | |
47: | |
48: | |
49: | public $status = null; |
50: | |
51: | |
52: | |
53: | |
54: | public $statusTimestamp = null; |
55: | |
56: | |
57: | |
58: | |
59: | public $totalAuthorizedAmount = null; |
60: | |
61: | |
62: | |
63: | |
64: | public function toObject() |
65: | { |
66: | $object = parent::toObject(); |
67: | if (!is_null($this->cardPaymentData)) { |
68: | $object->cardPaymentData = $this->cardPaymentData->toObject(); |
69: | } |
70: | if (!is_null($this->initialAuthorizationCode)) { |
71: | $object->initialAuthorizationCode = $this->initialAuthorizationCode; |
72: | } |
73: | if (!is_null($this->operations)) { |
74: | $object->operations = []; |
75: | foreach ($this->operations as $element) { |
76: | if (!is_null($element)) { |
77: | $object->operations[] = $element->toObject(); |
78: | } |
79: | } |
80: | } |
81: | if (!is_null($this->paymentId)) { |
82: | $object->paymentId = $this->paymentId; |
83: | } |
84: | if (!is_null($this->references)) { |
85: | $object->references = $this->references->toObject(); |
86: | } |
87: | if (!is_null($this->retryAfter)) { |
88: | $object->retryAfter = $this->retryAfter; |
89: | } |
90: | if (!is_null($this->status)) { |
91: | $object->status = $this->status; |
92: | } |
93: | if (!is_null($this->statusTimestamp)) { |
94: | $object->statusTimestamp = $this->statusTimestamp->format('Y-m-d\\TH:i:s.vP'); |
95: | } |
96: | if (!is_null($this->totalAuthorizedAmount)) { |
97: | $object->totalAuthorizedAmount = $this->totalAuthorizedAmount->toObject(); |
98: | } |
99: | return $object; |
100: | } |
101: | |
102: | |
103: | |
104: | |
105: | |
106: | |
107: | public function fromObject($object) |
108: | { |
109: | parent::fromObject($object); |
110: | if (property_exists($object, 'cardPaymentData')) { |
111: | if (!is_object($object->cardPaymentData)) { |
112: | throw new UnexpectedValueException('value \'' . print_r($object->cardPaymentData, true) . '\' is not an object'); |
113: | } |
114: | $value = new CardPaymentDataForResource(); |
115: | $this->cardPaymentData = $value->fromObject($object->cardPaymentData); |
116: | } |
117: | if (property_exists($object, 'initialAuthorizationCode')) { |
118: | $this->initialAuthorizationCode = $object->initialAuthorizationCode; |
119: | } |
120: | if (property_exists($object, 'operations')) { |
121: | if (!is_array($object->operations) && !is_object($object->operations)) { |
122: | throw new UnexpectedValueException('value \'' . print_r($object->operations, true) . '\' is not an array or object'); |
123: | } |
124: | $this->operations = []; |
125: | foreach ($object->operations as $element) { |
126: | $value = new SubOperation(); |
127: | $this->operations[] = $value->fromObject($element); |
128: | } |
129: | } |
130: | if (property_exists($object, 'paymentId')) { |
131: | $this->paymentId = $object->paymentId; |
132: | } |
133: | if (property_exists($object, 'references')) { |
134: | if (!is_object($object->references)) { |
135: | throw new UnexpectedValueException('value \'' . print_r($object->references, true) . '\' is not an object'); |
136: | } |
137: | $value = new ApiReferencesForResponses(); |
138: | $this->references = $value->fromObject($object->references); |
139: | } |
140: | if (property_exists($object, 'retryAfter')) { |
141: | $this->retryAfter = $object->retryAfter; |
142: | } |
143: | if (property_exists($object, 'status')) { |
144: | $this->status = $object->status; |
145: | } |
146: | if (property_exists($object, 'statusTimestamp')) { |
147: | $this->statusTimestamp = new DateTime($object->statusTimestamp); |
148: | } |
149: | if (property_exists($object, 'totalAuthorizedAmount')) { |
150: | if (!is_object($object->totalAuthorizedAmount)) { |
151: | throw new UnexpectedValueException('value \'' . print_r($object->totalAuthorizedAmount, true) . '\' is not an object'); |
152: | } |
153: | $value = new AmountData(); |
154: | $this->totalAuthorizedAmount = $value->fromObject($object->totalAuthorizedAmount); |
155: | } |
156: | return $this; |
157: | } |
158: | } |
159: | |