diff --git a/README.md b/README.md index 107f5c9a2..0f8fa9c92 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,15 @@ Update composer to get the client: composer update ``` +# Warning: under active development + +This library is under active development. The public API's could change any time at the moment! + +We will release a 0.1 version when we feel the library is stable enough, after which we will be following semantic versioning. + +For now, if you want the bleeding edge, point your composer.json towards `dev-develop`. If you only want what we have verified as working, go for `dev-master`. + # Usage - [About & Get Started](docs/about-get-started.rst) -- [Examples](docs/samples.rst) \ No newline at end of file +- [Examples](docs/samples.rst) diff --git a/docs/about-get-started.rst b/docs/about-get-started.rst index e1ae3d976..bd5936994 100644 --- a/docs/about-get-started.rst +++ b/docs/about-get-started.rst @@ -94,7 +94,9 @@ This is the list of messages that are at least partially supported at this time: - Security_SignOut - PNR_Retrieve - PNR_RetrieveAndDisplay -- PNR_AddMultiElements *(Currently there is one call to create a PNR, later support will be added for modifying PNR's)* +- PNR_AddMultiElements (pnrCreate to create a PNR from scratch) +- PNR_AddMultiElements (possibility to do actionCode operations on a PNR in context without further actions) +- PNR_Cancel - Queue_List - Queue_PlacePNR - Queue_RemoveItem @@ -104,9 +106,11 @@ This is the list of messages that are at least partially supported at this time: - Air_SellFromRecommendation - Offer_VerifyOffer - Offer_ConfirmAirOffer -- Command_Cryptic - MiniRule_GetFromPricingRec - Ticket_CreateTSTFromPricing +- Command_Cryptic +- PriceXplorer_ExtremeSearch + We plan to support an entire basic booking flow (MasterPricer, SellFromRecommendation, Pricing, ...) later on. @@ -126,7 +130,6 @@ On the to-do list / work in progress: - Fare_CalculateMileage - Info_EncodeDecodeCity - Offer_ConfirmHotelOffer -- PriceXplorer_ExtremeSearch - PointOfRef_Search - Ticket_DisplayTST diff --git a/docs/samples.rst b/docs/samples.rst index d25722803..c2db57c79 100644 --- a/docs/samples.rst +++ b/docs/samples.rst @@ -117,10 +117,23 @@ Creating a PNR (simplified example containing only the most basic PNR elements n 'value' => '+3222222222' ]); - //The required Received From (RF) element will automatically be added by the library. + //The required Received From (RF) element will automatically be added by the library if you didn't provide one. $createdPnr = $client->pnrCreatePnr($opt); + +Save a PNR which you have in context (created with actionCode 0 for example) and is now ready to be saved: + +.. code-block:: php + + use Amadeus\Client\RequestOptions\PnrAddMultiElementsOptions; + + $pnrReply = $client->pnrAddMultiElements( + new PnrAddMultiElementsOptions([ + 'actionCode' => 11 //ET / END AND RETRIEVE + ]) + ); + ------------ PNR_Retrieve ------------ @@ -129,8 +142,10 @@ Retrieving a PNR: .. code-block:: php + use Amadeus\Client\RequestOptions\PnrRetrieveOptions; + $pnrContent = $client->pnrRetrieve( - new Amadeus\Client\RequestOptions\PnrRetrieveOptions(['recordLocator' => 'ABC123']) + new PnrRetrieveOptions(['recordLocator' => 'ABC123']) ); @@ -142,13 +157,83 @@ Retrieving a PNR with PNR content AND all offers: .. code-block:: php + use Amadeus\Client\RequestOptions\PnrRetrieveAndDisplayOptions; + $pnrContent = $client->pnrRetrieveAndDisplay( - new Amadeus\Client\RequestOptions\PnrRetrieveAndDisplayOptions([ + new PnrRetrieveAndDisplayOptions([ 'recordLocator' => 'ABC123', - 'retrieveOption' => Client\RequestOptions\PnrRetrieveAndDisplayOptions::RETRIEVEOPTION_ALL + 'retrieveOption' => PnrRetrieveAndDisplayOptions::RETRIEVEOPTION_ALL + ]) + ); + +---------- +PNR_Cancel +---------- + +Cancel the entire itinerary of the PNR in context and do an end transact to save the changes: + +.. code-block:: php + + use Amadeus\Client\RequestOptions\PnrCancelOptions; + + $cancelReply = $client->pnrCancel( + new PnrCancelOptions([ + 'cancelItinerary' => true, + 'actionCode' => 10 + ]) + ); + + +Cancel a PNR element with tatoo number 15 and do an End and Retrieve (ER) to receive the resulting PNR_Reply: + +.. code-block:: php + + use Amadeus\Client\RequestOptions\PnrCancelOptions; + + $cancelReply = $client->pnrCancel( + new PnrCancelOptions([ + 'elementsByTatoo' => [15], + 'actionCode' => 11 + ]) + ); + +Same as before, but this time without having a PNR in context (you must provide the PNR's record locator) + +.. code-block:: php + + use Amadeus\Client\RequestOptions\PnrCancelOptions; + + $cancelReply = $client->pnrCancel( + new PnrCancelOptions([ + 'recordLocator' => 'ABC123, + 'elementsByTatoo' => [15], + 'actionCode' => 11 ]) ); +Cancel the Offer with Offer reference 1: + +.. code-block:: php + + use Amadeus\Client\RequestOptions\PnrCancelOptions; + + $cancelReply = $client->pnrCancel( + new PnrCancelOptions([ + 'offers' => [1] + ]) + ); + +Remove passenger with passenger reference 2 from the PNR: + +.. code-block:: php + + use Amadeus\Client\RequestOptions\PnrCancelOptions; + + $cancelReply = $client->pnrCancel( + new PnrCancelOptions([ + 'passengers' => [2] + ]) + ); ***** Queue @@ -162,9 +247,12 @@ Get a list of all PNR's on a given queue: .. code-block:: php + use Amadeus\Client\RequestOptions\QueueListOptions; + use Amadeus\Client\RequestOptions\Queue; + $queueContent = $client->queueList( - new Amadeus\Client\RequestOptions\QueueListOptions([ - 'queue' => new Client\RequestOptions\Queue([ + new QueueListOptions([ + 'queue' => new Queue([ 'queue' => 50, 'category' => 0 ]) @@ -179,9 +267,12 @@ Place a PNR on a queue: .. code-block:: php + use Amadeus\Client\RequestOptions\QueuePlacePnrOptions; + use Amadeus\Client\RequestOptions\Queue; + $placeResult = $client->queuePlacePnr( - new Amadeus\Client\RequestOptions\QueuePlacePnrOptions([ - 'targetQueue' => new Client\RequestOptions\Queue([ + new QueuePlacePnrOptions([ + 'targetQueue' => new Queue([ 'queue' => 50, 'category' => 0 ]), @@ -197,9 +288,12 @@ Remove a PNR from a queue: .. code-block:: php + use Amadeus\Client\RequestOptions\QueueRemoveItemOptions; + use Amadeus\Client\RequestOptions\Queue; + $removeResult = $client->queueRemoveItem( - new Amadeus\Client\RequestOptions\QueueRemoveItemOptions([ - 'queue' => new Amadeus\Client\RequestOptions\Queue([ + new QueueRemoveItemOptions([ + 'queue' => new Queue([ 'queue' => 50, 'category' => 0 ]), @@ -215,13 +309,16 @@ Move a PNR from one queue to another: .. code-block:: php + use Amadeus\Client\RequestOptions\QueueMoveItemOptions; + use Amadeus\Client\RequestOptions\Queue; + $moveResult = $client->queueMoveItem( - new Amadeus\Client\RequestOptions\QueueMoveItemOptions([ - 'sourceQueue' => new Amadeus\Client\RequestOptions\Queue([ + new QueueMoveItemOptions([ + 'sourceQueue' => new Queue([ 'queue' => 50, 'category' => 0 ]), - 'destinationQueue' => new Amadeus\Client\RequestOptions\Queue([ + 'destinationQueue' => new Queue([ 'queue' => 60, 'category' => 3 ]), @@ -241,20 +338,26 @@ Make a simple Masterpricer availability & fare search: .. code-block:: php - $opt = new Amadeus\Client\RequestOptions\FareMasterPricerTbSearch([ + use Amadeus\Client\RequestOptions\FareMasterPricerTbSearch; + use Amadeus\Client\RequestOptions\Fare\MPPassenger; + use Amadeus\Client\RequestOptions\Fare\MPItinerary; + use Amadeus\Client\RequestOptions\Fare\MPDate; + use Amadeus\Client\RequestOptions\Fare\MPLocation; + + $opt = new FareMasterPricerTbSearch([ 'nrOfRequestedResults' => 200, 'nrOfRequestedPassengers' => 1, 'passengers' => [ - new Amadeus\Client\RequestOptions\Fare\MPPassenger([ - 'type' => Amadeus\Client\RequestOptions\Fare\MPPassenger::TYPE_ADULT, + new MPPassenger([ + 'type' => MPPassenger::TYPE_ADULT, 'count' => 1 ]) ], 'itinerary' => [ - new Amadeus\Client\RequestOptions\Fare\MPItinerary([ - 'departureLocation' => new Amadeus\Client\RequestOptions\Fare\MPLocation(['city' => 'BRU']), - 'arrivalLocation' => new Amadeus\Client\RequestOptions\Fare\MPLocation(['city' => 'LON']), - 'date' => new Amadeus\Client\RequestOptions\Fare\MPDate([ + new MPItinerary([ + 'departureLocation' => new MPLocation(['city' => 'BRU']), + 'arrivalLocation' => new MPLocation(['city' => 'LON']), + 'date' => new MPDate([ 'date' => new \DateTime('2017-01-15T00:00:00+0000', new \DateTimeZone('UTC')) ]) ]) @@ -271,11 +374,13 @@ Do a pricing on the PNR in context: .. code-block:: php - $opt = new Amadeus\Client\RequestOptions\FarePricePnrWithBookingClassOptions([ - 'validatingCarrier' => 'SN' - ]); + use Amadeus\Client\RequestOptions\FarePricePnrWithBookingClassOptions; - $pricingResponse = $client->farePricePnrWithBookingClass($opt); + $pricingResponse = $client->farePricePnrWithBookingClass( + new FarePricePnrWithBookingClassOptions([ + 'validatingCarrier' => 'SN' + ]) + ); *** @@ -327,6 +432,20 @@ Ticket_CreateTSTFromPricing Create a TST from a Pricing made by a Fare_PricePNRWithBookingClass call: +.. code-block:: php + + use Amadeus\Client\RequestOptions\TicketCreateTstFromPricingOptions; + use Amadeus\Client\RequestOptions\Ticket\Pricing; + + $createTstResponse = $client->ticketCreateTSTFromPricing( + new TicketCreateTstFromPricingOptions([ + 'pricings' => [ + new Pricing([ + 'tstNumber' => 1 + ]) + ] + ]) + ); ----------------- Ticket_DisplayTST @@ -343,10 +462,31 @@ Offer_VerifyOffer ----------------- Verify if an offer is still valid: +.. code-block:: php + + use Amadeus\Client\RequestOptions\OfferVerifyOptions; + + $offerVerifyResponse = $client->offerVerify( + new OfferVerifyOptions([ + 'offerReference' => 1, + 'segmentName' => 'AIR' + ]) + ); + --------------------- Offer_ConfirmAirOffer --------------------- -Confirm a given AIR offer: +Confirm a given AIR offer by providing office reference / tatoo: + +.. code-block:: php + + use Amadeus\Client\RequestOptions\OfferConfirmAirOptions; + + $response = $client->offerConfirmAir( + new OfferConfirmAirOptions([ + 'tatooNumber' => 1 + ]) + ); ----------------------- Offer_ConfirmHotelOffer @@ -366,19 +506,17 @@ Get MiniRules for a pricing in context (either a TST pricing, Offers or a pricin use Amadeus\Client\RequestOptions\MiniRuleGetFromPricingRecOptions; use Amadeus\Client\RequestOptions\MiniRule\Pricing; - use Amadeus\Client; - - $opt = new MiniRuleGetFromPricingRecOptions([ - 'pricings' => [ - new Pricing([ - 'type' => Pricing::TYPE_TST, - 'id' => Pricing::ALL_PRICINGS - ]) - ] - ]); - - $miniRules = $client->miniRuleGetFromPricingRec($opt); + $miniRules = $client->miniRuleGetFromPricingRec( + new MiniRuleGetFromPricingRecOptions([ + 'pricings' => [ + new Pricing([ + 'type' => Pricing::TYPE_TST, + 'id' => Pricing::ALL_PRICINGS + ]) + ] + ]) + ); *************** @@ -398,3 +536,24 @@ Send any cryptic Amadeus Selling Platform entry which does not have a structured $crypticResponse = $client->commandCryptic($opt); +************************** +PriceXplorer_ExtremeSearch +************************** + +Request a basic Extreme Search result: + +.. code-block:: php + + use Amadeus\Client\RequestOptions\PriceXplorerExtremeSearchOptions; + + $opt = new PriceXplorerExtremeSearchOptions([ + 'resultAggregationOption' => PriceXplorerExtremeSearchOptions::AGGR_COUNTRY, + 'origin' => 'BRU', + 'destinations' => ['SYD', 'CBR'], + 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-08-25', new \DateTimeZone('UTC')), + 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-09-28', new \DateTimeZone('UTC')), + 'searchOffice' => 'LONBG2222' + ]); + + $extremeSearchResult = $client->priceXplorerExtremeSearch($opt); + diff --git a/src/Amadeus/Client.php b/src/Amadeus/Client.php index 74b341383..f7b92589e 100644 --- a/src/Amadeus/Client.php +++ b/src/Amadeus/Client.php @@ -49,9 +49,7 @@ * * * - implement more PNR_AddMultiElements: - * ABU segment * OSI segment - * SSR segment * * @package Amadeus * @author Dieter Devlieghere @@ -298,6 +296,28 @@ public function pnrRetrieveAndDisplay(RequestOptions\PnrRetrieveAndDisplayOption ); } + /** + * PNR_Cancel + * + * @param RequestOptions\PnrCancelOptions $options + * @param array $messageOptions + * @return mixed + */ + public function pnrCancel(RequestOptions\PnrCancelOptions $options, $messageOptions = []) + { + $msgName = 'PNR_Cancel'; + $messageOptions = $this->makeMessageOptions($messageOptions, true); + + return $this->sessionHandler->sendMessage( + $msgName, + $this->requestCreator->createRequest( + $msgName, + $options + ), + $messageOptions + ); + } + /** * Queue_List - get a list of all PNR's on a given queue * @@ -614,6 +634,51 @@ public function infoEncodeDecodeCity(RequestOptions\InfoEncodeDecodeCityOptions ); } + + /** + * Ticket_CreateTSTFromPricing + * + * @param RequestOptions\TicketCreateTstFromPricingOptions $options + * @param array $messageOptions + * @return mixed + */ + public function ticketCreateTSTFromPricing(RequestOptions\TicketCreateTstFromPricingOptions $options, $messageOptions = []) + { + $msgName = 'Ticket_CreateTSTFromPricing'; + $messageOptions = $this->makeMessageOptions($messageOptions); + + return $this->sessionHandler->sendMessage( + $msgName, + $this->requestCreator->createRequest( + $msgName, + $options + ), + $messageOptions + ); + } + + /** + * PriceXplorer_ExtremeSearch + * + * @param RequestOptions\PriceXplorerExtremeSearchOptions $options + * @param array $messageOptions + * @return mixed + */ + public function priceXplorerExtremeSearch(RequestOptions\PriceXplorerExtremeSearchOptions $options, $messageOptions = []) + { + $msgName = 'PriceXplorer_ExtremeSearch'; + $messageOptions = $this->makeMessageOptions($messageOptions); + + return $this->sessionHandler->sendMessage( + $msgName, + $this->requestCreator->createRequest( + $msgName, + $options + ), + $messageOptions + ); + } + /** * Make message options * diff --git a/src/Amadeus/Client/Params/SessionHandlerParams.php b/src/Amadeus/Client/Params/SessionHandlerParams.php index 077a3d70a..23919a72a 100644 --- a/src/Amadeus/Client/Params/SessionHandlerParams.php +++ b/src/Amadeus/Client/Params/SessionHandlerParams.php @@ -95,7 +95,7 @@ protected function loadFromArray(array $params) { } $this->wsdl = (isset($params['wsdl'])) ? $params['wsdl'] : null; $this->stateful = (isset($params['stateful'])) ? $params['stateful'] : true; - $this->logger = ($params['logger'] instanceof LoggerInterface) ? $params['logger'] : null; + $this->logger = (isset($params['logger']) && $params['logger'] instanceof LoggerInterface) ? $params['logger'] : null; if (isset($params['authParams'])) { if ($params['authParams'] instanceof AuthParams) { diff --git a/src/Amadeus/Client/RequestCreator/Base.php b/src/Amadeus/Client/RequestCreator/Base.php index f12d482eb..ce9e5d7a5 100644 --- a/src/Amadeus/Client/RequestCreator/Base.php +++ b/src/Amadeus/Client/RequestCreator/Base.php @@ -37,14 +37,17 @@ use Amadeus\Client\RequestOptions\Pnr\Element\ReceivedFrom; use Amadeus\Client\RequestOptions\PnrAddMultiElementsBase; use Amadeus\Client\RequestOptions\PnrAddMultiElementsOptions; +use Amadeus\Client\RequestOptions\PnrCancelOptions; use Amadeus\Client\RequestOptions\PnrCreatePnrOptions; use Amadeus\Client\RequestOptions\PnrRetrieveAndDisplayOptions; use Amadeus\Client\RequestOptions\PnrRetrieveOptions; +use Amadeus\Client\RequestOptions\PriceXplorerExtremeSearchOptions; use Amadeus\Client\RequestOptions\QueueListOptions; use Amadeus\Client\RequestOptions\QueueMoveItemOptions; use Amadeus\Client\RequestOptions\QueuePlacePnrOptions; use Amadeus\Client\RequestOptions\QueueRemoveItemOptions; use Amadeus\Client\RequestOptions\RequestOptionsInterface; +use Amadeus\Client\RequestOptions\TicketCreateTstFromPricingOptions; use Amadeus\Client\Struct; /** @@ -96,11 +99,17 @@ public function createRequest($messageName, RequestOptionsInterface $params) } } + /** + * @return Struct\Security\Authenticate + */ protected function createSecurityAuthenticate() { - //TODO Only needed for SoapHeader 1 and 2 messages. + return new Struct\Security\Authenticate(); } + /** + * @return Struct\Security\SignOut + */ protected function createSecuritySignOut() { return new Struct\Security\SignOut(); @@ -142,13 +151,25 @@ protected function createPnrRetrieveAndDisplay(PnrRetrieveAndDisplayOptions $par */ protected function createPnrAddMultiElements(PnrAddMultiElementsBase $params) { - $params->receivedFrom = $this->params->receivedFrom; + if ($params instanceof PnrCreatePnrOptions && empty($params->receivedFrom)) { + //Automagically add RF if not present: + $params->receivedFrom = $this->params->receivedFrom; + } $req = new Struct\Pnr\AddMultiElements($params); return $req; } + /** + * @param PnrCancelOptions $params + * @return Struct\Pnr\Cancel + */ + protected function createPNRCancel(PnrCancelOptions $params) + { + return new Struct\Pnr\Cancel($params); + } + /** * @param QueueListOptions $params * @return Struct\Queue\QueueList @@ -247,7 +268,7 @@ protected function createOfferConfirmHotelOffer(OfferConfirmHotelOptions $params * @param OfferConfirmCarOptions $params * @return Struct\Offer\ConfirmCar */ - protected function createOfferConfirmCar(OfferConfirmCarOptions $params) + protected function createOfferConfirmCarOffer(OfferConfirmCarOptions $params) { return new Struct\Offer\ConfirmCar($params); } @@ -322,6 +343,26 @@ protected function createFarePricePnrWithBookingClass(FarePricePnrWithBookingCla } } + /** + * @param TicketCreateTstFromPricingOptions $params + * + * @return Struct\Ticket\CreateTSTFromPricing + */ + protected function createTicketCreateTSTFromPricing(TicketCreateTstFromPricingOptions $params) + { + return new Struct\Ticket\CreateTSTFromPricing($params); + } + + /** + * @param PriceXplorerExtremeSearchOptions $params + * + * @return Struct\PriceXplorer\ExtremeSearch + */ + protected function createPriceXplorerExtremeSearch(PriceXplorerExtremeSearchOptions $params) + { + return new Struct\PriceXplorer\ExtremeSearch($params); + } + /** * Check if a given message is in the active WSDL. Throws exception if it isn't. * diff --git a/src/Amadeus/Client/RequestOptions/Pnr/Element/AccountingInfo.php b/src/Amadeus/Client/RequestOptions/Pnr/Element/AccountingInfo.php new file mode 100644 index 000000000..d3833b406 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/Pnr/Element/AccountingInfo.php @@ -0,0 +1,61 @@ + + */ +class OtherServiceInfo +{ + +} diff --git a/src/Amadeus/Client/RequestOptions/PnrAddMultiElementsBase.php b/src/Amadeus/Client/RequestOptions/PnrAddMultiElementsBase.php index a1a2fd4bf..554a1fa47 100644 --- a/src/Amadeus/Client/RequestOptions/PnrAddMultiElementsBase.php +++ b/src/Amadeus/Client/RequestOptions/PnrAddMultiElementsBase.php @@ -30,5 +30,29 @@ */ class PnrAddMultiElementsBase extends Base { + /** + * How to handle the PNR after creating + * + * 0 No special processing + * 10 End transact (ET) + * 11 End transact with retrieve (ER) + * 12 End transact and change advice codes (ETK) + * 13 End transact with retrieve and change advice codes (ERK) + * 14 End transact split PNR (EF) + * 15 Cancel the itinerary for all PNRs connected by the AXR and end transact (ETX) + * 16 Cancel the itinerary for all PNRs connected by the AXR and end transact with retrieve (ERX) + * 20 Ignore (IG) + * 21 Ignore and retrieve (IR) + * 267 Stop EOT if segment sell error + * 30 Show warnings at first EOT + * 50 Reply with short message + * + * @var int + */ + public $actionCode = 0; + /** + * @var string + */ + public $receivedFrom; } diff --git a/src/Amadeus/Client/RequestOptions/PnrCancelOptions.php b/src/Amadeus/Client/RequestOptions/PnrCancelOptions.php new file mode 100644 index 000000000..f341f3fc9 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/PnrCancelOptions.php @@ -0,0 +1,98 @@ + + */ +class PriceXplorerExtremeSearchOptions extends Base +{ + const CURRENCY_EURO = "EUR"; + + const AGGR_DEST = 'D'; + + const AGGR_DEST_WEEK = 'DW'; + + const AGGR_DEST_WEEK_DEPART = 'DWDP'; + + const AGGR_DEST_WEEK_DEPART_STAY = 'DWDPS'; + + const AGGR_COUNTRY = 'C'; + + /** + * Departure location - airport or city code + * + * @var string + */ + public $origin; + + /** + * Destination locations - array of airport or city codes + * + * @var array + */ + public $destinations = []; + + /** + * Destination countries - array of country codes + * + * @var array + */ + public $destinationCountries = []; + + /** + * Currency for max/min budget options + * + * @var string + */ + public $currency; + + /** + * Maximum budget, expressed in $this->currency currency. + * + * @var int + */ + public $maxBudget; + + /** + * Minimum budget, expressed in $this->currency currency. + * + * @var int + */ + public $minBudget; + + /** + * Earliest possible departure date. + * + * @var \DateTime + */ + public $earliestDepartureDate; + + /** + * Latest possible departure date. + * + * @var \DateTime + */ + public $latestDepartureDate; + + /** + * (Consecutive) departure days of week for outbound flight + * + * 1: Monday + * 2: Tuesday + * 3: Wednesday + * 4: Thursday + * 5: Friday + * 6: Saturday + * 7: Sunday + * + * @var array + */ + public $departureDaysOutbound = []; + + /** + * (Consecutive) departure days of week for inbound flight + * + * 1: Monday + * 2: Tuesday + * 3: Wednesday + * 4: Thursday + * 5: Friday + * 6: Saturday + * 7: Sunday + * + * @var array + */ + public $departureDaysInbound = []; + + /** + * Stay Duration in days + * + * @var int + */ + public $stayDurationDays; + + /** + * Flexibility of Stay Duration in days + * + * @var int + */ + public $stayDurationFlexibilityDays; + + /** + * Set to True to return cheapest overall price + * + * @var boolean + */ + public $returnCheapestOverall = false; + + /** + * Set to True to return cheapest nonstop price + * + * @var boolean + */ + public $returnCheapestNonStop = false; + + /** + * Price result aggregation option - use one of the self::AGGR_* constants + * + * @var string + */ + public $resultAggregationOption; + + /** + * Which Office ID to use when finding prices + * + * @var string Amadeus Office ID + */ + public $searchOffice; +} diff --git a/src/Amadeus/Client/RequestOptions/Ticket/PassengerReference.php b/src/Amadeus/Client/RequestOptions/Ticket/PassengerReference.php new file mode 100644 index 000000000..750f00653 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/Ticket/PassengerReference.php @@ -0,0 +1,53 @@ +type === 'INF'); - $this->paxReference = new MasterPricer\PaxReference( + $paxRef = new MasterPricer\PaxReference( $isInfant ? $infantCounter : $counter, $isInfant, $passenger->type @@ -189,7 +189,7 @@ protected function loadPassenger($passenger, &$counter, &$infantCounter) if ($passenger->count > 1) { for ($i = 2; $i <= $passenger->count; $i++) { - $this->paxReference->traveller[] = new MasterPricer\Traveller($counter); + $paxRef->traveller[] = new MasterPricer\Traveller($counter); if ($isInfant) { $infantCounter++; @@ -198,6 +198,8 @@ protected function loadPassenger($passenger, &$counter, &$infantCounter) } } } + + $this->paxReference[] = $paxRef; } /** diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements.php index a17b96255..bd73ebe6a 100644 --- a/src/Amadeus/Client/Struct/Pnr/AddMultiElements.php +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements.php @@ -28,10 +28,12 @@ use Amadeus\Client\RequestOptions\Pnr\Traveller; use Amadeus\Client\RequestOptions\Pnr\TravellerGroup; use Amadeus\Client\RequestOptions\PnrAddMultiElementsBase; +use Amadeus\Client\RequestOptions\PnrAddMultiElementsOptions; use Amadeus\Client\RequestOptions\PnrCreatePnrOptions; use Amadeus\Client\RequestOptions\RequestOptionsInterface; use Amadeus\Client\Struct\BaseWsMessage; use Amadeus\Client\Struct\InvalidArgumentException; +use Amadeus\Client\Struct\Pnr\AddMultiElements\Accounting; use Amadeus\Client\Struct\Pnr\AddMultiElements\AirAuxItinerary; use Amadeus\Client\Struct\Pnr\AddMultiElements\DataElementsIndiv; use Amadeus\Client\Struct\Pnr\AddMultiElements\DataElementsMaster; @@ -53,6 +55,7 @@ use Amadeus\Client\Struct\Pnr\AddMultiElements\PassengerData; use Amadeus\Client\Struct\Pnr\AddMultiElements\ReferenceForDataElement; use Amadeus\Client\Struct\Pnr\AddMultiElements\ServiceRequest; +use Amadeus\Client\Struct\Pnr\AddMultiElements\StructuredAddress; use Amadeus\Client\Struct\Pnr\AddMultiElements\TicketElement; use Amadeus\Client\Struct\Pnr\AddMultiElements\TravellerInfo; @@ -93,10 +96,40 @@ public function __construct(PnrAddMultiElementsBase $params = null) if (!is_null($params)) { if ($params instanceof PnrCreatePnrOptions) { $this->loadCreatePnr($params); + } else if ($params instanceof PnrAddMultiElementsOptions) { + $this->loadBare($params); } } } + /** + * PNR_AddMultiElements call which only adds requested data to the message + * + * For doing specific actions like ignoring or saving PNR. + * + * @param $params + */ + protected function loadBare(PnrAddMultiElementsOptions $params) + { + if (!is_null($params->actionCode)) { + $this->pnrActions = new AddMultiElements\PnrActions( + $params->actionCode + ); + } + + if (!is_null($params->receivedFrom)) { + if ($this->dataElementsMaster === null) { + $this->dataElementsMaster = new DataElementsMaster(); + } + + $tatooCounter = 1; + + $this->dataElementsMaster->dataElementsIndiv[] = $this->createElement( + new ReceivedFrom(['receivedFrom' => $params->receivedFrom]), $tatooCounter + ); + } + } + /** * Make PNR_AddMultiElements structure from a PnrCreatePnrOptions input. * @@ -312,7 +345,7 @@ protected function createElement($element, &$tatooCounter) break; case 'ReceivedFrom': /** @var Element\ReceivedFrom $element */ - $createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_RECEIVE_FROM); + $createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_RECEIVE_FROM, $tatooCounter); $createdElement->freetextData = new FreetextData( $element->receivedFrom, FreetextDetail::TYPE_RECEIVE_FROM @@ -328,6 +361,20 @@ protected function createElement($element, &$tatooCounter) $createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_TICKETING_ELEMENT, $tatooCounter); $createdElement->ticketElement = new TicketElement($element); break; + case 'AccountingInfo': + /** @var Element\AccountingInfo $element */ + $createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_ACCOUNTING_INFORMATION, $tatooCounter); + $createdElement->accounting = new Accounting($element); + break; + case 'Address': + /** @var Element\Address $element */ + $createdElement = new DataElementsIndiv($element->type, $tatooCounter); + if ($element->type === ElementManagementData::SEGNAME_ADDRESS_BILLING_UNSTRUCTURED || $element->type === ElementManagementData::SEGNAME_ADDRESS_MAILING_UNSTRUCTURED) { + $createdElement->freetextData = new FreetextData($element->freeText, FreetextDetail::TYPE_MAILING_ADDRESS); + } else { + $createdElement->structuredAddress = new StructuredAddress($element); + } + break; default: throw new InvalidArgumentException('Element type ' . $elementType . 'is not supported'); } diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Account.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Account.php new file mode 100644 index 000000000..e5bce6608 --- /dev/null +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Account.php @@ -0,0 +1,66 @@ +number = $number; + } +} diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Accounting.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Accounting.php new file mode 100644 index 000000000..371b65a37 --- /dev/null +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Accounting.php @@ -0,0 +1,56 @@ +account = new Account($params->accountNumber); + $this->account->costNumber = $params->costCenter; + $this->account->clientReference = $params->clientRefNumber; + $this->account->companyNumber = $params->companyIdNumber; + } +} diff --git a/src/Amadeus/Client/RequestOptions/MessageOptions.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Address.php similarity index 53% rename from src/Amadeus/Client/RequestOptions/MessageOptions.php rename to src/Amadeus/Client/Struct/Pnr/AddMultiElements/Address.php index 4c1d3ec48..b822428d0 100644 --- a/src/Amadeus/Client/RequestOptions/MessageOptions.php +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Address.php @@ -20,36 +20,46 @@ * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0 */ -namespace Amadeus\Client\RequestOptions; - -use Amadeus\Client\LoadParamsFromArray; +namespace Amadeus\Client\Struct\Pnr\AddMultiElements; /** - * MessageOptions are meta options when sending messages + * Address * - * @todo use this class instead of messageOptions array in Client. - * @package Amadeus\Client\RequestOptions + * @package Amadeus\Client\Struct\Pnr\AddMultiElements * @author Dieter Devlieghere */ -class MessageOptions extends LoadParamsFromArray +class Address { + const OPT_ADDRESS_LINE_1 = "A1"; + + /** - * Get the response as a string (true) or a PHP Object (false) - * - * If true, we'll get the response message from the soap body in the soapclient's __getLastResponse() + * A1 Address line1 + * A2 Address line 2 + * CI City + * CO Country + * CY Company + * NA Name + * PO P.O. BOX + * ST State + * ZP Postal code * - * @var bool + * @var string */ - public $asString = false; + public $optionA1 = self::OPT_ADDRESS_LINE_1; + /** - * If you want to end a stateful session, set this to true. - * @var bool + * @var string */ - public $endSession = false; + public $optionTextA1; - public function __construct() + /** + * Address constructor. + * + * @param string $addressLineOne + */ + public function __construct($addressLineOne) { - parent::__construct([]); - throw new \RuntimeException('NOT YET IMPLEMENTED'); + $this->optionTextA1 = $addressLineOne; } } diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/DataElementsIndiv.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/DataElementsIndiv.php index 439b6fdfe..6150f2d0d 100644 --- a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/DataElementsIndiv.php +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/DataElementsIndiv.php @@ -39,6 +39,9 @@ class DataElementsIndiv */ public $elementManagementData; public $pnrSecurity; + /** + * @var Accounting + */ public $accounting; /** * To specify different kinds of remarks @@ -64,6 +67,9 @@ class DataElementsIndiv * @var FreetextData */ public $freetextData; + /** + * @var StructuredAddress + */ public $structuredAddress; public $optionElement; public $printer; diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/ElementManagementData.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/ElementManagementData.php index 7109c4d33..568f359f7 100644 --- a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/ElementManagementData.php +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/ElementManagementData.php @@ -36,6 +36,7 @@ class ElementManagementData * See documentation Amadeus Core webservices * Functional documentation PNR_AddMultiElements * [PNR segment or element name, coded codesets (Ref: 110P 1A 98.98.2)] + * * @var string */ const SEGNAME_RECEIVE_FROM = "RF"; @@ -45,52 +46,76 @@ class ElementManagementData * See documentation Amadeus Core webservices * Functional documentation PNR_AddMultiElements * [PNR segment or element name, coded codesets (Ref: 110P 1A 98.98.2)] + * * @var string */ const SEGNAME_GENERAL_REMARK = "RM"; /** * Segment name "Form Of Payment" + * * @var string */ const SEGNAME_FORM_OF_PAYMENT = "FP"; /** - * * Segment name "Ticketing Element" + * * @var string */ const SEGNAME_TICKETING_ELEMENT = "TK"; - /** * AP and related elements + * * @var string */ const SEGNAME_CONTACT_ELEMENT = "AP"; - /** * OSI - Other Service Information * * @var string */ const SEGNAME_OTHER_SERVICE_INFORMATION = "OS"; - /** * AI - Accounting Information * * @var string */ const SEGNAME_ACCOUNTING_INFORMATION = "AI"; - /** * SSR - Special Service Request * * @var string */ const SEGNAME_SPECIAL_SERVICE_REQUEST = "SSR"; + /** + * AB - Billing Address element + * + * @var string + */ + const SEGNAME_ADDRESS_BILLING_STRUCTURED = "AB"; + /** + * ABU - Unstructured Billing Address element + * + * @var string + */ + const SEGNAME_ADDRESS_BILLING_UNSTRUCTURED = "ABU"; + /** + * AM - Mailing address element + * + * @var string + */ + const SEGNAME_ADDRESS_MAILING_STRUCTURED = "AM"; + /** + * AMU - Unstructured Mailing Address Element + * + * @var string + */ + const SEGNAME_ADDRESS_MAILING_UNSTRUCTURED = "AMU"; /** * @var Reference */ public $reference; + /** * [PNR segment or element name, coded codesets (Ref: 110P 1A 98.98.2)] * @@ -101,8 +126,8 @@ class ElementManagementData /** * Create new ElementManagementData * - * @param string $segmentName one of the constants SEGNAME_* defined in this class - * @param int $tatoo optional tatoo nr to reference this element + * @param string|null $segmentName one of the constants SEGNAME_* defined in this class + * @param int|null $tatoo Optional tatoo nr to reference this element */ public function __construct($segmentName = null, $tatoo = null) { diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/FreetextDetail.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/FreetextDetail.php index 4f2c45678..4a5b5d2f5 100644 --- a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/FreetextDetail.php +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/FreetextDetail.php @@ -65,6 +65,8 @@ class FreetextDetail const TYPE_OTHER_SERVICE_INFO_OSI = "28"; + const TYPE_MAILING_ADDRESS = "P08"; + /** * @var string */ diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/OptionalData.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/OptionalData.php new file mode 100644 index 000000000..9c6224748 --- /dev/null +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/OptionalData.php @@ -0,0 +1,84 @@ + + */ +class OptionalData +{ + const OPT_ADDRESS_LINE_1 = "A1"; + + const OPT_ADDRESS_LINE_2 = "A2"; + + const OPT_CITY = "CI"; + + const OPT_COUNTRY = "CO"; + + const OPT_COMPANY = "CY"; + + const OPT_NAME = "NA"; + + const OPT_PO_BOX = "PO"; + + const OPT_STATE = "ST"; + + const OPT_ZIP_CODE = "ZP"; + + /** + * self::OPT_* + * + * A1 Address line1 + * A2 Address line 2 + * CI City + * CO Country + * CY Company + * NA Name + * PO P.O. BOX + * ST State + * ZP Postal code + * + * @var string + */ + public $option; + + /** + * @var string + */ + public $optionText; + + /** + * OptionalData constructor. + * + * @param string $text + * @param string $option self::OPT_* + */ + public function __construct($text, $option) + { + $this->optionText = $text; + $this->option = $option; + } +} diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/StructuredAddress.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/StructuredAddress.php new file mode 100644 index 000000000..4e781b173 --- /dev/null +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/StructuredAddress.php @@ -0,0 +1,129 @@ + + */ +class StructuredAddress +{ + const TYPE_BILLING_ADDRESS = "2"; + + const TYPE_MAILING_ADDRESS = "P08"; + + const TYPE_MISC_ADDRESS = "P18"; + + const TYPE_HOME_MAILING_ADDRESS = "P24"; + + const TYPE_DELIVERY_MAILING_ADDRESS = "P25"; + + /** + * @var string + */ + public $informationType; + /** + * @var Address + */ + public $address; + + /** + * @var OptionalData[] + */ + public $optionalData = []; + + /** + * StructuredAddress constructor. + * + * @param AddressOptions $params + */ + public function __construct(AddressOptions $params) + { + $this->informationType = $this->makeType($params->type); + + $this->address = new Address($params->addressLine1); + + if (!empty($params->addressLine2)) { + $this->optionalData[] = new OptionalData( + $params->addressLine2, + OptionalData::OPT_ADDRESS_LINE_2 + ); + }; + + if (!empty($params->city)) { + $this->optionalData[] = new OptionalData( + $params->city, + OptionalData::OPT_CITY + ); + }; + + if (!empty($params->country)) { + $this->optionalData[] = new OptionalData( + $params->country, + OptionalData::OPT_COUNTRY + ); + }; + + if (!empty($params->name)) { + $this->optionalData[] = new OptionalData( + $params->name, + OptionalData::OPT_NAME + ); + }; + + if (!empty($params->state)) { + $this->optionalData[] = new OptionalData( + $params->state, + OptionalData::OPT_STATE + ); + }; + + if (!empty($params->zipCode)) { + $this->optionalData[] = new OptionalData( + $params->zipCode, + OptionalData::OPT_ZIP_CODE + ); + }; + } + + /** + * @param string $segmentType + * @return string|null + */ + protected function makeType($segmentType) + { + $infType = null; + + if ($segmentType === ElementManagementData::SEGNAME_ADDRESS_BILLING_STRUCTURED) { + $infType = self::TYPE_BILLING_ADDRESS; + } elseif ($segmentType === ElementManagementData::SEGNAME_ADDRESS_MAILING_STRUCTURED) { + $infType = self::TYPE_MAILING_ADDRESS; + } + + return $infType; + } +} diff --git a/src/Amadeus/Client/Struct/Pnr/Cancel.php b/src/Amadeus/Client/Struct/Pnr/Cancel.php new file mode 100644 index 000000000..8c101a3f5 --- /dev/null +++ b/src/Amadeus/Client/Struct/Pnr/Cancel.php @@ -0,0 +1,111 @@ + + */ +class Cancel extends BaseWsMessage +{ + /** + * @var ReservationInfo + */ + public $reservationInfo; + + /** + * @var PnrActions + */ + public $pnrActions; + + /** + * @var Cancel\Elements[] + */ + public $cancelElements = []; + + /** + * Cancel constructor. + * + * @param PnrCancelOptions $params + */ + public function __construct(PnrCancelOptions $params) + { + if (is_string($params->recordLocator) && strlen($params->recordLocator) >= 6) { + $this->reservationInfo = new ReservationInfo($params->recordLocator); + } + + $this->pnrActions = new PnrActions($params->actionCode); + + if ($params->cancelItinerary === true) { + $this->cancelElements[] = new Cancel\Elements(Elements::ENTRY_ITINERARY); + } + + if (!empty($params->elementsByTatoo)) { + $tmp = new Cancel\Elements(Elements::ENTRY_ELEMENT); + + foreach ($params->elementsByTatoo as $tatoo) { + $tmp->element[] = new Element($tatoo, Element::IDENT_OTHER_TATOO); + } + + $this->cancelElements[] = $tmp; + } + + if (!empty($params->groupPassengers)) { + $tmp = new Cancel\Elements(Elements::ENTRY_NAME_INTEGRATION); + + foreach ($params->groupPassengers as $offerRef) { + $tmp->element[] = new Element($offerRef, Element::IDENT_PASSENGER_TATOO); + } + + $this->cancelElements[] = $tmp; + } + + if (!empty($params->passengers)) { + $tmp = new Cancel\Elements(Elements::ENTRY_ELEMENT); + + foreach ($params->passengers as $offerRef) { + $tmp->element[] = new Element($offerRef, Element::IDENT_PASSENGER_TATOO); + } + + $this->cancelElements[] = $tmp; + } + + if (!empty($params->offers)) { + $tmp = new Cancel\Elements(Elements::ENTRY_ELEMENT); + + foreach ($params->offers as $offerRef) { + $tmp->element[] = new Element($offerRef, Element::IDENT_OFFER_TATOO); + } + + $this->cancelElements[] = $tmp; + } + } +} diff --git a/src/Amadeus/Client/Struct/Pnr/Cancel/Element.php b/src/Amadeus/Client/Struct/Pnr/Cancel/Element.php new file mode 100644 index 000000000..2609526d8 --- /dev/null +++ b/src/Amadeus/Client/Struct/Pnr/Cancel/Element.php @@ -0,0 +1,94 @@ + + */ +class Element +{ + const IDENT_SEGMENT_TATOO = "ST"; + + const IDENT_PASSENGER_TATOO = "PT"; + + const IDENT_OFFER_TATOO = "OOT"; + + const IDENT_OTHER_TATOO = "OT"; + + + /** + * self::IDENT_* + * + * Code giving specific meaning to a reference segment or a reference number. + * + * 001 Customer identification number + * 002 Corporate identification number + * D Dominant segment in a marriage + * ESG ES element with receiver type G + * ESI ES element with receiver type I + * ESP ES element with receiver type P + * N Non dominant segment in a marriage + * OOT Offers - Other element tatoo reference number + * OT Other element tatoo reference number + * PR Passenger Client-request-message-defined ref. nbr + * PT Passenger tatoo reference number + * SR Segment Client-request-message-defined ref. nbr + * SS Segment Tatoo+SubTatoo reference number + * ST Segment Tatoo reference number + * + * @var string + */ + public $identifier; + + /** + * Identification number. + * + * @var string + */ + public $number; + + /** + * Identification number. + * + * @var int + */ + public $subElement; + + + /** + * Element constructor. + * + * @param string $number + * @param string $identifier self::IDENT_* + * @param int|null $subElement + */ + public function __construct($number, $identifier, $subElement = null) + { + $this->number = $number; + $this->identifier = $identifier; + $this->subElement = $subElement; + } +} diff --git a/src/Amadeus/Client/Struct/Pnr/Cancel/Elements.php b/src/Amadeus/Client/Struct/Pnr/Cancel/Elements.php new file mode 100644 index 000000000..68f4eb16d --- /dev/null +++ b/src/Amadeus/Client/Struct/Pnr/Cancel/Elements.php @@ -0,0 +1,66 @@ + + */ +class Elements +{ + const ENTRY_XD = "D"; + + const ENTRY_ELEMENT = "E"; + + const ENTRY_ITINERARY = "I"; + + const ENTRY_NAME_INTEGRATION = "G"; + + const ENTRY_PRIORITY_LINE = "P"; + + const ENTRY_ES = "S"; + + /** + * self::ENTRYTYPE_* + * + * @var string + */ + public $entryType; + + /** + * @var Element[] + */ + public $element = []; + + /** + * Elements constructor. + * + * @param string $entryType self::ENTRY_* + */ + public function __construct($entryType) + { + $this->entryType = $entryType; + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/AirlineInfo.php b/src/Amadeus/Client/Struct/PriceXplorer/AirlineInfo.php new file mode 100644 index 000000000..17e161267 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/AirlineInfo.php @@ -0,0 +1,42 @@ + + */ +class AirlineInfo +{ + /** + * @var mixed + */ + public $attributeInfo; + + /** + * @var mixed + */ + public $airlineDetails; +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/AttributeDetails.php b/src/Amadeus/Client/Struct/PriceXplorer/AttributeDetails.php new file mode 100644 index 000000000..a06449ff8 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/AttributeDetails.php @@ -0,0 +1,70 @@ + + */ +class AttributeDetails +{ + const TYPE_DEPARTURE_DAY = "DAY"; + + const TYPE_DESTINATION = "DES"; + + const TYPE_MONTH = "MTH"; + + const TYPE_PASSENGER_TYPE_PROFILE = "PRO"; + + const TYPE_STAY_DURATION = "SD"; + + const TYPE_WEEK = "WEEK"; + + const TYPE_COUNTRY = "CTRY"; + + /** + * DAY Per departure day + * DES Per destination + * MTH Per month + * PRO Passenger type profile + * SD Per stay duration + * WEEK Per week + * + * @var string self::TYPE_* + */ + public $attributeType; + /** + * @var string + */ + public $attributeDescription; + + /** + * @param string $type self::TYPE_* + */ + public function __construct($type) + { + $this->attributeType = $type; + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/AttributeInfo.php b/src/Amadeus/Client/Struct/PriceXplorer/AttributeInfo.php new file mode 100644 index 000000000..56a0aae74 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/AttributeInfo.php @@ -0,0 +1,59 @@ + + */ +class AttributeInfo +{ + const FUNC_GROUPING = "GRP"; + + const FUNC_PASSENGER = "PSG"; + + /** + * @var string self::FUNC_* + */ + public $attributeFunction; + + /** + * @var AttributeDetails[] + */ + public $attributeDetails = []; + + /** + * @param string $function self::FUNC_* + * @param array $groupTypes AttributeDetails::TYPE_* strings + */ + public function __construct($function = self::FUNC_GROUPING, $groupTypes = []) + { + $this->attributeFunction = $function; + + foreach ($groupTypes as $groupType) { + $this->attributeDetails[] = new AttributeDetails($groupType); + } + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/Budget.php b/src/Amadeus/Client/Struct/PriceXplorer/Budget.php new file mode 100644 index 000000000..8f9687b52 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/Budget.php @@ -0,0 +1,63 @@ + + */ +class Budget +{ + /** + * @var MonetaryDetails[] + */ + public $monetaryDetails = []; + + /** + * When providing MAX or MIN you MUST specify currency + * + * @param double|int|string|null $maxBudget + * @param double|int|string|null $minBudget + * @param string|null $currency + */ + public function __construct($maxBudget = null, $minBudget = null, $currency = null) + { + if ($maxBudget !== null && $currency !== null) { + $this->monetaryDetails[] = new MonetaryDetails( + $maxBudget, + MonetaryDetails::QUAL_MAX_BUDGET, + $currency + ); + } + + if ($minBudget !== null && $currency !== null) { + $this->monetaryDetails[] = new MonetaryDetails( + $minBudget, + MonetaryDetails::QUAL_MIN_BUDGET, + $currency + ); + } + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/DateAndTimeDetails.php b/src/Amadeus/Client/Struct/PriceXplorer/DateAndTimeDetails.php new file mode 100644 index 000000000..32d3340f7 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/DateAndTimeDetails.php @@ -0,0 +1,72 @@ + + */ +class DateAndTimeDetails +{ + const QUAL_DATEOFDEP = "D"; + const QUAL_ENDDATE = "E"; + const QUAL_RETURNDATE = "R"; + const QUAL_STARTDATE = "S"; + + /** + * @var string self::QUAL_* + */ + public $qualifier; + + /** + * @var string Format: ddmmyy + */ + public $date; + + /** + * @var string + */ + public $time; + + /** + * @var string + */ + public $otherQualifier; + + /** + * @var string + */ + public $otherTime; + + /** + * @param string $qualifier self::QUAL_* + * @param \DateTime $date + */ + public function __construct($qualifier, $date) + { + $this->qualifier = $qualifier; + $this->date = $date->format('dmy'); + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/DateAndTimeInfo.php b/src/Amadeus/Client/Struct/PriceXplorer/DateAndTimeInfo.php new file mode 100644 index 000000000..352322dfe --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/DateAndTimeInfo.php @@ -0,0 +1,37 @@ + + */ +class DateAndTimeInfo +{ + /** + * @var DateAndTimeDetails[] + */ + public $dateAndTimeDetails = []; +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/DaySelection.php b/src/Amadeus/Client/Struct/PriceXplorer/DaySelection.php new file mode 100644 index 000000000..fe7c5583b --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/DaySelection.php @@ -0,0 +1,53 @@ + + */ +class DaySelection +{ + /** + * Each wanted day of the week in a string + * + * e.g. "123" for Monday, Tuesday and Wednesday. + * Must be consecutive. + * + * @var string + */ + public $dayOfWeek; + + /** + * @param array $weekDays Week days in array format: e.g. array(1, 2) for Monday and Tuesday. MUST BE CONSECUTIVE DAYS + */ + public function __construct($weekDays) + { + $this->dayOfWeek = ""; + foreach ($weekDays as $weekDay) { + $this->dayOfWeek .= $weekDay; + } + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/DepartureDays.php b/src/Amadeus/Client/Struct/PriceXplorer/DepartureDays.php new file mode 100644 index 000000000..006490b18 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/DepartureDays.php @@ -0,0 +1,60 @@ + + */ +class DepartureDays +{ + /** + * @var DaySelection + */ + public $daySelection; + /** + * @var DaySelection + */ + public $additionalDaySelection; + /** + * @var SelectionInfo + */ + public $selectionInfo; + + /** + * @param array $weekDays Week days in array format: e.g. array(1, 2) for Monday and Tuesday. MUST BE CONSECUTIVE DAYS + * @param string $departureDayOption + */ + public function __construct($weekDays = array(), $departureDayOption = null) + { + $this->daySelection = new DaySelection($weekDays); + + if ($departureDayOption === null) { + $this->selectionInfo = new SelectionInfo(); + } else { + $this->selectionInfo = new SelectionInfo($departureDayOption); + } + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/ExtremeSearch.php b/src/Amadeus/Client/Struct/PriceXplorer/ExtremeSearch.php new file mode 100644 index 000000000..1c1344159 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/ExtremeSearch.php @@ -0,0 +1,238 @@ + + */ +class ExtremeSearch extends BaseWsMessage +{ + /** + * Itinerary information group + * + * @var ItineraryGrp[] + */ + public $itineraryGrp = []; + + /** + * Budget info + * + * @var Budget + */ + public $budget; + + /** + * Departure dates ranges + * + * @var TravelDates + */ + public $travelDates; + + /** + * Stay duration and flexibility + * + * @var StayDuration + */ + public $stayDuration; + + /** + * Attribute Information + * + * @var AttributeInfo[] + */ + public $attributeInfo = []; + + /** + * Option description : Price result distribution, ... + * + * @var SelectionDetailsGroup[] + */ + public $selectionDetailsGroup = []; + + /** + * List of departure days + * + * @var DepartureDays[] + */ + public $departureDays = []; + + /** + * Airline information + * + * @var AirlineInfo[] + */ + public $airlineInfo = []; + + /** + * List of Office Id Details + * + * @var OfficeIdInfo[] + */ + public $officeIdInfo = []; + + /** + * Construct PriceXplorer_ExtremeSearch Request message + * + * @param PriceXplorerExtremeSearchOptions $params + */ + public function __construct(PriceXplorerExtremeSearchOptions $params) + { + $this->itineraryGrp[] = new ItineraryGrp($params->origin); + + if ($params->earliestDepartureDate instanceof \DateTime || $params->latestDepartureDate instanceof \DateTime) { + $this->travelDates = new TravelDates($params->earliestDepartureDate, $params->latestDepartureDate); + } + + if ($params->searchOffice !== null) { + $this->officeIdInfo[] = new OfficeIdInfo($params->searchOffice); + } + + if (($params->maxBudget !== null || $params->minBudget !== null) && $params->currency !== null) { + $this->budget = new Budget( + $params->maxBudget, + $params->minBudget, + $params->currency + ); + } + + if (!empty($params->destinations)) { + foreach ($params->destinations as $destination) { + $this->itineraryGrp[] = new ItineraryGrp(null, $destination); + } + } + + if (!empty($params->destinationCountries)) { + foreach ($params->destinationCountries as $destCountry) { + $tmpGrp = new ItineraryGrp(); + + $tmpGrp->locationInfo = new LocationInfo(LocationInfo::LOC_COUNTRY); + + $tmpGrp->locationInfo->locationDescription = new LocationIdentificationType(); + $tmpGrp->locationInfo->locationDescription->qualifier = LocationIdentificationType::QUAL_DESTINATION; + $tmpGrp->locationInfo->locationDescription->code = $destCountry; + + $this->itineraryGrp[] = $tmpGrp; + } + } + + if (!empty($params->departureDaysInbound)) { + $this->departureDays[] = new DepartureDays($params->departureDaysInbound, SelectionDetails::OPT_INBOUND_DEP_DAYS); + } + if (!empty($params->departureDaysOutbound)) { + $this->departureDays[] = new DepartureDays( + $params->departureDaysOutbound, + SelectionDetails::OPT_OUTBOUND_DEP_DAYS + ); + } + + if ($params->stayDurationDays !== null) { + $this->stayDuration = new StayDuration($params->stayDurationDays); + + if ($params->stayDurationFlexibilityDays !== null) { + $this->stayDuration->flexibilityInfo = new FlexibilityInfo($params->stayDurationFlexibilityDays); + } + } + + if ($params->returnCheapestNonStop || $params->returnCheapestOverall) { + + $tmpSelDet = new SelectionDetailsGroup(); + + $tmpSelDet->selectionDetailsInfo = new SelectionDetailsInfo(); + $tmpSelDet->selectionDetailsInfo->selectionDetails[] = new SelectionDetails( + SelectionDetails::OPT_PRICE_RESULT_DISTRIBUTION + ); + + $tmpSelDet->nbOfUnitsInfo = new NbOfUnitsInfo(); + + if ($params->returnCheapestNonStop) { + + $tmpSelDet->nbOfUnitsInfo->quantityDetails[] = new NumberOfUnitDetailsType( + null, + NumberOfUnitDetailsType::QUAL_CHEAPEST_NONSTOP + ); + } + + if ($params->returnCheapestOverall) { + + $tmpSelDet->nbOfUnitsInfo->quantityDetails[] = new NumberOfUnitDetailsType( + null, + NumberOfUnitDetailsType::QUAL_CHEAPEST_OVERALL + ); + } + + $this->selectionDetailsGroup[] = $tmpSelDet; + } + + if ($params->resultAggregationOption !== null) { + $groupTypes = $this->makeAggregationGroupTypes($params->resultAggregationOption); + + $tmpAttrInfo = new AttributeInfo( + AttributeInfo::FUNC_GROUPING, + $groupTypes + ); + + $this->attributeInfo[] = $tmpAttrInfo; + } + } + + /** + * @param string $groupTypeString + * @return array + */ + protected function makeAggregationGroupTypes($groupTypeString) + { + $result = []; + + switch($groupTypeString) { + case PriceXplorerExtremeSearchOptions::AGGR_DEST: + $result[] = AttributeDetails::TYPE_DESTINATION; + break; + case PriceXplorerExtremeSearchOptions::AGGR_COUNTRY: + $result[] = AttributeDetails::TYPE_COUNTRY; + break; + case PriceXplorerExtremeSearchOptions::AGGR_DEST_WEEK: + $result[] = AttributeDetails::TYPE_DESTINATION; + $result[] = AttributeDetails::TYPE_WEEK; + break; + case PriceXplorerExtremeSearchOptions::AGGR_DEST_WEEK_DEPART: + $result[] = AttributeDetails::TYPE_DESTINATION; + $result[] = AttributeDetails::TYPE_WEEK; + $result[] = AttributeDetails::TYPE_DEPARTURE_DAY; + break; + case PriceXplorerExtremeSearchOptions::AGGR_DEST_WEEK_DEPART_STAY: + $result[] = AttributeDetails::TYPE_DESTINATION; + $result[] = AttributeDetails::TYPE_WEEK; + $result[] = AttributeDetails::TYPE_DEPARTURE_DAY; + $result[] = AttributeDetails::TYPE_STAY_DURATION; + break; + } + + return $result; + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/FlexibilityInfo.php b/src/Amadeus/Client/Struct/PriceXplorer/FlexibilityInfo.php new file mode 100644 index 000000000..1998ecda5 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/FlexibilityInfo.php @@ -0,0 +1,47 @@ + + */ +class FlexibilityInfo +{ + /** + * @var QuantityDetailsType[] + */ + public $quantityDetails = []; + + /** + * @param int $flexibilityDays Number of flexible days + */ + public function __construct($flexibilityDays = null) + { + if ($flexibilityDays !== null && is_int($flexibilityDays)) { + $this->quantityDetails[] = new QuantityDetailsType($flexibilityDays); + } + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/ItineraryGrp.php b/src/Amadeus/Client/Struct/PriceXplorer/ItineraryGrp.php new file mode 100644 index 000000000..5648e1dff --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/ItineraryGrp.php @@ -0,0 +1,53 @@ + + */ +class ItineraryGrp +{ + /** + * @var ItineraryInfo + */ + public $itineraryInfo; + + /** + * @var LocationInfo + */ + public $locationInfo; + + /** + * Construct ItineraryGrp + * + * @param string|null $origin + * @param string|null $destination + */ + public function __construct($origin = null, $destination = null) + { + $this->itineraryInfo = new ItineraryInfo($origin, $destination); + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/ItineraryInfo.php b/src/Amadeus/Client/Struct/PriceXplorer/ItineraryInfo.php new file mode 100644 index 000000000..c5695e1c0 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/ItineraryInfo.php @@ -0,0 +1,52 @@ + + */ +class ItineraryInfo +{ + /** + * @var string + */ + public $origin; + + /** + * @var string + */ + public $destination; + + /** + * @param string $origin + * @param string $destination + */ + public function __construct($origin = null, $destination = null) + { + $this->origin = $origin; + $this->destination = $destination; + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/LocationIdentificationType.php b/src/Amadeus/Client/Struct/PriceXplorer/LocationIdentificationType.php new file mode 100644 index 000000000..3e8d5209f --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/LocationIdentificationType.php @@ -0,0 +1,61 @@ + + */ +class LocationIdentificationType +{ + const QUAL_DESTINATION = "D"; + + const QUAL_ORIGIN = "O"; + + /** + * Identification of the name of place/location, other than 3164 City name. + * + * IATA Code or: + * ARNK ARNK (for RTG use only) + * ZZZ ZZZ (used to designate all cities) + * + * @var string + */ + public $code; + + /** + * Identification of a code list. + * + * @var string self::QUAL_* + */ + public $qualifier; + + /** + * Name of place/location, other than 3164 city name. + * + * @var string + */ + public $name; +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/LocationInfo.php b/src/Amadeus/Client/Struct/PriceXplorer/LocationInfo.php new file mode 100644 index 000000000..43865360c --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/LocationInfo.php @@ -0,0 +1,64 @@ + + */ +class LocationInfo +{ + /** + * Location Types: + * 25 City + * 26 Country + * A Airport + * R Region + */ + const LOC_CITY = 25; + + const LOC_COUNTRY = 26; + + const LOC_AIRPORT = "A"; + + const LOC_REGION = "R"; + + /** + * @var string + */ + public $locationType; + /** + * @var LocationIdentificationType + */ + public $locationDescription; + + /** + * @param string|int $locationType One of the constants self::LOC_* + */ + public function __construct($locationType) + { + $this->locationType = $locationType; + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/MonetaryDetails.php b/src/Amadeus/Client/Struct/PriceXplorer/MonetaryDetails.php new file mode 100644 index 000000000..e404c33ce --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/MonetaryDetails.php @@ -0,0 +1,61 @@ + + */ +class MonetaryDetails +{ + const QUAL_MAX_BUDGET = "MAX"; + + const QUAL_MIN_BUDGET = "MIN"; + + /** + * @var string self::QUAL_* + */ + public $typeQualifier; + /** + * @var string + */ + public $amount; + /** + * @var string + */ + public $currency; + + /** + * @param double|string $amount + * @param string $qualifier MonetaryDetails::QUAL_* + * @param string $currency Currency code + */ + public function __construct($amount, $qualifier = self::QUAL_MAX_BUDGET, $currency = "EUR") + { + $this->amount = $amount; + $this->typeQualifier = $qualifier; + $this->currency = $currency; + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/NbOfUnitsInfo.php b/src/Amadeus/Client/Struct/PriceXplorer/NbOfUnitsInfo.php new file mode 100644 index 000000000..f0f2e83da --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/NbOfUnitsInfo.php @@ -0,0 +1,47 @@ + + */ +class NbOfUnitsInfo +{ + /** + * @var NumberOfUnitDetailsType[] + */ + public $quantityDetails = []; + + /** + * @param int $numberOfDays + */ + public function __construct($numberOfDays = null) + { + if ($numberOfDays !== null) { + $this->quantityDetails[] = new NumberOfUnitDetailsType($numberOfDays); + } + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/NumberOfUnitDetailsType.php b/src/Amadeus/Client/Struct/PriceXplorer/NumberOfUnitDetailsType.php new file mode 100644 index 000000000..6ba2c8fa5 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/NumberOfUnitDetailsType.php @@ -0,0 +1,74 @@ + + */ +class NumberOfUnitDetailsType +{ + + /* + * https://webservices.amadeus.com/extranet/structures/viewMessageStructure.do?id=2338&serviceVersionId=2304&isQuery=true# + * CNS Cheapest non-stop + * COP Cheapest over all price + * DAY Day + * MTH Month + * PR Number of price results + */ + const QUAL_CHEAPEST_NONSTOP = "CNS"; + + const QUAL_CHEAPEST_OVERALL = "COP"; + + const QUAL_DAY = "DAY"; + + const QUAL_MONTH = "MTH"; + + const QUAL_NR_OF_PRICE_RESULTS = "PR"; + + + /** + * @var int + */ + public $numberOfUnit; + + /** + * @var string self::QUAL_* + */ + public $unitQualifier; + + /** + * Create NumberOfUnitDetailsType + * + * @param int $numberOfUnit + * @param string $qualifier One of the constants self::QUAL_* + */ + public function __construct($numberOfUnit = null, $qualifier = self::QUAL_DAY) + { + $this->numberOfUnit = $numberOfUnit; + $this->unitQualifier = $qualifier; + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/OfficeId.php b/src/Amadeus/Client/Struct/PriceXplorer/OfficeId.php new file mode 100644 index 000000000..37eafc9e3 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/OfficeId.php @@ -0,0 +1,54 @@ + + */ +class OfficeId +{ + /** + * + * @var OriginIdentification + */ + public $originIdentification; + /** + * @var mixed + */ + public $originatorTypeCode; + /** + * @var mixed + */ + public $originator; + + /** + * @param string $officeId + */ + public function __construct($officeId) + { + $this->originIdentification = new OriginIdentification($officeId); + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/OfficeIdInfo.php b/src/Amadeus/Client/Struct/PriceXplorer/OfficeIdInfo.php new file mode 100644 index 000000000..0ae25afdf --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/OfficeIdInfo.php @@ -0,0 +1,48 @@ + + */ +class OfficeIdInfo +{ + /** + * Office identification details + * + * @var OfficeId + */ + public $officeId; + + /** + * + * @param string $officeId + */ + public function __construct($officeId) + { + $this->officeId = new OfficeId($officeId); + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/OriginIdentification.php b/src/Amadeus/Client/Struct/PriceXplorer/OriginIdentification.php new file mode 100644 index 000000000..802f3672b --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/OriginIdentification.php @@ -0,0 +1,60 @@ + + */ +class OriginIdentification +{ + /** + * @var string + */ + public $originatorId; + + /** + * @var string + */ + public $inHouseIdentification1; + + /** + * @var string + */ + public $inHouseIdentification2; + + /** + * @var string + */ + public $inHouseIdentification3; + + /** + * @param string $officeId + */ + public function __construct($officeId) + { + $this->inHouseIdentification1 = $officeId; + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/QuantityDetailsType.php b/src/Amadeus/Client/Struct/PriceXplorer/QuantityDetailsType.php new file mode 100644 index 000000000..0a2623519 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/QuantityDetailsType.php @@ -0,0 +1,78 @@ + + */ +class QuantityDetailsType +{ + /** + * https://webservices.amadeus.com/extranet/structures/viewMessageStructure.do?id=2338&serviceVersionId=2304&isQuery=true# + * PriceXplorer_ExtremeSearch/itineraryGrp/quantityInfo/quantityDetails/unit + * UNITS: + * DAY Day + * MTH Month + * WK Week + */ + const UNIT_DAY = "DAY"; + + const UNIT_WEEK = "WK"; + + const UNIT_MONTH = "MTH"; + + /** + * https://webservices.amadeus.com/extranet/structures/viewMessageStructure.do?id=2338&serviceVersionId=2304&isQuery=true# + * PriceXplorer_ExtremeSearch/itineraryGrp/quantityInfo/quantityDetails/qualifier + * @var string + */ + const QUAL_PLUS = "P"; + + /** + * @var string + */ + public $qualifier; + /** + * @var int + */ + public $value; + /** + * @var string + */ + public $unit; + + /** + * @param int $value + * @param string $unit + * @param string $qualifier + */ + public function __construct($value, $unit = self::UNIT_DAY, $qualifier = self::QUAL_PLUS) + { + $this->value = $value; + $this->unit = $unit; + $this->qualifier = $qualifier; + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/QuantityInfo.php b/src/Amadeus/Client/Struct/PriceXplorer/QuantityInfo.php new file mode 100644 index 000000000..5d5ec0f84 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/QuantityInfo.php @@ -0,0 +1,37 @@ + + */ +class QuantityInfo +{ + /** + * @var QuantityDetailsType[] + */ + public $quantityDetails = []; +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/SelectionDetails.php b/src/Amadeus/Client/Struct/PriceXplorer/SelectionDetails.php new file mode 100644 index 000000000..e53c53461 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/SelectionDetails.php @@ -0,0 +1,62 @@ + + */ +class SelectionDetails +{ + const OPT_INBOUND_DEP_DAYS = "I"; + + const OPT_OUTBOUND_DEP_DAYS = "O"; + + /* + * PRD Price result distribution + * TWD Time window distribution + */ + const OPT_PRICE_RESULT_DISTRIBUTION = "PRD"; + + const OPT_TIME_WINDOW_DISTRIBUTION = "TWD"; + + + /** + * @var string + */ + public $option; + /** + * @var string + */ + public $optionInformation; + + /** + * @param string $option self::OPT_* + */ + public function __construct($option) + { + $this->option = $option; + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/SelectionDetailsGroup.php b/src/Amadeus/Client/Struct/PriceXplorer/SelectionDetailsGroup.php new file mode 100644 index 000000000..94459cf19 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/SelectionDetailsGroup.php @@ -0,0 +1,58 @@ + + */ +class SelectionDetailsGroup +{ + + /** + * @var SelectionDetailsInfo + */ + public $selectionDetailsInfo; + + /** + * @var NbOfUnitsInfo + */ + public $nbOfUnitsInfo; + + /** + * @var DateAndTimeInfo + */ + public $dateAndTimeInfo; + + /** + * @var QuantityInfo + */ + public $quantityInfo; + + /** + * @var array + */ + public $attributeInfo = []; +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/SelectionDetailsInfo.php b/src/Amadeus/Client/Struct/PriceXplorer/SelectionDetailsInfo.php new file mode 100644 index 000000000..563a7d9e9 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/SelectionDetailsInfo.php @@ -0,0 +1,37 @@ + + */ +class SelectionDetailsInfo +{ + /** + * @var SelectionDetails[] + */ + public $selectionDetails = []; +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/SelectionInfo.php b/src/Amadeus/Client/Struct/PriceXplorer/SelectionInfo.php new file mode 100644 index 000000000..4de25327a --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/SelectionInfo.php @@ -0,0 +1,45 @@ + + */ +class SelectionInfo +{ + /** + * @var SelectionDetails[] + */ + public $selectionDetails = []; + + /** + * @param string $departureDayOption SelectionDetails::OPT_* + */ + public function __construct($departureDayOption = SelectionDetails::OPT_OUTBOUND_DEP_DAYS) + { + $this->selectionDetails[] = new SelectionDetails($departureDayOption); + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/StayDuration.php b/src/Amadeus/Client/Struct/PriceXplorer/StayDuration.php new file mode 100644 index 000000000..64d2ffba6 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/StayDuration.php @@ -0,0 +1,49 @@ + + */ +class StayDuration +{ + /** + * @var NbOfUnitsInfo + */ + public $nbOfUnitsInfo; + /** + * @var FlexibilityInfo + */ + public $flexibilityInfo; + + /** + * @param int $numberOfDays + */ + public function __construct($numberOfDays = null) + { + $this->nbOfUnitsInfo = new NbOfUnitsInfo($numberOfDays); + } +} diff --git a/src/Amadeus/Client/Struct/PriceXplorer/TravelDates.php b/src/Amadeus/Client/Struct/PriceXplorer/TravelDates.php new file mode 100644 index 000000000..833607f22 --- /dev/null +++ b/src/Amadeus/Client/Struct/PriceXplorer/TravelDates.php @@ -0,0 +1,58 @@ + + */ +class TravelDates +{ + /** + * @var DateAndTimeDetails[] + */ + public $dateAndTimeDetails = []; + + /** + * @param \DateTime|null $earliestDepartureDate + * @param \DateTime|null $latestDepartureDate + */ + public function __construct($earliestDepartureDate = null, $latestDepartureDate = null) + { + if ($earliestDepartureDate instanceof \DateTime) { + $this->dateAndTimeDetails[] = new DateAndTimeDetails( + DateAndTimeDetails::QUAL_STARTDATE, + $earliestDepartureDate + ); + } + + if ($latestDepartureDate instanceof \DateTime) { + $this->dateAndTimeDetails[] = new DateAndTimeDetails( + DateAndTimeDetails::QUAL_ENDDATE, + $latestDepartureDate + ); + } + } +} diff --git a/src/Amadeus/Client/Struct/Security/Authenticate.php b/src/Amadeus/Client/Struct/Security/Authenticate.php new file mode 100644 index 000000000..76322781a --- /dev/null +++ b/src/Amadeus/Client/Struct/Security/Authenticate.php @@ -0,0 +1,33 @@ +pricings as $pricing) { + $tmp = new PsaList( + $pricing->tstNumber, + ItemReference::REFTYPE_TST + ); + + if (!empty($pricing->passengerReferences)) { + $tmp->paxReference = new PaxReference(); + + foreach ($pricing->passengerReferences as $passengerReference) { + $tmp->paxReference->refDetails[] = new RefDetails( + $passengerReference->id, + $passengerReference->type + ); + } + } + + $this->psaList[] = $tmp; + } + } } diff --git a/src/Amadeus/Client/Struct/Ticket/ItemReference.php b/src/Amadeus/Client/Struct/Ticket/ItemReference.php new file mode 100644 index 000000000..7a9e0232b --- /dev/null +++ b/src/Amadeus/Client/Struct/Ticket/ItemReference.php @@ -0,0 +1,57 @@ +uniqueReference = $reference; + $this->referenceType = $type; + } +} diff --git a/src/Amadeus/Client/Struct/Ticket/PaxReference.php b/src/Amadeus/Client/Struct/Ticket/PaxReference.php new file mode 100644 index 000000000..f497288cf --- /dev/null +++ b/src/Amadeus/Client/Struct/Ticket/PaxReference.php @@ -0,0 +1,36 @@ +reservationInformation = new ReservationInformation($recordLocator); + } +} diff --git a/src/Amadeus/Client/Struct/Ticket/PsaList.php b/src/Amadeus/Client/Struct/Ticket/PsaList.php new file mode 100644 index 000000000..84b592388 --- /dev/null +++ b/src/Amadeus/Client/Struct/Ticket/PsaList.php @@ -0,0 +1,66 @@ +itemReference = new ItemReference($itemRef, $itemRefType); + + if (!is_null($paxRef)) { + $this->paxReference = new PaxReference(); + $this->paxReference->refDetails[] = new RefDetails($paxRef, $paxRefType); + } + } +} diff --git a/src/Amadeus/Client/Struct/Ticket/RefDetails.php b/src/Amadeus/Client/Struct/Ticket/RefDetails.php new file mode 100644 index 000000000..97e120156 --- /dev/null +++ b/src/Amadeus/Client/Struct/Ticket/RefDetails.php @@ -0,0 +1,73 @@ +refNumber = $segNum; + $this->refQualifier = $segQual; + } +} diff --git a/src/Amadeus/Client/Struct/Ticket/ReservationInformation.php b/src/Amadeus/Client/Struct/Ticket/ReservationInformation.php new file mode 100644 index 000000000..cd7f4bf98 --- /dev/null +++ b/src/Amadeus/Client/Struct/Ticket/ReservationInformation.php @@ -0,0 +1,46 @@ +controlNumber = $recordLocator; + } +} diff --git a/tests/Amadeus/Client/Params/SessionHandlerParamsTest.php b/tests/Amadeus/Client/Params/SessionHandlerParamsTest.php new file mode 100644 index 000000000..5c1e14869 --- /dev/null +++ b/tests/Amadeus/Client/Params/SessionHandlerParamsTest.php @@ -0,0 +1,99 @@ +assertNull($par->authParams); + $this->assertNull($par->logger); + $this->assertNull($par->overrideSoapClient); + $this->assertTrue($par->stateful); + $this->assertNull($par->wsdl); + $this->assertEquals(Client::HEADER_V4,$par->soapHeaderVersion); + } + + public function testCanMakeSessionHandlerParamsWithAuthParamsInstance() + { + $par = new Params\SessionHandlerParams([ + 'wsdl' => realpath(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "testfiles" . DIRECTORY_SEPARATOR . "dummywsdl.wsdl"), + 'stateful' => true, + 'logger' => new NullLogger(), + 'authParams' => new Params\AuthParams([ + 'officeId' => 'BRUXXXXXX', + 'userId' => 'WSXXXXXX', + 'passwordData' => base64_encode('TEST') + ]) + ]); + + $this->assertInstanceOf( + 'Amadeus\Client\Params\AuthParams', + $par->authParams + ); + $this->assertEquals('BRUXXXXXX', $par->authParams->officeId); + $this->assertEquals('WSXXXXXX', $par->authParams->userId); + $this->assertEquals(base64_encode('TEST'), $par->authParams->passwordData); + $this->assertInstanceOf('\Psr\Log\LoggerInterface', $par->logger); + $this->assertTrue($par->stateful); + $this->assertEquals(Client::HEADER_V4,$par->soapHeaderVersion); + $this->assertNull($par->overrideSoapClient); + } + + public function testCanMakeSessionHandlerParamsWithoutLogger() + { + $par = new Params\SessionHandlerParams([ + 'wsdl' => realpath(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "testfiles" . DIRECTORY_SEPARATOR . "dummywsdl.wsdl"), + 'stateful' => true, + 'authParams' => new Params\AuthParams([ + 'officeId' => 'BRUXXXXXX', + 'userId' => 'WSXXXXXX', + 'passwordData' => base64_encode('TEST') + ]) + ]); + + $this->assertInstanceOf( + 'Amadeus\Client\Params\AuthParams', + $par->authParams + ); + $this->assertEquals('BRUXXXXXX', $par->authParams->officeId); + $this->assertEquals('WSXXXXXX', $par->authParams->userId); + $this->assertEquals(base64_encode('TEST'), $par->authParams->passwordData); + $this->assertNull($par->logger); + $this->assertTrue($par->stateful); + $this->assertEquals(Client::HEADER_V4,$par->soapHeaderVersion); + $this->assertNull($par->overrideSoapClient); + } +} diff --git a/tests/Amadeus/Client/Session/Handler/HandlerFactoryTest.php b/tests/Amadeus/Client/Session/Handler/HandlerFactoryTest.php new file mode 100644 index 000000000..cb05526eb --- /dev/null +++ b/tests/Amadeus/Client/Session/Handler/HandlerFactoryTest.php @@ -0,0 +1,74 @@ +setExpectedException('\InvalidArgumentException'); + + $params = $par = new SessionHandlerParams([ + 'wsdl' => '/dummy/path', + 'stateful' => false, + 'receivedFrom' => 'unittests', + 'logger' => new NullLogger() + ]); + + HandlerFactory::createHandler($params); + } + public function testCreateSoapHeader2WillThrowException() + { + $this->setExpectedException('\InvalidArgumentException'); + + $params = $par = new SessionHandlerParams([ + 'wsdl' => '/dummy/path', + 'stateful' => false, + 'soapHeaderVersion' => Client::HEADER_V2, + 'receivedFrom' => 'unittests', + 'logger' => new NullLogger(), + 'authParams' => [ + 'officeId' => 'BRUXX0000', + 'originatorTypeCode' => 'U', + 'userId' => 'DUMMYORIG', + 'organizationId' => 'DUMMYORG', + 'passwordLength' => 12, + 'passwordData' => 'dGhlIHBhc3N3b3Jk' + ] + ]); + + HandlerFactory::createHandler($params); + } +} diff --git a/tests/Amadeus/Client/Session/Handler/SoapHeader4Test.php b/tests/Amadeus/Client/Session/Handler/SoapHeader4Test.php index 18958d44a..5ebb2b34a 100644 --- a/tests/Amadeus/Client/Session/Handler/SoapHeader4Test.php +++ b/tests/Amadeus/Client/Session/Handler/SoapHeader4Test.php @@ -35,7 +35,6 @@ */ class SoapHeader4Test extends BaseTestCase { - public function testCanCreateSoapHeadersForStatelessCall() { $expectedSecurityNodeStructureXml = 'nrOfRequestedResults = 200; + $opt->nrOfRequestedPassengers = 1; + $opt->passengers[] = new MPPassenger([ + 'type' => MPPassenger::TYPE_ADULT, + 'count' => 1 + ]); + $opt->itinerary[] = new MPItinerary([ + 'departureLocation' => new MPLocation(['city' => 'BRU']), + 'arrivalLocation' => new MPLocation(['city' => 'LON']), + 'date' => new MPDate(['date' => new \DateTime('2017-01-15T00:00:00+0000', new \DateTimeZone('UTC'))]) + ]); + $opt->cabinClass = FareMasterPricerTbSearch::CABIN_ECONOMY_PREMIUM; + + + $message = new MasterPricerTravelBoardSearch($opt); + + $this->assertEquals(FareMasterPricerTbSearch::CABIN_ECONOMY_PREMIUM, $message->travelFlightInfo->cabinId->cabin); + $this->assertNull($message->travelFlightInfo->cabinId->cabinQualifier); + } + + public function testCanMakeMasterPricerMessageWithMultiAdultAndInfant() + { + $opt = new FareMasterPricerTbSearch(); + $opt->nrOfRequestedResults = 200; + $opt->nrOfRequestedPassengers = 3; + $opt->passengers[] = new MPPassenger([ + 'type' => MPPassenger::TYPE_ADULT, + 'count' => 2 + ]); + $opt->passengers[] = new MPPassenger([ + 'type' => MPPassenger::TYPE_INFANT, + 'count' => 1 + ]); + $opt->itinerary[] = new MPItinerary([ + 'departureLocation' => new MPLocation(['city' => 'BRU']), + 'arrivalLocation' => new MPLocation(['city' => 'LON']), + 'date' => new MPDate(['date' => new \DateTime('2017-01-15T00:00:00+0000', new \DateTimeZone('UTC'))]) + ]); + + $message = new MasterPricerTravelBoardSearch($opt); + + $this->assertEquals('ADT', $message->paxReference[0]->ptc[0]); + $this->assertNull($message->paxReference[0]->traveller[0]->infantIndicator); + $this->assertEquals(1, $message->paxReference[0]->traveller[0]->ref); + $this->assertNull($message->paxReference[0]->traveller[1]->infantIndicator); + $this->assertEquals(2, $message->paxReference[0]->traveller[1]->ref); + + $this->assertEquals('INF', $message->paxReference[1]->ptc[0]); + $this->assertEquals(1, $message->paxReference[1]->traveller[0]->ref); + $this->assertEquals(1, $message->paxReference[1]->traveller[0]->infantIndicator); + } + + public function testCanMakeMasterPricerMessageWithCityLocationAndGeoCoordinatesAndRadius() + { + $opt = new FareMasterPricerTbSearch(); + $opt->nrOfRequestedResults = 200; + $opt->nrOfRequestedPassengers = 1; + $opt->passengers[] = new MPPassenger([ + 'type' => MPPassenger::TYPE_ADULT, + 'count' => 1 + ]); + $opt->itinerary[] = new MPItinerary([ + 'departureLocation' => new MPLocation([ + 'airport' => 'OST', + 'radiusDistance' => 100, + 'radiusUnit' => MPLocation::RADIUSUNIT_KILOMETERS, + ]), + 'arrivalLocation' => new MPLocation([ + 'latitude' => '50.9139922', + 'longitude' => '4.406143' + ]), + 'date' => new MPDate(['date' => new \DateTime('2017-01-15T00:00:00+0000', new \DateTimeZone('UTC'))]) + ]); + + $message = new MasterPricerTravelBoardSearch($opt); + + $this->assertEquals(100, $message->itinerary[0]->departureLocalization->departurePoint->distance); + $this->assertEquals('K', $message->itinerary[0]->departureLocalization->departurePoint->distanceUnit); + $this->assertEquals('OST', $message->itinerary[0]->departureLocalization->departurePoint->locationId); + $this->assertEquals('A', $message->itinerary[0]->departureLocalization->departurePoint->airportCityQualifier); + + $this->assertEquals('50.9139922', $message->itinerary[0]->arrivalLocalization->arrivalPointDetails->latitude); + $this->assertEquals('4.406143', $message->itinerary[0]->arrivalLocalization->arrivalPointDetails->longitude); + + } + } diff --git a/tests/Amadeus/Client/Struct/Offer/ConfirmAirOfferTest.php b/tests/Amadeus/Client/Struct/Offer/ConfirmAirOfferTest.php new file mode 100644 index 000000000..efa5cec9e --- /dev/null +++ b/tests/Amadeus/Client/Struct/Offer/ConfirmAirOfferTest.php @@ -0,0 +1,64 @@ + + */ +class ConfirmAirOfferTest extends BaseTestCase +{ + public function testCanMakeMessageWithPassengerReassociation() + { + $opt = new OfferConfirmAirOptions([ + 'tatooNumber' => 2, + 'passengerReassociation' => [ + new PassengerReAssocOptions([ + 'pricingReference' => 5, + 'paxReferences' => [ + new PassengerDef([ + 'passengerType' => "PA", //ADULT + 'passengerTatoo' => 1 + ]) + ] + ]) + ] + ]); + + $message = new ConfirmAir($opt); + + $this->assertEquals(2, $message->offerTatoo->reference->value); + $this->assertEquals(Reference::TYPE_OFFER_TATOO, $message->offerTatoo->reference->type); + $this->assertEquals(OfferTatoo::SEGMENT_AIR, $message->offerTatoo->segmentName); + $this->assertEquals('PA', $message->passengerReassociation[0]->paxReference->passengerReference[0]->type); + $this->assertEquals(1, $message->passengerReassociation[0]->paxReference->passengerReference[0]->value); + $this->assertEquals(PricingRecordId::REFTYPE_PRODQUOTREC, $message->passengerReassociation[0]->pricingRecordId->referenceType); + $this->assertEquals(5, $message->passengerReassociation[0]->pricingRecordId->uniqueReference); + } +} diff --git a/tests/Amadeus/Client/Struct/Pnr/AddMultiElementsTest.php b/tests/Amadeus/Client/Struct/Pnr/AddMultiElementsTest.php index 7442dcc51..03a2e17e6 100644 --- a/tests/Amadeus/Client/Struct/Pnr/AddMultiElementsTest.php +++ b/tests/Amadeus/Client/Struct/Pnr/AddMultiElementsTest.php @@ -22,8 +22,12 @@ namespace Test\Amadeus\Client\Struct\Pnr; +use Amadeus\Client\RequestOptions\Pnr\Element\AccountingInfo; +use Amadeus\Client\RequestOptions\Pnr\Element\Address; use Amadeus\Client\RequestOptions\Pnr\Element\Contact; use Amadeus\Client\RequestOptions\Pnr\Element\FormOfPayment; +use Amadeus\Client\RequestOptions\Pnr\Element\MiscellaneousRemark; +use Amadeus\Client\RequestOptions\Pnr\Element\ReceivedFrom; use Amadeus\Client\RequestOptions\Pnr\Element\ServiceRequest; use Amadeus\Client\RequestOptions\Pnr\Element\Ticketing; use Amadeus\Client\RequestOptions\Pnr\Reference; @@ -345,6 +349,7 @@ public function testMakePnrWithPassengerDateOfBirth() 'company' => '1A' ]); + $requestStruct = new AddMultiElements($createPnrOptions); $this->assertEquals(1, count($requestStruct->travellerInfo)); @@ -352,4 +357,144 @@ public function testMakePnrWithPassengerDateOfBirth() $this->assertEquals(706, $requestStruct->travellerInfo[0]->passengerData[0]->dateOfBirth->dateAndTimeDetails->qualifier); $this->assertEquals('08011947', $requestStruct->travellerInfo[0]->passengerData[0]->dateOfBirth->dateAndTimeDetails->date); } + + public function testMakePnrWithGenericRemarkAndExplicitReceivedFrom() + { + $createPnrOptions = new PnrCreatePnrOptions(); + $createPnrOptions->receivedFrom = "unittest"; + $createPnrOptions->travellers[] = new Traveller([ + 'number' => 1, + 'lastName' => 'Bowie', + 'firstName' => 'David' + ]); + $createPnrOptions->actionCode = PnrActions::ACTIONOPTION_END_TRANSACT_W_RETRIEVE; + $createPnrOptions->tripSegments[] = new Miscellaneous([ + 'date' => \DateTime::createFromFormat('Y-m-d', "2016-10-02", new \DateTimeZone('UTC')), + 'cityCode' => 'BRU', + 'freeText' => 'GENERIC TRAVEL REQUEST', + 'company' => '1A' + ]); + $createPnrOptions->elements[] = new MiscellaneousRemark([ + 'text' => 'MARKUP: 20.00 EUR' + ]); + $createPnrOptions->elements[] = new ReceivedFrom([ + 'receivedFrom' => 'my magical robot' + ]); + + $requestStruct = new AddMultiElements($createPnrOptions); + + $this->assertEquals(2, count($requestStruct->dataElementsMaster->dataElementsIndiv)); + $this->assertEquals(AddMultiElements\ElementManagementData::SEGNAME_GENERAL_REMARK, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->elementManagementData->segmentName); + $this->assertEquals('MARKUP: 20.00 EUR', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->miscellaneousRemark->remarks->freetext); + $this->assertEquals(MiscellaneousRemark::TYPE_MISCELLANEOUS, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->miscellaneousRemark->remarks->type); + $this->assertEquals(AddMultiElements\ElementManagementData::SEGNAME_RECEIVE_FROM, $requestStruct->dataElementsMaster->dataElementsIndiv[1]->elementManagementData->segmentName); + $this->assertEquals('my magical robot', $requestStruct->dataElementsMaster->dataElementsIndiv[1]->freetextData->longFreetext); + $this->assertEquals(AddMultiElements\FreetextDetail::TYPE_RECEIVE_FROM, $requestStruct->dataElementsMaster->dataElementsIndiv[1]->freetextData->freetextDetail->type); + } + + public function testCanCreateAccountingInfoElement() + { + $createPnrOptions = new PnrCreatePnrOptions(); + $createPnrOptions->receivedFrom = "unittest"; + $createPnrOptions->travellers[] = new Traveller([ + 'number' => 1, + 'lastName' => 'Bowie', + 'firstName' => 'David' + ]); + $createPnrOptions->actionCode = PnrActions::ACTIONOPTION_END_TRANSACT_W_RETRIEVE; + $createPnrOptions->tripSegments[] = new Miscellaneous([ + 'date' => \DateTime::createFromFormat('Y-m-d', "2016-10-02", new \DateTimeZone('UTC')), + 'cityCode' => 'BRU', + 'freeText' => 'GENERIC TRAVEL REQUEST', + 'company' => '1A' + ]); + $createPnrOptions->elements[] = new AccountingInfo([ + 'accountNumber' => 'BUZA' + ]); + + $requestStruct = new AddMultiElements($createPnrOptions); + + $this->assertEquals(2, count($requestStruct->dataElementsMaster->dataElementsIndiv)); + $this->assertEquals(AddMultiElements\ElementManagementData::SEGNAME_ACCOUNTING_INFORMATION, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->elementManagementData->segmentName); + $this->assertEquals('BUZA', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->accounting->account->number); + } + + public function testCanCreateUnstructuredAddress() + { + $createPnrOptions = new PnrCreatePnrOptions(); + $createPnrOptions->receivedFrom = "unittest"; + $createPnrOptions->travellers[] = new Traveller([ + 'number' => 1, + 'lastName' => 'Bowie', + 'firstName' => 'David' + ]); + $createPnrOptions->actionCode = PnrActions::ACTIONOPTION_END_TRANSACT_W_RETRIEVE; + $createPnrOptions->tripSegments[] = new Miscellaneous([ + 'date' => \DateTime::createFromFormat('Y-m-d', "2016-10-02", new \DateTimeZone('UTC')), + 'cityCode' => 'BRU', + 'freeText' => 'GENERIC TRAVEL REQUEST', + 'company' => '1A' + ]); + $createPnrOptions->elements[] = new Address([ + 'type' => Address::TYPE_BILLING_UNSTRUCTURED, + 'freeText' => 'Amadeus Benelux NV,Medialaan 30,1800 Vilvoorde' + ]); + + $requestStruct = new AddMultiElements($createPnrOptions); + + $this->assertEquals(2, count($requestStruct->dataElementsMaster->dataElementsIndiv)); + $this->assertEquals(AddMultiElements\ElementManagementData::SEGNAME_ADDRESS_BILLING_UNSTRUCTURED, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->elementManagementData->segmentName); + $this->assertEquals('Amadeus Benelux NV,Medialaan 30,1800 Vilvoorde', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->freetextData->longFreetext); + $this->assertEquals(AddMultiElements\FreetextDetail::TYPE_MAILING_ADDRESS, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->freetextData->freetextDetail->type); + $this->assertEquals(AddMultiElements\FreetextDetail::QUALIFIER_LITERALTEXT, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->freetextData->freetextDetail->subjectQualifier); + } + + public function testCanCreateStructuredAddress() + { + $createPnrOptions = new PnrCreatePnrOptions(); + $createPnrOptions->receivedFrom = "unittest"; + $createPnrOptions->travellers[] = new Traveller([ + 'number' => 1, + 'lastName' => 'Bowie', + 'firstName' => 'David' + ]); + $createPnrOptions->actionCode = PnrActions::ACTIONOPTION_END_TRANSACT_W_RETRIEVE; + $createPnrOptions->tripSegments[] = new Miscellaneous([ + 'date' => \DateTime::createFromFormat('Y-m-d', "2016-10-02", new \DateTimeZone('UTC')), + 'cityCode' => 'BRU', + 'freeText' => 'GENERIC TRAVEL REQUEST', + 'company' => '1A' + ]); + $createPnrOptions->elements[] = new Address([ + 'type' => Address::TYPE_MAILING_STRUCTURED, + 'name' => 'Mister Amadeus', + 'addressLine1' => 'Amadeus Benelux NV', + 'addressLine2' => 'Medialaan 30', + 'city' => 'Vilvoorde', + 'state' => 'Vlaams-Brabant', + 'country' => 'Belgium', + 'zipCode' => '1800', + + ]); + + $requestStruct = new AddMultiElements($createPnrOptions); + + $this->assertEquals(2, count($requestStruct->dataElementsMaster->dataElementsIndiv)); + $this->assertEquals(AddMultiElements\ElementManagementData::SEGNAME_ADDRESS_MAILING_STRUCTURED, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->elementManagementData->segmentName); + $this->assertEquals(AddMultiElements\Address::OPT_ADDRESS_LINE_1, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->address->optionA1); + $this->assertEquals('Amadeus Benelux NV', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->address->optionTextA1); + $this->assertEquals(6, count($requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->optionalData)); + $this->assertEquals(AddMultiElements\OptionalData::OPT_ADDRESS_LINE_2, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->optionalData[0]->option); + $this->assertEquals('Medialaan 30', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->optionalData[0]->optionText); + $this->assertEquals(AddMultiElements\OptionalData::OPT_CITY, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->optionalData[1]->option); + $this->assertEquals('Vilvoorde', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->optionalData[1]->optionText); + $this->assertEquals(AddMultiElements\OptionalData::OPT_COUNTRY, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->optionalData[2]->option); + $this->assertEquals('Belgium', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->optionalData[2]->optionText); + $this->assertEquals(AddMultiElements\OptionalData::OPT_NAME, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->optionalData[3]->option); + $this->assertEquals('Mister Amadeus', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->optionalData[3]->optionText); + $this->assertEquals(AddMultiElements\OptionalData::OPT_STATE, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->optionalData[4]->option); + $this->assertEquals('Vlaams-Brabant', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->optionalData[4]->optionText); + $this->assertEquals(AddMultiElements\OptionalData::OPT_ZIP_CODE, $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->optionalData[5]->option); + $this->assertEquals('1800', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->structuredAddress->optionalData[5]->optionText); + } } diff --git a/tests/Amadeus/Client/Struct/Pnr/CancelTest.php b/tests/Amadeus/Client/Struct/Pnr/CancelTest.php new file mode 100644 index 000000000..4813f4855 --- /dev/null +++ b/tests/Amadeus/Client/Struct/Pnr/CancelTest.php @@ -0,0 +1,133 @@ + 10, + 'offers' => [2] + ]) + ); + + $this->assertEquals(10, $message->pnrActions->optionCode); + $this->assertNull($message->reservationInfo); + $this->assertEquals(1, count($message->cancelElements)); + $this->assertEquals(Cancel\Elements::ENTRY_ELEMENT, $message->cancelElements[0]->entryType); + $this->assertEquals(1, count($message->cancelElements[0]->element)); + $this->assertEquals(Cancel\Element::IDENT_OFFER_TATOO, $message->cancelElements[0]->element[0]->identifier); + $this->assertEquals(2, $message->cancelElements[0]->element[0]->number); + $this->assertNull($message->cancelElements[0]->element[0]->subElement); + } + + public function testCanMakeCancelByTatooMessageWithPnrRetrieve() + { + $message = new Cancel( + new PnrCancelOptions([ + 'recordLocator' => 'ABC123', + 'actionCode' => 0, + 'elementsByTatoo' => [14, 16, 20] + ]) + ); + + $this->assertEquals(0, $message->pnrActions->optionCode); + $this->assertEquals('ABC123', $message->reservationInfo->reservation->controlNumber); + $this->assertEquals(1, count($message->cancelElements)); + $this->assertEquals(Cancel\Elements::ENTRY_ELEMENT, $message->cancelElements[0]->entryType); + $this->assertEquals(3, count($message->cancelElements[0]->element)); + $this->assertEquals(Cancel\Element::IDENT_OTHER_TATOO, $message->cancelElements[0]->element[0]->identifier); + $this->assertEquals(14, $message->cancelElements[0]->element[0]->number); + $this->assertEquals(Cancel\Element::IDENT_OTHER_TATOO, $message->cancelElements[0]->element[1]->identifier); + $this->assertEquals(16, $message->cancelElements[0]->element[1]->number); + $this->assertEquals(Cancel\Element::IDENT_OTHER_TATOO, $message->cancelElements[0]->element[2]->identifier); + $this->assertEquals(20, $message->cancelElements[0]->element[2]->number); + } + + public function testCanMakeCancelItineraryMessage() + { + $message = new Cancel( + new PnrCancelOptions([ + 'actionCode' => 11, + 'cancelItinerary' => true + ]) + ); + + $this->assertEquals(11, $message->pnrActions->optionCode); + $this->assertEquals(1, count($message->cancelElements)); + $this->assertEquals(Cancel\Elements::ENTRY_ITINERARY, $message->cancelElements[0]->entryType); + $this->assertEquals(0, count($message->cancelElements[0]->element)); + } + + public function testCanMakeCancelPassengerMessage() + { + $message = new Cancel( + new PnrCancelOptions([ + 'actionCode' => 0, + 'passengers' => [3] + ]) + ); + + $this->assertEquals(0, $message->pnrActions->optionCode); + $this->assertNull($message->reservationInfo); + $this->assertEquals(1, count($message->cancelElements)); + $this->assertEquals(Cancel\Elements::ENTRY_ELEMENT, $message->cancelElements[0]->entryType); + $this->assertEquals(1, count($message->cancelElements[0]->element)); + $this->assertEquals(Cancel\Element::IDENT_PASSENGER_TATOO, $message->cancelElements[0]->element[0]->identifier); + $this->assertEquals(3, $message->cancelElements[0]->element[0]->number); + } + + public function testCanMakeCancelGroupPassengerMessage() + { + $message = new Cancel( + new PnrCancelOptions([ + 'actionCode' => 0, + 'groupPassengers' => [5,6] + ]) + ); + + $this->assertEquals(0, $message->pnrActions->optionCode); + $this->assertNull($message->reservationInfo); + $this->assertEquals(1, count($message->cancelElements)); + $this->assertEquals(Cancel\Elements::ENTRY_NAME_INTEGRATION, $message->cancelElements[0]->entryType); + $this->assertEquals(2, count($message->cancelElements[0]->element)); + $this->assertEquals(Cancel\Element::IDENT_PASSENGER_TATOO, $message->cancelElements[0]->element[0]->identifier); + $this->assertEquals(5, $message->cancelElements[0]->element[0]->number); + $this->assertEquals(Cancel\Element::IDENT_PASSENGER_TATOO, $message->cancelElements[0]->element[1]->identifier); + $this->assertEquals(6, $message->cancelElements[0]->element[1]->number); + } + + +} diff --git a/tests/Amadeus/Client/Struct/PriceXplorer/ExtremeSearchTest.php b/tests/Amadeus/Client/Struct/PriceXplorer/ExtremeSearchTest.php new file mode 100644 index 000000000..2c6aae1ff --- /dev/null +++ b/tests/Amadeus/Client/Struct/PriceXplorer/ExtremeSearchTest.php @@ -0,0 +1,241 @@ + + */ +class ExtremeSearchTest extends BaseTestCase +{ + public function testCanMakeFullXsMessage() + { + $opt = new PriceXplorerExtremeSearchOptions([ + 'resultAggregationOption' => PriceXplorerExtremeSearchOptions::AGGR_DEST_WEEK_DEPART_STAY, + 'origin' => 'BRU', + 'destinations' => ['SYD','CBR'], + 'currency' => 'EUR', + 'maxBudget' => 650, + 'minBudget' => 200, + 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-08-25', new \DateTimeZone('UTC')), + 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-09-28', new \DateTimeZone('UTC')), + //'departureDaysOutbound' => [1,2,3,4,5], + 'stayDurationDays' => 2, + 'stayDurationFlexibilityDays' => 3, + 'searchOffice' => 'LONBG2222' + ]); + + $message = new ExtremeSearch($opt); + + $this->assertEquals(3, count($message->itineraryGrp)); + $this->assertEquals('BRU', $message->itineraryGrp[0]->itineraryInfo->origin); + $this->assertEquals(null, $message->itineraryGrp[0]->itineraryInfo->destination); + $this->assertNull($message->itineraryGrp[0]->locationInfo); + $this->assertEquals(null, $message->itineraryGrp[1]->itineraryInfo->origin); + $this->assertEquals('SYD', $message->itineraryGrp[1]->itineraryInfo->destination); + $this->assertNull($message->itineraryGrp[1]->locationInfo); + $this->assertEquals(null, $message->itineraryGrp[2]->itineraryInfo->origin); + $this->assertEquals('CBR', $message->itineraryGrp[2]->itineraryInfo->destination); + $this->assertNull($message->itineraryGrp[2]->locationInfo); + + $this->assertEquals(MonetaryDetails::QUAL_MAX_BUDGET, $message->budget->monetaryDetails[0]->typeQualifier); + $this->assertEquals(650, $message->budget->monetaryDetails[0]->amount); + $this->assertEquals('EUR', $message->budget->monetaryDetails[0]->currency); + $this->assertEquals(MonetaryDetails::QUAL_MIN_BUDGET, $message->budget->monetaryDetails[1]->typeQualifier); + $this->assertEquals(200, $message->budget->monetaryDetails[1]->amount); + $this->assertEquals('EUR', $message->budget->monetaryDetails[1]->currency); + + $this->assertEquals('250816', $message->travelDates->dateAndTimeDetails[0]->date); + $this->assertEquals(DateAndTimeDetails::QUAL_STARTDATE, $message->travelDates->dateAndTimeDetails[0]->qualifier); + $this->assertEquals('280916', $message->travelDates->dateAndTimeDetails[1]->date); + $this->assertEquals(DateAndTimeDetails::QUAL_ENDDATE, $message->travelDates->dateAndTimeDetails[1]->qualifier); + + $this->assertEquals(QuantityDetailsType::UNIT_DAY, $message->stayDuration->nbOfUnitsInfo->quantityDetails[0]->unitQualifier); + $this->assertEquals(2, $message->stayDuration->nbOfUnitsInfo->quantityDetails[0]->numberOfUnit); + $this->assertEquals(QuantityDetailsType::QUAL_PLUS, $message->stayDuration->flexibilityInfo->quantityDetails[0]->qualifier); + $this->assertEquals(3, $message->stayDuration->flexibilityInfo->quantityDetails[0]->value); + $this->assertEquals(QuantityDetailsType::UNIT_DAY, $message->stayDuration->flexibilityInfo->quantityDetails[0]->unit); + + $this->assertEquals(AttributeInfo::FUNC_GROUPING, $message->attributeInfo[0]->attributeFunction); + $this->assertEquals(4, count($message->attributeInfo[0]->attributeDetails)); + $this->assertEquals(AttributeDetails::TYPE_DESTINATION, $message->attributeInfo[0]->attributeDetails[0]->attributeType); + $this->assertEquals(AttributeDetails::TYPE_WEEK, $message->attributeInfo[0]->attributeDetails[1]->attributeType); + $this->assertEquals(AttributeDetails::TYPE_DEPARTURE_DAY, $message->attributeInfo[0]->attributeDetails[2]->attributeType); + $this->assertEquals(AttributeDetails::TYPE_STAY_DURATION, $message->attributeInfo[0]->attributeDetails[3]->attributeType); + + $this->assertEquals(0, count($message->departureDays)); + $this->assertEquals('LONBG2222', $message->officeIdInfo[0]->officeId->originIdentification->inHouseIdentification1); + } + + public function testCanMakeXSCallWithDays() + { + $opt = new PriceXplorerExtremeSearchOptions([ + 'resultAggregationOption' => PriceXplorerExtremeSearchOptions::AGGR_DEST_WEEK_DEPART_STAY, + 'origin' => 'BRU', + 'destinations' => ['SYD'], + 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-08-25', new \DateTimeZone('UTC')), + 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-09-28', new \DateTimeZone('UTC')), + 'departureDaysInbound' => [1,2,3,4,5], + 'departureDaysOutbound' => [1,2,3], + 'searchOffice' => 'LONBG2222' + ]); + + $message = new ExtremeSearch($opt); + + $this->assertEquals(2, count($message->departureDays)); + $this->assertEquals('12345', $message->departureDays[0]->daySelection->dayOfWeek); + $this->assertEquals(SelectionDetails::OPT_INBOUND_DEP_DAYS, $message->departureDays[0]->selectionInfo->selectionDetails[0]->option); + + $this->assertEquals('123', $message->departureDays[1]->daySelection->dayOfWeek); + $this->assertEquals(SelectionDetails::OPT_OUTBOUND_DEP_DAYS, $message->departureDays[1]->selectionInfo->selectionDetails[0]->option); + } + + public function testCanMakeXSCallAggregationOpions() + { + $opt = new PriceXplorerExtremeSearchOptions([ + 'resultAggregationOption' => PriceXplorerExtremeSearchOptions::AGGR_COUNTRY, + 'origin' => 'BRU', + 'destinations' => ['SYD'], + 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-08-25', new \DateTimeZone('UTC')), + 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-09-28', new \DateTimeZone('UTC')), + 'searchOffice' => 'LONBG2222' + ]); + + $message = new ExtremeSearch($opt); + + $this->assertEquals(AttributeInfo::FUNC_GROUPING, $message->attributeInfo[0]->attributeFunction); + $this->assertEquals(1, count($message->attributeInfo[0]->attributeDetails)); + $this->assertEquals(AttributeDetails::TYPE_COUNTRY, $message->attributeInfo[0]->attributeDetails[0]->attributeType); + + + + $opt = new PriceXplorerExtremeSearchOptions([ + 'resultAggregationOption' => PriceXplorerExtremeSearchOptions::AGGR_DEST, + 'origin' => 'BRU', + 'destinations' => ['SYD'], + 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-08-25', new \DateTimeZone('UTC')), + 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-09-28', new \DateTimeZone('UTC')), + 'searchOffice' => 'LONBG2222' + ]); + + $message = new ExtremeSearch($opt); + + $this->assertEquals(AttributeInfo::FUNC_GROUPING, $message->attributeInfo[0]->attributeFunction); + $this->assertEquals(1, count($message->attributeInfo[0]->attributeDetails)); + $this->assertEquals(AttributeDetails::TYPE_DESTINATION, $message->attributeInfo[0]->attributeDetails[0]->attributeType); + + + + $opt = new PriceXplorerExtremeSearchOptions([ + 'resultAggregationOption' => PriceXplorerExtremeSearchOptions::AGGR_DEST_WEEK, + 'origin' => 'BRU', + 'destinations' => ['SYD'], + 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-08-25', new \DateTimeZone('UTC')), + 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-09-28', new \DateTimeZone('UTC')), + 'searchOffice' => 'LONBG2222' + ]); + + $message = new ExtremeSearch($opt); + + $this->assertEquals(AttributeInfo::FUNC_GROUPING, $message->attributeInfo[0]->attributeFunction); + $this->assertEquals(2, count($message->attributeInfo[0]->attributeDetails)); + $this->assertEquals(AttributeDetails::TYPE_DESTINATION, $message->attributeInfo[0]->attributeDetails[0]->attributeType); + $this->assertEquals(AttributeDetails::TYPE_WEEK, $message->attributeInfo[0]->attributeDetails[1]->attributeType); + + + + + $opt = new PriceXplorerExtremeSearchOptions([ + 'resultAggregationOption' => PriceXplorerExtremeSearchOptions::AGGR_DEST_WEEK_DEPART, + 'origin' => 'BRU', + 'destinations' => ['SYD'], + 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-08-25', new \DateTimeZone('UTC')), + 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-09-28', new \DateTimeZone('UTC')), + 'searchOffice' => 'LONBG2222' + ]); + + $message = new ExtremeSearch($opt); + + $this->assertEquals(AttributeInfo::FUNC_GROUPING, $message->attributeInfo[0]->attributeFunction); + $this->assertEquals(3, count($message->attributeInfo[0]->attributeDetails)); + $this->assertEquals(AttributeDetails::TYPE_DESTINATION, $message->attributeInfo[0]->attributeDetails[0]->attributeType); + $this->assertEquals(AttributeDetails::TYPE_WEEK, $message->attributeInfo[0]->attributeDetails[1]->attributeType); + $this->assertEquals(AttributeDetails::TYPE_DEPARTURE_DAY, $message->attributeInfo[0]->attributeDetails[2]->attributeType); + } + + public function testCanMakeXSCallWithDestCountries() + { + $opt = new PriceXplorerExtremeSearchOptions([ + 'resultAggregationOption' => PriceXplorerExtremeSearchOptions::AGGR_DEST_WEEK_DEPART_STAY, + 'origin' => 'BRU', + 'destinationCountries' => ['AU','NZ'], + 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-08-25', new \DateTimeZone('UTC')), + 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-09-28', new \DateTimeZone('UTC')), + 'searchOffice' => 'LONBG2222' + ]); + + $message = new ExtremeSearch($opt); + + $this->assertEquals(3, count($message->itineraryGrp)); + $this->assertEquals('BRU', $message->itineraryGrp[0]->itineraryInfo->origin); + $this->assertNull($message->itineraryGrp[0]->itineraryInfo->destination); + $this->assertNull( $message->itineraryGrp[1]->itineraryInfo->origin); + $this->assertNull($message->itineraryGrp[1]->itineraryInfo->destination); + $this->assertEquals(LocationInfo::LOC_COUNTRY, $message->itineraryGrp[1]->locationInfo->locationType); + $this->assertEquals('AU', $message->itineraryGrp[1]->locationInfo->locationDescription->code); + $this->assertEquals(LocationIdentificationType::QUAL_DESTINATION, $message->itineraryGrp[1]->locationInfo->locationDescription->qualifier); + $this->assertNull( $message->itineraryGrp[2]->itineraryInfo->origin); + $this->assertNull( $message->itineraryGrp[2]->itineraryInfo->destination); + $this->assertEquals(LocationInfo::LOC_COUNTRY, $message->itineraryGrp[2]->locationInfo->locationType); + $this->assertEquals('NZ', $message->itineraryGrp[2]->locationInfo->locationDescription->code); + $this->assertEquals(LocationIdentificationType::QUAL_DESTINATION, $message->itineraryGrp[2]->locationInfo->locationDescription->qualifier); + } + + public function testCanMakeXSCallWithCheapestFlags() + { + $opt = new PriceXplorerExtremeSearchOptions([ + 'resultAggregationOption' => PriceXplorerExtremeSearchOptions::AGGR_DEST_WEEK_DEPART_STAY, + 'origin' => 'BRU', + 'destinations' => ['SYD'], + 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-08-25', new \DateTimeZone('UTC')), + 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-09-28', new \DateTimeZone('UTC')), + 'returnCheapestNonStop' => true, + 'returnCheapestOverall' => true, + 'searchOffice' => 'LONBG2222' + ]); + + $message = new ExtremeSearch($opt); + + $this->assertEquals(1, count($message->selectionDetailsGroup)); + $this->assertEmpty($message->selectionDetailsGroup[0]->attributeInfo); + $this->assertEquals(SelectionDetails::OPT_PRICE_RESULT_DISTRIBUTION, $message->selectionDetailsGroup[0]->selectionDetailsInfo->selectionDetails[0]->option); + $this->assertEquals(2, count($message->selectionDetailsGroup[0]->nbOfUnitsInfo->quantityDetails)); + $this->assertEquals(NumberOfUnitDetailsType::QUAL_CHEAPEST_NONSTOP, $message->selectionDetailsGroup[0]->nbOfUnitsInfo->quantityDetails[0]->unitQualifier); + $this->assertEquals(NumberOfUnitDetailsType::QUAL_CHEAPEST_OVERALL, $message->selectionDetailsGroup[0]->nbOfUnitsInfo->quantityDetails[1]->unitQualifier); + } +} diff --git a/tests/Amadeus/ClientTest.php b/tests/Amadeus/ClientTest.php index 87c38bbe2..fd2a6b5a1 100644 --- a/tests/Amadeus/ClientTest.php +++ b/tests/Amadeus/ClientTest.php @@ -58,15 +58,20 @@ public function testCanCreateClient() $this->assertTrue($client->isStateful()); } - public function testCanCreateClientWithOverriddenSessionHandlerAndRequestCreator() + public function testCanCreateClientWithOverriddenSessionHandlerRequestCreatorAndResponseHandler() { $par = new Params([ 'sessionHandler' => $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(), - 'requestCreator' => $this->getMockBuilder('Amadeus\Client\RequestCreator\RequestCreatorInterface')->getMock() + 'requestCreator' => $this->getMockBuilder('Amadeus\Client\RequestCreator\RequestCreatorInterface')->getMock(), + 'responseHandler' => $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock() ]); $client = new Client($par); + $this->assertInstanceOf('Amadeus\Client\Session\Handler\HandlerInterface', $par->sessionHandler); + $this->assertInstanceOf('Amadeus\Client\RequestCreator\RequestCreatorInterface', $par->requestCreator); + $this->assertInstanceOf('Amadeus\Client\ResponseHandler\ResponseHandlerInterface', $par->responseHandler); + $this->assertInstanceOf('Amadeus\Client', $client); } @@ -209,12 +214,11 @@ public function testCanDoCreatePnrCall() $expectedPnrResult = new Client\Struct\Pnr\AddMultiElements($options); - $receivedFromElement = new Client\Struct\Pnr\AddMultiElements\DataElementsIndiv(Client\Struct\Pnr\AddMultiElements\ElementManagementData::SEGNAME_RECEIVE_FROM); + $receivedFromElement = new Client\Struct\Pnr\AddMultiElements\DataElementsIndiv(Client\Struct\Pnr\AddMultiElements\ElementManagementData::SEGNAME_RECEIVE_FROM, 4); $receivedFromElement->freetextData = new Client\Struct\Pnr\AddMultiElements\FreetextData( 'some RF string amabnl-amadeus-ws-client-0.0.1dev', Client\Struct\Pnr\AddMultiElements\FreetextDetail::TYPE_RECEIVE_FROM ); - $expectedPnrResult->dataElementsMaster->dataElementsIndiv[] = $receivedFromElement; $mockSessionHandler @@ -242,6 +246,131 @@ public function testCanDoCreatePnrCall() } + public function testCanDoAddMultiElementsSavePNR() + { + $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); + + $messageResult = 'A dummy message result'; // Not an actual XML reply. + + $options = new Client\RequestOptions\PnrAddMultiElementsOptions(); + $options->actionCode = 11; //11 End transact with retrieve (ER) + + $expectedPnrResult = new Client\Struct\Pnr\AddMultiElements($options); + + $mockSessionHandler + ->expects($this->once()) + ->method('sendMessage') + ->with('PNR_AddMultiElements', $expectedPnrResult, ['asString' => true, 'endSession' => false]) + ->will($this->returnValue($messageResult)); + + $mockSessionHandler + ->expects($this->once()) + ->method('getMessagesAndVersions') + ->will($this->returnValue(['PNR_AddMultiElements' => '14.2'])); + + $par = new Params(); + $par->sessionHandler = $mockSessionHandler; + $par->requestCreatorParams = new Params\RequestCreatorParams([ + 'receivedFrom' => 'some RF string', + 'originatorOfficeId' => 'BRUXXXXXX' + ]); + + $client = new Client($par); + + $response = $client->pnrAddMultiElements($options); + + $this->assertEquals($messageResult, $response); + } + + public function testCanDoAddMultiElementsSavePNRWithRf() + { + $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); + + $messageResult = 'A dummy message result'; // Not an actual XML reply. + + $options = new Client\RequestOptions\PnrAddMultiElementsOptions(); + $options->actionCode = 11; //11 End transact with retrieve (ER) + $options->receivedFrom = 'a unit test machine thingie'; + + $expectedPnrResult = new Client\Struct\Pnr\AddMultiElements($options); + + $expectedPnrResult->dataElementsMaster = new Client\Struct\Pnr\AddMultiElements\DataElementsMaster(); + + $receivedFromElement = new Client\Struct\Pnr\AddMultiElements\DataElementsIndiv(Client\Struct\Pnr\AddMultiElements\ElementManagementData::SEGNAME_RECEIVE_FROM, 2); + $receivedFromElement->freetextData = new Client\Struct\Pnr\AddMultiElements\FreetextData( + 'a unit test machine thingie', + Client\Struct\Pnr\AddMultiElements\FreetextDetail::TYPE_RECEIVE_FROM + ); + + $expectedPnrResult->dataElementsMaster->dataElementsIndiv[] = $receivedFromElement; + + $mockSessionHandler + ->expects($this->once()) + ->method('sendMessage') + ->with('PNR_AddMultiElements', $expectedPnrResult, ['asString' => true, 'endSession' => false]) + ->will($this->returnValue($messageResult)); + + $mockSessionHandler + ->expects($this->once()) + ->method('getMessagesAndVersions') + ->will($this->returnValue(['PNR_AddMultiElements' => '14.2'])); + + $par = new Params(); + $par->sessionHandler = $mockSessionHandler; + $par->requestCreatorParams = new Params\RequestCreatorParams([ + 'receivedFrom' => 'some RF string', + 'originatorOfficeId' => 'BRUXXXXXX' + ]); + + $client = new Client($par); + + $response = $client->pnrAddMultiElements($options); + + $this->assertEquals($messageResult, $response); + } + + public function testCanDoDummyPnrCancelCall() + { + $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); + + $messageResult = 'A dummy message result'; // Not an actual XML reply. + + $expectedPnrResult = new Client\Struct\Pnr\Cancel( + new Client\RequestOptions\PnrCancelOptions([ + 'actionCode' => 10, + 'cancelItinerary' => true + ]) + ); + + $mockSessionHandler + ->expects($this->once()) + ->method('sendMessage') + ->with('PNR_Cancel', $expectedPnrResult, ['asString' => true, 'endSession' => false]) + ->will($this->returnValue($messageResult)); + $mockSessionHandler + ->expects($this->once()) + ->method('getMessagesAndVersions') + ->will($this->returnValue(['PNR_Cancel' => '14.2'])); + + $par = new Params(); + $par->sessionHandler = $mockSessionHandler; + $par->requestCreatorParams = new Params\RequestCreatorParams([ + 'receivedFrom' => 'some RF string', + 'originatorOfficeId' => 'BRUXXXXXX' + ]); + + $client = new Client($par); + + $response = $client->pnrCancel( + new Client\RequestOptions\PnrCancelOptions([ + 'actionCode' => 10, + 'cancelItinerary' => true + ]) + ); + + $this->assertEquals($messageResult, $response); + } + public function testCanDoDummyQueueListCall() { @@ -544,6 +673,180 @@ public function testCanDoOfferVerifyCall() $this->assertEquals($messageResult, $response); } + public function testCanDoOfferConfirmHotelOffer() + { + $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); + + $messageResult = 'dummyofferconfirmhotelmessage'; + + $expectedMessageResult = new Client\Struct\Offer\ConfirmHotel( + new Client\RequestOptions\OfferConfirmHotelOptions([ + ]) + ); + + $mockSessionHandler + ->expects($this->once()) + ->method('sendMessage') + ->with('Offer_ConfirmHotelOffer', $expectedMessageResult, ['asString' => false, 'endSession' => false]) + ->will($this->returnValue($messageResult)); + $mockSessionHandler + ->expects($this->never()) + ->method('getLastResponse'); + $mockSessionHandler + ->expects($this->once()) + ->method('getMessagesAndVersions') + ->will($this->returnValue(['Offer_ConfirmHotelOffer' => "11.1"])); + + $par = new Params(); + $par->sessionHandler = $mockSessionHandler; + $par->requestCreatorParams = new Params\RequestCreatorParams([ + 'receivedFrom' => 'some RF string', + 'originatorOfficeId' => 'BRUXXXXXX' + ]); + + $client = new Client($par); + + $response = $client->offerConfirmHotel( + new Client\RequestOptions\OfferConfirmHotelOptions([ + ]) + ); + + $this->assertEquals($messageResult, $response); + } + + public function testCanDoOfferConfirmCarOffer() + { + $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); + + $messageResult = 'dummyofferconfirmcarmessage'; + + $expectedMessageResult = new Client\Struct\Offer\ConfirmCar( + new Client\RequestOptions\OfferConfirmCarOptions([ + ]) + ); + + $mockSessionHandler + ->expects($this->once()) + ->method('sendMessage') + ->with('Offer_ConfirmCarOffer', $expectedMessageResult, ['asString' => false, 'endSession' => false]) + ->will($this->returnValue($messageResult)); + $mockSessionHandler + ->expects($this->never()) + ->method('getLastResponse'); + $mockSessionHandler + ->expects($this->once()) + ->method('getMessagesAndVersions') + ->will($this->returnValue(['Offer_ConfirmCarOffer' => "11.1"])); + + $par = new Params(); + $par->sessionHandler = $mockSessionHandler; + $par->requestCreatorParams = new Params\RequestCreatorParams([ + 'receivedFrom' => 'some RF string', + 'originatorOfficeId' => 'BRUXXXXXX' + ]); + + $client = new Client($par); + + $response = $client->offerConfirmCar( + new Client\RequestOptions\OfferConfirmCarOptions([ + ]) + ); + + $this->assertEquals($messageResult, $response); + } + + public function testCanDoInfoEncodeDecodeCity() + { + $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); + + $messageResult = 'dummyinfo-encodedecodecity-message'; + + $expectedMessageResult = new Client\Struct\Info\EncodeDecodeCity( + new Client\RequestOptions\InfoEncodeDecodeCityOptions([ + ]) + ); + + $mockSessionHandler + ->expects($this->once()) + ->method('sendMessage') + ->with('Info_EncodeDecodeCity', $expectedMessageResult, ['asString' => false, 'endSession' => false]) + ->will($this->returnValue($messageResult)); + $mockSessionHandler + ->expects($this->never()) + ->method('getLastResponse'); + $mockSessionHandler + ->expects($this->once()) + ->method('getMessagesAndVersions') + ->will($this->returnValue(['Info_EncodeDecodeCity' => "05.1"])); + + $par = new Params(); + $par->sessionHandler = $mockSessionHandler; + $par->requestCreatorParams = new Params\RequestCreatorParams([ + 'receivedFrom' => 'some RF string', + 'originatorOfficeId' => 'BRUXXXXXX' + ]); + + $client = new Client($par); + + $response = $client->infoEncodeDecodeCity( + new Client\RequestOptions\InfoEncodeDecodeCityOptions([ + ]) + ); + + $this->assertEquals($messageResult, $response); + } + + public function testCanDoTicketCreateTSTFromPricing() + { + $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); + + $messageResult = 'dummyTicketCreateTSTFromPricingmessage'; + + $expectedMessageResult = new Client\Struct\Ticket\CreateTSTFromPricing( + new Client\RequestOptions\TicketCreateTstFromPricingOptions([ + 'pricings' => [ + new Client\RequestOptions\Ticket\Pricing([ + 'tstNumber' => 1 + ]) + ] + ]) + ); + + $mockSessionHandler + ->expects($this->once()) + ->method('sendMessage') + ->with('Ticket_CreateTSTFromPricing', $expectedMessageResult, ['asString' => false, 'endSession' => false]) + ->will($this->returnValue($messageResult)); + $mockSessionHandler + ->expects($this->never()) + ->method('getLastResponse'); + $mockSessionHandler + ->expects($this->once()) + ->method('getMessagesAndVersions') + ->will($this->returnValue(['Ticket_CreateTSTFromPricing' => "04.1"])); + + $par = new Params(); + $par->sessionHandler = $mockSessionHandler; + $par->requestCreatorParams = new Params\RequestCreatorParams([ + 'receivedFrom' => 'some RF string', + 'originatorOfficeId' => 'BRUXXXXXX' + ]); + + $client = new Client($par); + + $response = $client->ticketCreateTSTFromPricing( + new Client\RequestOptions\TicketCreateTstFromPricingOptions([ + 'pricings' => [ + new Client\RequestOptions\Ticket\Pricing([ + 'tstNumber' => 1 + ]) + ] + ]) + ); + + $this->assertEquals($messageResult, $response); + } + public function testCanDoOfferConfirmAirOffer() { $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); @@ -668,7 +971,7 @@ public function testCanSendFareMasterPricerTravelBoardSearch() { $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); - $messageResult = 'dummyfarepricepnrwithbookingclassmessage'; + $messageResult = 'dummyfarepricemasterpricertravelboardsearchresponsemessage'; $expectedMessageResult = new Client\Struct\Fare\MasterPricerTravelBoardSearch( new Client\RequestOptions\FareMasterPricerTbSearch([ @@ -741,6 +1044,59 @@ public function testCanSendFareMasterPricerTravelBoardSearch() $this->assertEquals($messageResult, $response); } + public function testCanSendPriceXplorerExtremeSearch() + { + $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); + + $messageResult = 'dummyfarepricemasterpricertravelboardsearchresponsemessage'; + + $expectedMessageResult = new Client\Struct\PriceXplorer\ExtremeSearch( + new Client\RequestOptions\PriceXplorerExtremeSearchOptions([ + 'resultAggregationOption' => Client\RequestOptions\PriceXplorerExtremeSearchOptions::AGGR_COUNTRY, + 'origin' => 'BRU', + 'destinations' => ['SYD', 'CBR'], + 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-08-25', new \DateTimeZone('UTC')), + 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-09-28', new \DateTimeZone('UTC')), + 'searchOffice' => 'LONBG2222' + ]) + ); + + $mockSessionHandler + ->expects($this->once()) + ->method('sendMessage') + ->with('PriceXplorer_ExtremeSearch', $expectedMessageResult, ['asString' => false, 'endSession' => false]) + ->will($this->returnValue($messageResult)); + $mockSessionHandler + ->expects($this->never()) + ->method('getLastResponse'); + $mockSessionHandler + ->expects($this->once()) + ->method('getMessagesAndVersions') + ->will($this->returnValue(['PriceXplorer_ExtremeSearch' => "10.3"])); + + $par = new Params(); + $par->sessionHandler = $mockSessionHandler; + $par->requestCreatorParams = new Params\RequestCreatorParams([ + 'receivedFrom' => 'some RF string', + 'originatorOfficeId' => 'BRUXXXXXX' + ]); + + $client = new Client($par); + + $response = $client->priceXplorerExtremeSearch( + new Client\RequestOptions\PriceXplorerExtremeSearchOptions([ + 'resultAggregationOption' => Client\RequestOptions\PriceXplorerExtremeSearchOptions::AGGR_COUNTRY, + 'origin' => 'BRU', + 'destinations' => ['SYD', 'CBR'], + 'earliestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-08-25', new \DateTimeZone('UTC')), + 'latestDepartureDate' => \DateTime::createFromFormat('Y-m-d','2016-09-28', new \DateTimeZone('UTC')), + 'searchOffice' => 'LONBG2222' + ]) + ); + + $this->assertEquals($messageResult, $response); + } + public function testCanFarePricePnrWithBookingClassVersion12() { $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); @@ -784,6 +1140,41 @@ public function testCanFarePricePnrWithBookingClassVersion12() $this->assertEquals($messageResult, $response); } + public function testCanFarePricePnrWithBookingClassVersion14() + { + $this->setExpectedException('\Amadeus\Client\RequestCreator\MessageVersionUnsupportedException'); + + $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); + + $messageResult = 'dummyfarepricepnrwithbookingclassmessage'; + + $mockSessionHandler + ->expects($this->never()) + ->method('sendMessage'); + $mockSessionHandler + ->expects($this->never()) + ->method('getLastResponse'); + $mockSessionHandler + ->expects($this->once()) + ->method('getMessagesAndVersions') + ->will($this->returnValue(['Fare_PricePNRWithBookingClass' => "14.3"])); + + $par = new Params(); + $par->sessionHandler = $mockSessionHandler; + $par->requestCreatorParams = new Params\RequestCreatorParams([ + 'receivedFrom' => 'some RF string', + 'originatorOfficeId' => 'BRUXXXXXX' + ]); + + $client = new Client($par); + + $client->farePricePnrWithBookingClass( + new Client\RequestOptions\FarePricePnrWithBookingClassOptions([ + 'validatingCarrier' => 'SN' + ]) + ); + } + public function testCanDoSignOutCall() { $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();