Skip to content

Commit

Permalink
Started implementing PNR_Cancel. Implemented Ticket_CreateTSTFromPric…
Browse files Browse the repository at this point in the history
…ing. Support for PNR_AddMultiElements for just sending ActionCodes (for example to save the PNR in context). Extra examples.
  • Loading branch information
DerMika committed Feb 25, 2016
1 parent d338a1d commit 7665b3f
Show file tree
Hide file tree
Showing 20 changed files with 926 additions and 72 deletions.
3 changes: 2 additions & 1 deletion docs/about-get-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ This is the list of messages that are at least partially supported at this time:
- 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_Cancel
- Queue_List
- Queue_PlacePNR
- Queue_RemoveItem
Expand All @@ -104,9 +105,9 @@ 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

We plan to support an entire basic booking flow (MasterPricer, SellFromRecommendation, Pricing, ...) later on.

Expand Down
90 changes: 68 additions & 22 deletions docs/samples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ Creating a PNR (simplified example containing only the most basic PNR elements n
$createdPnr = $client->pnrCreatePnr($opt);
Save a PNR which you started (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
------------
Expand Down Expand Up @@ -241,20 +254,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'))
])
])
Expand All @@ -271,11 +290,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'
])
);
***
Expand Down Expand Up @@ -327,6 +348,21 @@ Ticket_CreateTSTFromPricing

Create a TST from a Pricing made by a Fare_PricePNRWithBookingClass call:

.. code-block:: php
use Amadeus\Client;
use Amadeus\Client\RequestOptions\TicketCreateTstFromPricingOptions;
use Amadeus\Client\RequestOptions\Ticket\Pricing;
$createTstResponse = $client->ticketCreateTSTFromPricing(
new TicketCreateTstFromPricingOptions([
'pricings' => [
new Pricing([
'tstNumber' => 1
])
]
])
);
-----------------
Ticket_DisplayTST
Expand All @@ -343,6 +379,17 @@ 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
---------------------
Expand All @@ -368,17 +415,16 @@ Get MiniRules for a pricing in context (either a TST pricing, Offers or a pricin
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
])
]
])
);
***************
Expand Down
45 changes: 45 additions & 0 deletions src/Amadeus/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,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
*
Expand Down Expand Up @@ -614,6 +636,29 @@ 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
);
}

/**
* Make message options
*
Expand Down
26 changes: 25 additions & 1 deletion src/Amadeus/Client/RequestCreator/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
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;
Expand All @@ -45,6 +46,7 @@
use Amadeus\Client\RequestOptions\QueuePlacePnrOptions;
use Amadeus\Client\RequestOptions\QueueRemoveItemOptions;
use Amadeus\Client\RequestOptions\RequestOptionsInterface;
use Amadeus\Client\RequestOptions\TicketCreateTstFromPricingOptions;
use Amadeus\Client\Struct;

/**
Expand Down Expand Up @@ -142,13 +144,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
Expand Down Expand Up @@ -322,6 +336,16 @@ protected function createFarePricePnrWithBookingClass(FarePricePnrWithBookingCla
}
}

/**
* @param TicketCreateTstFromPricingOptions $params
*
* @return Struct\Ticket\CreateTSTFromPricing
*/
protected function createTicketCreateTSTFromPricing(TicketCreateTstFromPricingOptions $params)
{
return new Struct\Ticket\CreateTSTFromPricing($params);
}

/**
* Check if a given message is in the active WSDL. Throws exception if it isn't.
*
Expand Down
24 changes: 24 additions & 0 deletions src/Amadeus/Client/RequestOptions/PnrAddMultiElementsBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
56 changes: 56 additions & 0 deletions src/Amadeus/Client/RequestOptions/PnrCancelOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* amadeus-ws-client
*
* Copyright 2015 Amadeus Benelux NV
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @package Amadeus
* @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
*/

namespace Amadeus\Client\RequestOptions;

/**
* PnrCancelOptions
*
* @package Amadeus\Client\RequestOptions
*/
class PnrCancelOptions extends Base
{
public $recordLocator;

/**
* How to handle the PNR after doing the Cancel operation
*
* 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;


}
25 changes: 0 additions & 25 deletions src/Amadeus/Client/RequestOptions/PnrCreatePnrOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,6 @@
*/
class PnrCreatePnrOptions extends PnrAddMultiElementsBase
{
/**
* 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;

/**
* A group of travellers
Expand Down
Loading

0 comments on commit 7665b3f

Please sign in to comment.