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..a1d9b2a20 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 FilteringSelection([ + 'type' => FilteringSelection::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..bc722ff2d --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php @@ -0,0 +1,66 @@ + + */ +class GetFromRec +{ + /** + * @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..9d759a0a3 --- /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..fc60a81bb --- /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); + } + +}