From 75346578127572f0c25af8ef174cebe20808d6a3 Mon Sep 17 00:00:00 2001 From: Aleksandr Kaluhyn Date: Thu, 24 Sep 2020 03:41:18 +0300 Subject: [PATCH 01/12] Add Function: MiniRule_GetFromRec --- docs/list-of-supported-messages.rst | 1 + docs/samples.rst | 59 +++++ src/Amadeus/Client.php | 17 ++ .../Converter/MiniRule/GetFromRecConv.php | 46 ++++ .../MiniRule/FilteringSelection.php | 56 +++++ .../RequestOptions/MiniRule/Language.php | 56 +++++ .../RequestOptions/MiniRule/Pricing.php | 31 ++- .../MiniRuleGetFromRecOptions.php | 48 ++++ .../MiniRule/HandlerGetFromRec.php | 36 +++ .../Client/Struct/MiniRule/GetFromRec.php | 59 +++++ .../Client/Struct/MiniRule/Language.php | 56 +++++ .../Struct/MiniRule/LanguageDetails.php | 47 ++++ .../Client/Struct/MiniRule/RecordId.php | 16 ++ .../Struct/MiniRule/ReferenceDetails.php | 66 +++++ .../Client/ResponseHandler/BaseTest.php | 15 ++ .../dummyMiniRuleGetFromRecErrorResponse.txt | 22 ++ .../Client/Struct/MiniRule/GetFromRecTest.php | 235 ++++++++++++++++++ 17 files changed, 862 insertions(+), 4 deletions(-) create mode 100644 src/Amadeus/Client/RequestCreator/Converter/MiniRule/GetFromRecConv.php create mode 100644 src/Amadeus/Client/RequestOptions/MiniRule/FilteringSelection.php create mode 100644 src/Amadeus/Client/RequestOptions/MiniRule/Language.php create mode 100644 src/Amadeus/Client/RequestOptions/MiniRuleGetFromRecOptions.php create mode 100644 src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php create mode 100644 src/Amadeus/Client/Struct/MiniRule/GetFromRec.php create mode 100644 src/Amadeus/Client/Struct/MiniRule/Language.php create mode 100644 src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php create mode 100644 src/Amadeus/Client/Struct/MiniRule/ReferenceDetails.php create mode 100644 tests/Amadeus/Client/ResponseHandler/testfiles/dummyMiniRuleGetFromRecErrorResponse.txt create mode 100644 tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php 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..797d3b9ef 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" + ]), + 'filteringSelections' => [ + 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/FilteringSelection.php b/src/Amadeus/Client/RequestOptions/MiniRule/FilteringSelection.php new file mode 100644 index 000000000..4112db3f2 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/MiniRule/FilteringSelection.php @@ -0,0 +1,56 @@ + + */ +class FilteringSelection 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; +} \ No newline at end of file diff --git a/src/Amadeus/Client/RequestOptions/MiniRule/Language.php b/src/Amadeus/Client/RequestOptions/MiniRule/Language.php new file mode 100644 index 000000000..56f726f8d --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/MiniRule/Language.php @@ -0,0 +1,56 @@ + + */ +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"; +} \ No newline at end of file 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..65ed5d76e --- /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\FilteringSelection[] + */ + public $filteringSelections = []; +} diff --git a/src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php b/src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php new file mode 100644 index 000000000..be019c709 --- /dev/null +++ b/src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php @@ -0,0 +1,36 @@ + + */ +class HandlerGetFromRec extends HandlerGetFromPricingRec +{ + +} \ No newline at end of file diff --git a/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php new file mode 100644 index 000000000..6c917ab47 --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php @@ -0,0 +1,59 @@ + + */ +class GetFromRec +{ + /** + * @var Language|null + */ + public $language = null; + /** + * @var array + */ + public $groupRecords = []; + + /** + * GetFromRec constructor. + * @param MiniRuleGetFromRecOptions $options + */ + public function __construct(MiniRuleGetFromRecOptions $options) + { + $this->language = new Language($options->language->qualifier, $options->language->code); + + $this->groupRecords['recordID'] = new RecordId($options->pricing->id, $options->pricing->type); + + foreach ($options->filteringSelections as $filteringSelection) { + $this->groupRecords['filteringSelection']['referenceDetails'][] = new ReferenceDetails($filteringSelection->type, $filteringSelection->value); + } + } +} \ No newline at end of file diff --git a/src/Amadeus/Client/Struct/MiniRule/Language.php b/src/Amadeus/Client/Struct/MiniRule/Language.php new file mode 100644 index 000000000..e9b674758 --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/Language.php @@ -0,0 +1,56 @@ + + */ +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); + } +} \ No newline at end of file diff --git a/src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php b/src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php new file mode 100644 index 000000000..c1f662202 --- /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; + } +} \ No newline at end of file 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..feb45c6f2 --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/ReferenceDetails.php @@ -0,0 +1,66 @@ + + */ +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; + } +} \ No newline at end of file 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..623412921 --- /dev/null +++ b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php @@ -0,0 +1,235 @@ + + */ +class GetFromRecTest extends BaseTestCase +{ + public function testCanMakeMiniRulesRequestForAllOffers() + { + $opt = new MiniRuleGetFromRecOptions([ + 'pricings' => [ + 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([ + 'pricings' => [ + 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([ + 'pricings' => [ + 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([ + 'pricings' => [ + 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 + ]), + 'filteringSelections' => [ + new FilteringSelection([ + 'type' => FilteringSelection::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]->filteringSelections->referenceDetails); + $this->assertEquals(ReferenceDetails::REFERENCE_TYPE_PAX, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->type); + $this->assertEquals(1, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->value); + } + + public function testCanMakeMiniRulesRequestForPNRWithSpecificSegment() + { + $opt = new MiniRuleGetFromRecOptions([ + 'pricing' => new Pricing([ + 'id' => "RECLOCNUM123", + 'type' => Pricing::TYPE_RECORD_LOCATOR + ]), + 'filteringSelections' => [ + new FilteringSelection([ + 'type' => FilteringSelection::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]->filteringSelections->referenceDetails); + $this->assertEquals(ReferenceDetails::REFERENCE_TYPE_SEGMENT, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->type); + $this->assertEquals(2, $message->groupRecords[0]->filteringSelections->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); + } + +} From 32841760b1de8320b9a57972d8e5cad5ccb1481a Mon Sep 17 00:00:00 2001 From: Aleksandr Kaluhyn Date: Thu, 24 Sep 2020 03:41:18 +0300 Subject: [PATCH 02/12] Add Function: MiniRule_GetFromRec --- CHANGELOG.md | 3 + docs/list-of-supported-messages.rst | 1 + docs/samples.rst | 59 +++++ src/Amadeus/Client.php | 17 ++ .../Converter/MiniRule/GetFromRecConv.php | 46 ++++ .../MiniRule/FilteringSelection.php | 56 +++++ .../RequestOptions/MiniRule/Language.php | 56 +++++ .../RequestOptions/MiniRule/Pricing.php | 31 ++- .../MiniRuleGetFromRecOptions.php | 48 ++++ .../MiniRule/HandlerGetFromRec.php | 36 +++ .../Client/Struct/MiniRule/GetFromRec.php | 59 +++++ .../Client/Struct/MiniRule/Language.php | 56 +++++ .../Struct/MiniRule/LanguageDetails.php | 47 ++++ .../Client/Struct/MiniRule/RecordId.php | 16 ++ .../Struct/MiniRule/ReferenceDetails.php | 66 +++++ .../Client/ResponseHandler/BaseTest.php | 15 ++ .../dummyMiniRuleGetFromRecErrorResponse.txt | 22 ++ .../Client/Struct/MiniRule/GetFromRecTest.php | 235 ++++++++++++++++++ 18 files changed, 865 insertions(+), 4 deletions(-) create mode 100644 src/Amadeus/Client/RequestCreator/Converter/MiniRule/GetFromRecConv.php create mode 100644 src/Amadeus/Client/RequestOptions/MiniRule/FilteringSelection.php create mode 100644 src/Amadeus/Client/RequestOptions/MiniRule/Language.php create mode 100644 src/Amadeus/Client/RequestOptions/MiniRuleGetFromRecOptions.php create mode 100644 src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php create mode 100644 src/Amadeus/Client/Struct/MiniRule/GetFromRec.php create mode 100644 src/Amadeus/Client/Struct/MiniRule/Language.php create mode 100644 src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php create mode 100644 src/Amadeus/Client/Struct/MiniRule/ReferenceDetails.php create mode 100644 tests/Amadeus/Client/ResponseHandler/testfiles/dummyMiniRuleGetFromRecErrorResponse.txt create mode 100644 tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php 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..797d3b9ef 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" + ]), + 'filteringSelections' => [ + 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/FilteringSelection.php b/src/Amadeus/Client/RequestOptions/MiniRule/FilteringSelection.php new file mode 100644 index 000000000..4112db3f2 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/MiniRule/FilteringSelection.php @@ -0,0 +1,56 @@ + + */ +class FilteringSelection 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; +} \ No newline at end of file diff --git a/src/Amadeus/Client/RequestOptions/MiniRule/Language.php b/src/Amadeus/Client/RequestOptions/MiniRule/Language.php new file mode 100644 index 000000000..56f726f8d --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/MiniRule/Language.php @@ -0,0 +1,56 @@ + + */ +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"; +} \ No newline at end of file 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..65ed5d76e --- /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\FilteringSelection[] + */ + public $filteringSelections = []; +} diff --git a/src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php b/src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php new file mode 100644 index 000000000..be019c709 --- /dev/null +++ b/src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php @@ -0,0 +1,36 @@ + + */ +class HandlerGetFromRec extends HandlerGetFromPricingRec +{ + +} \ No newline at end of file diff --git a/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php new file mode 100644 index 000000000..6c917ab47 --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php @@ -0,0 +1,59 @@ + + */ +class GetFromRec +{ + /** + * @var Language|null + */ + public $language = null; + /** + * @var array + */ + public $groupRecords = []; + + /** + * GetFromRec constructor. + * @param MiniRuleGetFromRecOptions $options + */ + public function __construct(MiniRuleGetFromRecOptions $options) + { + $this->language = new Language($options->language->qualifier, $options->language->code); + + $this->groupRecords['recordID'] = new RecordId($options->pricing->id, $options->pricing->type); + + foreach ($options->filteringSelections as $filteringSelection) { + $this->groupRecords['filteringSelection']['referenceDetails'][] = new ReferenceDetails($filteringSelection->type, $filteringSelection->value); + } + } +} \ No newline at end of file diff --git a/src/Amadeus/Client/Struct/MiniRule/Language.php b/src/Amadeus/Client/Struct/MiniRule/Language.php new file mode 100644 index 000000000..e9b674758 --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/Language.php @@ -0,0 +1,56 @@ + + */ +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); + } +} \ No newline at end of file diff --git a/src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php b/src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php new file mode 100644 index 000000000..c1f662202 --- /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; + } +} \ No newline at end of file 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..feb45c6f2 --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/ReferenceDetails.php @@ -0,0 +1,66 @@ + + */ +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; + } +} \ No newline at end of file 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..623412921 --- /dev/null +++ b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php @@ -0,0 +1,235 @@ + + */ +class GetFromRecTest extends BaseTestCase +{ + public function testCanMakeMiniRulesRequestForAllOffers() + { + $opt = new MiniRuleGetFromRecOptions([ + 'pricings' => [ + 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([ + 'pricings' => [ + 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([ + 'pricings' => [ + 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([ + 'pricings' => [ + 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 + ]), + 'filteringSelections' => [ + new FilteringSelection([ + 'type' => FilteringSelection::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]->filteringSelections->referenceDetails); + $this->assertEquals(ReferenceDetails::REFERENCE_TYPE_PAX, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->type); + $this->assertEquals(1, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->value); + } + + public function testCanMakeMiniRulesRequestForPNRWithSpecificSegment() + { + $opt = new MiniRuleGetFromRecOptions([ + 'pricing' => new Pricing([ + 'id' => "RECLOCNUM123", + 'type' => Pricing::TYPE_RECORD_LOCATOR + ]), + 'filteringSelections' => [ + new FilteringSelection([ + 'type' => FilteringSelection::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]->filteringSelections->referenceDetails); + $this->assertEquals(ReferenceDetails::REFERENCE_TYPE_SEGMENT, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->type); + $this->assertEquals(2, $message->groupRecords[0]->filteringSelections->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); + } + +} From 3bfbeaac12fb3645de2ed8d9633b3a163614bf3e Mon Sep 17 00:00:00 2001 From: Aleksandr Kaluhyn Date: Thu, 24 Sep 2020 04:16:24 +0300 Subject: [PATCH 03/12] Apply code style --- .../Client/RequestOptions/MiniRule/FilteringSelection.php | 3 +-- .../Client/ResponseHandler/MiniRule/HandlerGetFromRec.php | 4 +--- src/Amadeus/Client/Struct/MiniRule/GetFromRec.php | 3 +-- src/Amadeus/Client/Struct/MiniRule/Language.php | 3 +-- src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php | 2 +- src/Amadeus/Client/Struct/MiniRule/ReferenceDetails.php | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Amadeus/Client/RequestOptions/MiniRule/FilteringSelection.php b/src/Amadeus/Client/RequestOptions/MiniRule/FilteringSelection.php index 4112db3f2..e87fe16f0 100644 --- a/src/Amadeus/Client/RequestOptions/MiniRule/FilteringSelection.php +++ b/src/Amadeus/Client/RequestOptions/MiniRule/FilteringSelection.php @@ -23,7 +23,6 @@ namespace Amadeus\Client\RequestOptions\MiniRule; - use Amadeus\Client\LoadParamsFromArray; /** @@ -53,4 +52,4 @@ class FilteringSelection extends LoadParamsFromArray * @var string|int */ public $value; -} \ No newline at end of file +} diff --git a/src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php b/src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php index be019c709..ed016dcf8 100644 --- a/src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php +++ b/src/Amadeus/Client/ResponseHandler/MiniRule/HandlerGetFromRec.php @@ -23,7 +23,6 @@ namespace Amadeus\Client\ResponseHandler\MiniRule; - /** * HandlerGetFromRec * @@ -32,5 +31,4 @@ */ class HandlerGetFromRec extends HandlerGetFromPricingRec { - -} \ No newline at end of file +} diff --git a/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php index 6c917ab47..58c2385dc 100644 --- a/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php +++ b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php @@ -23,7 +23,6 @@ namespace Amadeus\Client\Struct\MiniRule; - use Amadeus\Client\RequestOptions\MiniRuleGetFromRecOptions; /** @@ -56,4 +55,4 @@ public function __construct(MiniRuleGetFromRecOptions $options) $this->groupRecords['filteringSelection']['referenceDetails'][] = new ReferenceDetails($filteringSelection->type, $filteringSelection->value); } } -} \ No newline at end of file +} diff --git a/src/Amadeus/Client/Struct/MiniRule/Language.php b/src/Amadeus/Client/Struct/MiniRule/Language.php index e9b674758..b0fa123b2 100644 --- a/src/Amadeus/Client/Struct/MiniRule/Language.php +++ b/src/Amadeus/Client/Struct/MiniRule/Language.php @@ -23,7 +23,6 @@ namespace Amadeus\Client\Struct\MiniRule; - /** * Class Language * @package Amadeus\Client\Struct\MiniRule @@ -53,4 +52,4 @@ public function __construct($languageQualifier, $languageCode) $this->languageQualifier = $languageQualifier; $this->languageDetails = new LanguageDetails($languageCode); } -} \ No newline at end of file +} diff --git a/src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php b/src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php index c1f662202..ba1396aaa 100644 --- a/src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php +++ b/src/Amadeus/Client/Struct/MiniRule/LanguageDetails.php @@ -44,4 +44,4 @@ public function __construct($languageCode, $languageName = null) $this->languageCode = $languageCode; $this->languageName = $languageName; } -} \ No newline at end of file +} diff --git a/src/Amadeus/Client/Struct/MiniRule/ReferenceDetails.php b/src/Amadeus/Client/Struct/MiniRule/ReferenceDetails.php index feb45c6f2..1da22c10d 100644 --- a/src/Amadeus/Client/Struct/MiniRule/ReferenceDetails.php +++ b/src/Amadeus/Client/Struct/MiniRule/ReferenceDetails.php @@ -23,7 +23,6 @@ namespace Amadeus\Client\Struct\MiniRule; - /** * MiniRule ReferenceDetails * @@ -63,4 +62,4 @@ public function __construct($type, $value) $this->type = $type; $this->value = $value; } -} \ No newline at end of file +} From a8bf48a15d4c25a87a566e3f62c2c73c10dca933 Mon Sep 17 00:00:00 2001 From: Aleksandr Kaluhyn Date: Thu, 24 Sep 2020 04:19:15 +0300 Subject: [PATCH 04/12] Apply code style --- src/Amadeus/Client/RequestOptions/MiniRule/Language.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Amadeus/Client/RequestOptions/MiniRule/Language.php b/src/Amadeus/Client/RequestOptions/MiniRule/Language.php index 56f726f8d..bc4ce0738 100644 --- a/src/Amadeus/Client/RequestOptions/MiniRule/Language.php +++ b/src/Amadeus/Client/RequestOptions/MiniRule/Language.php @@ -22,7 +22,6 @@ namespace Amadeus\Client\RequestOptions\MiniRule; - use Amadeus\Client\LoadParamsFromArray; /** @@ -53,4 +52,4 @@ class Language extends LoadParamsFromArray * @var string */ public $code = "EN"; -} \ No newline at end of file +} From be781b4ee1ae682ad51a2a7c188d5de360cce4d3 Mon Sep 17 00:00:00 2001 From: Aleksandr Kaluhyn Date: Thu, 24 Sep 2020 04:25:07 +0300 Subject: [PATCH 05/12] Fix filed name --- .../Client/Struct/MiniRule/GetFromRecTest.php | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php index 623412921..7aab90554 100644 --- a/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php +++ b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php @@ -42,7 +42,7 @@ class GetFromRecTest extends BaseTestCase public function testCanMakeMiniRulesRequestForAllOffers() { $opt = new MiniRuleGetFromRecOptions([ - 'pricings' => [ + 'pricing' => [ new Pricing([ 'id' => Pricing::ALL_PRICINGS, 'type' => Pricing::TYPE_OFFER @@ -60,7 +60,7 @@ public function testCanMakeMiniRulesRequestForAllOffers() public function testCanMakeMiniRulesRequestForSpecificOffer() { $opt = new MiniRuleGetFromRecOptions([ - 'pricings' => [ + 'pricing' => [ new Pricing([ 'id' => 2, 'type' => Pricing::TYPE_OFFER @@ -78,7 +78,7 @@ public function testCanMakeMiniRulesRequestForSpecificOffer() public function testCanMakeMiniRulesRequestForAllPqrs() { $opt = new MiniRuleGetFromRecOptions([ - 'pricings' => [ + 'pricing' => [ new Pricing([ 'id' => Pricing::ALL_PRICINGS, 'type' => Pricing::TYPE_PROD_QUOTATION @@ -96,7 +96,7 @@ public function testCanMakeMiniRulesRequestForAllPqrs() public function testCanMakeMiniRulesRequestForSpecificTst() { $opt = new MiniRuleGetFromRecOptions([ - 'pricings' => [ + 'pricing' => [ new Pricing([ 'id' => 1, 'type' => Pricing::TYPE_TST @@ -110,14 +110,14 @@ public function testCanMakeMiniRulesRequestForSpecificTst() $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 - ]) + 'id' => Pricing::ALL_PRICINGS, + 'type' => Pricing::TYPE_FARE_RECOMMENDATION_NUMBER + ]) ]); $message = new GetFromRec($opt); @@ -131,9 +131,9 @@ public function testCanMakeMiniRulesRequestForAllFUN() { $opt = new MiniRuleGetFromRecOptions([ 'pricing' => new Pricing([ - 'id' => Pricing::ALL_PRICINGS, - 'type' => Pricing::TYPE_FARE_UPSELL_RECOMMENDATION_NUMBER - ]) + 'id' => Pricing::ALL_PRICINGS, + 'type' => Pricing::TYPE_FARE_UPSELL_RECOMMENDATION_NUMBER + ]) ]); $message = new GetFromRec($opt); @@ -147,9 +147,9 @@ public function testCanMakeMiniRulesRequestForPNR() { $opt = new MiniRuleGetFromRecOptions([ 'pricing' => new Pricing([ - 'id' => "RECLOCNUM123", - 'type' => Pricing::TYPE_RECORD_LOCATOR - ]) + 'id' => "RECLOCNUM123", + 'type' => Pricing::TYPE_RECORD_LOCATOR + ]) ]); $message = new GetFromRec($opt); @@ -163,9 +163,9 @@ public function testCanMakeMiniRulesRequestForPNRWithSpecificPassenger() { $opt = new MiniRuleGetFromRecOptions([ 'pricing' => new Pricing([ - 'id' => "RECLOCNUM123", - 'type' => Pricing::TYPE_RECORD_LOCATOR - ]), + 'id' => "RECLOCNUM123", + 'type' => Pricing::TYPE_RECORD_LOCATOR + ]), 'filteringSelections' => [ new FilteringSelection([ 'type' => FilteringSelection::TYPE_PAX, @@ -188,9 +188,9 @@ public function testCanMakeMiniRulesRequestForPNRWithSpecificSegment() { $opt = new MiniRuleGetFromRecOptions([ 'pricing' => new Pricing([ - 'id' => "RECLOCNUM123", - 'type' => Pricing::TYPE_RECORD_LOCATOR - ]), + 'id' => "RECLOCNUM123", + 'type' => Pricing::TYPE_RECORD_LOCATOR + ]), 'filteringSelections' => [ new FilteringSelection([ 'type' => FilteringSelection::TYPE_SEGMENT, From 929e5b3cafe6d3f8d1fcf0932832e171c7d296d4 Mon Sep 17 00:00:00 2001 From: Aleksandr Kaluhyn Date: Thu, 24 Sep 2020 04:40:08 +0300 Subject: [PATCH 06/12] Add GroupRecords struct; Refactor test to use it --- .../Client/Struct/MiniRule/GetFromRec.php | 14 +++--- .../Client/Struct/MiniRule/GroupRecords.php | 43 +++++++++++++++++++ .../Client/Struct/MiniRule/GetFromRecTest.php | 40 ++++++++--------- 3 files changed, 72 insertions(+), 25 deletions(-) create mode 100644 src/Amadeus/Client/Struct/MiniRule/GroupRecords.php diff --git a/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php index 58c2385dc..c61351f09 100644 --- a/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php +++ b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php @@ -37,7 +37,7 @@ class GetFromRec */ public $language = null; /** - * @var array + * @var array|GroupRecords[] */ public $groupRecords = []; @@ -47,12 +47,16 @@ class GetFromRec */ public function __construct(MiniRuleGetFromRecOptions $options) { - $this->language = new Language($options->language->qualifier, $options->language->code); + $this->groupRecords[] = new GroupRecords(new RecordId($options->pricing->id, $options->pricing->type)); - $this->groupRecords['recordID'] = new RecordId($options->pricing->id, $options->pricing->type); + if (isset($options->language)) { + $this->language = new Language($options->language->qualifier, $options->language->code); + } - foreach ($options->filteringSelections as $filteringSelection) { - $this->groupRecords['filteringSelection']['referenceDetails'][] = new ReferenceDetails($filteringSelection->type, $filteringSelection->value); + if (isset($options->filteringSelections)) { + foreach ($options->filteringSelections as $filteringSelection) { + $this->groupRecords['filteringSelection']['referenceDetails'][] = new ReferenceDetails($filteringSelection->type, $filteringSelection->value); + } } } } diff --git a/src/Amadeus/Client/Struct/MiniRule/GroupRecords.php b/src/Amadeus/Client/Struct/MiniRule/GroupRecords.php new file mode 100644 index 000000000..fb4caf798 --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/GroupRecords.php @@ -0,0 +1,43 @@ + + */ +class GroupRecords +{ + /** + * @var RecordId + */ + public $recordId; + + public function __construct($recordId) + { + $this->recordId = $recordId; + } +} diff --git a/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php index 7aab90554..88457c303 100644 --- a/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php +++ b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php @@ -53,8 +53,8 @@ public function testCanMakeMiniRulesRequestForAllOffers() $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); + $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() @@ -71,8 +71,8 @@ public function testCanMakeMiniRulesRequestForSpecificOffer() $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); + $this->assertEquals(RecordId::REFERENCE_TYPE_OFFER, $message->groupRecords[0]->recordId->referenceType); + $this->assertEquals(2, $message->groupRecords[0]->recordId->uniqueReference); } public function testCanMakeMiniRulesRequestForAllPqrs() @@ -89,8 +89,8 @@ public function testCanMakeMiniRulesRequestForAllPqrs() $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); + $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() @@ -107,8 +107,8 @@ public function testCanMakeMiniRulesRequestForSpecificTst() $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); + $this->assertEquals(RecordId::REFERENCE_TYPE_TST, $message->groupRecords[0]->recordId->referenceType); + $this->assertEquals(1, $message->groupRecords[0]->recordId->uniqueReference); } public function testCanMakeMiniRulesRequestForAllFRN() @@ -123,8 +123,8 @@ public function testCanMakeMiniRulesRequestForAllFRN() $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); + $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() @@ -139,8 +139,8 @@ public function testCanMakeMiniRulesRequestForAllFUN() $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); + $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() @@ -155,8 +155,8 @@ public function testCanMakeMiniRulesRequestForPNR() $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->assertEquals(RecordId::REFERENCE_TYPE_RECORD_LOCATOR, $message->groupRecords[0]->recordId->referenceType); + $this->assertEquals("RECLOCNUM123", $message->groupRecords[0]->recordId->uniqueReference); } public function testCanMakeMiniRulesRequestForPNRWithSpecificPassenger() @@ -177,8 +177,8 @@ public function testCanMakeMiniRulesRequestForPNRWithSpecificPassenger() $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->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]->filteringSelections->referenceDetails); $this->assertEquals(ReferenceDetails::REFERENCE_TYPE_PAX, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->type); $this->assertEquals(1, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->value); @@ -202,8 +202,8 @@ public function testCanMakeMiniRulesRequestForPNRWithSpecificSegment() $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->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]->filteringSelections->referenceDetails); $this->assertEquals(ReferenceDetails::REFERENCE_TYPE_SEGMENT, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->type); $this->assertEquals(2, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->value); @@ -228,8 +228,8 @@ public function testCanMakeMiniRulesRequestForPNRWithSpecificLanguage() $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); + $this->assertEquals(RecordId::REFERENCE_TYPE_RECORD_LOCATOR, $message->groupRecords[0]->recordId->referenceType); + $this->assertEquals("RECLOCNUM123", $message->groupRecords[0]->recordId->uniqueReference); } } From 9b8557f87b9179cf52d073391e111fcbca5d90f4 Mon Sep 17 00:00:00 2001 From: Aleksandr Kaluhyn Date: Thu, 24 Sep 2020 04:51:40 +0300 Subject: [PATCH 07/12] Fix options initialization; --- .../Client/Struct/MiniRule/GetFromRecTest.php | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php index 88457c303..e295f27a9 100644 --- a/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php +++ b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php @@ -42,12 +42,10 @@ class GetFromRecTest extends BaseTestCase public function testCanMakeMiniRulesRequestForAllOffers() { $opt = new MiniRuleGetFromRecOptions([ - 'pricing' => [ - new Pricing([ - 'id' => Pricing::ALL_PRICINGS, - 'type' => Pricing::TYPE_OFFER - ]) - ] + 'pricing' => new Pricing([ + 'id' => Pricing::ALL_PRICINGS, + 'type' => Pricing::TYPE_OFFER + ]) ]); $message = new GetFromRec($opt); @@ -60,12 +58,10 @@ public function testCanMakeMiniRulesRequestForAllOffers() public function testCanMakeMiniRulesRequestForSpecificOffer() { $opt = new MiniRuleGetFromRecOptions([ - 'pricing' => [ - new Pricing([ - 'id' => 2, - 'type' => Pricing::TYPE_OFFER - ]) - ] + 'pricing' => new Pricing([ + 'id' => 2, + 'type' => Pricing::TYPE_OFFER + ]) ]); $message = new GetFromRec($opt); @@ -78,12 +74,10 @@ public function testCanMakeMiniRulesRequestForSpecificOffer() public function testCanMakeMiniRulesRequestForAllPqrs() { $opt = new MiniRuleGetFromRecOptions([ - 'pricing' => [ - new Pricing([ - 'id' => Pricing::ALL_PRICINGS, - 'type' => Pricing::TYPE_PROD_QUOTATION - ]) - ] + 'pricing' => new Pricing([ + 'id' => Pricing::ALL_PRICINGS, + 'type' => Pricing::TYPE_PROD_QUOTATION + ]) ]); $message = new GetFromRec($opt); @@ -96,12 +90,10 @@ public function testCanMakeMiniRulesRequestForAllPqrs() public function testCanMakeMiniRulesRequestForSpecificTst() { $opt = new MiniRuleGetFromRecOptions([ - 'pricing' => [ - new Pricing([ - 'id' => 1, - 'type' => Pricing::TYPE_TST - ]) - ] + 'pricing' => new Pricing([ + 'id' => 1, + 'type' => Pricing::TYPE_TST + ]) ]); $message = new GetFromRec($opt); From de424673150b95535caffa4ca0193bc31f064fe1 Mon Sep 17 00:00:00 2001 From: Aleksandr Kaluhyn Date: Thu, 24 Sep 2020 05:06:27 +0300 Subject: [PATCH 08/12] Add FilteringSelection struct; Refactoring; --- docs/samples.rst | 2 +- ...eringSelection.php => FilteringOption.php} | 2 +- .../MiniRuleGetFromRecOptions.php | 4 +- .../Struct/MiniRule/FilteringSelection.php | 38 +++++++++++++++++++ .../Client/Struct/MiniRule/GetFromRec.php | 14 ++++--- .../Client/Struct/MiniRule/GroupRecords.php | 9 ++--- .../Client/Struct/MiniRule/GetFromRecTest.php | 14 +++---- 7 files changed, 62 insertions(+), 21 deletions(-) rename src/Amadeus/Client/RequestOptions/MiniRule/{FilteringSelection.php => FilteringOption.php} (95%) create mode 100644 src/Amadeus/Client/Struct/MiniRule/FilteringSelection.php diff --git a/docs/samples.rst b/docs/samples.rst index 797d3b9ef..a1d9b2a20 100644 --- a/docs/samples.rst +++ b/docs/samples.rst @@ -3852,7 +3852,7 @@ Get MiniRules for specific PNR, and specific passenger 'qualifier' => Language::LQ_LANGUAGE_NORMALLY_USED, 'code' => "UA" ]), - 'filteringSelections' => [ + 'filteringOptions' => [ new FilteringSelection([ 'type' => FilteringSelection::TYPE_PAX, 'value' => 1 diff --git a/src/Amadeus/Client/RequestOptions/MiniRule/FilteringSelection.php b/src/Amadeus/Client/RequestOptions/MiniRule/FilteringOption.php similarity index 95% rename from src/Amadeus/Client/RequestOptions/MiniRule/FilteringSelection.php rename to src/Amadeus/Client/RequestOptions/MiniRule/FilteringOption.php index e87fe16f0..841228dd2 100644 --- a/src/Amadeus/Client/RequestOptions/MiniRule/FilteringSelection.php +++ b/src/Amadeus/Client/RequestOptions/MiniRule/FilteringOption.php @@ -31,7 +31,7 @@ * @package Amadeus\Client\RequestOptions\MiniRule * @author Aleksandr Kalugin */ -class FilteringSelection extends LoadParamsFromArray +class FilteringOption extends LoadParamsFromArray { const TYPE_PAX = 'P'; diff --git a/src/Amadeus/Client/RequestOptions/MiniRuleGetFromRecOptions.php b/src/Amadeus/Client/RequestOptions/MiniRuleGetFromRecOptions.php index 65ed5d76e..35362e99d 100644 --- a/src/Amadeus/Client/RequestOptions/MiniRuleGetFromRecOptions.php +++ b/src/Amadeus/Client/RequestOptions/MiniRuleGetFromRecOptions.php @@ -42,7 +42,7 @@ class MiniRuleGetFromRecOptions extends Base public $pricing = null; /** - * @var MiniRule\FilteringSelection[] + * @var MiniRule\FilteringOption[] */ - public $filteringSelections = []; + public $filteringOptions = []; } diff --git a/src/Amadeus/Client/Struct/MiniRule/FilteringSelection.php b/src/Amadeus/Client/Struct/MiniRule/FilteringSelection.php new file mode 100644 index 000000000..c7140fc9e --- /dev/null +++ b/src/Amadeus/Client/Struct/MiniRule/FilteringSelection.php @@ -0,0 +1,38 @@ + + */ +class FilteringSelection +{ + /** + * @var array|ReferenceDetails[] + */ + public $referenceDetails = []; +} \ No newline at end of file diff --git a/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php index c61351f09..bc722ff2d 100644 --- a/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php +++ b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php @@ -47,16 +47,20 @@ class GetFromRec */ public function __construct(MiniRuleGetFromRecOptions $options) { - $this->groupRecords[] = new GroupRecords(new RecordId($options->pricing->id, $options->pricing->type)); - if (isset($options->language)) { $this->language = new Language($options->language->qualifier, $options->language->code); } - if (isset($options->filteringSelections)) { - foreach ($options->filteringSelections as $filteringSelection) { - $this->groupRecords['filteringSelection']['referenceDetails'][] = new ReferenceDetails($filteringSelection->type, $filteringSelection->value); + $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 index fb4caf798..9d759a0a3 100644 --- a/src/Amadeus/Client/Struct/MiniRule/GroupRecords.php +++ b/src/Amadeus/Client/Struct/MiniRule/GroupRecords.php @@ -35,9 +35,8 @@ class GroupRecords * @var RecordId */ public $recordId; - - public function __construct($recordId) - { - $this->recordId = $recordId; - } + /** + * @var FilteringSelection + */ + public $filteringSelection; } diff --git a/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php index e295f27a9..fac9b5d86 100644 --- a/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php +++ b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php @@ -22,7 +22,7 @@ namespace Test\Amadeus\Client\Struct\MiniRule; -use Amadeus\Client\RequestOptions\MiniRule\FilteringSelection; +use Amadeus\Client\RequestOptions\MiniRule\FilteringOption; use Amadeus\Client\RequestOptions\MiniRule\Language; use Amadeus\Client\RequestOptions\MiniRule\Pricing; use Amadeus\Client\RequestOptions\MiniRuleGetFromRecOptions; @@ -158,9 +158,9 @@ public function testCanMakeMiniRulesRequestForPNRWithSpecificPassenger() 'id' => "RECLOCNUM123", 'type' => Pricing::TYPE_RECORD_LOCATOR ]), - 'filteringSelections' => [ - new FilteringSelection([ - 'type' => FilteringSelection::TYPE_PAX, + 'filteringOptions' => [ + new FilteringOption([ + 'type' => FilteringOption::TYPE_PAX, 'value' => 1 ]) ] @@ -183,9 +183,9 @@ public function testCanMakeMiniRulesRequestForPNRWithSpecificSegment() 'id' => "RECLOCNUM123", 'type' => Pricing::TYPE_RECORD_LOCATOR ]), - 'filteringSelections' => [ - new FilteringSelection([ - 'type' => FilteringSelection::TYPE_SEGMENT, + 'filteringOptions' => [ + new FilteringOption([ + 'type' => FilteringOption::TYPE_SEGMENT, 'value' => 2 ]) ] From 0d0201906830bfa486aa48091fc79208435ca432 Mon Sep 17 00:00:00 2001 From: Aleksandr Kaluhyn Date: Thu, 24 Sep 2020 05:07:24 +0300 Subject: [PATCH 09/12] Apply code style; --- src/Amadeus/Client/Struct/MiniRule/FilteringSelection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Amadeus/Client/Struct/MiniRule/FilteringSelection.php b/src/Amadeus/Client/Struct/MiniRule/FilteringSelection.php index c7140fc9e..7a25d623e 100644 --- a/src/Amadeus/Client/Struct/MiniRule/FilteringSelection.php +++ b/src/Amadeus/Client/Struct/MiniRule/FilteringSelection.php @@ -35,4 +35,4 @@ class FilteringSelection * @var array|ReferenceDetails[] */ public $referenceDetails = []; -} \ No newline at end of file +} From 0a527912dbe7134f67544bf91050d48b4252af33 Mon Sep 17 00:00:00 2001 From: Aleksandr Kaluhyn Date: Thu, 24 Sep 2020 05:12:12 +0300 Subject: [PATCH 10/12] Fix, use correct field; --- .../Client/Struct/MiniRule/GetFromRecTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php index fac9b5d86..fc60a81bb 100644 --- a/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php +++ b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php @@ -171,9 +171,9 @@ public function testCanMakeMiniRulesRequestForPNRWithSpecificPassenger() $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]->filteringSelections->referenceDetails); - $this->assertEquals(ReferenceDetails::REFERENCE_TYPE_PAX, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->type); - $this->assertEquals(1, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->value); + $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() @@ -196,9 +196,9 @@ public function testCanMakeMiniRulesRequestForPNRWithSpecificSegment() $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]->filteringSelections->referenceDetails); - $this->assertEquals(ReferenceDetails::REFERENCE_TYPE_SEGMENT, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->type); - $this->assertEquals(2, $message->groupRecords[0]->filteringSelections->referenceDetails[0]->value); + $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); } From ad8eb04935cd1ab508ce82ddfa84610651178891 Mon Sep 17 00:00:00 2001 From: Aleksandr Kaluhyn Date: Thu, 24 Sep 2020 05:19:13 +0300 Subject: [PATCH 11/12] Rename field to match xml field name; --- .../Client/Struct/MiniRule/GetFromRec.php | 2 +- .../Client/Struct/MiniRule/GroupRecords.php | 2 +- .../Client/Struct/MiniRule/GetFromRecTest.php | 40 +++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php index bc722ff2d..529ae6ac1 100644 --- a/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php +++ b/src/Amadeus/Client/Struct/MiniRule/GetFromRec.php @@ -52,7 +52,7 @@ public function __construct(MiniRuleGetFromRecOptions $options) } $obj = new GroupRecords(); - $obj->recordId = new RecordId($options->pricing->id, $options->pricing->type); + $obj->recordID = new RecordId($options->pricing->id, $options->pricing->type); if (isset($options->filteringOptions)) { $obj->filteringSelection = new FilteringSelection(); diff --git a/src/Amadeus/Client/Struct/MiniRule/GroupRecords.php b/src/Amadeus/Client/Struct/MiniRule/GroupRecords.php index 9d759a0a3..c1fcf8771 100644 --- a/src/Amadeus/Client/Struct/MiniRule/GroupRecords.php +++ b/src/Amadeus/Client/Struct/MiniRule/GroupRecords.php @@ -34,7 +34,7 @@ class GroupRecords /** * @var RecordId */ - public $recordId; + public $recordID; /** * @var FilteringSelection */ diff --git a/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php index fc60a81bb..0e9abe611 100644 --- a/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php +++ b/tests/Amadeus/Client/Struct/MiniRule/GetFromRecTest.php @@ -51,8 +51,8 @@ public function testCanMakeMiniRulesRequestForAllOffers() $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); + $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() @@ -67,8 +67,8 @@ public function testCanMakeMiniRulesRequestForSpecificOffer() $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); + $this->assertEquals(RecordId::REFERENCE_TYPE_OFFER, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals(2, $message->groupRecords[0]->recordID->uniqueReference); } public function testCanMakeMiniRulesRequestForAllPqrs() @@ -83,8 +83,8 @@ public function testCanMakeMiniRulesRequestForAllPqrs() $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); + $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() @@ -99,8 +99,8 @@ public function testCanMakeMiniRulesRequestForSpecificTst() $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); + $this->assertEquals(RecordId::REFERENCE_TYPE_TST, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals(1, $message->groupRecords[0]->recordID->uniqueReference); } public function testCanMakeMiniRulesRequestForAllFRN() @@ -115,8 +115,8 @@ public function testCanMakeMiniRulesRequestForAllFRN() $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); + $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() @@ -131,8 +131,8 @@ public function testCanMakeMiniRulesRequestForAllFUN() $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); + $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() @@ -147,8 +147,8 @@ public function testCanMakeMiniRulesRequestForPNR() $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->assertEquals(RecordId::REFERENCE_TYPE_RECORD_LOCATOR, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals("RECLOCNUM123", $message->groupRecords[0]->recordID->uniqueReference); } public function testCanMakeMiniRulesRequestForPNRWithSpecificPassenger() @@ -169,8 +169,8 @@ public function testCanMakeMiniRulesRequestForPNRWithSpecificPassenger() $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->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); @@ -194,8 +194,8 @@ public function testCanMakeMiniRulesRequestForPNRWithSpecificSegment() $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->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); @@ -220,8 +220,8 @@ public function testCanMakeMiniRulesRequestForPNRWithSpecificLanguage() $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); + $this->assertEquals(RecordId::REFERENCE_TYPE_RECORD_LOCATOR, $message->groupRecords[0]->recordID->referenceType); + $this->assertEquals("RECLOCNUM123", $message->groupRecords[0]->recordID->uniqueReference); } } From 21f700b1402372d8bad31cbfc064e4c6904eb36e Mon Sep 17 00:00:00 2001 From: Aleksandr Kaluhyn Date: Thu, 24 Sep 2020 19:33:48 +0300 Subject: [PATCH 12/12] Rename class name; --- docs/samples.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/samples.rst b/docs/samples.rst index a1d9b2a20..200b215a6 100644 --- a/docs/samples.rst +++ b/docs/samples.rst @@ -3853,8 +3853,8 @@ Get MiniRules for specific PNR, and specific passenger 'code' => "UA" ]), 'filteringOptions' => [ - new FilteringSelection([ - 'type' => FilteringSelection::TYPE_PAX, + new FilteringOption([ + 'type' => FilteringOption::TYPE_PAX, 'value' => 1 ]) ]