| @@ 36-68 (lines=33) @@ | ||
| 33 | * @package Amadeus\Client\ResponseHandler\Air |
|
| 34 | * @author Dieter Devlieghere <[email protected]> |
|
| 35 | */ |
|
| 36 | class HandlerMultiAvailability extends StandardResponseHandler |
|
| 37 | { |
|
| 38 | /** |
|
| 39 | * @param SendResult $response |
|
| 40 | * @return Result |
|
| 41 | */ |
|
| 42 | public function analyze(SendResult $response) |
|
| 43 | { |
|
| 44 | $analyzeResponse = new Result($response); |
|
| 45 | ||
| 46 | $message = null; |
|
| 47 | ||
| 48 | $domXpath = $this->makeDomXpath($response->responseXml); |
|
| 49 | ||
| 50 | $codeNode = $domXpath->query("//m:errorOrWarningSection/m:errorOrWarningInfo//m:code")->item(0); |
|
| 51 | if ($codeNode instanceof \DOMNode) { |
|
| 52 | $analyzeResponse->status = Result::STATUS_ERROR; |
|
| 53 | ||
| 54 | $categoryNode = $domXpath->query("//m:errorOrWarningSection/m:errorOrWarningInfo//m:type")->item(0); |
|
| 55 | if ($categoryNode instanceof \DOMNode) { |
|
| 56 | $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue); |
|
| 57 | } |
|
| 58 | ||
| 59 | $messageNodes = $domXpath->query('//m:errorOrWarningSection/m:textInformation/m:freeText'); |
|
| 60 | if ($messageNodes->length > 0) { |
|
| 61 | $message = $this->makeMessageFromMessagesNodeList($messageNodes); |
|
| 62 | } |
|
| 63 | $analyzeResponse->messages [] = new Result\NotOk($codeNode->nodeValue, $message); |
|
| 64 | } |
|
| 65 | ||
| 66 | return $analyzeResponse; |
|
| 67 | } |
|
| 68 | } |
|
| 69 | ||
| @@ 35-71 (lines=37) @@ | ||
| 32 | * @package Amadeus\Client\ResponseHandler\Fare |
|
| 33 | * @author Dieter Devlieghere <[email protected]> |
|
| 34 | */ |
|
| 35 | class HandlerPricePNRWithBookingClass extends StandardResponseHandler |
|
| 36 | { |
|
| 37 | /** |
|
| 38 | * @param SendResult $response |
|
| 39 | * @return Result |
|
| 40 | */ |
|
| 41 | public function analyze(SendResult $response) |
|
| 42 | { |
|
| 43 | $analyzeResponse = new Result($response); |
|
| 44 | ||
| 45 | $domXpath = $this->makeDomXpath($response->responseXml); |
|
| 46 | ||
| 47 | $queryErrorCode = "//m:applicationError//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode"; |
|
| 48 | $queryErrorCategory = "//m:applicationError//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCategory"; |
|
| 49 | $queryErrorMsg = "//m:applicationError/m:errorWarningDescription/m:freeText"; |
|
| 50 | ||
| 51 | $errorCodeNodeList = $domXpath->query($queryErrorCode); |
|
| 52 | ||
| 53 | if ($errorCodeNodeList->length > 0) { |
|
| 54 | $analyzeResponse->status = Result::STATUS_ERROR; |
|
| 55 | ||
| 56 | $errorCatNode = $domXpath->query($queryErrorCategory)->item(0); |
|
| 57 | if ($errorCatNode instanceof \DOMNode) { |
|
| 58 | $analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue); |
|
| 59 | } |
|
| 60 | ||
| 61 | $analyzeResponse->messages[] = new Result\NotOk( |
|
| 62 | $errorCodeNodeList->item(0)->nodeValue, |
|
| 63 | $this->makeMessageFromMessagesNodeList( |
|
| 64 | $domXpath->query($queryErrorMsg) |
|
| 65 | ) |
|
| 66 | ); |
|
| 67 | } |
|
| 68 | ||
| 69 | return $analyzeResponse; |
|
| 70 | } |
|
| 71 | } |
|
| 72 | ||