diff --git a/CHANGELOG.md b/CHANGELOG.md index 5084e793a..cf6126670 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## Unreleased +* Implemented `MiniRule_GetFromRec` (Amadeus docs emphasize to use `MiniRule_GetFromRec` instead of `MiniRule_GetFromETicket`, `MiniRule_GetFromPricing`, `MiniRule_GetFromPricingRec`) - Aleksandr Kalugin + ## Release 1.11.0 (9 July 2020) https://github.com/amabnl/amadeus-ws-client/pull/344: * Added support to add accountNumber in ``Queue_List`` diff --git a/docs/list-of-supported-messages.rst b/docs/list-of-supported-messages.rst index 2a9f27db2..c39d7e79e 100644 --- a/docs/list-of-supported-messages.rst +++ b/docs/list-of-supported-messages.rst @@ -76,6 +76,7 @@ This is the list of messages that are at least partially supported at this time: - Offer_ConfirmAirOffer - Offer_ConfirmHotelOffer - Offer_ConfirmCarOffer +- MiniRule_GetFromRec - MiniRule_GetFromPricingRec - MiniRule_GetFromPricing - MiniRule_GetFromETicket diff --git a/docs/samples.rst b/docs/samples.rst index cb66ce934..200b215a6 100644 --- a/docs/samples.rst +++ b/docs/samples.rst @@ -3812,10 +3812,63 @@ Confirm a given CAR offer: ******** MiniRule ******** +-------------------------- +MiniRule_GetFromRec +-------------------------- +Mini Rules provides a short and easy to read summary of the most important rules and restrictions in a structured output so that they can be clearly understood by end-users and customers. This service is used to retrieve the Mini Rules data from: - PNR Record Locator - Offer Notice - Offer ID - TST (Transitional Stored Ticket) - PQR (Quotation Record for Amadeus Offer). - Pricing context - Upsell Context - TKT (eTicket) - Cart (Shopping cart) + +MiniRules_GetFromRec function provides possibility to retrieve those mini-rules + + - from an e-ticket + - from a PNR (with possible passengers and segments selection ) + - from a list of TST returned by pricing/re-pricing + - from all TSTs returned by pricing/re-pricing + - from a list of PQRs + - from all PQR + - from all PQR associated to a list of air Offer + - from all PQR associated to all air Offer + - from a list of fare recommendation returned by pricing/re-pricing + - from all fare recommendations returned by pricing/re-pricing + - from a list of upsell returned by upsell transaction + - from all upsell returned by upsell transaction + + +Get MiniRules for specific PNR, and specific passenger + +.. code-block:: php + + use Amadeus\Client\RequestOptions\MiniRuleGetFromRecOptions; + use Amadeus\Client\RequestOptions\MiniRule\Pricing; + + $miniRulesResponse = $client->miniRuleGetFromRec( + new MiniRuleGetFromRecOptions([ + // mandatory + 'pricing' => new Pricing([ + 'id' => "RECLOCNUM123", + 'type' => Pricing::TYPE_RECORD_LOCATOR + ]), + // optional + 'language' => new Language([ + 'qualifier' => Language::LQ_LANGUAGE_NORMALLY_USED, + 'code' => "UA" + ]), + 'filteringOptions' => [ + new FilteringOption([ + 'type' => FilteringOption::TYPE_PAX, + 'value' => 1 + ]) + ] + ]) + ); + + -------------------------- MiniRule_GetFromPricingRec -------------------------- +*This web service will not profit of latest Mini Rules enhancements. +Please use MiniRule_GetFromRec (TMRXRQ) instead.* + Get MiniRules for a pricing in context (either a TST pricing, Offers or a pricing quotation): .. code-block:: php @@ -3838,6 +3891,9 @@ Get MiniRules for a pricing in context (either a TST pricing, Offers or a pricin MiniRule_GetFromPricing ----------------------- +*This web service will not profit of latest Mini Rules enhancements. +Please use MiniRule_GetFromRec (TMRXRQ) instead.* + Get MiniRules for a pricing in context *(After a Fare_PricePNRWithBookingClass, Fare_PricePNRWithLowerFares, FarePricePNRWithLowestFare, Fare_InformativePricingWithoutPNR or Fare_InformativeBestPricingWithoutPNR message)*: Get Minirules for all pricings returned: @@ -3867,6 +3923,9 @@ Get Minirules for specific recommendations *(recommendations nr 1 & 2 in this ex MiniRule_GetFromETicket ----------------------- +*This web service will not profit of latest Mini Rules enhancements. +Please use MiniRule_GetFromRec (TMRXRQ) instead.* + Display Mini Rules corresponding to the e-ticket number 1234567891987: .. code-block:: php diff --git a/src/Amadeus/Client.php b/src/Amadeus/Client.php index d90fb2e24..0e0ab1dd8 100644 --- a/src/Amadeus/Client.php +++ b/src/Amadeus/Client.php @@ -918,6 +918,23 @@ public function commandCryptic(RequestOptions\CommandCrypticOptions $options, $m return $this->callMessage($msgName, $options, $messageOptions); } + /** + * MiniRule_GetFromRec + * + * @param RequestOptions\MiniRuleGetFromRecOptions $options + * @param array $messageOptions (OPTIONAL) + * @return Result + * @throws Client\InvalidMessageException + * @throws Client\RequestCreator\MessageVersionUnsupportedException + * @throws Exception + */ + public function miniRuleGetFromRec(RequestOptions\MiniRuleGetFromRecOptions $options, $messageOptions = []) + { + $msgName = 'MiniRule_GetFromRec'; + + return $this->callMessage($msgName, $options, $messageOptions); + } + /** * MiniRule_GetFromPricingRec * diff --git a/src/Amadeus/Client/RequestCreator/Converter/MiniRule/GetFromRecConv.php b/src/Amadeus/Client/RequestCreator/Converter/MiniRule/GetFromRecConv.php new file mode 100644 index 000000000..292c5fb0e --- /dev/null +++ b/src/Amadeus/Client/RequestCreator/Converter/MiniRule/GetFromRecConv.php @@ -0,0 +1,46 @@ + + */ +class GetFromRecConv extends BaseConverter +{ + /** + * @param MiniRuleGetFromRecOptions $requestOptions + * @param int|string $version + * @return Struct\MiniRule\GetFromRec + */ + public function convert($requestOptions, $version) + { + return new Struct\MiniRule\GetFromRec($requestOptions); + } +} diff --git a/src/Amadeus/Client/RequestOptions/MiniRule/FilteringOption.php b/src/Amadeus/Client/RequestOptions/MiniRule/FilteringOption.php new file mode 100644 index 000000000..841228dd2 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/MiniRule/FilteringOption.php @@ -0,0 +1,55 @@ + + */ +class FilteringOption extends LoadParamsFromArray +{ + const TYPE_PAX = 'P'; + + const TYPE_ADULT_PASSENGER = "PA"; + + const TYPE_INFANT_PASSENGER = "PI"; + + const TYPE_SEGMENT = 'S'; + + /** + * self::TYPE_* + * + * @var string + */ + public $type; + + /** + * @var string|int + */ + public $value; +} diff --git a/src/Amadeus/Client/RequestOptions/MiniRule/Language.php b/src/Amadeus/Client/RequestOptions/MiniRule/Language.php new file mode 100644 index 000000000..bc4ce0738 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/MiniRule/Language.php @@ -0,0 +1,55 @@ + + */ +class Language extends LoadParamsFromArray +{ + const LQ_LANGUAGE_NORMALLY_USED = 1; + const LQ_LANGUAGE_UNDERSTOOD = 2; + const LQ_SPOKEN_LANGUAGE = 3; + const LQ_WRITTEN_LANGUAGE = 4; + const LQ_READ_LANGUAGE = 5; + const LQ_FOR_ALL_TYPES_OF_COMMUNICATION = 6; + const LQ_NATIVE_LANGUAGE = 7; + + /** + * self::LQ_* + * + * @var int + */ + public $qualifier = self::LQ_LANGUAGE_NORMALLY_USED; + + /** + * a two letters code (for example EN) + * + * @var string + */ + public $code = "EN"; +} diff --git a/src/Amadeus/Client/RequestOptions/MiniRule/Pricing.php b/src/Amadeus/Client/RequestOptions/MiniRule/Pricing.php index d309b49cd..42159442c 100644 --- a/src/Amadeus/Client/RequestOptions/MiniRule/Pricing.php +++ b/src/Amadeus/Client/RequestOptions/MiniRule/Pricing.php @@ -47,27 +47,50 @@ class Pricing extends LoadParamsFromArray /** * Transitional Stored Ticket * - * Only to be used with MiniRule_GetFromPricingRec + * Only to be used with MiniRule_GetFromPricingRec, MiniRule_GetFromRec */ const TYPE_TST = "TST"; + /** + * Ticket Number + * + * Only to be used with MiniRule_GetFromRec + */ + const TYPE_TKT = "TKT"; + + /** + * Record Locator + * + * Only to be used with MiniRule_GetFromRec + */ + const TYPE_RECORD_LOCATOR = "PNR"; + /** * Product Quotation Record Reference * - * Only to be used with MiniRule_GetFromPricingRec + * Only to be used with MiniRule_GetFromPricingRec, MiniRule_GetFromRec */ const TYPE_PROD_QUOTATION = "PQR"; /** * Fare Recommendation Number * - * Only to be used with MiniRule_GetFromPricing + * Only to be used with MiniRule_GetFromPricing, MiniRule_GetFromRec */ const TYPE_FARE_RECOMMENDATION_NUMBER = "FRN"; + /** + * Fare Upsell reco. Number + * + * Only to be used with MiniRule_GetFromRec + */ + const TYPE_FARE_UPSELL_RECOMMENDATION_NUMBER = "FUN"; + /** * self::ALL_PRICINGS to indicate ALL or a number indicating a specific pricing * + * Contains TST tatoo, ticket number, PNR recloc, fare recommendation, PQR Offer Id, fare upsell recommendation or the keyword 'ALL', when used with MiniRule_GetFromRec + * * @var int|string */ public $id; @@ -75,7 +98,7 @@ class Pricing extends LoadParamsFromArray /** * self::TYPE_* * - * Only necessary for MiniRule_GetFromPricingRec: + * Only necessary for MiniRule_GetFromPricingRec, MiniRule_GetFromRec: * For MiniRule_GetFromPricing, "FRN" is assumed. * * @var string diff --git a/src/Amadeus/Client/RequestOptions/MiniRuleGetFromRecOptions.php b/src/Amadeus/Client/RequestOptions/MiniRuleGetFromRecOptions.php new file mode 100644 index 000000000..35362e99d --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/MiniRuleGetFromRecOptions.php @@ -0,0 +1,48 @@ + + */ +class MiniRuleGetFromRecOptions extends Base +{ + /** + * @var null|Language + */ + public $language = null; + /** + * @var MiniRule\Pricing + */ + public $pricing = null; + + /** + * @var MiniRule\FilteringOption[] + */ + public $filteringOptions = []; +} diff --git a/src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php b/src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php new file mode 100644 index 000000000..ed016dcf8 --- /dev/null +++ b/src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php @@ -0,0 +1,34 @@ + + */ +class HandlerGetFromRec extends HandlerGetFromPricingRec +{ +} diff --git a/src/Amadeus/Client/Struct/MiniRule/FilteringSelection.php b/src/Amadeus/Client/Struct/MiniRule/FilteringSelection.php new file mode 100644 index 000000000..7a25d623e --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/FilteringSelection.php @@ -0,0 +1,38 @@ + + */ +class FilteringSelection +{ + /** + * @var array|ReferenceDetails[] + */ + public $referenceDetails = []; +} diff --git a/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php new file mode 100644 index 000000000..9d90421fb --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php @@ -0,0 +1,67 @@ + + */ +class GetFromRec extends BaseWsMessage +{ + /** + * @var Language|null + */ + public $language = null; + /** + * @var array|GroupRecords[] + */ + public $groupRecords = []; + + /** + * GetFromRec constructor. + * @param MiniRuleGetFromRecOptions $options + */ + public function __construct(MiniRuleGetFromRecOptions $options) + { + if (isset($options->language)) { + $this->language = new Language($options->language->qualifier, $options->language->code); + } + + $obj = new GroupRecords(); + $obj->recordID = new RecordId($options->pricing->id, $options->pricing->type); + + if (isset($options->filteringOptions)) { + $obj->filteringSelection = new FilteringSelection(); + foreach ($options->filteringOptions as $option) { + $obj->filteringSelection->referenceDetails[] = new ReferenceDetails($option->type, $option->value); + } + } + + $this->groupRecords[] = $obj; + } +} diff --git a/src/Amadeus/Client/Struct/MiniRule/GroupRecords.php b/src/Amadeus/Client/Struct/MiniRule/GroupRecords.php new file mode 100644 index 000000000..c1fcf8771 --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/GroupRecords.php @@ -0,0 +1,42 @@ + + */ +class GroupRecords +{ + /** + * @var RecordId + */ + public $recordID; + /** + * @var FilteringSelection + */ + public $filteringSelection; +} diff --git a/src/Amadeus/Client/Struct/MiniRule/Language.php b/src/Amadeus/Client/Struct/MiniRule/Language.php new file mode 100644 index 000000000..b0fa123b2 --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/Language.php @@ -0,0 +1,55 @@ + + */ +class Language +{ + const LQ_LANGUAGE_NORMALLY_USED = 1; + const LQ_LANGUAGE_UNDERSTOOD = 2; + const LQ_SPOKEN_LANGUAGE = 3; + const LQ_WRITTEN_LANGUAGE = 4; + const LQ_READ_LANGUAGE = 5; + const LQ_FOR_ALL_TYPES_OF_COMMUNICATION = 6; + const LQ_NATIVE_LANGUAGE = 7; + + /** + * @var int + */ + public $languageQualifier; + /** + * @var LanguageDetails + */ + public $languageDetails; + + public function __construct($languageQualifier, $languageCode) + { + $this->languageQualifier = $languageQualifier; + $this->languageDetails = new LanguageDetails($languageCode); + } +} diff --git a/src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php b/src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php new file mode 100644 index 000000000..ba1396aaa --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php @@ -0,0 +1,47 @@ + + */ +class LanguageDetails +{ + /** + * @var string + */ + public $languageCode; + /** + * @var string + */ + public $languageName; + + public function __construct($languageCode, $languageName = null) + { + $this->languageCode = $languageCode; + $this->languageName = $languageName; + } +} diff --git a/src/Amadeus/Client/Struct/MiniRule/RecordId.php b/src/Amadeus/Client/Struct/MiniRule/RecordId.php index cdc4ee751..64cbd1a29 100644 --- a/src/Amadeus/Client/Struct/MiniRule/RecordId.php +++ b/src/Amadeus/Client/Struct/MiniRule/RecordId.php @@ -46,6 +46,22 @@ class RecordId * Product Quotation Record Reference */ const REFERENCE_TYPE_PROD_QUOTATION = "PQR"; + /** + * Fare Recommendation Number + */ + const REFERENCE_TYPE_FARE_RECOMMENDATION_NUMBER = "FRN"; + /** + * Fare Upsell reco. Number + */ + const REFERENCE_TYPE_FARE_UPSELL_RECOMMENDATION_NUMBER = "FUN"; + /** + * Record Locator + */ + const REFERENCE_TYPE_RECORD_LOCATOR = "PNR"; + /** + * Ticket Number + */ + const REFERENCE_TYPE_TICKET_NUMBER = "TKT"; /** * self::REFERENCE_TYPE_* diff --git a/src/Amadeus/Client/Struct/MiniRule/ReferenceDetails.php b/src/Amadeus/Client/Struct/MiniRule/ReferenceDetails.php new file mode 100644 index 000000000..1da22c10d --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/ReferenceDetails.php @@ -0,0 +1,65 @@ + + */ +class ReferenceDetails +{ + const REFERENCE_TYPE_PAX = 'P'; + + const REFERENCE_TYPE_ADULT_PASSENGER = "PA"; + + const REFERENCE_TYPE_INFANT_PASSENGER = "PI"; + + const REFERENCE_TYPE_SEGMENT = 'S'; + + /** + * self::TYPE_* + * + * @var string + */ + public $type; + + /** + * @var int|string + */ + public $value; + + /** + * ReferenceDetails constructor. + * + * @param string $type + * @param int|string $value + */ + public function __construct($type, $value) + { + $this->type = $type; + $this->value = $value; + } +} diff --git a/tests/Amadeus/Client/ResponseHandler/BaseTest.php b/tests/Amadeus/Client/ResponseHandler/BaseTest.php index 41cfc8b74..bcce8e0ca 100644 --- a/tests/Amadeus/Client/ResponseHandler/BaseTest.php +++ b/tests/Amadeus/Client/ResponseHandler/BaseTest.php @@ -1424,6 +1424,21 @@ public function testCanHandleTicketProcessEDocErrorResponse() $this->assertEquals("SYSTEM UNABLE TO PROCESS", $result->messages[0]->text); } + public function testCanHandleMiniRuleGetFromRecErrResponse() + { + $respHandler = new ResponseHandler\Base(); + + $sendResult = new SendResult(); + $sendResult->responseXml = $this->getTestFile('dummyMiniRuleGetFromRecErrorResponse.txt'); + + $result = $respHandler->analyzeResponse($sendResult, 'MiniRule_GetFromPricingRec'); + + $this->assertEquals(Result::STATUS_ERROR, $result->status); + $this->assertEquals(1, count($result->messages)); + $this->assertEquals('32660', $result->messages[0]->code); + $this->assertEquals("INVALID CONTEXT - PNRRELOC MISMATCH", $result->messages[0]->text); + } + public function testCanHandleMiniRuleGetFromPricingRecErrResponse() { $respHandler = new ResponseHandler\Base(); diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/dummyMiniRuleGetFromRecErrorResponse.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyMiniRuleGetFromRecErrorResponse.txt new file mode 100644 index 000000000..37cf11cac --- /dev/null +++ b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyMiniRuleGetFromRecErrorResponse.txt @@ -0,0 +1,22 @@ + + + N + + + + + 32660 + EC + + + + + 3 + EN + S + 1 + + INVALID CONTEXT - PNRRELOC MISMATCH + + + \ No newline at end of file diff --git a/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php new file mode 100644 index 000000000..0e9abe611 --- /dev/null +++ b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php @@ -0,0 +1,227 @@ + + */ +class GetFromRecTest extends BaseTestCase +{ + public function testCanMakeMiniRulesRequestForAllOffers() + { + $opt = new MiniRuleGetFromRecOptions([ + 'pricing' => new Pricing([ + 'id' => Pricing::ALL_PRICINGS, + 'type' => Pricing::TYPE_OFFER + ]) + ]); + + $message = new GetFromRec($opt); + + $this->assertCount(1, $message->groupRecords); + $this->assertEquals(RecordId::REFERENCE_TYPE_OFFER, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals(RecordId::PRICING_ID_ALL, $message->groupRecords[0]->recordID->uniqueReference); + } + + public function testCanMakeMiniRulesRequestForSpecificOffer() + { + $opt = new MiniRuleGetFromRecOptions([ + 'pricing' => new Pricing([ + 'id' => 2, + 'type' => Pricing::TYPE_OFFER + ]) + ]); + + $message = new GetFromRec($opt); + + $this->assertCount(1, $message->groupRecords); + $this->assertEquals(RecordId::REFERENCE_TYPE_OFFER, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals(2, $message->groupRecords[0]->recordID->uniqueReference); + } + + public function testCanMakeMiniRulesRequestForAllPqrs() + { + $opt = new MiniRuleGetFromRecOptions([ + 'pricing' => new Pricing([ + 'id' => Pricing::ALL_PRICINGS, + 'type' => Pricing::TYPE_PROD_QUOTATION + ]) + ]); + + $message = new GetFromRec($opt); + + $this->assertCount(1, $message->groupRecords); + $this->assertEquals(RecordId::REFERENCE_TYPE_PROD_QUOTATION, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals(RecordId::PRICING_ID_ALL, $message->groupRecords[0]->recordID->uniqueReference); + } + + public function testCanMakeMiniRulesRequestForSpecificTst() + { + $opt = new MiniRuleGetFromRecOptions([ + 'pricing' => new Pricing([ + 'id' => 1, + 'type' => Pricing::TYPE_TST + ]) + ]); + + $message = new GetFromRec($opt); + + $this->assertCount(1, $message->groupRecords); + $this->assertEquals(RecordId::REFERENCE_TYPE_TST, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals(1, $message->groupRecords[0]->recordID->uniqueReference); + } + + public function testCanMakeMiniRulesRequestForAllFRN() + { + $opt = new MiniRuleGetFromRecOptions([ + 'pricing' => new Pricing([ + 'id' => Pricing::ALL_PRICINGS, + 'type' => Pricing::TYPE_FARE_RECOMMENDATION_NUMBER + ]) + ]); + + $message = new GetFromRec($opt); + + $this->assertCount(1, $message->groupRecords); + $this->assertEquals(RecordId::REFERENCE_TYPE_FARE_RECOMMENDATION_NUMBER, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals(RecordId::PRICING_ID_ALL, $message->groupRecords[0]->recordID->uniqueReference); + } + + public function testCanMakeMiniRulesRequestForAllFUN() + { + $opt = new MiniRuleGetFromRecOptions([ + 'pricing' => new Pricing([ + 'id' => Pricing::ALL_PRICINGS, + 'type' => Pricing::TYPE_FARE_UPSELL_RECOMMENDATION_NUMBER + ]) + ]); + + $message = new GetFromRec($opt); + + $this->assertCount(1, $message->groupRecords); + $this->assertEquals(RecordId::REFERENCE_TYPE_FARE_UPSELL_RECOMMENDATION_NUMBER, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals(RecordId::PRICING_ID_ALL, $message->groupRecords[0]->recordID->uniqueReference); + } + + public function testCanMakeMiniRulesRequestForPNR() + { + $opt = new MiniRuleGetFromRecOptions([ + 'pricing' => new Pricing([ + 'id' => "RECLOCNUM123", + 'type' => Pricing::TYPE_RECORD_LOCATOR + ]) + ]); + + $message = new GetFromRec($opt); + + $this->assertCount(1, $message->groupRecords); + $this->assertEquals(RecordId::REFERENCE_TYPE_RECORD_LOCATOR, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals("RECLOCNUM123", $message->groupRecords[0]->recordID->uniqueReference); + } + + public function testCanMakeMiniRulesRequestForPNRWithSpecificPassenger() + { + $opt = new MiniRuleGetFromRecOptions([ + 'pricing' => new Pricing([ + 'id' => "RECLOCNUM123", + 'type' => Pricing::TYPE_RECORD_LOCATOR + ]), + 'filteringOptions' => [ + new FilteringOption([ + 'type' => FilteringOption::TYPE_PAX, + 'value' => 1 + ]) + ] + ]); + + $message = new GetFromRec($opt); + + $this->assertCount(1, $message->groupRecords); + $this->assertEquals(RecordId::REFERENCE_TYPE_RECORD_LOCATOR, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals("RECLOCNUM123", $message->groupRecords[0]->recordID->uniqueReference); + $this->assertCount(1, $message->groupRecords[0]->filteringSelection->referenceDetails); + $this->assertEquals(ReferenceDetails::REFERENCE_TYPE_PAX, $message->groupRecords[0]->filteringSelection->referenceDetails[0]->type); + $this->assertEquals(1, $message->groupRecords[0]->filteringSelection->referenceDetails[0]->value); + } + + public function testCanMakeMiniRulesRequestForPNRWithSpecificSegment() + { + $opt = new MiniRuleGetFromRecOptions([ + 'pricing' => new Pricing([ + 'id' => "RECLOCNUM123", + 'type' => Pricing::TYPE_RECORD_LOCATOR + ]), + 'filteringOptions' => [ + new FilteringOption([ + 'type' => FilteringOption::TYPE_SEGMENT, + 'value' => 2 + ]) + ] + ]); + + $message = new GetFromRec($opt); + + $this->assertCount(1, $message->groupRecords); + $this->assertEquals(RecordId::REFERENCE_TYPE_RECORD_LOCATOR, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals("RECLOCNUM123", $message->groupRecords[0]->recordID->uniqueReference); + $this->assertCount(1, $message->groupRecords[0]->filteringSelection->referenceDetails); + $this->assertEquals(ReferenceDetails::REFERENCE_TYPE_SEGMENT, $message->groupRecords[0]->filteringSelection->referenceDetails[0]->type); + $this->assertEquals(2, $message->groupRecords[0]->filteringSelection->referenceDetails[0]->value); + } + + + public function testCanMakeMiniRulesRequestForPNRWithSpecificLanguage() + { + $opt = new MiniRuleGetFromRecOptions([ + 'language' => new Language([ + 'qualifier' => Language::LQ_LANGUAGE_NORMALLY_USED, + 'code' => "UA" + ]), + 'pricing' => new Pricing([ + 'id' => "RECLOCNUM123", + 'type' => Pricing::TYPE_RECORD_LOCATOR + ]) + ]); + + $message = new GetFromRec($opt); + + $this->assertEquals(\Amadeus\Client\Struct\MiniRule\Language::LQ_LANGUAGE_NORMALLY_USED, $message->language->languageQualifier); + $this->assertEquals("UA", $message->language->languageDetails->languageCode); + $this->assertCount(1, $message->groupRecords); + $this->assertEquals(RecordId::REFERENCE_TYPE_RECORD_LOCATOR, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals("RECLOCNUM123", $message->groupRecords[0]->recordID->uniqueReference); + } + +} diff --git a/tests/Amadeus/ClientTest.php b/tests/Amadeus/ClientTest.php index 6fc88b541..ee9439671 100644 --- a/tests/Amadeus/ClientTest.php +++ b/tests/Amadeus/ClientTest.php @@ -207,7 +207,7 @@ public function testCanDoDummyPnrRetrieveCall() $client = new Client($par); - $response = $client->pnrRetrieve(new Client\RequestOptions\PnrRetrieveOptions(['recordLocator'=>'ABC123'])); + $response = $client->pnrRetrieve(new Client\RequestOptions\PnrRetrieveOptions(['recordLocator' => 'ABC123'])); $this->assertEquals($messageResult, $response); } @@ -254,7 +254,7 @@ public function testCanDoDummyPnrRetrieveAndDisplayCall() $client = new Client($par); - $response = $client->pnrRetrieveAndDisplay(new Client\RequestOptions\PnrRetrieveAndDisplayOptions(['recordLocator'=>'ABC123'])); + $response = $client->pnrRetrieveAndDisplay(new Client\RequestOptions\PnrRetrieveAndDisplayOptions(['recordLocator' => 'ABC123'])); $this->assertEquals($messageResult, $response); } @@ -296,7 +296,7 @@ public function testCanDoCreatePnrCall() 'type' => Client\RequestOptions\Pnr\Element\Contact::TYPE_PHONE_MOBILE, 'value' => '+3222222222' ]); - $options->defaultReceivedFrom = 'some RF string amabnl-amadeus-ws-client-'.Client::VERSION; + $options->defaultReceivedFrom = 'some RF string amabnl-amadeus-ws-client-' . Client::VERSION; $options->autoAddReceivedFrom = true; $expectedPnrResult = new Client\Struct\Pnr\AddMultiElements($options); @@ -353,7 +353,7 @@ public function testCanDoAddMultiElementsSavePNR() /** @var Client\RequestOptions\PnrAddMultiElementsOptions $expectedResultOpt */ $expectedResultOpt = clone $options; - $expectedResultOpt->receivedFrom = 'some RF string '.Client::RECEIVED_FROM_IDENTIFIER.'-'.Client::VERSION; + $expectedResultOpt->receivedFrom = 'some RF string ' . Client::RECEIVED_FROM_IDENTIFIER . '-' . Client::VERSION; $expectedPnrResult = new Client\Struct\Pnr\AddMultiElements($expectedResultOpt); @@ -818,7 +818,7 @@ public function testCanDoPlacePNRCall() 'ABC123', 'BRUXX0000', new Client\RequestOptions\Queue([ - 'queue'=> 50, + 'queue' => 50, 'category' => 0 ]) ); @@ -874,7 +874,7 @@ public function testCanDoQueueRemoveItemCall() $messageResult = new Client\Result($mockedSendResult); - $expectedMessageResult = new Client\Struct\Queue\RemoveItem(new Client\RequestOptions\Queue(['queue'=> 50, 'category' => 0]), 'ABC123', 'BRUXX0000'); + $expectedMessageResult = new Client\Struct\Queue\RemoveItem(new Client\RequestOptions\Queue(['queue' => 50, 'category' => 0]), 'ABC123', 'BRUXX0000'); $mockSessionHandler ->expects($this->once()) @@ -927,7 +927,7 @@ public function testCanDoQueueMoveItemCall() $messageResult = new Client\Result($mockedSendResult); - $expectedMessageResult = new Client\Struct\Queue\MoveItem('ABC123', 'BRUXX0000', new Client\RequestOptions\Queue(['queue'=> 50, 'category' => 0]), new Client\RequestOptions\Queue(['queue'=> 60, 'category' => 5])); + $expectedMessageResult = new Client\Struct\Queue\MoveItem('ABC123', 'BRUXX0000', new Client\RequestOptions\Queue(['queue' => 50, 'category' => 0]), new Client\RequestOptions\Queue(['queue' => 60, 'category' => 5])); $mockSessionHandler ->expects($this->once()) @@ -1025,6 +1025,70 @@ public function testCanCrypticCall() $this->assertEquals($messageResult, $response); } + public function testCanSendMiniRuleGetFromRec() + { + $mockedSendResult = new Client\Session\Handler\SendResult(); + $mockedSendResult->responseXml = $this->getTestFile('miniRuleGetFromRecReply18.1.txt'); + $mockedSendResult->responseObject = new \stdClass(); + + $messageResult = new Client\Result($mockedSendResult); + + $expectedMessageResult = new Client\Struct\MiniRule\GetFromRec( + new Client\RequestOptions\MiniRuleGetFromRecOptions([ + 'pricing' => new Client\RequestOptions\MiniRule\Pricing([ + 'type' => Client\RequestOptions\MiniRule\Pricing::TYPE_RECORD_LOCATOR, + 'id' => 'XXXXXX' + ]) + ] + ) + ); + + $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); + + $mockSessionHandler + ->expects($this->once()) + ->method('sendMessage') + ->with('MiniRule_GetFromRec', $expectedMessageResult, ['endSession' => false, 'returnXml' => true]) + ->will($this->returnValue($mockedSendResult)); + $mockSessionHandler + ->expects($this->never()) + ->method('getLastResponse'); + $mockSessionHandler + ->expects($this->once()) + ->method('getMessagesAndVersions') + ->will($this->returnValue(['MiniRule_GetFromRec' => ['version' => "18.1", 'wsdl' => 'dc22e4ee']])); + + $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock(); + + $mockResponseHandler + ->expects($this->once()) + ->method('analyzeResponse') + ->with($mockedSendResult, 'MiniRule_GetFromRec') + ->will($this->returnValue($messageResult)); + + + $par = new Params(); + $par->sessionHandler = $mockSessionHandler; + $par->requestCreatorParams = new Params\RequestCreatorParams([ + 'receivedFrom' => 'some RF string', + 'originatorOfficeId' => 'BRUXXXXXX' + ]); + $par->responseHandler = $mockResponseHandler; + + $client = new Client($par); + + $response = $client->miniRuleGetFromRec( + new Client\RequestOptions\MiniRuleGetFromRecOptions([ + 'pricing' => new Client\RequestOptions\MiniRule\Pricing([ + 'type' => Client\RequestOptions\MiniRule\Pricing::TYPE_RECORD_LOCATOR, + 'id' => "XXXXXX" + ]) + ]) + ); + + $this->assertEquals($messageResult, $response); + } + public function testCanSendMiniRuleGetFromPricingRec() { $mockedSendResult = new Client\Session\Handler\SendResult(); @@ -2791,7 +2855,7 @@ public function testCanSendAirSellFromRecommendation() 'to' => 'LON', 'segments' => [ new Client\RequestOptions\Air\SellFromRecommendation\Segment([ - 'departureDate' => \DateTime::createFromFormat('YmdHis','20170120000000', new \DateTimeZone('UTC')), + 'departureDate' => \DateTime::createFromFormat('YmdHis', '20170120000000', new \DateTimeZone('UTC')), 'from' => 'BRU', 'to' => 'LGW', 'companyCode' => 'SN', @@ -2845,7 +2909,7 @@ public function testCanSendAirSellFromRecommendation() 'to' => 'LON', 'segments' => [ new Client\RequestOptions\Air\SellFromRecommendation\Segment([ - 'departureDate' => \DateTime::createFromFormat('YmdHis','20170120000000', new \DateTimeZone('UTC')), + 'departureDate' => \DateTime::createFromFormat('YmdHis', '20170120000000', new \DateTimeZone('UTC')), 'from' => 'BRU', 'to' => 'LGW', 'companyCode' => 'SN', @@ -2881,8 +2945,8 @@ public function testCanSendAirRebookAirSegment() 'to' => 'BKK', 'segments' => [ new Client\RequestOptions\Air\SellFromRecommendation\Segment([ - 'departureDate' => \DateTime::createFromFormat('YmdHis','20040308220000', new \DateTimeZone('UTC')), - 'arrivalDate' => \DateTime::createFromFormat('YmdHis','20040309141000', new \DateTimeZone('UTC')), + 'departureDate' => \DateTime::createFromFormat('YmdHis', '20040308220000', new \DateTimeZone('UTC')), + 'arrivalDate' => \DateTime::createFromFormat('YmdHis', '20040309141000', new \DateTimeZone('UTC')), 'dateVariation' => 1, 'from' => 'FRA', 'to' => 'BKK', @@ -2899,8 +2963,8 @@ public function testCanSendAirRebookAirSegment() 'to' => 'BKK', 'segments' => [ new Client\RequestOptions\Air\SellFromRecommendation\Segment([ - 'departureDate' => \DateTime::createFromFormat('YmdHis','20040308220000', new \DateTimeZone('UTC')), - 'arrivalDate' => \DateTime::createFromFormat('YmdHis','00000000141000', new \DateTimeZone('UTC')), + 'departureDate' => \DateTime::createFromFormat('YmdHis', '20040308220000', new \DateTimeZone('UTC')), + 'arrivalDate' => \DateTime::createFromFormat('YmdHis', '00000000141000', new \DateTimeZone('UTC')), 'from' => 'FRA', 'to' => 'BKK', 'companyCode' => 'LH', @@ -2955,8 +3019,8 @@ public function testCanSendAirRebookAirSegment() 'to' => 'BKK', 'segments' => [ new Client\RequestOptions\Air\SellFromRecommendation\Segment([ - 'departureDate' => \DateTime::createFromFormat('YmdHis','20040308220000', new \DateTimeZone('UTC')), - 'arrivalDate' => \DateTime::createFromFormat('YmdHis','20040309141000', new \DateTimeZone('UTC')), + 'departureDate' => \DateTime::createFromFormat('YmdHis', '20040308220000', new \DateTimeZone('UTC')), + 'arrivalDate' => \DateTime::createFromFormat('YmdHis', '20040309141000', new \DateTimeZone('UTC')), 'dateVariation' => 1, 'from' => 'FRA', 'to' => 'BKK', @@ -2973,8 +3037,8 @@ public function testCanSendAirRebookAirSegment() 'to' => 'BKK', 'segments' => [ new Client\RequestOptions\Air\SellFromRecommendation\Segment([ - 'departureDate' => \DateTime::createFromFormat('YmdHis','20040308220000', new \DateTimeZone('UTC')), - 'arrivalDate' => \DateTime::createFromFormat('YmdHis','00000000141000', new \DateTimeZone('UTC')), + 'departureDate' => \DateTime::createFromFormat('YmdHis', '20040308220000', new \DateTimeZone('UTC')), + 'arrivalDate' => \DateTime::createFromFormat('YmdHis', '00000000141000', new \DateTimeZone('UTC')), 'from' => 'FRA', 'to' => 'BKK', 'companyCode' => 'LH', @@ -3193,12 +3257,12 @@ public function testCanSendAirMultiAvailability() $this->assertEquals($messageResult, $response); } - public function testCanSendFareMasterPricerExpertSearch() - { + public function testCanSendFareMasterPricerExpertSearch() + { $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); $mockedSendResult = new Client\Session\Handler\SendResult(); - $mockedSendResult->responseXml = $this->getTestFile('fareMasterPricerExpertSearchReply-12.4.txt'); + $mockedSendResult->responseXml = $this->getTestFile('fareMasterPricerExpertSearchReply-12.4.txt'); $messageResult = new Client\Result($mockedSendResult); @@ -3280,10 +3344,10 @@ public function testCanSendFareMasterPricerExpertSearch() Client\RequestOptions\FareMasterPricerExSearchOptions::FLIGHTTYPE_DIRECT ] ]) - ); + ); $this->assertEquals($messageResult, $response); - } + } public function testCanSendFareMasterPricerTravelBoardSearch() { @@ -3489,8 +3553,8 @@ public function testCanSendPriceXplorerExtremeSearch() 'resultAggregationOption' => Client\RequestOptions\PriceXplorerExtremeSearchOptions::AGGR_COUNTRY, 'origin' => 'BRU', 'destinations' => ['SYD', 'CBR'], - 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-08-25', new \DateTimeZone('UTC')), - 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-09-28', new \DateTimeZone('UTC')), + 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d', '2016-08-25', new \DateTimeZone('UTC')), + 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d', '2016-09-28', new \DateTimeZone('UTC')), 'searchOffice' => 'LONBG2222' ]) ); @@ -3531,8 +3595,8 @@ public function testCanSendPriceXplorerExtremeSearch() 'resultAggregationOption' => Client\RequestOptions\PriceXplorerExtremeSearchOptions::AGGR_COUNTRY, 'origin' => 'BRU', 'destinations' => ['SYD', 'CBR'], - 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-08-25', new \DateTimeZone('UTC')), - 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-09-28', new \DateTimeZone('UTC')), + 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d', '2016-08-25', new \DateTimeZone('UTC')), + 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d', '2016-09-28', new \DateTimeZone('UTC')), 'searchOffice' => 'LONBG2222' ]) ); @@ -4475,15 +4539,15 @@ public function testCanSendServiceBookPriceService() $mockedSendResult->responseXml = $this->getTestFile('serviceBookPriceServiceReply.txt'); $messageResult = new Client\Result($mockedSendResult); - + $opts = new Client\RequestOptions\ServiceBookPriceServiceOptions([ 'services' => [new Client\RequestOptions\Service\BookPriceService\Service([ 'TID' => 1, 'serviceProvider' => 'LH', 'identifier' => new Client\RequestOptions\Service\BookPriceService\Identifier([ - 'bookingMethod' => '01', - 'RFIC' => 'F', - 'RFISC' => '040' + 'bookingMethod' => '01', + 'RFIC' => 'F', + 'RFISC' => '040' ]) ])] ]); @@ -6287,8 +6351,8 @@ protected function makeClientWithMockedSessionHandler() protected function makePathToDummyWSDL() { return realpath( - dirname(__FILE__).DIRECTORY_SEPARATOR."Client". - DIRECTORY_SEPARATOR."testfiles".DIRECTORY_SEPARATOR."dummywsdl.wsdl" + dirname(__FILE__) . DIRECTORY_SEPARATOR . "Client" . + DIRECTORY_SEPARATOR . "testfiles" . DIRECTORY_SEPARATOR . "dummywsdl.wsdl" ); } } diff --git a/tests/Amadeus/testfiles/miniRuleGetFromRecReply18.1.txt b/tests/Amadeus/testfiles/miniRuleGetFromRecReply18.1.txt new file mode 100644 index 000000000..1b7078723 --- /dev/null +++ b/tests/Amadeus/testfiles/miniRuleGetFromRecReply18.1.txt @@ -0,0 +1,579 @@ + + + O + + + + TST + 1 + + + + PA + 1 + + + + + + XXXXXXX + + + + + PU + NPU + + + FC + 1 + + + + FRA + LON + + + + ST + 1 + + + + + + + XXXXXXXX + + + + + PU + NPU + + + FC + 2 + + + + LON + FRA + + + + ST + 2 + + + + + + + 5 + + ASS + + + + + FC + 1 + + + FC + 2 + + + + + + + + 6 + + ASS + + + + + FC + 1 + + + FC + 2 + + + + + + + + 7 + + + + + + FC + 2 + + + + 25 + + LHR + + + + + + + MSC + 12DEC20 + + + + + + + + + 31 + + + + + + FC + 1 + + + FC + 2 + + + + + + + BDM + 0 + THB + + + BDX + 0 + THB + + + BDF + 0 + THB + + + BDG + 0 + THB + + + BDT + 0 + THB + + + BDI + 0 + THB + + + BDU + 0 + THB + + + BDH + 0 + THB + + + BDL + 0 + THB + + + BDC + 0 + THB + + + BNM + 0 + THB + + + BNX + 0 + THB + + + BNF + 0 + THB + + + BNG + 0 + THB + + + BNT + 0 + THB + + + BNI + 0 + THB + + + BNU + 0 + THB + + + BNH + 0 + THB + + + BNL + 0 + THB + + + BNC + 0 + THB + + + + + + + ADM + 0 + THB + + + ADX + 0 + THB + + + ADF + 0 + THB + + + ADG + 0 + THB + + + ADT + 0 + THB + + + ADI + 0 + THB + + + ADU + 0 + THB + + + ADH + 0 + THB + + + ADL + 0 + THB + + + ADC + 0 + THB + + + ANM + 0 + THB + + + ANX + 0 + THB + + + ANF + 0 + THB + + + ANG + 0 + THB + + + ANT + 0 + THB + + + ANI + 0 + THB + + + ANU + 0 + THB + + + ANH + 0 + THB + + + ANL + 0 + THB + + + ANC + 0 + THB + + + + + + + FFT + 0 + + + WAI + 0 + + + RVA + 0 + + + BDA + 0 + + + BNW + 0 + + + BNR + 0 + + + BNA + 0 + + + ADW + 0 + + + ADR + 0 + + + ADA + 0 + + + ANW + 0 + + + ANR + 0 + + + ANA + 0 + + + GUA + 1 + + + + + + + + 33 + + + + + + FC + 1 + + + FC + 2 + + + + + + + BDM + 0 + THB + + + BDX + 0 + THB + + + BDF + 0 + THB + + + BDG + 0 + THB + + + BDT + 0 + THB + + + BNM + 0 + THB + + + BNX + 0 + THB + + + BNF + 0 + THB + + + BNG + 0 + THB + + + BNT + 0 + THB + + + ADM + 0 + THB + + + ADX + 0 + THB + + + ADF + 0 + THB + + + ADG + 0 + THB + + + ADT + 0 + THB + + + ANM + 0 + THB + + + ANX + 0 + THB + + + ANF + 0 + THB + + + ANG + 0 + THB + + + ANT + 0 + THB + + + + + + + FFT + 0 + + + BDA + 0 + + + BNA + 0 + + + ADA + 0 + + + ANA + 0 + + + GUA + 1 + + + + + + \ No newline at end of file