From 4f4e529650d850c61bd5ec69f5931c5b5df3122a Mon Sep 17 00:00:00 2001 From: dieter Date: Tue, 21 Mar 2017 16:05:23 +0100 Subject: [PATCH] Support for PNR_Reply 14.1 and older General error format (fixes #51) --- .../ResponseHandler/PNR/HandlerRetrieve.php | 16 +- .../Client/ResponseHandler/BaseTest.php | 16 + ...ddMultiElements14_1_need_received_from.txt | 844 ++++++++++++++++++ .../Struct/Pnr/AddMultiElementsTest.php | 83 ++ 4 files changed, 958 insertions(+), 1 deletion(-) create mode 100644 tests/Amadeus/Client/ResponseHandler/testfiles/pnrAddMultiElements14_1_need_received_from.txt diff --git a/src/Amadeus/Client/ResponseHandler/PNR/HandlerRetrieve.php b/src/Amadeus/Client/ResponseHandler/PNR/HandlerRetrieve.php index d557307b3..22eee91aa 100644 --- a/src/Amadeus/Client/ResponseHandler/PNR/HandlerRetrieve.php +++ b/src/Amadeus/Client/ResponseHandler/PNR/HandlerRetrieve.php @@ -22,7 +22,6 @@ namespace Amadeus\Client\ResponseHandler\PNR; -use Amadeus\Client\Exception; use Amadeus\Client\ResponseHandler\StandardResponseHandler; use Amadeus\Client\Result; use Amadeus\Client\Session\Handler\SendResult; @@ -37,6 +36,8 @@ class HandlerRetrieve extends StandardResponseHandler { const Q_G_ERR = "//m:generalErrorInfo//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode"; const Q_G_MSG = "//m:generalErrorInfo/m:errorWarningDescription/m:freeText"; + const Q_G_OLD_ERR = "//m:generalErrorInfo//m:messageErrorInformation/m:errorDetail/m:errorCode"; + const Q_G_OLD_MSG = "//m:generalErrorInfo/m:messageErrorText/m:text"; const Q_S_ERR = "//m:originDestinationDetails//m:errorInfo/m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode"; const Q_S_MSG = "//m:originDestinationDetails//m:errorInfo/m:errorWarningDescription/m:freeText"; const Q_E_ERR = "//m:dataElementsIndiv/m:elementErrorInformation/m:errorOrWarningCodeDetails//m:errorCode"; @@ -67,6 +68,19 @@ public function analyze(SendResult $response) $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'general'); } + //General Errors - PNR_Reply v 14.1 and below: + $errorCodeNodeList = $domXpath->query(self::Q_G_OLD_ERR); + + if ($errorCodeNodeList->length > 0) { + $analyzeResponse->status = Result::STATUS_ERROR; + + $code = $errorCodeNodeList->item(0)->nodeValue; + $errorTextNodeList = $domXpath->query(self::Q_G_OLD_MSG); + $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList); + + $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'general'); + } + //Segment errors: $errorCodeNodeList = $domXpath->query(self::Q_S_ERR); diff --git a/tests/Amadeus/Client/ResponseHandler/BaseTest.php b/tests/Amadeus/Client/ResponseHandler/BaseTest.php index a62bbe27e..1f513af88 100644 --- a/tests/Amadeus/Client/ResponseHandler/BaseTest.php +++ b/tests/Amadeus/Client/ResponseHandler/BaseTest.php @@ -51,6 +51,22 @@ public function testCanFindSimultaneousChangesErrorMessageInPnrReply() $this->assertEquals('general', $result->messages[0]->level); } + public function testCanHandleIssue50ErrorMessageInPnrReply() + { + $respHandler = new ResponseHandler\Base(); + + $sendResult = new SendResult(); + $sendResult->responseXml = $this->getTestFile('pnrAddMultiElements14_1_need_received_from.txt'); + + $result = $respHandler->analyzeResponse($sendResult, 'PNR_AddMultiElements'); + + $this->assertEquals(Result::STATUS_ERROR, $result->status); + $this->assertCount(1, $result->messages); + $this->assertEquals('8111', $result->messages[0]->code); + $this->assertEquals("ERROR AT END OF TRANSACTION TIME - ERROR AT EOT TIME - NEED RECEIVED FROM", $result->messages[0]->text); + $this->assertEquals('general', $result->messages[0]->level); + } + public function testCanFindTopLevelErrorMessageInPnrReply() { $respHandler = new ResponseHandler\Base(); diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/pnrAddMultiElements14_1_need_received_from.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/pnrAddMultiElements14_1_need_received_from.txt new file mode 100644 index 000000000..0452516f6 --- /dev/null +++ b/tests/Amadeus/Client/ResponseHandler/testfiles/pnrAddMultiElements14_1_need_received_from.txt @@ -0,0 +1,844 @@ + + + + + + 1A + 2ZIW6R + 210317 + + + + + + + RP + PIRC + XXXXXXX + XXXXXXX + + + XXXXXXX + + MLE + + XXXXXXX + 9999WS + 210317 + XXXXXXX + 1345 + + + + + + 8111 + EC + 1A + + + + + 3 + + ERROR AT END OF TRANSACTION TIME + ERROR AT EOT TIME + NEED RECEIVED FROM + + + + + 3 + P12 + + --- TST RLR --- + + + + TST + + + RLR + + + + + + XXXXXXX + XXXXXXX + + T + + + + 1A + MLE + + + + + MV + + + + + + + XXXXXXX + XXXXXXX + + T + + + + 1A + MLE + + + + + MV + + + + + + + DOHQR01CC + + A + + + + QR + DOH + + + + + QA + + + + + + + 2 + + + + 1 + + + + 2017 + 4 + 25 + + + + + MOD + + + + + + + PT + 2 + + NM + 1 + + + + + DOE + 1 + + + JOHN + ADT + + + + + 706 + 01011985 + + + + + + + 1 + ADT + + + UN + Y + Y + DOE + JOHN + + + + + 706 + 01011985 + + + + + + + + + + ST + 1 + + AIR + 2 + + + + 230417 + 1015 + 230417 + 1245 + + + MLE + + + DOH + + + QR + + + 673 + M + + + ET + + + + + 1 + + + + + QR + 2ZIW6R + + + + 1 + HK + + + + 332 + 0 + 0430 + 7 + + + 2052 + M + + + M + M + + + + + M + + + + + + + + + + + + 230417 + 1015 + 230417 + 1245 + + + MLE + + + DOH + + + + + ACO + + AIRCRAFT OWNER QATAR AIRWAYS + + + + + + + + ST + 2 + + AIR + 3 + + + + 250417 + 0215 + 250417 + 0900 + + + DOH + + + MLE + + + QR + + + 672 + M + + + ET + + + + + 1 + + + + + QR + 2ZIW6R + + + + 1 + HK + + + + 333 + 0 + 0445 + 2 + + + 2052 + M + + + M + M + + + + + M + + + + + + + + + + + + 250417 + 0215 + 250417 + 0900 + + + DOH + + + MLE + + + + + ACO + + AIRCRAFT OWNER QATAR AIRWAYS + + + + + + + + + + + OT + 4 + + AP + 4 + + + + 3 + P02 + + JOHN@DOE.COM + + + + + + OT + 3 + + AP + 5 + + + + 3 + 7 + + 777111122 + + + + + + OT + 7 + + TK + 6 + + + PAX + + OK + 210317 + XXXXXXX + + + + + + + OT + 21 + + SSR + 7 + + + + OTHS + + 1A + PLS TICKET BY 2359/28MAR2017 LCLT AT BOARD POINT OR QR WILL CXL + + + + + + + OT + 22 + + SSR + 8 + + + + OTHS + + 1A + TKNA/TKNM/FA PT/FH TKT ENTRY PROHIBITED FOR BSP/ARC/EDIRECT MRKT + + + + + + + OT + 23 + + SSR + 9 + + + + OTHS + + 1A + TICKETING DEADLINE IN FARE RULE MUST BE OBSERVED IF MORE RESTRICTIVE + + + + + + + OT + 24 + + SSR + 10 + + + + OTHS + + 1A + - PLS PROVIDE FULL SECURE FLIGHT DATA / + + + + + + + OT + 25 + + SSR + 11 + + + + OTHS + + 1A + APIS IN DOCA/DOCO/DOCS AND ACTION URGENTLY. + + + + + + + OT + 26 + + SSR + 12 + + + + OTHS + + 1A + FOR USA FLTS QR RESERVES THE RIGHT TO CANCEL + + + + + + + OT + 27 + + SSR + 13 + + + + DOCS + HK + 1 + QR + P/MDV/012345678/MDV/20APR85/M/20APR22/DOE/JOHN + + + + + PT + 2 + + + + + + + OT + 19 + + RC + 14 + + + + RC + RESTRICTED + + + + + RC + RESTRICTED + + + + + + + OT + 20 + + RC + 15 + + + + RC + RESTRICTED + + + + + RC + RESTRICTED + + + + + + + OT + 8 + + FE + 16 + + + + 3 + 10 + + PAX /C1-2 NON END/CHNG PENALTIES AS PER RULE + + + + ST + 1 + + + ST + 2 + + + PT + 2 + + + + + + + OT + 5 + + FM + 17 + + + + 3 + 11 + + PAX *M*7 + + + + + + OT + 6 + + FP + 18 + + + + 3 + 16 + + CASH + + + + + + OT + 9 + + FV + 19 + + + + 3 + P18 + + PAX QR + + + + ST + 1 + + + ST + 2 + + + PT + 2 + + + + + + + + 1 + 210317 + + + + + 3 + 41 + + PAX + + + + 3 + 37 + + MLE QR DOH476.00QR MLE476.00NUC952.00END ROE1.000000 + + + + MJR + 230417 + 30K + 4R1SE + + + MJR + O + 230417 + 30K + 4R1SE + + + + F + + F + 952.00 + USD + + + T + 1239.72 + USD + + + X + USD + 234.00 + YQ + AC + + + X + USD + 4.00 + YR + VB + + + X + USD + 25.00 + BQ + DP + + + X + USD + 9.62 + G4 + AF + + + X + USD + 2.05 + PZ + SE + + + X + USD + 2.05 + PZ + AV + + + X + USD + 11.00 + QA + AP + + + + + + + + + + + + + PT + 2 + + + ST + 1 + + + ST + 2 + + + + diff --git a/tests/Amadeus/Client/Struct/Pnr/AddMultiElementsTest.php b/tests/Amadeus/Client/Struct/Pnr/AddMultiElementsTest.php index edc1ba67a..9e13d2bef 100644 --- a/tests/Amadeus/Client/Struct/Pnr/AddMultiElementsTest.php +++ b/tests/Amadeus/Client/Struct/Pnr/AddMultiElementsTest.php @@ -1499,5 +1499,88 @@ public function testCanCreateItineraryWithArnk() $this->assertEquals(1, $msg->originDestinationDetails[2]->itineraryInfo[0]->airAuxItinerary->relatedProduct->quantity); $this->assertEquals(AddMultiElements\RelatedProduct::STATUS_NEED_SEGMENT, $msg->originDestinationDetails[2]->itineraryInfo[0]->airAuxItinerary->relatedProduct->status); } + + public function testCanMakePnrWithMultiPaxElementAssoc() + { + $createPnrOptions = new PnrAddMultiElementsOptions([ + 'receivedFrom' => 'unittest', + 'travellers' => [ + new Traveller([ + 'number' => 1, + 'lastName' => 'Bowie', + 'firstName' => 'David' + ]), + new Traveller([ + 'number' => 2, + 'lastName' => 'Bowie', + 'firstName' => 'David2' + ]) + ], + 'actionCode' => PnrCreatePnrOptions::ACTION_END_TRANSACT_RETRIEVE, + 'itineraries' => [ + new Itinerary([ + 'origin' => 'BRU', + 'destination' => 'LIS', + 'segments' => [ + new Air([ + 'date' => \DateTime::createFromFormat('Y-m-d His', "2008-06-10 000000", new \DateTimeZone('UTC')), + 'origin' => 'BRU', + 'destination' => 'LIS', + 'flightNumber' => '349', + 'bookingClass' => 'Y', + 'company' => 'TP' + ]) + ] + ]) + ], + 'elements' => [ + new Ticketing([ + 'ticketMode' => Ticketing::TICKETMODE_OK + ]), + new Contact([ + 'type' => Contact::TYPE_PHONE_GENERAL, + 'value' => '+3223456789', + 'references' => [ + new Reference([ + 'type' => Reference::TYPE_PASSENGER_REQUEST, + 'id' => 1 + ]), + new Reference([ + 'type' => Reference::TYPE_PASSENGER_REQUEST, + 'id' => 2 + ]), + ] + ]) + ] + ]); + + $msg = new AddMultiElements($createPnrOptions); + + $this->assertCount(3, $msg->dataElementsMaster->dataElementsIndiv); + $this->assertEquals(AddMultiElements\ElementManagementData::SEGNAME_TICKETING_ELEMENT, $msg->dataElementsMaster->dataElementsIndiv[0]->elementManagementData->segmentName); + $this->assertEquals('OT', $msg->dataElementsMaster->dataElementsIndiv[0]->elementManagementData->reference->qualifier); + $this->assertEquals(2, $msg->dataElementsMaster->dataElementsIndiv[0]->elementManagementData->reference->number); + $this->assertEquals('OK', $msg->dataElementsMaster->dataElementsIndiv[0]->ticketElement->ticket->indicator); + $this->assertNull($msg->dataElementsMaster->dataElementsIndiv[0]->ticketElement->ticket->date); + $this->assertNull($msg->dataElementsMaster->dataElementsIndiv[0]->ticketElement->ticket->time); + $this->assertNull($msg->dataElementsMaster->dataElementsIndiv[0]->ticketElement->ticket->officeId); + $this->assertNull($msg->dataElementsMaster->dataElementsIndiv[0]->ticketElement->ticket->freetext); + $this->assertNull($msg->dataElementsMaster->dataElementsIndiv[0]->ticketElement->ticket->airlineCode); + $this->assertNull($msg->dataElementsMaster->dataElementsIndiv[0]->ticketElement->ticket->queueCategory); + $this->assertNull($msg->dataElementsMaster->dataElementsIndiv[0]->ticketElement->ticket->queueNumber); + $this->assertEmpty($msg->dataElementsMaster->dataElementsIndiv[0]->ticketElement->ticket->sitaAddress); + $this->assertEquals(AddMultiElements\TicketElement::PASSTYPE_PAX, $msg->dataElementsMaster->dataElementsIndiv[0]->ticketElement->passengerType); + $this->assertNull($msg->dataElementsMaster->dataElementsIndiv[0]->ticketElement->printOptions); + + $this->assertEquals(AddMultiElements\ElementManagementData::SEGNAME_CONTACT_ELEMENT, $msg->dataElementsMaster->dataElementsIndiv[1]->elementManagementData->segmentName); + $this->assertEquals('OT', $msg->dataElementsMaster->dataElementsIndiv[1]->elementManagementData->reference->qualifier); + $this->assertEquals(3, $msg->dataElementsMaster->dataElementsIndiv[1]->elementManagementData->reference->number); + $this->assertCount(2, $msg->dataElementsMaster->dataElementsIndiv[1]->referenceForDataElement->reference); + $this->assertEquals(1, $msg->dataElementsMaster->dataElementsIndiv[1]->referenceForDataElement->reference[0]->number); + $this->assertEquals(AddMultiElements\Reference::QUAL_PASSENGER, $msg->dataElementsMaster->dataElementsIndiv[1]->referenceForDataElement->reference[0]->qualifier); + $this->assertEquals(2, $msg->dataElementsMaster->dataElementsIndiv[1]->referenceForDataElement->reference[1]->number); + $this->assertEquals(AddMultiElements\Reference::QUAL_PASSENGER, $msg->dataElementsMaster->dataElementsIndiv[1]->referenceForDataElement->reference[1]->qualifier); + + } }