Completed
Push — master ( d17808...738038 )
by Dieter
07:30
created

analyzeFareInformativeBestPricingWithoutPNRResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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
 * Analyses the responses received from the Amadeus WS server and checks for error messages.
34
 * If errors are found, the error information will be extracted and the response status will be changed
35
 * accordingly.
36
 *
37
 * @package Amadeus\Client\ResponseHandler
38
 * @author Dieter Devlieghere <[email protected]>
39
 */
40
class Base extends BaseUtils
41
{
42
    /**
43
     * Analyze the response from the server and throw an exception when an error has been detected.
44
     *
45
     * @param SendResult $sendResult The Send Result from the Session Handler
46
     * @param string $messageName The message that was called
47
     *
48
     * @throws Exception
49
     * @throws \RuntimeException
50
     * @return Result
51
     */
52
    public function analyzeResponse($sendResult, $messageName)
53
    {
54
        $methodName = 'analyze' . str_replace('_', '', ucfirst($messageName)) . 'Response';
55
56
        if (!empty($sendResult->exception)) {
57
            return $this->makeResultForException($sendResult);
58
        } elseif (method_exists($this, $methodName)) {
59
            return $this->$methodName(
60
                $sendResult
61
            );
62
        } else {
63
            return new Result($sendResult, Result::STATUS_UNKNOWN);
64
        }
65
    }
66
67
    /**
68
     * Analysing a Security_Authenticate
69
     *
70
     * @param SendResult $response Security_Authenticate result
71
     * @return Result
72
     */
73
    protected function analyzeSecurityAuthenticateResponse($response)
74
    {
75
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
76
    }
77
78
    /**
79
     * Analysing a Security_Authenticate
80
     *
81
     * @param SendResult $response Security_Authenticate result
82
     * @return Result
83
     */
84
    protected function analyzeSecuritySignOutResponse($response)
85
    {
86
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
87
    }
88
89
    /**
90
     * Unknown response for Command_Cryptic because you need to analyse the cryptic response yourself
91
     *
92
     * @param SendResult $response
93
     * @return Result
94
     */
95
    protected function analyzeCommandCrypticResponse($response)
96
    {
97
        $ccResult = new Result($response, Result::STATUS_UNKNOWN);
98
        $ccResult->messages[] = new Result\NotOk(
99
            0,
100
            "Response handling not supported for cryptic entries"
101
        );
102
103
        return $ccResult;
104
    }
105
106 View Code Duplication
    protected function analyzeAirMultiAvailabilityResponse($response)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
107
    {
108
        $analyzeResponse = new Result($response);
109
110
        $message = null;
111
112
        $domXpath = $this->makeDomXpath($response->responseXml);
113
114
        $codeNode = $domXpath->query("//m:errorOrWarningSection/m:errorOrWarningInfo//m:code")->item(0);
115
        if ($codeNode instanceof \DOMNode) {
116
            $analyzeResponse->status = Result::STATUS_ERROR;
117
118
            $categoryNode = $domXpath->query("//m:errorOrWarningSection/m:errorOrWarningInfo//m:type")->item(0);
119
            if ($categoryNode instanceof \DOMNode) {
120
                $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue);
121
            }
122
123
            $messageNodes = $domXpath->query('//m:errorOrWarningSection/m:textInformation/m:freeText');
124
            if ($messageNodes->length > 0) {
125
                $message = $this->makeMessageFromMessagesNodeList($messageNodes);
126
            }
127
            $analyzeResponse->messages [] = new Result\NotOk($codeNode->nodeValue, $message);
128
        }
129
130
        return $analyzeResponse;
131
    }
132
133
    protected function analyzeAirSellFromRecommendationResponse($response)
134
    {
135
        $analyzeResponse = new Result($response);
136
137
        $errMsgMap = [
138
            "288" => "UNABLE TO SATISFY, NEED CONFIRMED FLIGHT STATUS",
139
            "390" => "UNABLE TO REFORMAT"
140
        ];
141
142
        $domXpath = $this->makeDomXpath($response->responseXml);
143
144
        $codeNode = $domXpath->query("//m:errorSegment/m:errorDetails/m:errorCode")->item(0);
145
        if ($codeNode instanceof \DOMNode) {
146
            $analyzeResponse->status = Result::STATUS_ERROR;
147
148
            $categoryNode = $domXpath->query("//m:errorSegment/m:errorDetails/m:errorCategory")->item(0);
149
            if ($categoryNode instanceof \DOMNode) {
150
                $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue);
151
            }
152
153
            $message = (array_key_exists($codeNode->nodeValue, $errMsgMap)) ?
154
                $errMsgMap[$codeNode->nodeValue] : 'UNKNOWN ERROR';
155
156
            $analyzeResponse->messages [] = new Result\NotOk($codeNode->nodeValue, $message);
157
        }
158
159
        return $analyzeResponse;
160
    }
161
162
    /**
163
     * @param SendResult $response
164
     * @return Result
165
     */
166
    protected function analyzeAirFlightInfoResponse($response)
167
    {
168
        $analyzeResponse = new Result($response);
169
170
        $code = null;
171
        $message = null;
172
173
        $domXpath = $this->makeDomXpath($response->responseXml);
174
175
        $categoryNodes = $domXpath->query('//m:responseError/m:errorInfo/m:errorDetails/m:errorCategory');
176
        if ($categoryNodes->length > 0) {
177
            $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNodes->item(0)->nodeValue);
178
        }
179
180
        $codeNodes = $domXpath->query('//m:responseError/m:errorInfo/m:errorDetails/m:errorCode');
181
        if ($codeNodes->length > 0) {
182
            $code = $codeNodes->item(0)->nodeValue;
183
        }
184
185
        $messageNodes = $domXpath->query('//m:responseError/m:interactiveFreeText/m:freeText');
186
        if ($messageNodes->length > 0) {
187
            $message = $this->makeMessageFromMessagesNodeList($messageNodes);
188
        }
189
190
        if (!is_null($message) && !is_null($code)) {
191
            $analyzeResponse->messages[] = new Result\NotOk($code, $message);
192
        }
193
194
        return $analyzeResponse;
195
    }
196
197
    /**
198
     * @param SendResult $response
199
     * @return Result
200
     */
201
    protected function analyzeAirRetrieveSeatMapResponse($response)
202
    {
203
        $analyzeResponse = new Result($response);
204
205
        $domXpath = $this->makeDomXpath($response->responseXml);
206
207
        $errorCodeNode = $domXpath->query('//m:errorInformation/m:errorDetails/m:code');
208 View Code Duplication
        if ($errorCodeNode->length > 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
209
            $analyzeResponse->status = Result::STATUS_ERROR;
210
211
            $errCode = $errorCodeNode->item(0)->nodeValue;
212
            $level = null;
213
214
            $errorLevelNode = $domXpath->query('//m:errorInformation/m:errorDetails/m:processingLevel');
215
            if ($errorLevelNode->length > 0) {
216
                $level = RetrieveSeatMap::decodeProcessingLevel($errorLevelNode->item(0)->nodeValue);
217
            }
218
219
            $errorDescNode = $domXpath->query('//m:errorInformation/m:errorDetails/m:description');
220
            if ($errorDescNode->length > 0) {
221
                $errDesc = $errorDescNode->item(0)->nodeValue;
222
            } else {
223
                $errDesc = RetrieveSeatMap::findMessage($errCode);
224
            }
225
226
            $analyzeResponse->messages[] = new Result\NotOk(
227
                $errCode,
228
                $errDesc,
229
                $level
230
            );
231
        }
232
233
        $codeNode = $domXpath->query('//m:warningInformation/m:warningDetails/m:number');
234 View Code Duplication
        if ($codeNode->length > 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
235
            $analyzeResponse->status = Result::STATUS_WARN;
236
237
            $warnCode = $codeNode->item(0)->nodeValue;
238
            $level = null;
239
240
            $levelNode = $domXpath->query('//m:warningInformation/m:warningDetails/m:processingLevel');
241
            if ($levelNode->length > 0) {
242
                $level = RetrieveSeatMap::decodeProcessingLevel($levelNode->item(0)->nodeValue);
243
            }
244
245
            $descNode = $domXpath->query('//m:warningInformation/m:warningDetails/m:description');
246
            if ($descNode->length > 0) {
247
                $warnDesc = $descNode->item(0)->nodeValue;
248
            } else {
249
                $warnDesc = RetrieveSeatMap::findMessage($warnCode);
250
            }
251
252
            $analyzeResponse->messages[] = new Result\NotOk(
253
                $warnCode,
254
                $warnDesc,
255
                $level
256
            );
257
        }
258
259
        return $analyzeResponse;
260
    }
261
262
    /**
263
     * Analysing a PNR_Retrieve response
264
     *
265
     * @param SendResult $response PNR_Retrieve result
266
     * @return Result
267
     */
268
    protected function analyzePnrRetrieveResponse($response)
269
    {
270
        return $this->analyzePnrReply($response);
271
    }
272
273
    /**
274
     * @param SendResult $response PNR_AddMultiElements result
275
     * @return Result
276
     */
277
    protected function analyzePnrAddMultiElementsResponse($response)
278
    {
279
        return $this->analyzePnrReply($response);
280
    }
281
282
    /**
283
     * @param SendResult $response PNR_Cancel result
284
     * @return Result
285
     */
286
    protected function analyzePnrCancelResponse($response)
287
    {
288
        return $this->analyzePnrReply($response);
289
    }
290
291
    /**
292
     * @param SendResult $response Pnr_RetrieveAndDisplay response
293
     * @return Result
294
     * @throws Exception
295
     */
296
    protected function analyzePnrRetrieveAndDisplayResponse($response)
297
    {
298
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
299
    }
300
301
    /**
302
     * Analysing a PNR_TransferOwnershipReply
303
     *
304
     * @param SendResult $response PNR_TransferOwnership response
305
     * @return Result
306
     * @throws Exception
307
     */
308
    protected function analyzePNRTransferOwnershipResponse($response)
309
    {
310
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
311
    }
312
313
    /**
314
     * Analysing a PNR_DisplayHistoryReply
315
     *
316
     * @param SendResult $response PNR_DisplayHistoryReply result
317
     * @return Result
318
     * @throws Exception
319
     */
320
    protected function analyzePnrDisplayHistoryResponse($response)
321
    {
322
        $analyzeResponse = new Result($response);
323
324
        $domXpath = $this->makeDomXpath($response->responseXml);
325
326
        $queryAllErrorCodes = "//m:generalErrorGroup//m:errorNumber/m:errorDetails/m:errorCode";
327
        $queryAllErrorMsg = "//m:generalErrorGroup/m:genrealErrorText/m:freeText";
328
329
        $errorCodeNodeList = $domXpath->query($queryAllErrorCodes);
330
331 View Code Duplication
        if ($errorCodeNodeList->length > 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
332
            $analyzeResponse->status = Result::STATUS_ERROR;
333
334
            $code = $errorCodeNodeList->item(0)->nodeValue;
335
            $errorTextNodeList = $domXpath->query($queryAllErrorMsg);
336
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);
337
338
            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message));
339
        }
340
341
        return $analyzeResponse;
342
    }
343
344
    /**
345
     * @param SendResult $response Queue_RemoveItem response
346
     * @return Result
347
     * @throws Exception
348
     */
349
    protected function analyzeQueueRemoveItemResponse($response)
350
    {
351
        return $this->analyzeGenericQueueResponse($response);
352
    }
353
354
    /**
355
     * @param SendResult $response Queue_MoveItem response
356
     * @return Result
357
     * @throws Exception
358
     */
359
    protected function analyzeQueueMoveItemResponse($response)
360
    {
361
        return $this->analyzeGenericQueueResponse($response);
362
    }
363
364
    /**
365
     * @param SendResult $response Queue_PlacePNR response
366
     * @return Result
367
     * @throws Exception
368
     */
369
    protected function analyzeQueuePlacePNRResponse($response)
370
    {
371
        return $this->analyzeGenericQueueResponse($response);
372
    }
373
374
    /**
375
     * @param SendResult $response Queue_List result
376
     * @return Result
377
     * @throws Exception
378
     */
379
    protected function analyzeQueueListResponse($response)
380
    {
381
        return $this->analyzeGenericQueueResponse($response);
382
    }
383
384
    /**
385
     * Analyze a generic Queue response
386
     *
387
     * @param SendResult $response Queue_*Reply result
388
     * @return Result
389
     * @throws Exception
390
     */
391
    protected function analyzeGenericQueueResponse($response)
392
    {
393
        $analysisResponse = new Result($response);
394
395
        $domDoc = $this->loadDomDocument($response->responseXml);
396
397
        $errorCodeNode = $domDoc->getElementsByTagName("errorCode")->item(0);
398
399
        if (!is_null($errorCodeNode)) {
400
            $analysisResponse->status = Result::STATUS_WARN;
401
402
            $errorCode = $errorCodeNode->nodeValue;
403
            $errorMessage = $this->getErrorTextFromQueueErrorCode($errorCode);
404
405
            $analysisResponse->messages[] = new Result\NotOk($errorCode, $errorMessage);
406
        }
407
408
        return $analysisResponse;
409
    }
410
411
412
    /**
413
     * @param SendResult $response Fare_PricePNRWithBookingClass result
414
     * @return Result
415
     * @throws Exception
416
     */
417 View Code Duplication
    protected function analyzeFarePricePNRWithBookingClassResponse($response)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
418
    {
419
        $analyzeResponse = new Result($response);
420
421
        $domXpath = $this->makeDomXpath($response->responseXml);
422
423
        $queryErrorCode = "//m:applicationError//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode";
424
        $queryErrorCategory = "//m:applicationError//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCategory";
425
        $queryErrorMsg = "//m:applicationError/m:errorWarningDescription/m:freeText";
426
427
        $errorCodeNodeList = $domXpath->query($queryErrorCode);
428
429
        if ($errorCodeNodeList->length > 0) {
430
            $analyzeResponse->status = Result::STATUS_ERROR;
431
432
            $errorCatNode = $domXpath->query($queryErrorCategory)->item(0);
433
            if ($errorCatNode instanceof \DOMNode) {
434
                $analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue);
435
            }
436
437
            $analyzeResponse->messages[] = new Result\NotOk(
438
                $errorCodeNodeList->item(0)->nodeValue,
439
                $this->makeMessageFromMessagesNodeList(
440
                    $domXpath->query($queryErrorMsg)
441
                )
442
            );
443
        }
444
445
        return $analyzeResponse;
446
    }
447
448
    /**
449
     * @param SendResult $response Fare_PricePNRWithLowerFares result
450
     * @return Result
451
     * @throws Exception
452
     */
453
    protected function analyzeFarePricePNRWithLowerFaresResponse($response)
454
    {
455
        return $this->analyzeFarePricePNRWithBookingClassResponse($response);
456
    }
457
458
    /**
459
     * @param SendResult $response Fare_PricePNRWithLowestFare result
460
     * @return Result
461
     * @throws Exception
462
     */
463
    protected function analyzeFarePricePNRWithLowestFareResponse($response)
464
    {
465
        return $this->analyzeFarePricePNRWithBookingClassResponse($response);
466
    }
467
468
    /**
469
     * @param SendResult $response
470
     * @return Result
471
     */
472
    protected function analyzeFareMasterPricerCalendarResponse($response)
473
    {
474
        return $this->analyzeFareMasterPricerTravelBoardSearchResponse($response);
475
    }
476
477
    /**
478
     * @param SendResult $response
479
     * @return Result
480
     */
481
    protected function analyzeFareMasterPricerTravelBoardSearchResponse($response)
482
    {
483
        $analyzeResponse = new Result($response);
484
485
        $domXpath = $this->makeDomXpath($response->responseXml);
486
487
        $queryErrCode = "//m:applicationError//m:applicationErrorDetail/m:error";
488
        $queryErrMsg = "//m:errorMessageText/m:description";
489
490
        $codeNode = $domXpath->query($queryErrCode)->item(0);
491
492
        if ($codeNode instanceof \DOMNode) {
493
            $analyzeResponse->status = Result::STATUS_ERROR;
494
495
            $errMsg = '';
496
            $errMsgNode = $domXpath->query($queryErrMsg)->item(0);
497
            if ($errMsgNode instanceof \DOMNode) {
498
                $errMsg = $errMsgNode->nodeValue;
499
            }
500
501
            $analyzeResponse->messages[] = new Result\NotOk(
502
                $codeNode->nodeValue,
503
                $errMsg
504
            );
505
        }
506
507
        return $analyzeResponse;
508
    }
509
510
    /**
511
     * @param SendResult $response
512
     * @return Result
513
     */
514
    protected function analyzeFareConvertCurrencyResponse($response)
515
    {
516
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
517
    }
518
519
    /**
520
     * @param SendResult $response
521
     * @return Result
522
     */
523
    protected function analyzeFareCheckRulesResponse($response)
524
    {
525
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
526
    }
527
528
    /**
529
     * @param SendResult $response
530
     * @return Result
531
     */
532
    protected function analyzeFareInformativePricingWithoutPNRResponse($response)
533
    {
534
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
535
    }
536
537
    /**
538
     * @param SendResult $response
539
     * @return Result
540
     */
541
    protected function analyzeFareInformativeBestPricingWithoutPNRResponse($response)
542
    {
543
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
544
    }
545
546
    /**
547
     * @param SendResult $response
548
     * @return Result
549
     */
550
    protected function analyzeDocIssuanceIssueTicketResponse($response)
551
    {
552
        return $this->analyzeSimpleResponseErrorCodeAndMessageStatusCode($response);
553
    }
554
555
    /**
556
     * @param SendResult $response Ticket_DeleteTST result
557
     * @return Result
558
     */
559
    protected function analyzeTicketDisplayTSTResponse($response)
560
    {
561
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
562
    }
563
564
    /**
565
     * @param SendResult $response Ticket_DeleteTST result
566
     * @return Result
567
     */
568
    protected function analyzeTicketDeleteTSTResponse($response)
569
    {
570
        return $this->analyzeTicketCreateTSTFromPricingResponse($response);
571
    }
572
573
    /**
574
     * @param SendResult $response Ticket_CreateTSTFromPricing result
575
     * @return Result
576
     */
577 View Code Duplication
    protected function analyzeTicketCreateTSTFromPricingResponse($response)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
578
    {
579
        $analyzeResponse = new Result($response);
580
581
        $domDoc = $this->loadDomDocument($response->responseXml);
582
583
        $errorCodeNode = $domDoc->getElementsByTagName("applicationErrorCode")->item(0);
584
585
        if (!is_null($errorCodeNode)) {
586
            $analyzeResponse->status = Result::STATUS_ERROR;
587
588
            $errorCatNode = $domDoc->getElementsByTagName("codeListQualifier")->item(0);
589
            if ($errorCatNode instanceof \DOMNode) {
590
                $analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue);
591
            }
592
593
            $errorCode = $errorCodeNode->nodeValue;
594
            $errorTextNodeList = $domDoc->getElementsByTagName("errorFreeText");
595
596
            $analyzeResponse->messages[] = new Result\NotOk(
597
                $errorCode,
598
                $this->makeMessageFromMessagesNodeList($errorTextNodeList)
599
            );
600
        }
601
602
        return $analyzeResponse;
603
    }
604
605
    /**
606
     * @param SendResult $response Ticket_CreateTSMFromPricing result
607
     * @return Result
608
     */
609
    protected function analyzeTicketCreateTSMFromPricingResponse($response)
610
    {
611
        return $this->analyzeTicketCreateTSTFromPricingResponse($response);
612
    }
613
614
    /**
615
     * @param SendResult $response
616
     * @return Result
617
     */
618
    protected function analyzeOfferConfirmCarOfferResponse($response)
619
    {
620
        return $this->analyzeGenericOfferResponse($response);
621
    }
622
623
    /**
624
     * @param SendResult $response
625
     * @return Result
626
     */
627
    protected function analyzeOfferConfirmHotelOfferResponse($response)
628
    {
629
        $analyzeResponse = new Result($response);
630
631
        $domXpath = $this->makeDomXpath($response->responseXml);
632
633
        $codeNode = $domXpath->query("//m:errorDetails/m:errorCode")->item(0);
634
        if ($codeNode instanceof \DOMNode) {
635
            $analyzeResponse->status = Result::STATUS_ERROR;
636
637
            $categoryNode = $domXpath->query("//m:errorDetails/m:errorCategory")->item(0);
638
            if ($categoryNode instanceof \DOMNode) {
639
                $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue);
640
            }
641
642
            $msgNode = $domXpath->query('//m:errorDescription/m:freeText')->item(0);
643
644
            $analyzeResponse->messages[] = new Result\NotOk(
645
                $codeNode->nodeValue,
646
                trim($msgNode->nodeValue)
647
            );
648
        }
649
650
        return $analyzeResponse;
651
    }
652
653
    /**
654
     * Offer_ConfirmAirOffer
655
     *
656
     * @param SendResult $response
657
     * @return Result
658
     */
659
    protected function analyzeOfferConfirmAirOfferResponse($response)
660
    {
661
        return $this->analyzeGenericOfferResponse($response);
662
    }
663
664
    /**
665
     * Offer_VerifyOffer
666
     *
667
     * @param SendResult $response
668
     * @return Result
669
     */
670
    protected function analyzeOfferVerifyOfferResponse($response)
671
    {
672
        return $this->analyzeGenericOfferResponse($response);
673
    }
674
675
    /**
676
     * Offer_CreateOffer
677
     *
678
     * @param SendResult $response
679
     * @return Result
680
     */
681
    protected function analyzeOfferCreateOfferResponse($response)
682
    {
683
        return $this->analyzeGenericOfferResponse($response);
684
    }
685
686
    /**
687
     * @param SendResult $response
688
     * @return Result
689
     */
690
    protected function analyzeMiniRuleGetFromPricingRecResponse($response)
691
    {
692
        $analyzeResponse = new Result($response);
693
694
        $domXpath = $this->makeDomXpath($response->responseXml);
695
696
        $statusNode = $domXpath->query('//m:responseDetails/m:statusCode')->item(0);
697
        if ($statusNode instanceof \DOMNode) {
698
            $code = $statusNode->nodeValue;
699
700
            if ($code !== 'O') {
701
                $categoryNode = $domXpath->query(
702
                    '//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCategory'
703
                )->item(0);
704
                $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue);
705
706
                $codeNode = $domXpath->query('//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode')->item(0);
707
                $msgNode = $domXpath->query('//m:errorWarningDescription/m:freeText')->item(0);
708
709
                if ($codeNode instanceof \DOMNode && $msgNode instanceof \DOMNode) {
710
                    $analyzeResponse->messages[] = new Result\NotOk(
711
                        $codeNode->nodeValue,
712
                        $msgNode->nodeValue
713
                    );
714
                }
715
            }
716
        }
717
718
        return $analyzeResponse;
719
    }
720
721
    /**
722
     * @param SendResult $response
723
     * @return Result
724
     */
725
    protected function analyzeMiniRuleGetFromPricingResponse($response)
726
    {
727
        return $this->analyzeMiniRuleGetFromPricingRecResponse($response);
728
    }
729
730
    /**
731
     * @param SendResult $response
732
     * @return Result
733
     */
734
    protected function analyzeInfoEncodeDecodeCityResponse($response)
735
    {
736
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
737
    }
738
739
    /**
740
     * @param SendResult $response
741
     * @return Result
742
     */
743
    protected function analyzePriceXplorerExtremeSearchResponse($response)
744
    {
745
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
746
    }
747
748
    /**
749
     * @param SendResult $response
750
     * @return Result
751
     */
752
    protected function analyzeSalesReportsDisplayQueryReportResponse($response)
753
    {
754
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
755
    }
756
757
    /**
758
     * @param SendResult $response
759
     * @return Result
760
     */
761
    protected function analyzeServiceIntegratedPricingResponse($response)
762
    {
763
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
764
    }
765
}
766