1: <?php
2: /*
3: * This file was automatically generated.
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: * @package Worldline\Acquiring\Sdk\V1\Domain
13: */
14: class ApiPaymentResponse extends DataObject
15: {
16: /**
17: * @var CardPaymentDataForResponse
18: */
19: public $cardPaymentData = null;
20:
21: /**
22: * @var EmvDataItem[]
23: */
24: public $emvData = null;
25:
26: /**
27: * @var string
28: */
29: public $initialAuthorizationCode = null;
30:
31: /**
32: * @var string
33: */
34: public $operationId = null;
35:
36: /**
37: * @var string
38: */
39: public $paymentId = null;
40:
41: /**
42: * @var ApiReferencesForResponses
43: */
44: public $references = null;
45:
46: /**
47: * @var string
48: */
49: public $responder = null;
50:
51: /**
52: * @var string
53: */
54: public $responseCode = null;
55:
56: /**
57: * @var string
58: */
59: public $responseCodeCategory = null;
60:
61: /**
62: * @var string
63: */
64: public $responseCodeDescription = null;
65:
66: /**
67: * @var string
68: */
69: public $retryAfter = null;
70:
71: /**
72: * @var string
73: */
74: public $status = null;
75:
76: /**
77: * @var DateTime
78: */
79: public $statusTimestamp = null;
80:
81: /**
82: * @var AmountData
83: */
84: public $totalAuthorizedAmount = null;
85:
86: /**
87: * @return object
88: */
89: public function toObject()
90: {
91: $object = parent::toObject();
92: if (!is_null($this->cardPaymentData)) {
93: $object->cardPaymentData = $this->cardPaymentData->toObject();
94: }
95: if (!is_null($this->emvData)) {
96: $object->emvData = [];
97: foreach ($this->emvData as $element) {
98: if (!is_null($element)) {
99: $object->emvData[] = $element->toObject();
100: }
101: }
102: }
103: if (!is_null($this->initialAuthorizationCode)) {
104: $object->initialAuthorizationCode = $this->initialAuthorizationCode;
105: }
106: if (!is_null($this->operationId)) {
107: $object->operationId = $this->operationId;
108: }
109: if (!is_null($this->paymentId)) {
110: $object->paymentId = $this->paymentId;
111: }
112: if (!is_null($this->references)) {
113: $object->references = $this->references->toObject();
114: }
115: if (!is_null($this->responder)) {
116: $object->responder = $this->responder;
117: }
118: if (!is_null($this->responseCode)) {
119: $object->responseCode = $this->responseCode;
120: }
121: if (!is_null($this->responseCodeCategory)) {
122: $object->responseCodeCategory = $this->responseCodeCategory;
123: }
124: if (!is_null($this->responseCodeDescription)) {
125: $object->responseCodeDescription = $this->responseCodeDescription;
126: }
127: if (!is_null($this->retryAfter)) {
128: $object->retryAfter = $this->retryAfter;
129: }
130: if (!is_null($this->status)) {
131: $object->status = $this->status;
132: }
133: if (!is_null($this->statusTimestamp)) {
134: $object->statusTimestamp = $this->statusTimestamp->format('Y-m-d\\TH:i:s.vP');
135: }
136: if (!is_null($this->totalAuthorizedAmount)) {
137: $object->totalAuthorizedAmount = $this->totalAuthorizedAmount->toObject();
138: }
139: return $object;
140: }
141:
142: /**
143: * @param object $object
144: * @return $this
145: * @throws UnexpectedValueException
146: */
147: public function fromObject($object)
148: {
149: parent::fromObject($object);
150: if (property_exists($object, 'cardPaymentData')) {
151: if (!is_object($object->cardPaymentData)) {
152: throw new UnexpectedValueException('value \'' . print_r($object->cardPaymentData, true) . '\' is not an object');
153: }
154: $value = new CardPaymentDataForResponse();
155: $this->cardPaymentData = $value->fromObject($object->cardPaymentData);
156: }
157: if (property_exists($object, 'emvData')) {
158: if (!is_array($object->emvData) && !is_object($object->emvData)) {
159: throw new UnexpectedValueException('value \'' . print_r($object->emvData, true) . '\' is not an array or object');
160: }
161: $this->emvData = [];
162: foreach ($object->emvData as $element) {
163: $value = new EmvDataItem();
164: $this->emvData[] = $value->fromObject($element);
165: }
166: }
167: if (property_exists($object, 'initialAuthorizationCode')) {
168: $this->initialAuthorizationCode = $object->initialAuthorizationCode;
169: }
170: if (property_exists($object, 'operationId')) {
171: $this->operationId = $object->operationId;
172: }
173: if (property_exists($object, 'paymentId')) {
174: $this->paymentId = $object->paymentId;
175: }
176: if (property_exists($object, 'references')) {
177: if (!is_object($object->references)) {
178: throw new UnexpectedValueException('value \'' . print_r($object->references, true) . '\' is not an object');
179: }
180: $value = new ApiReferencesForResponses();
181: $this->references = $value->fromObject($object->references);
182: }
183: if (property_exists($object, 'responder')) {
184: $this->responder = $object->responder;
185: }
186: if (property_exists($object, 'responseCode')) {
187: $this->responseCode = $object->responseCode;
188: }
189: if (property_exists($object, 'responseCodeCategory')) {
190: $this->responseCodeCategory = $object->responseCodeCategory;
191: }
192: if (property_exists($object, 'responseCodeDescription')) {
193: $this->responseCodeDescription = $object->responseCodeDescription;
194: }
195: if (property_exists($object, 'retryAfter')) {
196: $this->retryAfter = $object->retryAfter;
197: }
198: if (property_exists($object, 'status')) {
199: $this->status = $object->status;
200: }
201: if (property_exists($object, 'statusTimestamp')) {
202: $this->statusTimestamp = new DateTime($object->statusTimestamp);
203: }
204: if (property_exists($object, 'totalAuthorizedAmount')) {
205: if (!is_object($object->totalAuthorizedAmount)) {
206: throw new UnexpectedValueException('value \'' . print_r($object->totalAuthorizedAmount, true) . '\' is not an object');
207: }
208: $value = new AmountData();
209: $this->totalAuthorizedAmount = $value->fromObject($object->totalAuthorizedAmount);
210: }
211: return $this;
212: }
213: }
214: