From c7cebc577714f82114acfd84485dc04c784207f3 Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Wed, 15 Feb 2017 16:58:46 +0200 Subject: [PATCH 1/3] Corporate qualifier --- .../RequestOptions/FareMasterPricerTbSearch.php | 14 ++++++++++++++ .../Struct/Fare/MasterPricer/CorporateId.php | 8 +++++++- .../Struct/Fare/MasterPricer/FareOptions.php | 5 +++-- .../Struct/Fare/MasterPricerTravelBoardSearch.php | 3 ++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/Amadeus/Client/RequestOptions/FareMasterPricerTbSearch.php b/src/Amadeus/Client/RequestOptions/FareMasterPricerTbSearch.php index e74989f2c..43c4122fb 100644 --- a/src/Amadeus/Client/RequestOptions/FareMasterPricerTbSearch.php +++ b/src/Amadeus/Client/RequestOptions/FareMasterPricerTbSearch.php @@ -64,6 +64,9 @@ class FareMasterPricerTbSearch extends Base const FLIGHTOPT_NO_SLICE_AND_DICE = "NSD"; const FLIGHTOPT_DISPLAY_MIN_MAX_STAY = "MST"; + const CORPORATE_QUALIFIER_AMADEUS_NEGO = "RC"; + const CORPORATE_QUALIFIER_UNIFARE = "RW"; + /** * Major cabin */ @@ -141,6 +144,17 @@ class FareMasterPricerTbSearch extends Base */ public $corporateCodesUnifares = []; + /** + * Corporate qualifier for returning Corporate Unifares + * + * In combination with fareType self::FARETYPE::CORPORATE_UNIFARES + * + * self::CORPORATE_QUALIFIER_* + * + * @var string + */ + public $corporateQualifier; + /** * The currency to convert to. * diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/CorporateId.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/CorporateId.php index b4a8d4a78..163d5f3fd 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricer/CorporateId.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/CorporateId.php @@ -30,7 +30,12 @@ */ class CorporateId { + const CORPORATE_QUALIFIER_AMADEUS_NEGO = "RC"; + const CORPORATE_QUALIFIER_UNIFARE = "RW"; + /** + * self::CORPORATE_QUALIFIER_* + * * @var string */ public $corporateQualifier; @@ -44,8 +49,9 @@ class CorporateId * * @param string[] $identity */ - public function __construct($identity) + public function __construct($identity, $corporateQualifier) { $this->identity = $identity; + $this->corporateQualifier = $corporateQualifier; } } diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/FareOptions.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/FareOptions.php index 4ebf2e95f..8d4d42bc7 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricer/FareOptions.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/FareOptions.php @@ -63,8 +63,9 @@ class FareOptions * @param bool $tickPreCheck Do Ticketability pre-check? * @param string|null $currency Override Currency conversion * @param \Amadeus\Client\RequestOptions\Fare\MPFeeId[]|null $flightOptions List of FeeIds + * @param string|null Corporate qualifier for Corporate Unifares */ - public function __construct(array $flightOptions, array $corpCodesUniFares, $tickPreCheck, $currency, $feeIds) + public function __construct(array $flightOptions, array $corpCodesUniFares, $tickPreCheck, $currency, $feeIds, $corporateQualifier) { if ($tickPreCheck === true) { $this->addPriceType(PricingTicketing::PRICETYPE_TICKETABILITY_PRECHECK); @@ -75,7 +76,7 @@ public function __construct(array $flightOptions, array $corpCodesUniFares, $tic if ($flightOption === PricingTicketing::PRICETYPE_CORPORATE_UNIFARES) { $this->corporate = new Corporate(); - $this->corporate->corporateId[] = new CorporateId($corpCodesUniFares); + $this->corporate->corporateId[] = new CorporateId($corpCodesUniFares, $corporateQualifier); } } diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php b/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php index 27c96bba1..f9b612781 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php @@ -148,7 +148,8 @@ protected function loadOptions($options) $options->corporateCodesUnifares, $options->doTicketabilityPreCheck, $options->currencyOverride, - $options->feeIds + $options->feeIds, + $options->corporateQualifier ); } From 2a827510219907ed6b7ce1b5f1de33eb351c8374 Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Wed, 15 Feb 2017 17:18:24 +0200 Subject: [PATCH 2/3] Update test and sample --- docs/samples/masterpricertravelboard.rst | 3 ++- .../Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/samples/masterpricertravelboard.rst b/docs/samples/masterpricertravelboard.rst index 8b2230758..11a2d48f1 100644 --- a/docs/samples/masterpricertravelboard.rst +++ b/docs/samples/masterpricertravelboard.rst @@ -366,7 +366,8 @@ Simple flight, request published fares, unifares and corporate unifares (with a FareMasterPricerTbSearch::FLIGHTOPT_UNIFARES, FareMasterPricerTbSearch::FLIGHTOPT_CORPORATE_UNIFARES, ], - 'corporateCodesUnifares' => ['123456'] + 'corporateCodesUnifares' => ['123456'], + 'corporateQualifier' => FareMasterPricerTbSearch::CORPORATE_QUALIFIER_UNIFARE ]); diff --git a/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php b/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php index 2bc258129..ccfa62149 100644 --- a/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php +++ b/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php @@ -665,7 +665,8 @@ public function testCanMakeMessageWithPublishedUnifaresCorporateUnifares() FareMasterPricerTbSearch::FLIGHTOPT_UNIFARES, FareMasterPricerTbSearch::FLIGHTOPT_CORPORATE_UNIFARES, ], - 'corporateCodesUnifares' => ['123456'] + 'corporateCodesUnifares' => ['123456'], + 'corporateQualifier' => FareMasterPricerTbSearch::CORPORATE_QUALIFIER_UNIFARE ]); $message = new MasterPricerTravelBoardSearch($opt); @@ -680,6 +681,7 @@ public function testCanMakeMessageWithPublishedUnifaresCorporateUnifares() $message->fareOptions->pricingTickInfo->pricingTicketing->priceType ); $this->assertEquals('123456', $message->fareOptions->corporate->corporateId[0]->identity[0]); + $this->assertEquals(FareMasterPricerTbSearch::CORPORATE_QUALIFIER_UNIFARE, $message->fareOptions->corporate->corporateId[0]->corporateQualifier); } public function testCanMakeMessageWithPriceToBeat() From ffdf3a798fa18a19091bc5ff01f1a9094b5a6456 Mon Sep 17 00:00:00 2001 From: Michal Hernas Date: Fri, 24 Feb 2017 23:13:19 +0200 Subject: [PATCH 3/3] Added office ids --- .../FareMasterPricerTbSearch.php | 7 +++ .../Fare/MasterPricer/OfficeIdDetails.php | 47 +++++++++++++++++++ .../Fare/MasterPricer/OfficeIdInformation.php | 47 +++++++++++++++++++ .../MasterPricer/OfficeIdentification.php | 47 +++++++++++++++++++ .../Fare/MasterPricerTravelBoardSearch.php | 14 +++++- .../MasterPricerTravelBoardSearchTest.php | 39 +++++++++++++++ 6 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 src/Amadeus/Client/Struct/Fare/MasterPricer/OfficeIdDetails.php create mode 100644 src/Amadeus/Client/Struct/Fare/MasterPricer/OfficeIdInformation.php create mode 100644 src/Amadeus/Client/Struct/Fare/MasterPricer/OfficeIdentification.php diff --git a/src/Amadeus/Client/RequestOptions/FareMasterPricerTbSearch.php b/src/Amadeus/Client/RequestOptions/FareMasterPricerTbSearch.php index 43c4122fb..1d26e8ac3 100644 --- a/src/Amadeus/Client/RequestOptions/FareMasterPricerTbSearch.php +++ b/src/Amadeus/Client/RequestOptions/FareMasterPricerTbSearch.php @@ -225,4 +225,11 @@ class FareMasterPricerTbSearch extends Base * @var Fare\MPFareFamily[] */ public $fareFamilies = []; + + /** + * Office IDs + * + * @var string[] + */ + public $officeIds = []; } diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/OfficeIdDetails.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/OfficeIdDetails.php new file mode 100644 index 000000000..35e8a765b --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/OfficeIdDetails.php @@ -0,0 +1,47 @@ + + */ +class OfficeIdDetails +{ + /** + * OfficeId Information + * + * @var OfficeIdInformation + */ + public $officeIdInformation; + + /** + * @param string $officeId + */ + public function __construct($officeId) + { + $this->officeIdInformation = new OfficeIdInformation($officeId); + } +} diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/OfficeIdInformation.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/OfficeIdInformation.php new file mode 100644 index 000000000..2203bb35c --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/OfficeIdInformation.php @@ -0,0 +1,47 @@ + + */ +class OfficeIdInformation +{ + /** + * OfficeId Identification + * + * @var OfficeIdentification + */ + public $officeIdentification; + + /** + * @param string $officeId + */ + public function __construct($officeId) + { + $this->officeIdentification = new OfficeIdentification($officeId); + } +} diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricer/OfficeIdentification.php b/src/Amadeus/Client/Struct/Fare/MasterPricer/OfficeIdentification.php new file mode 100644 index 000000000..471cd4584 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/MasterPricer/OfficeIdentification.php @@ -0,0 +1,47 @@ + + */ +class OfficeIdentification +{ + /** + * Agent Sign In + * + * @var string + */ + public $agentSignin; + + /** + * @param string $officeId + */ + public function __construct($officeId) + { + $this->agentSignin = $officeId; + } +} diff --git a/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php b/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php index f9b612781..3cc31b2cb 100644 --- a/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php +++ b/src/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearch.php @@ -117,7 +117,7 @@ class MasterPricerTravelBoardSearch extends BaseWsMessage */ public $feeOption; /** - * @var mixed + * @var MasterPricer\OfficeIdDetails[] */ public $officeIdDetails; @@ -164,6 +164,10 @@ protected function loadOptions($options) $this->loadItinerary($itinerary, $segmentCounter); } + foreach ($options->officeIds as $officeId) { + $this->loadOfficeId($officeId); + } + if ($this->checkAnyNotEmpty( $options->cabinClass, $options->cabinOption, @@ -188,6 +192,14 @@ protected function loadOptions($options) $this->loadFareFamilies($options->fareFamilies); } + /** + * @param string $officeId + */ + protected function loadOfficeId($officeId) + { + $this->officeIdDetails[] = new MasterPricer\OfficeIdDetails($officeId); + } + /** * @param MPPassenger $passenger * @param int $counter BYREF diff --git a/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php b/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php index ccfa62149..d6dca372a 100644 --- a/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php +++ b/tests/Amadeus/Client/Struct/Fare/MasterPricerTravelBoardSearchTest.php @@ -684,6 +684,45 @@ public function testCanMakeMessageWithPublishedUnifaresCorporateUnifares() $this->assertEquals(FareMasterPricerTbSearch::CORPORATE_QUALIFIER_UNIFARE, $message->fareOptions->corporate->corporateId[0]->corporateQualifier); } + public function testCanMakeMessageWithManyOfficeIDs() + { + $opt = new FareMasterPricerTbSearch([ + 'nrOfRequestedResults' => 30, + 'nrOfRequestedPassengers' => 1, + 'passengers' => [ + new MPPassenger([ + 'type' => MPPassenger::TYPE_ADULT, + 'count' => 1 + ]) + ], + 'itinerary' => [ + new MPItinerary([ + 'departureLocation' => new MPLocation(['city' => 'BER']), + 'arrivalLocation' => new MPLocation(['city' => 'MOW']), + 'date' => new MPDate([ + 'dateTime' => new \DateTime('2017-05-01T00:00:00+0000', new \DateTimeZone('UTC')) + ]) + ]) + ], + 'flightOptions' => [ + FareMasterPricerTbSearch::FLIGHTOPT_PUBLISHED, + FareMasterPricerTbSearch::FLIGHTOPT_UNIFARES, + FareMasterPricerTbSearch::FLIGHTOPT_CORPORATE_UNIFARES, + ], + 'officeIds' => ['A', 'B'] + ]); + + $message = new MasterPricerTravelBoardSearch($opt); + + $this->assertCount(2, $message->officeIdDetails); + $this->assertEquals('A', + $message->officeIdDetails[0]->officeIdInformation->officeIdentification->agentSignin + ); + $this->assertEquals('B', + $message->officeIdDetails[1]->officeIdInformation->officeIdentification->agentSignin + ); + } + public function testCanMakeMessageWithPriceToBeat() { $opt = new FareMasterPricerTbSearch([