Skip to content

Commit

Permalink
Support for adding elements & segments to an existing PNR. Support fo…
Browse files Browse the repository at this point in the history
…r Offer_ConfirmHotelOffer
  • Loading branch information
DerMika committed Mar 3, 2016
1 parent 4953246 commit 1e69e60
Show file tree
Hide file tree
Showing 25 changed files with 605 additions and 28 deletions.
10 changes: 5 additions & 5 deletions docs/samples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Creating a PNR (simplified example containing only the most basic PNR elements n
use Amadeus\Client\RequestOptions\Pnr\Element\Contact;
$opt = new PnrCreatePnrOptions();
$opt->actionCode = 11; //11 End transact with retrieve (ER)
$opt->actionCode = PnrCreatePnrOptions::ACTION_NO_PROCESSING; //0 Do not yet save the PNR and keep in context.
$opt->travellers[] = new Traveller([
'number' => 1,
'firstName' => 'FirstName',
Expand Down Expand Up @@ -155,7 +155,7 @@ Save a PNR which you have in context (created with actionCode 0 for example) and
$pnrReply = $client->pnrAddMultiElements(
new PnrAddMultiElementsOptions([
'actionCode' => 11 //ET / END AND RETRIEVE
'actionCode' => PnrAddMultiElementsOptions::ACTION_END_TRANSACT_RETRIEVE //ET: END AND RETRIEVE
])
);
Expand Down Expand Up @@ -206,7 +206,7 @@ Cancel the entire itinerary of the PNR in context and do an end transact to save
$cancelReply = $client->pnrCancel(
new PnrCancelOptions([
'cancelItinerary' => true,
'actionCode' => 10
'actionCode' => PnrCancelOptions::ACTION_END_TRANSACT
])
);
Expand All @@ -220,7 +220,7 @@ Cancel a PNR element with tatoo number 15 and do an End and Retrieve (ER) to rec
$cancelReply = $client->pnrCancel(
new PnrCancelOptions([
'elementsByTatoo' => [15],
'actionCode' => 11
'actionCode' => PnrCancelOptions::ACTION_END_TRANSACT_RETRIEVE
])
);
Expand All @@ -234,7 +234,7 @@ Same as before, but this time without having a PNR in context (you must provide
new PnrCancelOptions([
'recordLocator' => 'ABC123,
'elementsByTatoo' => [15],
'actionCode' => 11
'actionCode' => PnrCancelOptions::ACTION_END_TRANSACT_RETRIEVE
])
);
Expand Down
74 changes: 74 additions & 0 deletions src/Amadeus/Client/RequestOptions/Offer/PaymentDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?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\Offer;

use Amadeus\Client\LoadParamsFromArray;

/**
* PaymentDetails
*
* @package Amadeus\Client\RequestOptions\Offer
* @author Dieter Devlieghere <dieter.devlieghere@benelux.amadeus.com>
*/
class PaymentDetails extends LoadParamsFromArray
{
/**
* 2-character company code for the credit card vendor
*
* VI = Visa
* AX = American Express
* BC = BC Card
* CA = MasterCard
* DS = Discover
* DC = Diners Club
* T = Carta Si
* R = Carte Bleue
* E = Visa Electron
* JC = Japan Credit Bureau
* TO = Maestro
* ...
*
* @var string
*/
public $ccVendor;

/**
* The credit card number
* @var string
*/
public $ccCardNumber;

/**
* The name on the credit card
*
* @var string
*/
public $ccCardHolder;

/**
* MMYY - expiry date of credit card
*
* @var string
*/
public $ccExpiry;
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,17 @@ class OfferConfirmHotelOptions extends Base
*
* @var int
*/
public $paymentType = self::PAYMENT_GUARANTEED;
public $paymentType;

/**
* self::FOP_*
*
* @var string
*/
public $formOfPayment;

/**
* @var Offer\PaymentDetails
*/
public $paymentDetails;
}
4 changes: 4 additions & 0 deletions src/Amadeus/Client/RequestOptions/Pnr/Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ class Reference extends LoadParamsFromArray
{
const TYPE_PASSENGER_TATOO = "PT";

const TYPE_PASSENGER_REQUEST = "PR";

const TYPE_SEGMENT_TATOO = "ST";

const TYPE_SEGMENT_REQUEST = "SR";

/**
* self::TYPE_*
*
Expand Down
4 changes: 2 additions & 2 deletions src/Amadeus/Client/RequestOptions/PnrAddMultiElementsBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
* @package Amadeus\Client\RequestOptions
* @author Dieter Devlieghere <dieter.devlieghere@benelux.amadeus.com>
*/
class PnrAddMultiElementsBase extends Base
class PnrAddMultiElementsBase extends PnrBase
{
/**
* How to handle the PNR after creating
* self::ACTION_* How to handle the PNR after creating
*
* 0 No special processing
* 10 End transact (ET)
Expand Down
31 changes: 31 additions & 0 deletions src/Amadeus/Client/RequestOptions/PnrAddMultiElementsOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,37 @@
*/
class PnrAddMultiElementsOptions extends PnrAddMultiElementsBase
{
/**
* PNR record locator
*
* (only specify when this PNR is not already in context!)
*
* @var string
*/
public $recordLocator;

/**
* Non-group travellers (max 9)
*
* Will be added to the existing PNR
*
* (travellerInfo)
*
* @var Pnr\Traveller[]
*/
public $travellers = [];

/**
* (originDestinationDetails)
*
* @var Pnr\Segment[]
*/
public $tripSegments = [];

/**
* (dataElementsMaster\dataElementsIndiv)
*
* @var Pnr\Element[]
*/
public $elements = [];
}
58 changes: 58 additions & 0 deletions src/Amadeus/Client/RequestOptions/PnrBase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?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;

/**
* PnrBase
*
* @package Amadeus\Client\RequestOptions
* @author Dieter Devlieghere <dieter.devlieghere@benelux.amadeus.com>
*/
class PnrBase extends Base
{
const ACTION_NO_PROCESSING = 0;

const ACTION_END_TRANSACT = 10;

const ACTION_END_TRANSACT_RETRIEVE = 11;

const ACTION_END_TRANSACT_CHANGE_ADV_CODES = 12;

const ACTION_END_TRANSACT_RETRIEVE_CHANGE_ADV_CODES = 13;

const ACTION_END_TRANSACT_SPLIT = 14;

const ACTION_CANCEL_ITIN_END_TRANSACT = 15;

const ACTION_CANCEL_ITIN_END_TRANSACT_RETRIEVE = 16;

const ACTION_IGNORE = 20;

const ACTION_IGNORE_RETRIEVE = 21;

const ACTION_STOP_EOT_ON_SELL_ERROR = 267;

const ACTION_WARNING_AT_EOT = 30;

const ACTION_REPLY_SHORT_MESSAGE = 50;
}
2 changes: 1 addition & 1 deletion src/Amadeus/Client/RequestOptions/PnrCancelOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* @package Amadeus\Client\RequestOptions
*/
class PnrCancelOptions extends Base
class PnrCancelOptions extends PnrBase
{
/**
* Only provide the Record Locator if the PNR is not yet in context!!
Expand Down
2 changes: 0 additions & 2 deletions src/Amadeus/Client/RequestOptions/PnrCreatePnrOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
*/
class PnrCreatePnrOptions extends PnrAddMultiElementsBase
{

/**
* A group of travellers
*
Expand Down Expand Up @@ -58,5 +57,4 @@ class PnrCreatePnrOptions extends PnrAddMultiElementsBase
* @var Pnr\Element[]
*/
public $elements = [];

}
56 changes: 55 additions & 1 deletion src/Amadeus/Client/Struct/Offer/ConfirmHotel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,23 @@
namespace Amadeus\Client\Struct\Offer;

use Amadeus\Client\RequestOptions\OfferConfirmHotelOptions;
use Amadeus\Client\RequestOptions\Offer\PaymentDetails as PaymentDetailsOptions;
use Amadeus\Client\Struct\BaseWsMessage;
use Amadeus\Client\Struct\InvalidArgumentException;
use Amadeus\Client\Struct\Offer\ConfirmHotel\CcInfo;
use Amadeus\Client\Struct\Offer\ConfirmHotel\CreditCardInfo;
use Amadeus\Client\Struct\Offer\ConfirmHotel\GlobalBookingInfo;
use Amadeus\Client\Struct\Offer\ConfirmHotel\GroupCreditCardInfo;
use Amadeus\Client\Struct\Offer\ConfirmHotel\GuaranteeOrDeposit;
use Amadeus\Client\Struct\Offer\ConfirmHotel\HotelProductReference;
use Amadeus\Client\Struct\Offer\ConfirmHotel\OccupantList;
use Amadeus\Client\Struct\Offer\ConfirmHotel\PaymentDetails;
use Amadeus\Client\Struct\Offer\ConfirmHotel\PaymentInfo;
use Amadeus\Client\Struct\Offer\ConfirmHotel\PnrInfo;
use Amadeus\Client\Struct\Offer\ConfirmHotel\ReferenceDetails;
use Amadeus\Client\Struct\Offer\ConfirmHotel\RepresentativeParties;
use Amadeus\Client\Struct\Offer\ConfirmHotel\RoomList;
use Amadeus\Client\Struct\Offer\ConfirmHotel\RoomRateDetails;
use Amadeus\Client\Struct\Offer\ConfirmHotel\RoomStayData;
use Amadeus\Client\Struct\Offer\ConfirmHotel\TattooReference;

Expand Down Expand Up @@ -77,6 +92,45 @@ public function __construct(OfferConfirmHotelOptions $params)
$this->roomStayData[0]->tattooReference = new TattooReference($params->offerReference);
}

//if (!empty($params->))
if (!empty($params->passengers)) {
if (!isset($this->roomStayData[0])) {
$this->roomStayData[] = new RoomStayData();
}
$this->roomStayData[0]->globalBookingInfo = new GlobalBookingInfo();

foreach ($params->passengers as $singlePass) {
$tmp = new RepresentativeParties();
$tmp->occupantList = new OccupantList(
$singlePass,
PassengerReference::TYPE_BOOKING_HOLDER_OCCUPANT
);
$this->roomStayData[0]->globalBookingInfo->representativeParties[] = $tmp;
}
}

if (!empty($params->paymentType) && !empty($params->formOfPayment) && $params->paymentDetails instanceof PaymentDetailsOptions) {
if (!isset($this->roomStayData[0])) {
$this->roomStayData[] = new RoomStayData();
}

$this->roomStayData[0]->roomList[] = new RoomList();

$this->roomStayData[0]->roomList[0]->guaranteeOrDeposit = new GuaranteeOrDeposit();
$this->roomStayData[0]->roomList[0]->guaranteeOrDeposit->paymentInfo = new PaymentInfo(
$params->paymentType,
$params->formOfPayment
);

if ($params->formOfPayment === PaymentDetails::FOP_CREDIT_CARD) {
$this->roomStayData[0]->roomList[0]->guaranteeOrDeposit->groupCreditCardInfo = new GroupCreditCardInfo(
$params->paymentDetails->ccVendor,
$params->paymentDetails->ccCardHolder,
$params->paymentDetails->ccCardNumber,
$params->paymentDetails->ccExpiry
);
} else {
throw new InvalidArgumentException('Hotel Offer Confirm Form of Payment ' . $params->formOfPayment . ' is not yet supported');
}
}
}
}
19 changes: 19 additions & 0 deletions src/Amadeus/Client/Struct/Offer/ConfirmHotel/CcInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,23 @@ class CcInfo
* @var string
*/
public $ccHolderName;

/**
* CcInfo constructor.
*
* @param string $vendor
* @param string $name
* @param string $number
* @param string $expiry
* @param string|null $secId
*/
public function __construct($vendor, $name, $number, $expiry, $secId = null)
{
$this->vendorCode = $vendor;
$this->ccHolderName = $name;
$this->cardNumber = $number;
$this->expiryDate = $expiry;
$this->securityId = $secId;

}
}
Loading

0 comments on commit 1e69e60

Please sign in to comment.