|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* amadeus-ws-client |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright 2015 Amadeus Benelux NV |
|
6
|
|
|
* |
|
7
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
8
|
|
|
* you may not use this file except in compliance with the License. |
|
9
|
|
|
* You may obtain a copy of the License at |
|
10
|
|
|
* |
|
11
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
12
|
|
|
* |
|
13
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
14
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
15
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16
|
|
|
* See the License for the specific language governing permissions and |
|
17
|
|
|
* limitations under the License. |
|
18
|
|
|
* |
|
19
|
|
|
* @package Amadeus |
|
20
|
|
|
* @license https://opensource.org/licenses/Apache-2.0 Apache 2.0 |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace Amadeus\Client\ResponseHandler; |
|
24
|
|
|
|
|
25
|
|
|
use Amadeus\Client\Exception; |
|
26
|
|
|
use Amadeus\Client\ResponseHandler\Air\RetrieveSeatMap; |
|
27
|
|
|
use Amadeus\Client\Result; |
|
28
|
|
|
use Amadeus\Client\Session\Handler\SendResult; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Default Response Handler |
|
32
|
|
|
* |
|
33
|
|
|
* @package Amadeus\Client\ResponseHandler |
|
34
|
|
|
* @author Dieter Devlieghere <[email protected]> |
|
35
|
|
|
*/ |
|
36
|
|
|
class Base implements ResponseHandlerInterface |
|
37
|
|
|
{ |
|
38
|
|
|
/** |
|
39
|
|
|
* Default namespace prefix we'll be using for xpath queries |
|
40
|
|
|
* |
|
41
|
|
|
* Why not "m"? It's as good as any other letter. |
|
42
|
|
|
*/ |
|
43
|
|
|
const XMLNS_PREFIX = "m"; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Analyze the response from the server and throw an exception when an error has been detected. |
|
47
|
|
|
* |
|
48
|
|
|
* @param SendResult $sendResult The Send Result from the Session Handler |
|
49
|
|
|
* @param string $messageName The message that was called |
|
50
|
|
|
* |
|
51
|
|
|
* @throws Exception |
|
52
|
|
|
* @throws \RuntimeException |
|
53
|
|
|
* @return Result |
|
54
|
|
|
*/ |
|
55
|
|
|
public function analyzeResponse($sendResult, $messageName) |
|
56
|
|
|
{ |
|
57
|
|
|
$methodName = 'analyze' . str_replace('_', '', ucfirst($messageName)) . 'Response'; |
|
58
|
|
|
|
|
59
|
|
|
if (!empty($sendResult->exception)) { |
|
60
|
|
|
return $this->makeResultForException($sendResult); |
|
61
|
|
|
} elseif (method_exists($this, $methodName)) { |
|
62
|
|
|
return $this->$methodName( |
|
63
|
|
|
$sendResult |
|
64
|
|
|
); |
|
65
|
|
|
} else { |
|
66
|
|
|
return new Result($sendResult, Result::STATUS_UNKNOWN); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Analysing a Security_Authenticate |
|
72
|
|
|
* |
|
73
|
|
|
* @param SendResult $response Security_Authenticate result |
|
74
|
|
|
* @return Result |
|
75
|
|
|
*/ |
|
76
|
|
|
protected function analyzeSecurityAuthenticateResponse($response) |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Analysing a Security_Authenticate |
|
83
|
|
|
* |
|
84
|
|
|
* @param SendResult $response Security_Authenticate result |
|
85
|
|
|
* @return Result |
|
86
|
|
|
*/ |
|
87
|
|
|
protected function analyzeSecuritySignOutResponse($response) |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Unknown response for Command_Cryptic because you need to analyse the cryptic response yourself |
|
94
|
|
|
* |
|
95
|
|
|
* @param SendResult $response |
|
96
|
|
|
* @return Result |
|
97
|
|
|
*/ |
|
98
|
|
|
protected function analyzeCommandCrypticResponse($response) |
|
99
|
|
|
{ |
|
100
|
|
|
$ccResult = new Result($response, Result::STATUS_UNKNOWN); |
|
101
|
|
|
$ccResult->messages[] = new Result\NotOk( |
|
102
|
|
|
0, |
|
103
|
|
|
"Response handling not supported for cryptic entries" |
|
104
|
|
|
); |
|
105
|
|
|
|
|
106
|
|
|
return $ccResult; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
View Code Duplication |
protected function analyzeAirMultiAvailabilityResponse($response) |
|
|
|
|
|
|
110
|
|
|
{ |
|
111
|
|
|
$analyzeResponse = new Result($response); |
|
112
|
|
|
|
|
113
|
|
|
$message = null; |
|
114
|
|
|
|
|
115
|
|
|
$domXpath = $this->makeDomXpath($response->responseXml); |
|
116
|
|
|
|
|
117
|
|
|
$codeNode = $domXpath->query("//m:errorOrWarningSection/m:errorOrWarningInfo//m:code")->item(0); |
|
118
|
|
|
if ($codeNode instanceof \DOMNode) { |
|
119
|
|
|
$analyzeResponse->status = Result::STATUS_ERROR; |
|
120
|
|
|
|
|
121
|
|
|
$categoryNode = $domXpath->query("//m:errorOrWarningSection/m:errorOrWarningInfo//m:type")->item(0); |
|
122
|
|
|
if ($categoryNode instanceof \DOMNode) { |
|
123
|
|
|
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
$messageNodes = $domXpath->query('//m:errorOrWarningSection/m:textInformation/m:freeText'); |
|
127
|
|
|
if ($messageNodes->length > 0) { |
|
128
|
|
|
$message = $this->makeMessageFromMessagesNodeList($messageNodes); |
|
129
|
|
|
} |
|
130
|
|
|
$analyzeResponse->messages [] = new Result\NotOk($codeNode->nodeValue, $message); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
return $analyzeResponse; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
protected function analyzeAirSellFromRecommendationResponse($response) |
|
137
|
|
|
{ |
|
138
|
|
|
$analyzeResponse = new Result($response); |
|
139
|
|
|
|
|
140
|
|
|
$errMsgMap = [ |
|
141
|
|
|
"288" => "UNABLE TO SATISFY, NEED CONFIRMED FLIGHT STATUS", |
|
142
|
|
|
"390" => "UNABLE TO REFORMAT" |
|
143
|
|
|
]; |
|
144
|
|
|
|
|
145
|
|
|
$domXpath = $this->makeDomXpath($response->responseXml); |
|
146
|
|
|
|
|
147
|
|
|
$codeNode = $domXpath->query("//m:errorSegment/m:errorDetails/m:errorCode")->item(0); |
|
148
|
|
|
if ($codeNode instanceof \DOMNode) { |
|
149
|
|
|
$analyzeResponse->status = Result::STATUS_ERROR; |
|
150
|
|
|
|
|
151
|
|
|
$categoryNode = $domXpath->query("//m:errorSegment/m:errorDetails/m:errorCategory")->item(0); |
|
152
|
|
|
if ($categoryNode instanceof \DOMNode) { |
|
153
|
|
|
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
$message = (array_key_exists($codeNode->nodeValue, $errMsgMap)) ? $errMsgMap[$codeNode->nodeValue] : 'UNKNOWN ERROR'; |
|
|
|
|
|
|
157
|
|
|
|
|
158
|
|
|
$analyzeResponse->messages [] = new Result\NotOk($codeNode->nodeValue, $message); |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
return $analyzeResponse; |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* @param SendResult $response |
|
166
|
|
|
* @return Result |
|
167
|
|
|
*/ |
|
168
|
|
|
protected function analyzeAirFlightInfoResponse($response) |
|
169
|
|
|
{ |
|
170
|
|
|
$analyzeResponse = new Result($response); |
|
171
|
|
|
|
|
172
|
|
|
$code = null; |
|
173
|
|
|
$message = null; |
|
174
|
|
|
|
|
175
|
|
|
$domXpath = $this->makeDomXpath($response->responseXml); |
|
176
|
|
|
|
|
177
|
|
|
$categoryNodes = $domXpath->query('//m:responseError/m:errorInfo/m:errorDetails/m:errorCategory'); |
|
178
|
|
|
if ($categoryNodes->length > 0) { |
|
179
|
|
|
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNodes->item(0)->nodeValue); |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
$codeNodes = $domXpath->query('//m:responseError/m:errorInfo/m:errorDetails/m:errorCode'); |
|
183
|
|
|
if ($codeNodes->length > 0) { |
|
184
|
|
|
$code = $codeNodes->item(0)->nodeValue; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
$messageNodes = $domXpath->query('//m:responseError/m:interactiveFreeText/m:freeText'); |
|
188
|
|
|
if ($messageNodes->length > 0) { |
|
189
|
|
|
$message = $this->makeMessageFromMessagesNodeList($messageNodes); |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
if (!is_null($message) && !is_null($code)) { |
|
193
|
|
|
$analyzeResponse->messages[] = new Result\NotOk($code, $message); |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
return $analyzeResponse; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* @param SendResult $response |
|
201
|
|
|
* @return Result |
|
202
|
|
|
*/ |
|
203
|
|
|
protected function analyzeAirRetrieveSeatMapResponse($response) |
|
204
|
|
|
{ |
|
205
|
|
|
$analyzeResponse = new Result($response); |
|
206
|
|
|
|
|
207
|
|
|
$code = null; |
|
|
|
|
|
|
208
|
|
|
$message = null; |
|
|
|
|
|
|
209
|
|
|
|
|
210
|
|
|
$domXpath = $this->makeDomXpath($response->responseXml); |
|
211
|
|
|
|
|
212
|
|
|
$errorCodeNode = $domXpath->query('//m:errorInformation/m:errorDetails/m:code'); |
|
213
|
|
View Code Duplication |
if ($errorCodeNode->length > 0) { |
|
|
|
|
|
|
214
|
|
|
$analyzeResponse->status = Result::STATUS_ERROR; |
|
215
|
|
|
|
|
216
|
|
|
$errCode = $errorCodeNode->item(0)->nodeValue; |
|
217
|
|
|
$level = null; |
|
218
|
|
|
$errDesc = null; |
|
|
|
|
|
|
219
|
|
|
|
|
220
|
|
|
$errorLevelNode = $domXpath->query('//m:errorInformation/m:errorDetails/m:processingLevel'); |
|
221
|
|
|
if ($errorLevelNode->length > 0) { |
|
222
|
|
|
$level = RetrieveSeatMap::decodeProcessingLevel($errorLevelNode->item(0)->nodeValue); |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
$errorDescNode = $domXpath->query('//m:errorInformation/m:errorDetails/m:description'); |
|
226
|
|
|
if ($errorDescNode->length > 0) { |
|
227
|
|
|
$errDesc = $errorDescNode->item(0)->nodeValue; |
|
228
|
|
|
} else { |
|
229
|
|
|
$errDesc = RetrieveSeatMap::findMessage($errCode); |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
$analyzeResponse->messages[] = new Result\NotOk( |
|
233
|
|
|
$errCode, |
|
234
|
|
|
$errDesc, |
|
235
|
|
|
$level |
|
236
|
|
|
); |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
$codeNode = $domXpath->query('//m:warningInformation/m:warningDetails/m:number'); |
|
240
|
|
View Code Duplication |
if ($codeNode->length > 0) { |
|
|
|
|
|
|
241
|
|
|
$analyzeResponse->status = Result::STATUS_WARN; |
|
242
|
|
|
|
|
243
|
|
|
$warnCode = $codeNode->item(0)->nodeValue; |
|
244
|
|
|
$level = null; |
|
245
|
|
|
$warnDesc = null; |
|
|
|
|
|
|
246
|
|
|
|
|
247
|
|
|
$levelNode = $domXpath->query('//m:warningInformation/m:warningDetails/m:processingLevel'); |
|
248
|
|
|
if ($levelNode->length > 0) { |
|
249
|
|
|
$level = RetrieveSeatMap::decodeProcessingLevel($levelNode->item(0)->nodeValue); |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
$descNode = $domXpath->query('//m:warningInformation/m:warningDetails/m:description'); |
|
253
|
|
|
if ($descNode->length > 0) { |
|
254
|
|
|
$warnDesc = $descNode->item(0)->nodeValue; |
|
255
|
|
|
} else { |
|
256
|
|
|
$warnDesc = RetrieveSeatMap::findMessage($warnCode); |
|
257
|
|
|
} |
|
258
|
|
|
|
|
259
|
|
|
$analyzeResponse->messages[] = new Result\NotOk( |
|
260
|
|
|
$warnCode, |
|
261
|
|
|
$warnDesc, |
|
262
|
|
|
$level |
|
263
|
|
|
); |
|
264
|
|
|
} |
|
265
|
|
|
|
|
266
|
|
|
return $analyzeResponse; |
|
267
|
|
|
} |
|
268
|
|
|
|
|
269
|
|
|
/** |
|
270
|
|
|
* Analysing a PNR_Retrieve response |
|
271
|
|
|
* |
|
272
|
|
|
* @param SendResult $response PNR_Retrieve result |
|
273
|
|
|
* @return Result |
|
274
|
|
|
*/ |
|
275
|
|
|
protected function analyzePnrRetrieveResponse($response) |
|
276
|
|
|
{ |
|
277
|
|
|
return $this->analyzePnrReply($response); |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
/** |
|
281
|
|
|
* @param SendResult $response PNR_AddMultiElements result |
|
282
|
|
|
* @return Result |
|
283
|
|
|
*/ |
|
284
|
|
|
protected function analyzePnrAddMultiElementsResponse($response) |
|
285
|
|
|
{ |
|
286
|
|
|
return $this->analyzePnrReply($response); |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* @param SendResult $response PNR_Cancel result |
|
291
|
|
|
* @return Result |
|
292
|
|
|
*/ |
|
293
|
|
|
protected function analyzePnrCancelResponse($response) |
|
294
|
|
|
{ |
|
295
|
|
|
return $this->analyzePnrReply($response); |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* Analysing a PNR_Reply |
|
300
|
|
|
* |
|
301
|
|
|
* @param SendResult $response PNR_Retrieve result |
|
302
|
|
|
* @return Result |
|
303
|
|
|
*/ |
|
304
|
|
|
protected function analyzePnrReply($response) |
|
305
|
|
|
{ |
|
306
|
|
|
$analyzeResponse = new Result($response); |
|
307
|
|
|
|
|
308
|
|
|
$domXpath = $this->makeDomXpath($response->responseXml); |
|
309
|
|
|
|
|
310
|
|
|
//General Errors: |
|
311
|
|
|
$queryAllErrorCodes = "//m:generalErrorInfo//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode"; |
|
312
|
|
|
$queryAllErrorMsg = "//m:generalErrorInfo/m:errorWarningDescription/m:freeText"; |
|
313
|
|
|
|
|
314
|
|
|
$errorCodeNodeList = $domXpath->query($queryAllErrorCodes); |
|
315
|
|
|
|
|
316
|
|
View Code Duplication |
if ($errorCodeNodeList->length > 0) { |
|
|
|
|
|
|
317
|
|
|
$analyzeResponse->status = Result::STATUS_ERROR; |
|
318
|
|
|
|
|
319
|
|
|
$code = $errorCodeNodeList->item(0)->nodeValue; |
|
320
|
|
|
$errorTextNodeList = $domXpath->query($queryAllErrorMsg); |
|
321
|
|
|
$message = $this->makeMessageFromMessagesNodeList($errorTextNodeList); |
|
322
|
|
|
|
|
323
|
|
|
$analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'general'); |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
//Segment errors: |
|
327
|
|
|
$querySegmentErrorCodes = "//m:originDestinationDetails//m:errorInfo/m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode"; |
|
|
|
|
|
|
328
|
|
|
$querySegmentErrorMsg = "//m:originDestinationDetails//m:errorInfo/m:errorWarningDescription/m:freeText"; |
|
329
|
|
|
|
|
330
|
|
|
$errorCodeNodeList = $domXpath->query($querySegmentErrorCodes); |
|
331
|
|
|
|
|
332
|
|
View Code Duplication |
if ($errorCodeNodeList->length > 0) { |
|
|
|
|
|
|
333
|
|
|
$analyzeResponse->status = Result::STATUS_ERROR; |
|
334
|
|
|
|
|
335
|
|
|
$code = $errorCodeNodeList->item(0)->nodeValue; |
|
336
|
|
|
$errorTextNodeList = $domXpath->query($querySegmentErrorMsg); |
|
337
|
|
|
$message = $this->makeMessageFromMessagesNodeList($errorTextNodeList); |
|
338
|
|
|
|
|
339
|
|
|
$analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'segment'); |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
//Element errors: |
|
343
|
|
|
$queryElementErrorCodes = "//m:dataElementsIndiv/m:elementErrorInformation/m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode"; |
|
|
|
|
|
|
344
|
|
|
$queryElementErrorMsg = "//m:dataElementsIndiv//m:elementErrorInformation/m:errorWarningDescription/m:freeText"; |
|
345
|
|
|
|
|
346
|
|
|
$errorCodeNodeList = $domXpath->query($queryElementErrorCodes); |
|
347
|
|
|
|
|
348
|
|
View Code Duplication |
if ($errorCodeNodeList->length > 0) { |
|
|
|
|
|
|
349
|
|
|
$analyzeResponse->status = Result::STATUS_ERROR; |
|
350
|
|
|
|
|
351
|
|
|
$code = $errorCodeNodeList->item(0)->nodeValue; |
|
352
|
|
|
|
|
353
|
|
|
$errorTextNodeList = $domXpath->query($queryElementErrorMsg); |
|
354
|
|
|
$message = $this->makeMessageFromMessagesNodeList($errorTextNodeList); |
|
355
|
|
|
|
|
356
|
|
|
$analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'element'); |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
return $analyzeResponse; |
|
360
|
|
|
} |
|
361
|
|
|
|
|
362
|
|
|
/** |
|
363
|
|
|
* @param SendResult $response Pnr_RetrieveAndDisplay response |
|
364
|
|
|
* @return Result |
|
365
|
|
|
* @throws Exception |
|
366
|
|
|
*/ |
|
367
|
|
|
protected function analyzePnrRetrieveAndDisplayResponse($response) |
|
368
|
|
|
{ |
|
369
|
|
|
return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
|
370
|
|
|
} |
|
371
|
|
|
|
|
372
|
|
|
/** |
|
373
|
|
|
* Analysing a PNR_DisplayHistoryReply |
|
374
|
|
|
* |
|
375
|
|
|
* @param SendResult $response PNR_DisplayHistoryReply result |
|
376
|
|
|
* @return Result |
|
377
|
|
|
* @throws Exception |
|
378
|
|
|
*/ |
|
379
|
|
|
protected function analyzePnrDisplayHistoryResponse($response) |
|
380
|
|
|
{ |
|
381
|
|
|
$analyzeResponse = new Result($response); |
|
382
|
|
|
|
|
383
|
|
|
$domXpath = $this->makeDomXpath($response->responseXml); |
|
384
|
|
|
|
|
385
|
|
|
$queryAllErrorCodes = "//m:generalErrorGroup//m:errorNumber/m:errorDetails/m:errorCode"; |
|
386
|
|
|
$queryAllErrorMsg = "//m:generalErrorGroup/m:genrealErrorText/m:freeText"; |
|
387
|
|
|
|
|
388
|
|
|
$errorCodeNodeList = $domXpath->query($queryAllErrorCodes); |
|
389
|
|
|
|
|
390
|
|
View Code Duplication |
if ($errorCodeNodeList->length > 0) { |
|
|
|
|
|
|
391
|
|
|
$analyzeResponse->status = Result::STATUS_ERROR; |
|
392
|
|
|
|
|
393
|
|
|
$code = $errorCodeNodeList->item(0)->nodeValue; |
|
394
|
|
|
$errorTextNodeList = $domXpath->query($queryAllErrorMsg); |
|
395
|
|
|
$message = $this->makeMessageFromMessagesNodeList($errorTextNodeList); |
|
396
|
|
|
|
|
397
|
|
|
$analyzeResponse->messages[] = new Result\NotOk($code, trim($message)); |
|
398
|
|
|
} |
|
399
|
|
|
|
|
400
|
|
|
return $analyzeResponse; |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
/** |
|
404
|
|
|
* @param SendResult $response Queue_RemoveItem response |
|
405
|
|
|
* @return Result |
|
406
|
|
|
* @throws Exception |
|
407
|
|
|
*/ |
|
408
|
|
|
protected function analyzeQueueRemoveItemResponse($response) |
|
409
|
|
|
{ |
|
410
|
|
|
return $this->analyzeGenericQueueResponse($response); |
|
411
|
|
|
} |
|
412
|
|
|
|
|
413
|
|
|
/** |
|
414
|
|
|
* @param SendResult $response Queue_MoveItem response |
|
415
|
|
|
* @return Result |
|
416
|
|
|
* @throws Exception |
|
417
|
|
|
*/ |
|
418
|
|
|
protected function analyzeQueueMoveItemResponse($response) |
|
419
|
|
|
{ |
|
420
|
|
|
return $this->analyzeGenericQueueResponse($response); |
|
421
|
|
|
} |
|
422
|
|
|
|
|
423
|
|
|
/** |
|
424
|
|
|
* @param SendResult $response Queue_PlacePNR response |
|
425
|
|
|
* @return Result |
|
426
|
|
|
* @throws Exception |
|
427
|
|
|
*/ |
|
428
|
|
|
protected function analyzeQueuePlacePNRResponse($response) |
|
429
|
|
|
{ |
|
430
|
|
|
return $this->analyzeGenericQueueResponse($response); |
|
431
|
|
|
} |
|
432
|
|
|
|
|
433
|
|
|
/** |
|
434
|
|
|
* @param SendResult $response Queue_List result |
|
435
|
|
|
* @return Result |
|
436
|
|
|
* @throws Exception |
|
437
|
|
|
*/ |
|
438
|
|
|
protected function analyzeQueueListResponse($response) |
|
439
|
|
|
{ |
|
440
|
|
|
return $this->analyzeGenericQueueResponse($response); |
|
441
|
|
|
} |
|
442
|
|
|
|
|
443
|
|
|
/** |
|
444
|
|
|
* Analyze a generic Queue response |
|
445
|
|
|
* |
|
446
|
|
|
* @param SendResult $response Queue_*Reply result |
|
447
|
|
|
* @return Result |
|
448
|
|
|
* @throws Exception |
|
449
|
|
|
*/ |
|
450
|
|
|
protected function analyzeGenericQueueResponse($response) |
|
451
|
|
|
{ |
|
452
|
|
|
$analysisResponse = new Result($response); |
|
453
|
|
|
|
|
454
|
|
|
$domDoc = $this->loadDomDocument($response->responseXml); |
|
455
|
|
|
|
|
456
|
|
|
$errorCodeNode = $domDoc->getElementsByTagName("errorCode")->item(0); |
|
457
|
|
|
|
|
458
|
|
|
if (!is_null($errorCodeNode)) { |
|
459
|
|
|
$analysisResponse->status = Result::STATUS_WARN; |
|
460
|
|
|
|
|
461
|
|
|
$errorCode = $errorCodeNode->nodeValue; |
|
462
|
|
|
$errorMessage = $this->getErrorTextFromQueueErrorCode($errorCode); |
|
463
|
|
|
|
|
464
|
|
|
$analysisResponse->messages[] = new Result\NotOk($errorCode, $errorMessage); |
|
465
|
|
|
} |
|
466
|
|
|
|
|
467
|
|
|
return $analysisResponse; |
|
468
|
|
|
} |
|
469
|
|
|
|
|
470
|
|
|
|
|
471
|
|
|
/** |
|
472
|
|
|
* |
|
473
|
|
|
* <Fare_PricePNRWithBookingClassReply xmlns="http://xml.amadeus.com/TPCBRR_13_2_1A"> |
|
474
|
|
|
* <applicationError> |
|
475
|
|
|
* <errorOrWarningCodeDetails> |
|
476
|
|
|
* <errorDetails> |
|
477
|
|
|
* <errorCode>00477</errorCode> |
|
478
|
|
|
* <errorCategory>EC</errorCategory> |
|
479
|
|
|
* <errorCodeOwner>1A</errorCodeOwner> |
|
480
|
|
|
* </errorDetails> |
|
481
|
|
|
* </errorOrWarningCodeDetails> |
|
482
|
|
|
* <errorWarningDescription> |
|
483
|
|
|
* <freeText>INVALID FORMAT</freeText> |
|
484
|
|
|
* </errorWarningDescription> |
|
485
|
|
|
* </applicationError> |
|
486
|
|
|
* </Fare_PricePNRWithBookingClassReply> |
|
487
|
|
|
* |
|
488
|
|
|
* @param SendResult $response Fare_PricePNRWithBookingClass result |
|
489
|
|
|
* @return Result |
|
490
|
|
|
* @throws Exception |
|
491
|
|
|
*/ |
|
492
|
|
View Code Duplication |
protected function analyzeFarePricePNRWithBookingClassResponse($response) |
|
|
|
|
|
|
493
|
|
|
{ |
|
494
|
|
|
$analyzeResponse = new Result($response); |
|
495
|
|
|
|
|
496
|
|
|
$domXpath = $this->makeDomXpath($response->responseXml); |
|
497
|
|
|
|
|
498
|
|
|
$queryErrorCode = "//m:applicationError//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode"; |
|
499
|
|
|
$queryErrorCategory = "//m:applicationError//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCategory"; |
|
500
|
|
|
$queryErrorMsg = "//m:applicationError/m:errorWarningDescription/m:freeText"; |
|
501
|
|
|
|
|
502
|
|
|
$errorCodeNodeList = $domXpath->query($queryErrorCode); |
|
503
|
|
|
|
|
504
|
|
|
if ($errorCodeNodeList->length > 0) { |
|
505
|
|
|
$analyzeResponse->status = Result::STATUS_ERROR; |
|
506
|
|
|
|
|
507
|
|
|
$errorCatNode = $domXpath->query($queryErrorCategory)->item(0); |
|
508
|
|
|
if ($errorCatNode instanceof \DOMNode) { |
|
509
|
|
|
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue); |
|
510
|
|
|
} |
|
511
|
|
|
|
|
512
|
|
|
$analyzeResponse->messages[] = new Result\NotOk( |
|
513
|
|
|
$errorCodeNodeList->item(0)->nodeValue, |
|
514
|
|
|
$this->makeMessageFromMessagesNodeList( |
|
515
|
|
|
$domXpath->query($queryErrorMsg) |
|
516
|
|
|
) |
|
517
|
|
|
); |
|
518
|
|
|
} |
|
519
|
|
|
|
|
520
|
|
|
return $analyzeResponse; |
|
521
|
|
|
} |
|
522
|
|
|
|
|
523
|
|
|
protected function analyzeFareMasterPricerTravelBoardSearchResponse($response) |
|
524
|
|
|
{ |
|
525
|
|
|
$analyzeResponse = new Result($response); |
|
526
|
|
|
|
|
527
|
|
|
$domXpath = $this->makeDomXpath($response->responseXml); |
|
528
|
|
|
|
|
529
|
|
|
$queryErrCode = "//m:applicationError//m:applicationErrorDetail/m:error"; |
|
530
|
|
|
$queryErrMsg = "//m:errorMessageText/m:description"; |
|
531
|
|
|
|
|
532
|
|
|
$codeNode = $domXpath->query($queryErrCode)->item(0); |
|
533
|
|
|
|
|
534
|
|
|
if ($codeNode instanceof \DOMNode) { |
|
535
|
|
|
$analyzeResponse->status = Result::STATUS_ERROR; |
|
536
|
|
|
|
|
537
|
|
|
$errMsg = ''; |
|
538
|
|
|
$errMsgNode = $domXpath->query($queryErrMsg)->item(0); |
|
539
|
|
|
if ($errMsgNode instanceof \DOMNode) { |
|
540
|
|
|
$errMsg = $errMsgNode->nodeValue; |
|
541
|
|
|
} |
|
542
|
|
|
|
|
543
|
|
|
$analyzeResponse->messages[] = new Result\NotOk( |
|
544
|
|
|
$codeNode->nodeValue, |
|
545
|
|
|
$errMsg |
|
546
|
|
|
); |
|
547
|
|
|
} |
|
548
|
|
|
|
|
549
|
|
|
return $analyzeResponse; |
|
550
|
|
|
} |
|
551
|
|
|
|
|
552
|
|
|
/** |
|
553
|
|
|
* @param SendResult $response |
|
554
|
|
|
* @return Result |
|
555
|
|
|
*/ |
|
556
|
|
|
protected function analyzeFareConvertCurrencyResponse($response) |
|
557
|
|
|
{ |
|
558
|
|
|
return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
|
559
|
|
|
} |
|
560
|
|
|
|
|
561
|
|
|
/** |
|
562
|
|
|
* @param SendResult $response |
|
563
|
|
|
* @return Result |
|
564
|
|
|
*/ |
|
565
|
|
|
protected function analyzeFareCheckRulesResponse($response) |
|
566
|
|
|
{ |
|
567
|
|
|
return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
|
568
|
|
|
} |
|
569
|
|
|
|
|
570
|
|
|
/** |
|
571
|
|
|
* @param SendResult $response |
|
572
|
|
|
* @return Result |
|
573
|
|
|
*/ |
|
574
|
|
|
protected function analyzeFareInformativePricingWithoutPNRResponse($response) |
|
575
|
|
|
{ |
|
576
|
|
|
return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
|
577
|
|
|
} |
|
578
|
|
|
|
|
579
|
|
|
|
|
580
|
|
|
/** |
|
581
|
|
|
* @param SendResult $response |
|
582
|
|
|
* @return Result |
|
583
|
|
|
*/ |
|
584
|
|
|
protected function analyzeDocIssuanceIssueTicketResponse($response) |
|
585
|
|
|
{ |
|
586
|
|
|
return $this->analyzeSimpleResponseErrorCodeAndMessageStatusCode($response); |
|
587
|
|
|
} |
|
588
|
|
|
|
|
589
|
|
View Code Duplication |
protected function analyzeTicketCreateTSTFromPricingResponse($response) |
|
|
|
|
|
|
590
|
|
|
{ |
|
591
|
|
|
$analyzeResponse = new Result($response); |
|
592
|
|
|
|
|
593
|
|
|
$domDoc = $this->loadDomDocument($response->responseXml); |
|
594
|
|
|
|
|
595
|
|
|
$errorCodeNode = $domDoc->getElementsByTagName("applicationErrorCode")->item(0); |
|
596
|
|
|
|
|
597
|
|
|
if (!is_null($errorCodeNode)) { |
|
598
|
|
|
$analyzeResponse->status = Result::STATUS_ERROR; |
|
599
|
|
|
|
|
600
|
|
|
$errorCatNode = $domDoc->getElementsByTagName("codeListQualifier")->item(0); |
|
601
|
|
|
if ($errorCatNode instanceof \DOMNode) { |
|
602
|
|
|
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue); |
|
603
|
|
|
} |
|
604
|
|
|
|
|
605
|
|
|
$errorCode = $errorCodeNode->nodeValue; |
|
606
|
|
|
$errorTextNodeList = $domDoc->getElementsByTagName("errorFreeText"); |
|
607
|
|
|
|
|
608
|
|
|
$analyzeResponse->messages[] = new Result\NotOk( |
|
609
|
|
|
$errorCode, |
|
610
|
|
|
$this->makeMessageFromMessagesNodeList($errorTextNodeList) |
|
611
|
|
|
); |
|
612
|
|
|
} |
|
613
|
|
|
|
|
614
|
|
|
return $analyzeResponse; |
|
615
|
|
|
} |
|
616
|
|
|
|
|
617
|
|
|
/** |
|
618
|
|
|
* @param SendResult $response |
|
619
|
|
|
* @return Result |
|
620
|
|
|
*/ |
|
621
|
|
|
protected function analyzeOfferConfirmCarOfferResponse($response) |
|
622
|
|
|
{ |
|
623
|
|
|
return $this->analyzeGenericOfferResponse($response); |
|
624
|
|
|
} |
|
625
|
|
|
|
|
626
|
|
|
/** |
|
627
|
|
|
* @param SendResult $response |
|
628
|
|
|
* @return Result |
|
629
|
|
|
*/ |
|
630
|
|
|
protected function analyzeOfferConfirmHotelOfferResponse($response) |
|
631
|
|
|
{ |
|
632
|
|
|
$analyzeResponse = new Result($response); |
|
633
|
|
|
|
|
634
|
|
|
$domXpath = $this->makeDomXpath($response->responseXml); |
|
635
|
|
|
|
|
636
|
|
|
$codeNode = $domXpath->query("//m:errorDetails/m:errorCode")->item(0); |
|
637
|
|
|
if ($codeNode instanceof \DOMNode) { |
|
638
|
|
|
$analyzeResponse->status = Result::STATUS_ERROR; |
|
639
|
|
|
|
|
640
|
|
|
$categoryNode = $domXpath->query("//m:errorDetails/m:errorCategory")->item(0); |
|
641
|
|
|
if ($categoryNode instanceof \DOMNode) { |
|
642
|
|
|
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue); |
|
643
|
|
|
} |
|
644
|
|
|
|
|
645
|
|
|
$msgNode = $domXpath->query('//m:errorDescription/m:freeText')->item(0); |
|
646
|
|
|
|
|
647
|
|
|
$analyzeResponse->messages[] = new Result\NotOk( |
|
648
|
|
|
$codeNode->nodeValue, |
|
649
|
|
|
trim($msgNode->nodeValue) |
|
650
|
|
|
); |
|
651
|
|
|
} |
|
652
|
|
|
|
|
653
|
|
|
return $analyzeResponse; |
|
654
|
|
|
} |
|
655
|
|
|
|
|
656
|
|
|
/** |
|
657
|
|
|
* @param SendResult $response |
|
658
|
|
|
* @return Result |
|
659
|
|
|
*/ |
|
660
|
|
|
protected function analyzeOfferConfirmAirOfferResponse($response) |
|
661
|
|
|
{ |
|
662
|
|
|
return $this->analyzeGenericOfferResponse($response); |
|
663
|
|
|
} |
|
664
|
|
|
|
|
665
|
|
|
/** |
|
666
|
|
|
* @param SendResult $response |
|
667
|
|
|
* @return Result |
|
668
|
|
|
*/ |
|
669
|
|
|
protected function analyzeOfferVerifyOfferResponse($response) |
|
670
|
|
|
{ |
|
671
|
|
|
return $this->analyzeGenericOfferResponse($response); |
|
672
|
|
|
} |
|
673
|
|
|
|
|
674
|
|
|
/** |
|
675
|
|
|
* @param SendResult $response |
|
676
|
|
|
* @return Result |
|
677
|
|
|
*/ |
|
678
|
|
|
protected function analyzeGenericOfferResponse($response) |
|
679
|
|
|
{ |
|
680
|
|
|
$analyzeResponse = new Result($response); |
|
681
|
|
|
|
|
682
|
|
|
$domXpath = $this->makeDomXpath($response->responseXml); |
|
683
|
|
|
|
|
684
|
|
|
$msgNode = $domXpath->query('//m:errorsDescription/m:errorWarningDescription/m:freeText')->item(0); |
|
685
|
|
|
|
|
686
|
|
|
if ($msgNode instanceof \DOMNode) { |
|
687
|
|
|
if (trim($msgNode->nodeValue) === "OFFER CONFIRMED SUCCESSFULLY" || trim($msgNode->nodeValue) === "OFFER VERIFIED SUCCESSFULLY") { |
|
|
|
|
|
|
688
|
|
|
$analyzeResponse->messages[] = new Result\NotOk( |
|
689
|
|
|
0, |
|
690
|
|
|
trim($msgNode->nodeValue) |
|
691
|
|
|
); |
|
692
|
|
|
return $analyzeResponse; |
|
693
|
|
|
} |
|
694
|
|
|
|
|
695
|
|
|
$categoryNode = $domXpath->query('//m:errorDetails/m:errorCategory')->item(0); |
|
696
|
|
|
if ($categoryNode instanceof \DOMNode) { |
|
697
|
|
|
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue); |
|
698
|
|
|
} |
|
699
|
|
|
|
|
700
|
|
|
$codeNode = $domXpath->query('//m:errorDetails/m:errorCode')->item(0); |
|
701
|
|
|
|
|
702
|
|
|
$analyzeResponse->messages[] = new Result\NotOk( |
|
703
|
|
|
$codeNode->nodeValue, |
|
704
|
|
|
trim($msgNode->nodeValue) |
|
705
|
|
|
); |
|
706
|
|
|
} |
|
707
|
|
|
|
|
708
|
|
|
return $analyzeResponse; |
|
709
|
|
|
} |
|
710
|
|
|
|
|
711
|
|
|
protected function analyzeMiniRuleGetFromPricingRecResponse($response) |
|
712
|
|
|
{ |
|
713
|
|
|
$analyzeResponse = new Result($response); |
|
714
|
|
|
|
|
715
|
|
|
$domXpath = $this->makeDomXpath($response->responseXml); |
|
716
|
|
|
|
|
717
|
|
|
$statusNode = $domXpath->query('//m:responseDetails/m:statusCode')->item(0); |
|
718
|
|
|
if ($statusNode instanceof \DOMNode) { |
|
719
|
|
|
$code = $statusNode->nodeValue; |
|
720
|
|
|
|
|
721
|
|
|
if ($code !== 'O') { |
|
722
|
|
|
$categoryNode = $domXpath->query('//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCategory')->item(0); |
|
|
|
|
|
|
723
|
|
|
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue); |
|
724
|
|
|
|
|
725
|
|
|
$codeNode = $domXpath->query('//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode')->item(0); |
|
726
|
|
|
$msgNode = $domXpath->query('//m:errorWarningDescription/m:freeText')->item(0); |
|
727
|
|
|
|
|
728
|
|
|
if ($codeNode instanceof \DOMNode && $msgNode instanceof \DOMNode) { |
|
729
|
|
|
$analyzeResponse->messages[] = new Result\NotOk( |
|
730
|
|
|
$codeNode->nodeValue, |
|
731
|
|
|
$msgNode->nodeValue |
|
732
|
|
|
); |
|
733
|
|
|
} |
|
734
|
|
|
} |
|
735
|
|
|
} |
|
736
|
|
|
|
|
737
|
|
|
return $analyzeResponse; |
|
738
|
|
|
} |
|
739
|
|
|
|
|
740
|
|
|
/** |
|
741
|
|
|
* @param SendResult $response |
|
742
|
|
|
* @return Result |
|
743
|
|
|
*/ |
|
744
|
|
|
protected function analyzeInfoEncodeDecodeCityResponse($response) |
|
745
|
|
|
{ |
|
746
|
|
|
return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
|
747
|
|
|
} |
|
748
|
|
|
|
|
749
|
|
|
/** |
|
750
|
|
|
* @param SendResult $response |
|
751
|
|
|
* @return Result |
|
752
|
|
|
*/ |
|
753
|
|
|
protected function analyzePriceXplorerExtremeSearchResponse($response) |
|
754
|
|
|
{ |
|
755
|
|
|
return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
|
756
|
|
|
} |
|
757
|
|
|
|
|
758
|
|
|
/** |
|
759
|
|
|
* @param SendResult $response |
|
760
|
|
|
* @return Result |
|
761
|
|
|
*/ |
|
762
|
|
|
protected function analyzeSalesReportsDisplayQueryReportResponse($response) |
|
763
|
|
|
{ |
|
764
|
|
|
return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
|
765
|
|
|
} |
|
766
|
|
|
|
|
767
|
|
|
/** |
|
768
|
|
|
* @param SendResult $response WebService message Send Result |
|
769
|
|
|
* @return Result |
|
770
|
|
|
* @throws Exception |
|
771
|
|
|
*/ |
|
772
|
|
View Code Duplication |
protected function analyzeSimpleResponseErrorCodeAndMessage($response) |
|
|
|
|
|
|
773
|
|
|
{ |
|
774
|
|
|
$analyzeResponse = new Result($response); |
|
775
|
|
|
|
|
776
|
|
|
$domDoc = $this->loadDomDocument($response->responseXml); |
|
777
|
|
|
|
|
778
|
|
|
$errorCodeNode = $domDoc->getElementsByTagName("errorCode")->item(0); |
|
779
|
|
|
|
|
780
|
|
|
if (!is_null($errorCodeNode)) { |
|
781
|
|
|
$errorCatNode = $domDoc->getElementsByTagName("errorCategory")->item(0); |
|
782
|
|
|
if ($errorCatNode instanceof \DOMNode) { |
|
783
|
|
|
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue); |
|
784
|
|
|
} else { |
|
785
|
|
|
$analyzeResponse->status = Result::STATUS_ERROR; |
|
786
|
|
|
} |
|
787
|
|
|
|
|
788
|
|
|
$errorCode = $errorCodeNode->nodeValue; |
|
789
|
|
|
$errorTextNodeList = $domDoc->getElementsByTagName("freeText"); |
|
790
|
|
|
|
|
791
|
|
|
$analyzeResponse->messages[] = new Result\NotOk( |
|
792
|
|
|
$errorCode, |
|
793
|
|
|
$this->makeMessageFromMessagesNodeList($errorTextNodeList) |
|
794
|
|
|
); |
|
795
|
|
|
} |
|
796
|
|
|
|
|
797
|
|
|
return $analyzeResponse; |
|
798
|
|
|
} |
|
799
|
|
|
|
|
800
|
|
|
/** |
|
801
|
|
|
* @param SendResult $response WebService message Send Result |
|
802
|
|
|
* @return Result |
|
803
|
|
|
* @throws Exception |
|
804
|
|
|
*/ |
|
805
|
|
View Code Duplication |
protected function analyzeSimpleResponseErrorCodeAndMessageStatusCode($response) |
|
|
|
|
|
|
806
|
|
|
{ |
|
807
|
|
|
$analyzeResponse = new Result($response); |
|
808
|
|
|
|
|
809
|
|
|
$domDoc = $this->loadDomDocument($response->responseXml); |
|
810
|
|
|
|
|
811
|
|
|
$errorCodeNode = $domDoc->getElementsByTagName("errorCode")->item(0); |
|
812
|
|
|
|
|
813
|
|
|
if (!is_null($errorCodeNode)) { |
|
814
|
|
|
$analyzeResponse->status = Result::STATUS_ERROR; |
|
815
|
|
|
|
|
816
|
|
|
$errorCatNode = $domDoc->getElementsByTagName("statusCode")->item(0); |
|
817
|
|
|
if ($errorCatNode instanceof \DOMNode) { |
|
818
|
|
|
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue); |
|
819
|
|
|
} |
|
820
|
|
|
|
|
821
|
|
|
$errorCode = $errorCodeNode->nodeValue; |
|
822
|
|
|
$errorTextNodeList = $domDoc->getElementsByTagName("freeText"); |
|
823
|
|
|
|
|
824
|
|
|
$analyzeResponse->messages[] = new Result\NotOk( |
|
825
|
|
|
$errorCode, |
|
826
|
|
|
$this->makeMessageFromMessagesNodeList($errorTextNodeList) |
|
827
|
|
|
); |
|
828
|
|
|
} |
|
829
|
|
|
|
|
830
|
|
|
return $analyzeResponse; |
|
831
|
|
|
} |
|
832
|
|
|
|
|
833
|
|
|
/** |
|
834
|
|
|
* Returns the errortext from a Queue_*Reply errorcode |
|
835
|
|
|
* |
|
836
|
|
|
* This function is necessary because the core only responds |
|
837
|
|
|
* with errorcode but does not send an errortext. |
|
838
|
|
|
* |
|
839
|
|
|
* The errorcodes for all Queue_*Reply messages are the same. |
|
840
|
|
|
* |
|
841
|
|
|
* @link https://webservices.amadeus.com/extranet/viewArea.do?id=10 |
|
842
|
|
|
* @param string $errorCode |
|
843
|
|
|
* @return string the errortext for this errorcode. |
|
844
|
|
|
*/ |
|
845
|
|
|
protected function getErrorTextFromQueueErrorCode($errorCode) |
|
846
|
|
|
{ |
|
847
|
|
|
$recognizedErrors = [ |
|
848
|
|
|
'723' => "Invalid category", |
|
849
|
|
|
'911' => "Unable to process - system error", |
|
850
|
|
|
'913' => "Item/data not found or data not existing in processing host", |
|
851
|
|
|
'79D' => "Queue identifier has not been assigned for specified office identification", |
|
852
|
|
|
'91C' => "invalid record locator", |
|
853
|
|
|
'91F' => "Invalid queue number", |
|
854
|
|
|
'921' => "target not specified", |
|
855
|
|
|
'922' => "Targetted queue has wrong queue type", |
|
856
|
|
|
'926' => "Queue category empty", |
|
857
|
|
|
'928' => "Queue category not assigned", |
|
858
|
|
|
'92A' => "Queue category full", |
|
859
|
|
|
]; |
|
860
|
|
|
|
|
861
|
|
|
$errorMessage = (array_key_exists($errorCode, $recognizedErrors)) ? $recognizedErrors[$errorCode] : ''; |
|
862
|
|
|
|
|
863
|
|
|
if ($errorMessage === '') { |
|
864
|
|
|
$errorMessage = "QUEUE ERROR '" . $errorCode . "' (Error message unavailable)"; |
|
865
|
|
|
} |
|
866
|
|
|
|
|
867
|
|
|
return $errorMessage; |
|
868
|
|
|
} |
|
869
|
|
|
|
|
870
|
|
|
/** |
|
871
|
|
|
* @param string $response |
|
872
|
|
|
* @return \DOMDocument |
|
873
|
|
|
* @throws Exception when there's a problem loading the message |
|
874
|
|
|
*/ |
|
875
|
|
|
protected function loadDomDocument($response) |
|
876
|
|
|
{ |
|
877
|
|
|
$domDoc = new \DOMDocument('1.0', 'UTF-8'); |
|
878
|
|
|
|
|
879
|
|
|
$loadResult = $domDoc->loadXML($response); |
|
880
|
|
|
if ($loadResult === false) { |
|
881
|
|
|
throw new Exception('Could not load response message into DOMDocument'); |
|
882
|
|
|
} |
|
883
|
|
|
|
|
884
|
|
|
return $domDoc; |
|
885
|
|
|
} |
|
886
|
|
|
|
|
887
|
|
|
/** |
|
888
|
|
|
* @param string $qualifier |
|
889
|
|
|
* @param string|null $amadeusCodeList |
|
890
|
|
|
* @return string Result::STATUS_* |
|
891
|
|
|
*/ |
|
892
|
|
|
protected function makeStatusFromErrorQualifier($qualifier, $amadeusCodeList = null) |
|
|
|
|
|
|
893
|
|
|
{ |
|
894
|
|
|
$status = null; |
|
|
|
|
|
|
895
|
|
|
|
|
896
|
|
|
switch ($qualifier) { |
|
897
|
|
|
case 'INF': |
|
898
|
|
|
$status = Result::STATUS_INFO; |
|
899
|
|
|
break; |
|
900
|
|
|
case 'WEC': |
|
901
|
|
|
case 'WZZ': //Mutually defined warning |
|
902
|
|
|
case 'W': |
|
903
|
|
|
$status = Result::STATUS_WARN; |
|
904
|
|
|
break; |
|
905
|
|
|
case 'EC': |
|
906
|
|
|
case 'X': |
|
907
|
|
|
case '001': //Air_MultiAvailability |
|
908
|
|
|
$status = Result::STATUS_ERROR; |
|
909
|
|
|
break; |
|
910
|
|
|
case 'O': |
|
911
|
|
|
$status = Result::STATUS_OK; |
|
912
|
|
|
break; |
|
913
|
|
|
case 'ZZZ': //Mutually defined |
|
914
|
|
|
default: |
|
915
|
|
|
$status = Result::STATUS_UNKNOWN; |
|
916
|
|
|
break; |
|
917
|
|
|
} |
|
918
|
|
|
|
|
919
|
|
|
return $status; |
|
920
|
|
|
} |
|
921
|
|
|
|
|
922
|
|
|
|
|
923
|
|
|
/** |
|
924
|
|
|
* Make a Xpath-queryable object for an XML string |
|
925
|
|
|
* |
|
926
|
|
|
* registers TNS namespace with prefix self::XMLNS_PREFIX |
|
927
|
|
|
* |
|
928
|
|
|
* @param string $response |
|
929
|
|
|
* @return \DOMXPath |
|
930
|
|
|
* @throws Exception when there's a problem loading the message |
|
931
|
|
|
*/ |
|
932
|
|
|
protected function makeDomXpath($response) |
|
933
|
|
|
{ |
|
934
|
|
|
$domDoc = $this->loadDomDocument($response); |
|
935
|
|
|
$domXpath = new \DOMXPath($domDoc); |
|
936
|
|
|
|
|
937
|
|
|
$domXpath->registerNamespace( |
|
938
|
|
|
self::XMLNS_PREFIX, |
|
939
|
|
|
$domDoc->documentElement->lookupNamespaceUri(null) |
|
940
|
|
|
); |
|
941
|
|
|
|
|
942
|
|
|
return $domXpath; |
|
943
|
|
|
} |
|
944
|
|
|
|
|
945
|
|
|
/** |
|
946
|
|
|
* Convert a DomNodeList of nodes containing a (potentially partial) error message into a string. |
|
947
|
|
|
* |
|
948
|
|
|
* @param \DOMNodeList $errorTextNodeList |
|
949
|
|
|
* @return string|null |
|
950
|
|
|
*/ |
|
951
|
|
|
protected function makeMessageFromMessagesNodeList($errorTextNodeList) |
|
952
|
|
|
{ |
|
953
|
|
|
return implode( |
|
954
|
|
|
' - ', |
|
955
|
|
|
array_map( |
|
956
|
|
|
function ($item) { |
|
957
|
|
|
return trim($item->nodeValue); |
|
958
|
|
|
}, |
|
959
|
|
|
iterator_to_array($errorTextNodeList) |
|
960
|
|
|
) |
|
961
|
|
|
); |
|
962
|
|
|
} |
|
963
|
|
|
|
|
964
|
|
|
/** |
|
965
|
|
|
* @param SendResult $sendResult |
|
966
|
|
|
* @return Result |
|
967
|
|
|
*/ |
|
968
|
|
|
protected function makeResultForException($sendResult) |
|
969
|
|
|
{ |
|
970
|
|
|
$result = new Result($sendResult, Result::STATUS_FATAL); |
|
971
|
|
|
|
|
972
|
|
|
$result->messages[] = $this->makeMessageFromException($sendResult->exception); |
|
973
|
|
|
|
|
974
|
|
|
return $result; |
|
975
|
|
|
} |
|
976
|
|
|
|
|
977
|
|
|
/** |
|
978
|
|
|
* @param \Exception $exception |
|
979
|
|
|
* @return Result\NotOk |
|
980
|
|
|
* @throws Exception |
|
981
|
|
|
*/ |
|
982
|
|
|
protected function makeMessageFromException(\Exception $exception) |
|
983
|
|
|
{ |
|
984
|
|
|
$message = new Result\NotOk(); |
|
985
|
|
|
|
|
986
|
|
|
if ($exception instanceof \SoapFault) { |
|
987
|
|
|
$info = explode('|', $exception->getMessage()); |
|
988
|
|
|
$message->code = $info[0]; |
|
989
|
|
|
if (count($info) === 3) { |
|
990
|
|
|
$message->level = $info[1]; |
|
991
|
|
|
$message->text = $info[2]; |
|
992
|
|
|
} |
|
993
|
|
|
} |
|
994
|
|
|
|
|
995
|
|
|
return $message; |
|
996
|
|
|
} |
|
997
|
|
|
} |
|
998
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.