From db89dde0eb3bf38998bd54900c61aabbfff98576 Mon Sep 17 00:00:00 2001 From: dieter Date: Wed, 10 May 2017 17:12:39 +0200 Subject: [PATCH] Add support for Form of Payment override in Fare_* pricing messages and Service_IntegratedPricing message. Also support for Frequent Flyer override in Service_IntegratedPricing. (issue #72) --- CHANGELOG.md | 4 +- docs/samples.rst | 41 ++ docs/samples/pricepnr.rst | 88 ++++- .../Fare/PricePnr/FormOfPayment.php | 62 +++ .../FarePricePnrWithBookingClassOptions.php | 15 +- .../RequestOptions/Service/FormOfPayment.php | 33 ++ .../RequestOptions/Service/FrequentFlyer.php | 2 - .../ServiceIntegratedPricingOptions.php | 14 + .../Fare/PricePNRWithBookingClass13.php | 28 ++ .../Struct/Fare/PricePnr13/FormOfPayment.php | 14 +- .../PricePnr13/FormOfPaymentInformation.php | 18 + .../PricePnr13/FrequentFlyerInformation.php | 21 ++ .../Fare/PricePnr13/PricingOptionKey.php | 19 +- .../Struct/Service/IntegratedPricing.php | 52 +++ .../IntegratedPricing/PricingOptionKey.php | 96 ++++- .../Client/Struct/Air/FlightInfoTest.php | 60 +-- .../Fare/PricePNRWithBookingClass13Test.php | 357 ++++++++++-------- .../Struct/Security/AuthenticateTest.php | 20 +- .../Struct/Service/IntegratedPricingTest.php | 270 ++++++++----- .../Ticket/CreateTSMFromPricingTest.php | 18 +- .../Ticket/CreateTSTFromPricingTest.php | 18 +- .../Client/Struct/Ticket/DeleteTsmpTest.php | 52 +-- 22 files changed, 924 insertions(+), 378 deletions(-) create mode 100644 src/Amadeus/Client/RequestOptions/Fare/PricePnr/FormOfPayment.php create mode 100644 src/Amadeus/Client/RequestOptions/Service/FormOfPayment.php diff --git a/CHANGELOG.md b/CHANGELOG.md index af465e993..a62bed141 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ # Release 1.4.0 (UNRELEASED) -* Added support for ``Fare_PricePNRWithBookingClass`` errors in message version 7.3 format (https://github.com/amabnl/amadeus-ws-client/issues/57). +* Added support for ``Fare_PricePNRWithBookingClass`` errors in message version 7.3 format (https://github.com/amabnl/amadeus-ws-client/issues/57) * Added support for Seat Request elements in in ``PNR_AddMultiElements`` (https://github.com/amabnl/amadeus-ws-client/issues/64/) * Added support for Credit Card Holder name when adding FP elements with ``PNR_AddMultiElements`` (https://github.com/amabnl/amadeus-ws-client/issues/69) * Added the possibility to disable the automatic addition of an RF element on each ``PNR_AddMultiElements`` call (https://github.com/amabnl/amadeus-ws-client/issues/68) +* Added support for Form Of Payment overrides in all ``Fare_`` Pricing messages and in ``Service_IntegratedPricing`` (https://github.com/amabnl/amadeus-ws-client/issues/72) +* Added support for Frequent Flyer override in ``Service_IntegratedPricing`` * Implemented ``DocRefund_InitRefund`` (https://github.com/amabnl/amadeus-ws-client/issues/56) * Implemented ``DocRefund_UpdateRefund`` (https://github.com/amabnl/amadeus-ws-client/issues/56) * Implemented ``Fare_GetFareRules`` (https://github.com/amabnl/amadeus-ws-client/issues/63) diff --git a/docs/samples.rst b/docs/samples.rst index 7f9ab0e3a..16f494fc2 100644 --- a/docs/samples.rst +++ b/docs/samples.rst @@ -2288,6 +2288,47 @@ Assign an account code to a passenger: ]) ); +Form of Payment: + +.. code-block:: php + + use Amadeus\Client\RequestOptions\ServiceIntegratedPricingOptions; + use Amadeus\Client\RequestOptions\Service\FormOfPayment; + + $pricingResponse = $client->serviceIntegratedPricing( + new ServiceIntegratedPricingOptions([ + 'formOfPayment' => [ + new FormOfPayment([ + 'type' => FormOfPayment::TYPE_CREDIT_CARD, + 'amount' => 10, + 'creditCardNumber' => '400000' + ]), + new FormOfPayment([ + 'type' => FormOfPayment::TYPE_CASH + ]), + ] + ]) + ); + +Frequent Flyer: + +.. code-block:: php + + use Amadeus\Client\RequestOptions\ServiceIntegratedPricingOptions; + use Amadeus\Client\RequestOptions\Service\FrequentFlyer; + + $pricingResponse = $client->serviceIntegratedPricing( + new ServiceIntegratedPricingOptions([ + 'frequentFlyers' => [ + new FrequentFlyer([ + 'company' => '6X', + 'number' => '1234567891011', + 'tierLevel' => 'SILVER', + 'priorityCode' => '1' + ]) + ] + ]) + ); *** FOP diff --git a/docs/samples/pricepnr.rst b/docs/samples/pricepnr.rst index 015ac5391..40a1492a4 100644 --- a/docs/samples/pricepnr.rst +++ b/docs/samples/pricepnr.rst @@ -2,6 +2,11 @@ Fare_PricePNRWithBookingClass examples ====================================== +.. contents:: + +No options +========== + Price a PNR with no specific options: This option is used when no specific pricing option is requested. .. code-block:: php @@ -12,6 +17,10 @@ Price a PNR with no specific options: This option is used when no specific prici new FarePricePnrWithBookingClassOptions() ); + +List of all available fares (example of using override options) +=============================================================== + List of Fares: This option is used to request a list of available fares. .. code-block:: php @@ -26,6 +35,9 @@ List of Fares: This option is used to request a list of available fares. ]) ); +Lowest fare +=========== + Lowest fare: Return only the lowest fare: .. code-block:: php @@ -40,6 +52,9 @@ Lowest fare: Return only the lowest fare: ]) ); +Fare type overrides +=================== + Fare types: Take into account Published Fares, Unifares, Negotiated fares: .. code-block:: php @@ -56,6 +71,10 @@ Fare types: Take into account Published Fares, Unifares, Negotiated fares: ]) ); + +OB Fees +======= + Price a PNR with OB fees: **Example:** for passenger 1, include fee "FC1" with an amount of 10 USD and exempt from fee "T01". @@ -87,6 +106,10 @@ Price a PNR with OB fees: ]) ); + +Corporate negotiated fares +========================== + Price with corporate negotiated fare '012345': .. code-block:: php @@ -112,6 +135,10 @@ Price with corporate unifares '012345' and 'AMADEUS': ); + +Passenger PTC / Discount code +============================= + Price with Passenger PTC / Discount codes **Example:** use cumulative discount codes YTH, AD20 and MIL for passenger 1 on segment 4. @@ -137,6 +164,10 @@ Price with Passenger PTC / Discount codes ]) ); + +Point of Sale override +====================== + Override Point of Sale to LON: .. code-block:: php @@ -149,6 +180,10 @@ Override Point of Sale to LON: ]) ); + +Point of Ticketing override +=========================== + Override Point of Ticketing to PAR: .. code-block:: php @@ -162,6 +197,9 @@ Override Point of Ticketing to PAR: ); +Ticket type (electronic / paper ticket) +======================================= + Specify ticket type "Electronic Ticket": *Other possible values are:* @@ -180,6 +218,9 @@ Specify ticket type "Electronic Ticket": ); +Add taxes +========= + Add specific taxes: **Example:** @@ -209,6 +250,10 @@ Add specific taxes: ]) ); + +Exempt taxes +============ + Exempt from specific taxes. This option is used to exempt the passenger from one, several or all taxes. **Example:** exemption of tax ZVGO @@ -230,6 +275,9 @@ Exempt from specific taxes. This option is used to exempt the passenger from one ); +Passenger, Segment or TST selection +=================================== + Passenger/Segment/TST selection: This option is used to price only part of a PNR. **Example:** price infant number 1, non-infant number 2 and passenger 3 for segment 1 @@ -262,7 +310,11 @@ Passenger/Segment/TST selection: This option is used to price only part of a PNR ]) ); -Past Date Pricing: This option is used to target fares that were applicable on a given date. + +Past date pricing +================= + +This option is used to target fares that were applicable on a given date. **Example:** pricing using fare that was applicable on 27JUN2012. @@ -280,7 +332,11 @@ Past Date Pricing: This option is used to target fares that were applicable on a ]) ); -Award Pricing: This option is used to price an itinerary applying an award program for a given carrier. + +Award pricing +============= + +This option is used to price an itinerary applying an award program for a given carrier. *Note: The award option must be combined with the corporate option.* @@ -301,3 +357,31 @@ Award Pricing: This option is used to price an itinerary applying an award progr ]) ); + +Form of Payment override +======================== + +This option is used to specify the form of payment information to use. + +**Example:** Use a form of payment Credit Card with bin range 400000 for an amount of 10 and the remaining on a FOP Cash. + +.. code-block:: php + + use Amadeus\Client\RequestOptions\FarePricePnrWithBookingClassOptions; + user Amadeus\Client\RequestOptions\Fare\PricePnr\FormOfPayment; + + $pricingResponse = $client->farePricePnrWithBookingClass( + new FarePricePnrWithBookingClassOptions([ + 'formOfPayment' => [ + new FormOfPayment([ + 'type' => FormOfPayment::TYPE_CREDIT_CARD, + 'amount' => 10, + 'creditCardNumber' => '400000' + ]), + new FormOfPayment([ + 'type' => FormOfPayment::TYPE_CASH + ]), + ] + ]) + ); + diff --git a/src/Amadeus/Client/RequestOptions/Fare/PricePnr/FormOfPayment.php b/src/Amadeus/Client/RequestOptions/Fare/PricePnr/FormOfPayment.php new file mode 100644 index 000000000..e96725ec3 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/Fare/PricePnr/FormOfPayment.php @@ -0,0 +1,62 @@ + + */ +class FormOfPayment extends LoadParamsFromArray +{ + const TYPE_ON_BEHALF_OF_AGENT = "AGT"; + const TYPE_CASH = "CA"; + const TYPE_CREDIT_CARD = "CC"; + const TYPE_CHECK = "CK"; + const TYPE_GOVERNMENT_TRANSPORTATION_REQUEST = "GR"; + const TYPE_MISCELLANEOUS = "MS"; + const TYPE_NON_REFUNDABLE = "NR"; + const TYPE_PREPAID_TICKET_ADVICE = "PT"; + const TYPE_SINGLE_GOVERNMENT_TRANSPORTATION_REQUEST = "SGR"; + const TYPE_UNITED_NATIONS_TRANSPORTATION_REQUEST = "UN"; + + /** + * self::TYPE_* + * + * @var string + */ + public $type; + + /** + * @var int|float + */ + public $amount; + + /** + * @var string + */ + public $creditCardNumber; +} diff --git a/src/Amadeus/Client/RequestOptions/FarePricePnrWithBookingClassOptions.php b/src/Amadeus/Client/RequestOptions/FarePricePnrWithBookingClassOptions.php index f655a2c06..a26009c24 100644 --- a/src/Amadeus/Client/RequestOptions/FarePricePnrWithBookingClassOptions.php +++ b/src/Amadeus/Client/RequestOptions/FarePricePnrWithBookingClassOptions.php @@ -24,6 +24,9 @@ use Amadeus\Client\RequestOptions\Fare\PricePnr\AwardPricing; use Amadeus\Client\RequestOptions\Fare\PricePnr\ExemptTax; +use Amadeus\Client\RequestOptions\Fare\PricePnr\FareBasis; +use Amadeus\Client\RequestOptions\Fare\PricePnr\FormOfPayment; +use Amadeus\Client\RequestOptions\Fare\PricePnr\ObFee; use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef; use Amadeus\Client\RequestOptions\Fare\PricePnr\Tax; @@ -46,6 +49,7 @@ class FarePricePnrWithBookingClassOptions extends Base const OVERRIDE_RETURN_LOWEST_AVAILABLE = 'RLA'; const OVERRIDE_RETURN_ALL = 'RLI'; const OVERRIDE_PTC_ONLY = 'PTC'; + const OVERRIDE_FORM_OF_PAYMENT = 'FOP'; const PRICING_LOGIC_IATA = "IATA"; const PRICING_LOGIC_ATAF = "ATAF"; @@ -161,14 +165,14 @@ class FarePricePnrWithBookingClassOptions extends Base /** * Provide a fare basis to price with * - * @var Fare\PricePnr\FareBasis[] + * @var FareBasis[] */ public $pricingsFareBasis = []; /** * Add up to 3 OBFees and/or to exempt up to 3 OBFees * - * @var Fare\PricePnr\ObFee[] + * @var ObFee[] */ public $obFees = []; @@ -248,6 +252,13 @@ class FarePricePnrWithBookingClassOptions extends Base */ public $pastDatePricing; + /** + * Form of Payment override (max. 3) + * + * @var FormOfPayment[] + */ + public $formOfPayment = []; + /** * Passenger, Segment or TST references to partially price the PNR * diff --git a/src/Amadeus/Client/RequestOptions/Service/FormOfPayment.php b/src/Amadeus/Client/RequestOptions/Service/FormOfPayment.php new file mode 100644 index 000000000..2185c4dc6 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/Service/FormOfPayment.php @@ -0,0 +1,33 @@ + + */ +class FormOfPayment extends \Amadeus\Client\RequestOptions\Fare\PricePnr\FormOfPayment +{ +} diff --git a/src/Amadeus/Client/RequestOptions/Service/FrequentFlyer.php b/src/Amadeus/Client/RequestOptions/Service/FrequentFlyer.php index cf98e8ff6..144257ce3 100644 --- a/src/Amadeus/Client/RequestOptions/Service/FrequentFlyer.php +++ b/src/Amadeus/Client/RequestOptions/Service/FrequentFlyer.php @@ -27,8 +27,6 @@ /** * FrequentFlyer * - * CURRENTLY NOT IN USE - * * @package Amadeus\Client\RequestOptions\Service * @author Dieter Devlieghere */ diff --git a/src/Amadeus/Client/RequestOptions/ServiceIntegratedPricingOptions.php b/src/Amadeus/Client/RequestOptions/ServiceIntegratedPricingOptions.php index 546806d4a..431340c83 100644 --- a/src/Amadeus/Client/RequestOptions/ServiceIntegratedPricingOptions.php +++ b/src/Amadeus/Client/RequestOptions/ServiceIntegratedPricingOptions.php @@ -22,6 +22,8 @@ namespace Amadeus\Client\RequestOptions; +use Amadeus\Client\RequestOptions\Service\FormOfPayment; +use Amadeus\Client\RequestOptions\Service\FrequentFlyer; use Amadeus\Client\RequestOptions\Service\PaxSegRef; /** @@ -54,6 +56,8 @@ class ServiceIntegratedPricingOptions extends Base const OVERRIDE_SHOW_PRICING_DESCRIPTION = "SPD"; const OVERRIDE_TICKET_DESIGNATOR = "TKD"; const OVERRIDE_VALIDATING_CARRIER = "VC "; + const OVERRIDE_FORM_OF_PAYMENT = "FOP"; + const OVERRIDE_FREQUENT_FLYER_INFORMATION = "FTI"; const AWARDPRICING_MILES = "MIL"; const AWARDPRICING_POINTS = "PTS"; @@ -147,6 +151,16 @@ class ServiceIntegratedPricingOptions extends Base */ public $overrideDate; + /** + * @var FormOfPayment[] + */ + public $formOfPayment = []; + + /** + * @var FrequentFlyer[] + */ + public $frequentFlyers = []; + /** * Passenger, Segment or TST references to partially price the PNR * diff --git a/src/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13.php b/src/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13.php index ac6c5a4b9..a73d7b193 100644 --- a/src/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13.php +++ b/src/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13.php @@ -26,6 +26,7 @@ use Amadeus\Client\RequestOptions\Fare\PricePnr\AwardPricing; use Amadeus\Client\RequestOptions\Fare\PricePnr\ExemptTax; use Amadeus\Client\RequestOptions\Fare\PricePnr\FareBasis; +use Amadeus\Client\RequestOptions\Fare\PricePnr\FormOfPayment; use Amadeus\Client\RequestOptions\Fare\PricePnr\ObFee; use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef; use Amadeus\Client\RequestOptions\Fare\PricePnr\Tax; @@ -36,6 +37,7 @@ use Amadeus\Client\Struct\Fare\PricePnr13\CarrierInformation; use Amadeus\Client\Struct\Fare\PricePnr13\Currency; use Amadeus\Client\Struct\Fare\PricePnr13\DateInformation; +use Amadeus\Client\Struct\Fare\PricePnr13\FormOfPaymentInformation; use Amadeus\Client\Struct\Fare\PricePnr13\FrequentFlyerInformation; use Amadeus\Client\Struct\Fare\PricePnr13\FrequentTravellerDetails; use Amadeus\Client\Struct\Fare\PricePnr13\LocationInformation; @@ -153,6 +155,12 @@ public static function loadPricingOptionsFromRequestOptions($options) self::loadPastDate($options->pastDatePricing) ); + + $priceOptions = self::mergeOptions( + $priceOptions, + self::loadFormOfPayment($options->formOfPayment) + ); + $priceOptions = self::mergeOptions( $priceOptions, self::loadReferences($options->references) @@ -520,6 +528,26 @@ protected static function loadPastDate($pastDate) return $opt; } + + /** + * @param FormOfPayment[] $formOfPayment + * @return PricingOptionGroup[] + */ + protected static function loadFormOfPayment($formOfPayment) + { + $opt = []; + + if (!empty($formOfPayment)) { + $po = new PricingOptionGroup(PricingOptionKey::OPTION_FORM_OF_PAYMENT); + + $po->formOfPaymentInformation = new FormOfPaymentInformation($formOfPayment); + + $opt[] = $po; + } + + return $opt; + } + /** * @param PaxSegRef[] $references * @return PricingOptionGroup[] diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/FormOfPayment.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/FormOfPayment.php index 343dc0c58..f72cdd8f8 100644 --- a/src/Amadeus/Client/Struct/Fare/PricePnr13/FormOfPayment.php +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/FormOfPayment.php @@ -22,6 +22,8 @@ namespace Amadeus\Client\Struct\Fare\PricePnr13; +use Amadeus\Client\RequestOptions\Fare\PricePnr\FormOfPayment as FormOfPaymentOptions; + /** * FormOfPayment * @@ -131,10 +133,16 @@ class FormOfPayment /** * FormOfPayment constructor. * - * @param string $type self::TYPE_* + * @param string|FormOfPaymentOptions $options self::TYPE_* or object with FOP options */ - public function __construct($type) + public function __construct($options) { - $this->type = $type; + if ($options instanceof FormOfPaymentOptions) { + $this->type = $options->type; + $this->amount = $options->amount; + $this->creditCardNumber = $options->creditCardNumber; + } else { + $this->type = $options; + } } } diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/FormOfPaymentInformation.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/FormOfPaymentInformation.php index ddf169da1..2b16bd38f 100644 --- a/src/Amadeus/Client/Struct/Fare/PricePnr13/FormOfPaymentInformation.php +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/FormOfPaymentInformation.php @@ -22,6 +22,8 @@ namespace Amadeus\Client\Struct\Fare\PricePnr13; +use Amadeus\Client\RequestOptions\Fare\PricePnr\FormOfPayment as FormOfPaymentOptions; + /** * FormOfPaymentInformation * @@ -39,4 +41,20 @@ class FormOfPaymentInformation * @var FormOfPayment[] */ public $otherFormOfPayment = []; + + /** + * FormOfPaymentInformation constructor. + * + * @param FormOfPaymentOptions[] $fop + */ + public function __construct(array $fop) + { + foreach ($fop as $key => $fopOpt) { + if ($key === 0) { + $this->formOfPayment = new FormOfPayment($fopOpt); + } else { + $this->otherFormOfPayment[] = new FormOfPayment($fopOpt); + } + } + } } diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/FrequentFlyerInformation.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/FrequentFlyerInformation.php index c055fa75c..01bc61004 100644 --- a/src/Amadeus/Client/Struct/Fare/PricePnr13/FrequentFlyerInformation.php +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/FrequentFlyerInformation.php @@ -22,6 +22,8 @@ namespace Amadeus\Client\Struct\Fare\PricePnr13; +use Amadeus\Client\RequestOptions\Service\FrequentFlyer; + /** * FrequentFlyerInformation * @@ -34,4 +36,23 @@ class FrequentFlyerInformation * @var FrequentTravellerDetails[] */ public $frequentTravellerDetails = []; + + /** + * FrequentFlyerInformation constructor. + * + * @param FrequentFlyer[] $freqFlyers + */ + public function __construct($freqFlyers = null) + { + if (!empty($freqFlyers)) { + foreach ($freqFlyers as $freqFlyer) { + $this->frequentTravellerDetails[] = new FrequentTravellerDetails( + $freqFlyer->tierLevel, + $freqFlyer->number, + $freqFlyer->company, + $freqFlyer->priorityCode + ); + } + } + } } diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/PricingOptionKey.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/PricingOptionKey.php index 15e41acdb..f836d1f9c 100644 --- a/src/Amadeus/Client/Struct/Fare/PricePnr13/PricingOptionKey.php +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/PricingOptionKey.php @@ -51,10 +51,11 @@ class PricingOptionKey const OPTION_PAX_SEGMENT_TST_SELECTION = "SEL"; const OPTION_PAST_DATE_PRICING = "DAT"; const OPTION_AWARD_PRICING = "AWD"; - const OPTION_RETURN_LOWEST = 'RLO'; - const OPTION_RETURN_LOWEST_AVAILABLE = 'RLA'; - const OPTION_RETURN_ALL = 'RLI'; - const OPTION_PTC_ONLY = 'PTC'; + const OPTION_RETURN_LOWEST = "RLO"; + const OPTION_RETURN_LOWEST_AVAILABLE = "RLA"; + const OPTION_RETURN_ALL = "RLI"; + const OPTION_PTC_ONLY = "PTC"; + const OPTION_FORM_OF_PAYMENT = "FOP"; /** * AC Add Country taxes @@ -94,10 +95,10 @@ class PricingOptionKey * PRO Promo Certificate * PTA Point of Turnaround * PTC PTC only - * RC Corporate negociated fares + * RC Corporate negotiated fares * RLI Return LIst of fare * RLO Return LOwest possible fare - * RN Negociated fare + * RN Negotiated fare * RP Published Fares * RU Unifares * RW Corporate Unifares @@ -106,9 +107,9 @@ class PricingOptionKey * TKT TicKet Type * TRS Transitional Certificate * VC Validating Carrier - * WC Withold Country taxes - * WQ Withold Q surcharges - * WT Withold Tax + * WC Withhold Country taxes + * WQ Withhold Q surcharges + * WT Withhold Tax * ZAP ZAP-off * * @var string diff --git a/src/Amadeus/Client/Struct/Service/IntegratedPricing.php b/src/Amadeus/Client/Struct/Service/IntegratedPricing.php index acc467d17..2ac8128c9 100644 --- a/src/Amadeus/Client/Struct/Service/IntegratedPricing.php +++ b/src/Amadeus/Client/Struct/Service/IntegratedPricing.php @@ -23,11 +23,15 @@ namespace Amadeus\Client\Struct\Service; use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef; +use Amadeus\Client\RequestOptions\Service\FormOfPayment; +use Amadeus\Client\RequestOptions\Service\FrequentFlyer; use Amadeus\Client\RequestOptions\ServiceIntegratedPricingOptions; use Amadeus\Client\Struct\Fare\BasePricingMessage; use Amadeus\Client\Struct\Fare\PricePnr13\CarrierInformation; use Amadeus\Client\Struct\Fare\PricePnr13\Currency; use Amadeus\Client\Struct\Fare\PricePnr13\DateInformation; +use Amadeus\Client\Struct\Fare\PricePnr13\FormOfPaymentInformation; +use Amadeus\Client\Struct\Fare\PricePnr13\FrequentFlyerInformation; use Amadeus\Client\Struct\Fare\PricePnr13\LocationInformation; use Amadeus\Client\Struct\Fare\PricePnr13\OptionDetail; use Amadeus\Client\Struct\Fare\PricePnr13\PaxSegTstReference; @@ -123,6 +127,16 @@ protected function loadPricingOptions(ServiceIntegratedPricingOptions $options) self::loadPointOverrides($options->pointOfSaleOverride) ); + $priceOptions = self::mergeOptions( + $priceOptions, + self::loadFormOfPaymentOverride($options->formOfPayment) + ); + + $priceOptions = self::mergeOptions( + $priceOptions, + self::loadFrequentFlyerOverride($options->frequentFlyers) + ); + $priceOptions = self::mergeOptions( $priceOptions, self::loadReferences($options->references) @@ -248,6 +262,44 @@ protected static function loadPointOverrides($posOverride) return $opt; } + /** + * @param FormOfPayment[] $formOfPayment + * @return PricingOption[] + */ + protected static function loadFormOfPaymentOverride($formOfPayment) + { + $opt = []; + + if (!empty($formOfPayment)) { + $po = new PricingOption(PricingOptionKey::OVERRIDE_FORM_OF_PAYMENT); + + $po->formOfPaymentInformation = new FormOfPaymentInformation($formOfPayment); + + $opt[] = $po; + } + + return $opt; + } + + /** + * @param FrequentFlyer[] $frequentFlyers + * @return PricingOption[] + */ + protected static function loadFrequentFlyerOverride($frequentFlyers) + { + $opt = []; + + if (!empty($frequentFlyers)) { + $po = new PricingOption(PricingOptionKey::OVERRIDE_FREQUENT_FLYER_INFORMATION); + + $po->frequentFlyerInformation = new FrequentFlyerInformation($frequentFlyers); + + $opt[] = $po; + } + + return $opt; + } + /** * @param PaxSegRef[] $references * @return PricingOption[] diff --git a/src/Amadeus/Client/Struct/Service/IntegratedPricing/PricingOptionKey.php b/src/Amadeus/Client/Struct/Service/IntegratedPricing/PricingOptionKey.php index 4d8bc08b4..120bd6489 100644 --- a/src/Amadeus/Client/Struct/Service/IntegratedPricing/PricingOptionKey.php +++ b/src/Amadeus/Client/Struct/Service/IntegratedPricing/PricingOptionKey.php @@ -52,32 +52,94 @@ class PricingOptionKey const OVERRIDE_SHOW_PRICING_DESCRIPTION = "SPD"; const OVERRIDE_TICKET_DESIGNATOR = "TKD"; const OVERRIDE_VALIDATING_CARRIER = "VC "; + const OVERRIDE_FORM_OF_PAYMENT = "FOP"; + const OVERRIDE_FREQUENT_FLYER_INFORMATION = "FTI"; /** * self::OVERRIDE_* * + * AC Add Country taxes * ACC Account Code - * ALL Pricing all services - * AWD Award + * ALL Pricing All services + * AT Add Tax + * AWD AWarD + * BGA Baggage Allowance + * BK Booking class override + * BKT Booking or PNR Type + * CAB CABin option + * CMP Companions * COD Code selection - * CRP Corporation number - * DAT Pricing Date - * FCO Fare currency override + * CRP CoRPoration number + * DAT past DATe pricing + * DO booking Date Override + * ET Exempt Taxes + * EXC Exclude + * FBA Fare BAsis simple override + * FBL Fare Basis force override + * FBP Fare Break Point + * FCO Fare Currency Override + * FCS Fare Currency Selection + * FFB Force Fee Break point + * FLI FLight Indicator + * FNB Force No fee Break point + * FOP Form Of Payment + * FTI Frequent Flyer Information + * GRI Global Route Indicator + * GRP Service Group filtering + * INC Include only * INF Infant processing - * JTP Journey turnaround point - * NBP No break point - * NJT No journey turnaround point - * NOP No option - * NTR Non trusted request - * OD Origin and destination option + * IP Instant Pricing + * JTP Journey Turnaround Point + * LBC List Booking Code + * LVL Tier Level + * MA Mileage Accrual + * MBT Fare amount override with M/BT + * MC Miles and Cash (Pricing by Points) + * MIT Fare amount override with M/IT + * NBP No BreakPoint + * NF No ticketing Fee + * NJT No Journey Turnaround Point + * NOP No Option + * NS No Split + * NSD No Slice and Dice + * NTR Non Trusted Request + * NVO No Validation on Original class + * OBF OB Fees (include and/or exclude) + * OCO Occurrence override + * OD Origin and Destination option + * OIS Show Only Issuable recommendation * PAX Passenger discount/PTC - * POS Point of sale + * PFF Pricing by Fare Family + * PL Pricing Logic + * POS Point Of Sale + * POT Point Of Ticketing override + * PRM expanded PaRaMeters + * PRO Promo Certificate + * PSR PSR * PTC PTC only - * SCD Show commercial description - * SEL Passenger/Segment/Element selection - * SPD Show pricing description - * TKD Ticket designator - * VC Validating carrier + * RC Corporate negotiated fares + * RLA Return Lowest Available fare + * RLI Return LIst of fare + * RLO Return LOwest possible fare + * RN Negotiated fare + * RP Published Fares + * RU Unifares + * RW Corporate Unifares + * SCD Show Commercial Description + * SEL Passenger/Segment/Line/TST selection + * SPD Show Pricing Description + * STP Service Type override + * SUB Service Sub-Group filtering + * TKD Ticket Designator + * TKN Ticket Number + * TKT TicKet Type + * TRS Transitional Certificate + * UU corporate Unifares only + * VC Validating Carrier + * WC Withhold Country taxes + * WQ Withhold Q surcharges + * WT Withhold Tax + * ZAP ZAP-off * * @var string */ diff --git a/tests/Amadeus/Client/Struct/Air/FlightInfoTest.php b/tests/Amadeus/Client/Struct/Air/FlightInfoTest.php index ea95f42b4..50f990a3d 100644 --- a/tests/Amadeus/Client/Struct/Air/FlightInfoTest.php +++ b/tests/Amadeus/Client/Struct/Air/FlightInfoTest.php @@ -43,22 +43,22 @@ public function testCanMakeBasicFlightInfoMessage() 'arrivalLocation' => 'LIS' ]); - $message = new FlightInfo($options); + $msg = new FlightInfo($options); - $this->assertEquals('BRU', $message->generalFlightInfo->boardPointDetails->trueLocationId); - $this->assertEquals('LIS', $message->generalFlightInfo->offPointDetails->trueLocationId); - $this->assertEquals('180516', $message->generalFlightInfo->flightDate->departureDate); - $this->assertNull($message->generalFlightInfo->flightDate->departureTime); - $this->assertNull($message->generalFlightInfo->flightDate->arrivalDate); - $this->assertNull($message->generalFlightInfo->flightDate->arrivalTime); - $this->assertNull($message->generalFlightInfo->flightDate->dateVariation); - $this->assertEquals('SN', $message->generalFlightInfo->companyDetails->marketingCompany); - $this->assertNull($message->generalFlightInfo->companyDetails->operatingCompany); - $this->assertEquals('652', $message->generalFlightInfo->flightIdentification->flightNumber); - $this->assertNull( $message->generalFlightInfo->flightIdentification->bookingClass); - $this->assertNull($message->generalFlightInfo->flightIdentification->operationalSuffix); - $this->assertNull($message->generalFlightInfo->flightTypeDetails); - $this->assertEmpty($message->generalFlightInfo->marriageDetails); + $this->assertEquals('BRU', $msg->generalFlightInfo->boardPointDetails->trueLocationId); + $this->assertEquals('LIS', $msg->generalFlightInfo->offPointDetails->trueLocationId); + $this->assertEquals('180516', $msg->generalFlightInfo->flightDate->departureDate); + $this->assertNull($msg->generalFlightInfo->flightDate->departureTime); + $this->assertNull($msg->generalFlightInfo->flightDate->arrivalDate); + $this->assertNull($msg->generalFlightInfo->flightDate->arrivalTime); + $this->assertNull($msg->generalFlightInfo->flightDate->dateVariation); + $this->assertEquals('SN', $msg->generalFlightInfo->companyDetails->marketingCompany); + $this->assertNull($msg->generalFlightInfo->companyDetails->operatingCompany); + $this->assertEquals('652', $msg->generalFlightInfo->flightIdentification->flightNumber); + $this->assertNull( $msg->generalFlightInfo->flightIdentification->bookingClass); + $this->assertNull($msg->generalFlightInfo->flightIdentification->operationalSuffix); + $this->assertNull($msg->generalFlightInfo->flightTypeDetails); + $this->assertEmpty($msg->generalFlightInfo->marriageDetails); } public function testCanMakeFlightInfoWithOperationalSuffixMessage() @@ -72,21 +72,21 @@ public function testCanMakeFlightInfoWithOperationalSuffixMessage() 'arrivalLocation' => 'LIS' ]); - $message = new FlightInfo($options); + $msg = new FlightInfo($options); - $this->assertEquals('BRU', $message->generalFlightInfo->boardPointDetails->trueLocationId); - $this->assertEquals('LIS', $message->generalFlightInfo->offPointDetails->trueLocationId); - $this->assertEquals('180516', $message->generalFlightInfo->flightDate->departureDate); - $this->assertNull($message->generalFlightInfo->flightDate->departureTime); - $this->assertNull($message->generalFlightInfo->flightDate->arrivalDate); - $this->assertNull($message->generalFlightInfo->flightDate->arrivalTime); - $this->assertNull($message->generalFlightInfo->flightDate->dateVariation); - $this->assertEquals('SN', $message->generalFlightInfo->companyDetails->marketingCompany); - $this->assertNull($message->generalFlightInfo->companyDetails->operatingCompany); - $this->assertEquals('652', $message->generalFlightInfo->flightIdentification->flightNumber); - $this->assertEquals('A', $message->generalFlightInfo->flightIdentification->operationalSuffix); - $this->assertNull( $message->generalFlightInfo->flightIdentification->bookingClass); - $this->assertNull($message->generalFlightInfo->flightTypeDetails); - $this->assertEmpty($message->generalFlightInfo->marriageDetails); + $this->assertEquals('BRU', $msg->generalFlightInfo->boardPointDetails->trueLocationId); + $this->assertEquals('LIS', $msg->generalFlightInfo->offPointDetails->trueLocationId); + $this->assertEquals('180516', $msg->generalFlightInfo->flightDate->departureDate); + $this->assertNull($msg->generalFlightInfo->flightDate->departureTime); + $this->assertNull($msg->generalFlightInfo->flightDate->arrivalDate); + $this->assertNull($msg->generalFlightInfo->flightDate->arrivalTime); + $this->assertNull($msg->generalFlightInfo->flightDate->dateVariation); + $this->assertEquals('SN', $msg->generalFlightInfo->companyDetails->marketingCompany); + $this->assertNull($msg->generalFlightInfo->companyDetails->operatingCompany); + $this->assertEquals('652', $msg->generalFlightInfo->flightIdentification->flightNumber); + $this->assertEquals('A', $msg->generalFlightInfo->flightIdentification->operationalSuffix); + $this->assertNull( $msg->generalFlightInfo->flightIdentification->bookingClass); + $this->assertNull($msg->generalFlightInfo->flightTypeDetails); + $this->assertEmpty($msg->generalFlightInfo->marriageDetails); } } diff --git a/tests/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13Test.php b/tests/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13Test.php index ec5e354b5..f797f3a7e 100644 --- a/tests/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13Test.php +++ b/tests/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13Test.php @@ -25,6 +25,7 @@ use Amadeus\Client\RequestOptions\Fare\PricePnr\AwardPricing; use Amadeus\Client\RequestOptions\Fare\PricePnr\ExemptTax; use Amadeus\Client\RequestOptions\Fare\PricePnr\FareBasis; +use Amadeus\Client\RequestOptions\Fare\PricePnr\FormOfPayment; use Amadeus\Client\RequestOptions\Fare\PricePnr\ObFee; use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef; use Amadeus\Client\RequestOptions\Fare\PricePnr\Tax; @@ -67,28 +68,28 @@ public function testCanDoPricePnrCallWithLegacyFareBasisParams() ] ]); - $message = new PricePNRWithBookingClass13($opt); + $msg = new PricePNRWithBookingClass13($opt); $validatingCarrierPo = new PricingOptionGroup(PricingOptionKey::OPTION_VALIDATING_CARRIER); $validatingCarrierPo->carrierInformation = new CarrierInformation('BA'); - $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $validatingCarrierPo)); + $this->assertTrue($this->assertArrayContainsSameObject($msg->pricingOptionGroup, $validatingCarrierPo)); $currencyOverridePo = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_CURRENCY_OVERRIDE); $currencyOverridePo->currency = new Currency('EUR'); - $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $currencyOverridePo)); + $this->assertTrue($this->assertArrayContainsSameObject($msg->pricingOptionGroup, $currencyOverridePo)); $fareBasisOverridePo = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_BASIS_SIMPLE_OVERRIDE); $fareBasisOverridePo->optionDetail = new OptionDetail(); $fareBasisOverridePo->optionDetail->criteriaDetails[] = new CriteriaDetails('QNC469W2'); $fareBasisOverridePo->paxSegTstReference = new PaxSegTstReference(null, [2 => FareBasis::SEGREFTYPE_SEGMENT]); - $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $fareBasisOverridePo)); + $this->assertTrue($this->assertArrayContainsSameObject($msg->pricingOptionGroup, $fareBasisOverridePo)); $negofarePo = new PricingOptionGroup(PricingOptionKey::OPTION_NEGOTIATED_FARES); - $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $negofarePo)); + $this->assertTrue($this->assertArrayContainsSameObject($msg->pricingOptionGroup, $negofarePo)); } public function testCanDoPricePnrCallWithNewFareBasisParams() @@ -110,49 +111,49 @@ public function testCanDoPricePnrCallWithNewFareBasisParams() ] ]); - $message = new PricePNRWithBookingClass13($opt); + $msg = new PricePNRWithBookingClass13($opt); $validatingCarrierPo = new PricingOptionGroup(PricingOptionKey::OPTION_VALIDATING_CARRIER); $validatingCarrierPo->carrierInformation = new CarrierInformation('BA'); - $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $validatingCarrierPo)); + $this->assertTrue($this->assertArrayContainsSameObject($msg->pricingOptionGroup, $validatingCarrierPo)); $currencyOverridePo = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_CURRENCY_OVERRIDE); $currencyOverridePo->currency = new Currency('EUR'); - $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $currencyOverridePo)); + $this->assertTrue($this->assertArrayContainsSameObject($msg->pricingOptionGroup, $currencyOverridePo)); $fareBasisOverridePo = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_BASIS_SIMPLE_OVERRIDE); $fareBasisOverridePo->optionDetail = new OptionDetail(); $fareBasisOverridePo->optionDetail->criteriaDetails[] = new CriteriaDetails('QNC469W2'); $fareBasisOverridePo->paxSegTstReference = new PaxSegTstReference([new PaxSegRef(['type'=> PaxSegRef::TYPE_SEGMENT, 'reference' => 2])]); - $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $fareBasisOverridePo)); + $this->assertTrue($this->assertArrayContainsSameObject($msg->pricingOptionGroup, $fareBasisOverridePo)); $negofarePo = new PricingOptionGroup(PricingOptionKey::OPTION_NEGOTIATED_FARES); - $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $negofarePo)); + $this->assertTrue($this->assertArrayContainsSameObject($msg->pricingOptionGroup, $negofarePo)); } public function testCanDoPricePnrCallWithNoOptions() { $opt = new FarePricePnrWithBookingClassOptions(); - $message = new PricePNRWithBookingClass13($opt); - - $this->assertCount(1, $message->pricingOptionGroup); - $this->assertEquals('NOP', $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); - $this->assertNull($message->pricingOptionGroup[0]->currency); - $this->assertNull($message->pricingOptionGroup[0]->carrierInformation); - $this->assertNull($message->pricingOptionGroup[0]->dateInformation); - $this->assertNull($message->pricingOptionGroup[0]->formOfPaymentInformation); - $this->assertNull($message->pricingOptionGroup[0]->frequentFlyerInformation); - $this->assertNull($message->pricingOptionGroup[0]->locationInformation); - $this->assertNull($message->pricingOptionGroup[0]->monetaryInformation); - $this->assertNull($message->pricingOptionGroup[0]->optionDetail); - $this->assertNull($message->pricingOptionGroup[0]->paxSegTstReference); - $this->assertNull($message->pricingOptionGroup[0]->penDisInformation); - $this->assertEmpty($message->pricingOptionGroup[0]->taxInformation); + $msg = new PricePNRWithBookingClass13($opt); + + $this->assertCount(1, $msg->pricingOptionGroup); + $this->assertEquals('NOP', $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertNull($msg->pricingOptionGroup[0]->currency); + $this->assertNull($msg->pricingOptionGroup[0]->carrierInformation); + $this->assertNull($msg->pricingOptionGroup[0]->dateInformation); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation); + $this->assertNull($msg->pricingOptionGroup[0]->frequentFlyerInformation); + $this->assertNull($msg->pricingOptionGroup[0]->locationInformation); + $this->assertNull($msg->pricingOptionGroup[0]->monetaryInformation); + $this->assertNull($msg->pricingOptionGroup[0]->optionDetail); + $this->assertNull($msg->pricingOptionGroup[0]->paxSegTstReference); + $this->assertNull($msg->pricingOptionGroup[0]->penDisInformation); + $this->assertEmpty($msg->pricingOptionGroup[0]->taxInformation); } /** @@ -178,19 +179,19 @@ public function testCanDoPricePnrCallWithFareOverrideDuplicate() ] ]); - $message = new PricePNRWithBookingClass13($opt); + $msg = new PricePNRWithBookingClass13($opt); - $this->assertCount(4, $message->pricingOptionGroup); + $this->assertCount(4, $msg->pricingOptionGroup); $validatingCarrierPo = new PricingOptionGroup(PricingOptionKey::OPTION_VALIDATING_CARRIER); $validatingCarrierPo->carrierInformation = new CarrierInformation('BA'); - $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $validatingCarrierPo)); + $this->assertTrue($this->assertArrayContainsSameObject($msg->pricingOptionGroup, $validatingCarrierPo)); $currencyOverridePo = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_CURRENCY_OVERRIDE); $currencyOverridePo->currency = new Currency('EUR'); - $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $currencyOverridePo)); + $this->assertTrue($this->assertArrayContainsSameObject($msg->pricingOptionGroup, $currencyOverridePo)); $fareBasisOverridePo = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_BASIS_SIMPLE_OVERRIDE); $fareBasisOverridePo->optionDetail = new OptionDetail(); @@ -199,11 +200,11 @@ public function testCanDoPricePnrCallWithFareOverrideDuplicate() [new PaxSegRef(['type'=> PaxSegRef::TYPE_SEGMENT, 'reference' => 2])] ); - $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $fareBasisOverridePo)); + $this->assertTrue($this->assertArrayContainsSameObject($msg->pricingOptionGroup, $fareBasisOverridePo)); $negofarePo = new PricingOptionGroup(PricingOptionKey::OPTION_NEGOTIATED_FARES); - $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $negofarePo)); + $this->assertTrue($this->assertArrayContainsSameObject($msg->pricingOptionGroup, $negofarePo)); } public function testCanDoPricePnrCallWithObFees() @@ -225,18 +226,18 @@ public function testCanDoPricePnrCallWithObFees() ] ]); - $message = new PricePNRWithBookingClass13($opt); + $msg = new PricePNRWithBookingClass13($opt); - $this->assertCount(1, $message->pricingOptionGroup); + $this->assertCount(1, $msg->pricingOptionGroup); - $this->assertEquals(PricingOptionKey::OPTION_OB_FEES, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); - $this->assertEquals(PenDisInformation::QUAL_OB_FEES, $message->pricingOptionGroup[0]->penDisInformation->discountPenaltyQualifier); - $this->assertCount(1, $message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails); - $this->assertEquals(DiscountPenaltyDetails::FUNCTION_INCLUDE_FEE, $message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->function); - $this->assertEquals(10, $message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->amount); - $this->assertEquals('USD', $message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->currency); - $this->assertEquals(DiscountPenaltyDetails::AMOUNTTYPE_FIXED_WHOLE_AMOUNT, $message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->amountType); - $this->assertEquals('FC1', $message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->rate); + $this->assertEquals(PricingOptionKey::OPTION_OB_FEES, $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertEquals(PenDisInformation::QUAL_OB_FEES, $msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyQualifier); + $this->assertCount(1, $msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails); + $this->assertEquals(DiscountPenaltyDetails::FUNCTION_INCLUDE_FEE, $msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->function); + $this->assertEquals(10, $msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->amount); + $this->assertEquals('USD', $msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->currency); + $this->assertEquals(DiscountPenaltyDetails::AMOUNTTYPE_FIXED_WHOLE_AMOUNT, $msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->amountType); + $this->assertEquals('FC1', $msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->rate); } public function testCanDoPricePnrCallWithPricingLogic() @@ -245,13 +246,13 @@ public function testCanDoPricePnrCallWithPricingLogic() 'pricingLogic' => FarePricePnrWithBookingClassOptions::PRICING_LOGIC_IATA ]); - $message = new PricePNRWithBookingClass13($opt); + $msg = new PricePNRWithBookingClass13($opt); - $this->assertCount(1, $message->pricingOptionGroup); + $this->assertCount(1, $msg->pricingOptionGroup); - $this->assertEquals(PricingOptionKey::OPTION_PRICING_LOGIC, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); - $this->assertCount(1, $message->pricingOptionGroup[0]->optionDetail->criteriaDetails); - $this->assertEquals('IATA', $message->pricingOptionGroup[0]->optionDetail->criteriaDetails[0]->attributeType); + $this->assertEquals(PricingOptionKey::OPTION_PRICING_LOGIC, $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(1, $msg->pricingOptionGroup[0]->optionDetail->criteriaDetails); + $this->assertEquals('IATA', $msg->pricingOptionGroup[0]->optionDetail->criteriaDetails[0]->attributeType); } public function testCanDoPricePnrCallWithCorpNegoFare() @@ -260,12 +261,12 @@ public function testCanDoPricePnrCallWithCorpNegoFare() 'corporateNegoFare' => '012345' ]); - $message = new PricePNRWithBookingClass13($opt); + $msg = new PricePNRWithBookingClass13($opt); - $this->assertCount(1, $message->pricingOptionGroup); - $this->assertEquals(PricingOptionKey::OPTION_CORPORATE_NEGOTIATED_FARES, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); - $this->assertCount(1, $message->pricingOptionGroup[0]->optionDetail->criteriaDetails); - $this->assertEquals('012345', $message->pricingOptionGroup[0]->optionDetail->criteriaDetails[0]->attributeType); + $this->assertCount(1, $msg->pricingOptionGroup); + $this->assertEquals(PricingOptionKey::OPTION_CORPORATE_NEGOTIATED_FARES, $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(1, $msg->pricingOptionGroup[0]->optionDetail->criteriaDetails); + $this->assertEquals('012345', $msg->pricingOptionGroup[0]->optionDetail->criteriaDetails[0]->attributeType); } @@ -275,13 +276,13 @@ public function testCanDoPricePnrCallWithCorpUniFares() 'corporateUniFares' => ['012345', 'AMADEUS'] ]); - $message = new PricePNRWithBookingClass13($opt); + $msg = new PricePNRWithBookingClass13($opt); - $this->assertCount(1, $message->pricingOptionGroup); - $this->assertEquals(PricingOptionKey::OPTION_CORPORATE_UNIFARES, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); - $this->assertCount(2, $message->pricingOptionGroup[0]->optionDetail->criteriaDetails); - $this->assertEquals('012345', $message->pricingOptionGroup[0]->optionDetail->criteriaDetails[0]->attributeType); - $this->assertEquals('AMADEUS', $message->pricingOptionGroup[0]->optionDetail->criteriaDetails[1]->attributeType); + $this->assertCount(1, $msg->pricingOptionGroup); + $this->assertEquals(PricingOptionKey::OPTION_CORPORATE_UNIFARES, $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(2, $msg->pricingOptionGroup[0]->optionDetail->criteriaDetails); + $this->assertEquals('012345', $msg->pricingOptionGroup[0]->optionDetail->criteriaDetails[0]->attributeType); + $this->assertEquals('AMADEUS', $msg->pricingOptionGroup[0]->optionDetail->criteriaDetails[1]->attributeType); } @@ -301,35 +302,35 @@ public function testCanDoPricePnrCallWithPaxDiscountCodes() ] ]); - $message = new PricePNRWithBookingClass13($opt); - - $this->assertCount(1, $message->pricingOptionGroup); - $this->assertEquals(PricingOptionKey::OPTION_PASSENGER_DISCOUNT_PTC, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); - $this->assertEquals(PenDisInformation::QUAL_DISCOUNT, $message->pricingOptionGroup[0]->penDisInformation->discountPenaltyQualifier); - $this->assertCount(3, $message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails); - $this->assertEquals('YTH', $message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->rate); - $this->assertNull($message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->amount); - $this->assertNull($message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->amountType); - $this->assertNull($message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->currency); - $this->assertNull($message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->function); - - $this->assertEquals('AD20', $message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[1]->rate); - $this->assertNull($message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[1]->amount); - $this->assertNull($message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[1]->amountType); - $this->assertNull($message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[1]->currency); - $this->assertNull($message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[1]->function); - - $this->assertEquals('MIL', $message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[2]->rate); - $this->assertNull($message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[2]->amount); - $this->assertNull($message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[2]->amountType); - $this->assertNull($message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[2]->currency); - $this->assertNull($message->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[2]->function); - - $this->assertCount(2, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails); - $this->assertEquals(1, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[0]->value); - $this->assertEquals(ReferenceDetails::QUALIFIER_PAX_REFERENCE, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[0]->type); - $this->assertEquals(4, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[1]->value); - $this->assertEquals(ReferenceDetails::QUALIFIER_SEGMENT_REFERENCE, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[1]->type); + $msg = new PricePNRWithBookingClass13($opt); + + $this->assertCount(1, $msg->pricingOptionGroup); + $this->assertEquals(PricingOptionKey::OPTION_PASSENGER_DISCOUNT_PTC, $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertEquals(PenDisInformation::QUAL_DISCOUNT, $msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyQualifier); + $this->assertCount(3, $msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails); + $this->assertEquals('YTH', $msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->rate); + $this->assertNull($msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->amount); + $this->assertNull($msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->amountType); + $this->assertNull($msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->currency); + $this->assertNull($msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[0]->function); + + $this->assertEquals('AD20', $msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[1]->rate); + $this->assertNull($msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[1]->amount); + $this->assertNull($msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[1]->amountType); + $this->assertNull($msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[1]->currency); + $this->assertNull($msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[1]->function); + + $this->assertEquals('MIL', $msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[2]->rate); + $this->assertNull($msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[2]->amount); + $this->assertNull($msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[2]->amountType); + $this->assertNull($msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[2]->currency); + $this->assertNull($msg->pricingOptionGroup[0]->penDisInformation->discountPenaltyDetails[2]->function); + + $this->assertCount(2, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails); + $this->assertEquals(1, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[0]->value); + $this->assertEquals(ReferenceDetails::QUALIFIER_PAX_REFERENCE, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[0]->type); + $this->assertEquals(4, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[1]->value); + $this->assertEquals(ReferenceDetails::QUALIFIER_SEGMENT_REFERENCE, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[1]->type); } /** @@ -342,15 +343,15 @@ public function testCanDoPricePnrCallWithPosPotOverride() 'pointOfTicketingOverride' => 'MAN' ]); - $message = new PricePNRWithBookingClass13($opt); + $msg = new PricePNRWithBookingClass13($opt); - $this->assertCount(2, $message->pricingOptionGroup); - $this->assertEquals(PricingOptionKey::OPTION_POINT_OF_SALE_OVERRIDE, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); - $this->assertEquals(LocationInformation::TYPE_POINT_OF_SALE, $message->pricingOptionGroup[0]->locationInformation->locationType); - $this->assertEquals('LON', $message->pricingOptionGroup[0]->locationInformation->firstLocationDetails->code); - $this->assertEquals(PricingOptionKey::OPTION_POINT_OF_TICKETING_OVERRIDE, $message->pricingOptionGroup[1]->pricingOptionKey->pricingOptionKey); - $this->assertEquals(LocationInformation::TYPE_POINT_OF_TICKETING, $message->pricingOptionGroup[1]->locationInformation->locationType); - $this->assertEquals('MAN', $message->pricingOptionGroup[1]->locationInformation->firstLocationDetails->code); + $this->assertCount(2, $msg->pricingOptionGroup); + $this->assertEquals(PricingOptionKey::OPTION_POINT_OF_SALE_OVERRIDE, $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertEquals(LocationInformation::TYPE_POINT_OF_SALE, $msg->pricingOptionGroup[0]->locationInformation->locationType); + $this->assertEquals('LON', $msg->pricingOptionGroup[0]->locationInformation->firstLocationDetails->code); + $this->assertEquals(PricingOptionKey::OPTION_POINT_OF_TICKETING_OVERRIDE, $msg->pricingOptionGroup[1]->pricingOptionKey->pricingOptionKey); + $this->assertEquals(LocationInformation::TYPE_POINT_OF_TICKETING, $msg->pricingOptionGroup[1]->locationInformation->locationType); + $this->assertEquals('MAN', $msg->pricingOptionGroup[1]->locationInformation->firstLocationDetails->code); } public function testCanDoPricePnrCallWithTicketType() @@ -359,12 +360,12 @@ public function testCanDoPricePnrCallWithTicketType() 'ticketType' => FarePricePnrWithBookingClassOptions::TICKET_TYPE_ELECTRONIC ]); - $message = new PricePNRWithBookingClass13($opt); + $msg = new PricePNRWithBookingClass13($opt); - $this->assertCount(1, $message->pricingOptionGroup); - $this->assertEquals(PricingOptionKey::OPTION_TICKET_TYPE, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); - $this->assertCount(1, $message->pricingOptionGroup[0]->optionDetail->criteriaDetails); - $this->assertEquals(FarePricePnrWithBookingClassOptions::TICKET_TYPE_ELECTRONIC, $message->pricingOptionGroup[0]->optionDetail->criteriaDetails[0]->attributeType); + $this->assertCount(1, $msg->pricingOptionGroup); + $this->assertEquals(PricingOptionKey::OPTION_TICKET_TYPE, $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(1, $msg->pricingOptionGroup[0]->optionDetail->criteriaDetails); + $this->assertEquals(FarePricePnrWithBookingClassOptions::TICKET_TYPE_ELECTRONIC, $msg->pricingOptionGroup[0]->optionDetail->criteriaDetails[0]->attributeType); } public function testCanDoPricePnrCallWithAddTaxes() @@ -384,22 +385,22 @@ public function testCanDoPricePnrCallWithAddTaxes() ] ]); - $message = new PricePNRWithBookingClass13($opt); - - $this->assertCount(1, $message->pricingOptionGroup); - $this->assertEquals(PricingOptionKey::OPTION_ADD_TAX, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); - $this->assertCount(2, $message->pricingOptionGroup[0]->taxInformation); - $this->assertEquals(TaxInformation::QUALIFIER_TAX, $message->pricingOptionGroup[0]->taxInformation[0]->taxQualifier); - $this->assertEquals('GO', $message->pricingOptionGroup[0]->taxInformation[0]->taxNature); - $this->assertEquals(50, $message->pricingOptionGroup[0]->taxInformation[0]->taxData->taxRate); - $this->assertEquals(TaxData::QUALIFIER_AMOUNT, $message->pricingOptionGroup[0]->taxInformation[0]->taxData->taxValueQualifier); - $this->assertEquals('ZV', $message->pricingOptionGroup[0]->taxInformation[0]->taxType->isoCountry); - - $this->assertEquals(TaxInformation::QUALIFIER_TAX, $message->pricingOptionGroup[0]->taxInformation[1]->taxQualifier); - $this->assertNull($message->pricingOptionGroup[0]->taxInformation[1]->taxNature); - $this->assertEquals(10, $message->pricingOptionGroup[0]->taxInformation[1]->taxData->taxRate); - $this->assertEquals(TaxData::QUALIFIER_PERCENTAGE, $message->pricingOptionGroup[0]->taxInformation[1]->taxData->taxValueQualifier); - $this->assertEquals('FR', $message->pricingOptionGroup[0]->taxInformation[1]->taxType->isoCountry); + $msg = new PricePNRWithBookingClass13($opt); + + $this->assertCount(1, $msg->pricingOptionGroup); + $this->assertEquals(PricingOptionKey::OPTION_ADD_TAX, $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(2, $msg->pricingOptionGroup[0]->taxInformation); + $this->assertEquals(TaxInformation::QUALIFIER_TAX, $msg->pricingOptionGroup[0]->taxInformation[0]->taxQualifier); + $this->assertEquals('GO', $msg->pricingOptionGroup[0]->taxInformation[0]->taxNature); + $this->assertEquals(50, $msg->pricingOptionGroup[0]->taxInformation[0]->taxData->taxRate); + $this->assertEquals(TaxData::QUALIFIER_AMOUNT, $msg->pricingOptionGroup[0]->taxInformation[0]->taxData->taxValueQualifier); + $this->assertEquals('ZV', $msg->pricingOptionGroup[0]->taxInformation[0]->taxType->isoCountry); + + $this->assertEquals(TaxInformation::QUALIFIER_TAX, $msg->pricingOptionGroup[0]->taxInformation[1]->taxQualifier); + $this->assertNull($msg->pricingOptionGroup[0]->taxInformation[1]->taxNature); + $this->assertEquals(10, $msg->pricingOptionGroup[0]->taxInformation[1]->taxData->taxRate); + $this->assertEquals(TaxData::QUALIFIER_PERCENTAGE, $msg->pricingOptionGroup[0]->taxInformation[1]->taxData->taxValueQualifier); + $this->assertEquals('FR', $msg->pricingOptionGroup[0]->taxInformation[1]->taxType->isoCountry); } public function testCanDoPricePnrCallWithExemptTaxes() @@ -413,15 +414,15 @@ public function testCanDoPricePnrCallWithExemptTaxes() ] ]); - $message = new PricePNRWithBookingClass13($opt); + $msg = new PricePNRWithBookingClass13($opt); - $this->assertCount(1, $message->pricingOptionGroup); - $this->assertEquals(PricingOptionKey::OPTION_EXEMPT_FROM_TAX, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); - $this->assertCount(1, $message->pricingOptionGroup[0]->taxInformation); - $this->assertEquals(TaxInformation::QUALIFIER_TAX, $message->pricingOptionGroup[0]->taxInformation[0]->taxQualifier); - $this->assertEquals('GO', $message->pricingOptionGroup[0]->taxInformation[0]->taxNature); - $this->assertNull($message->pricingOptionGroup[0]->taxInformation[0]->taxData); - $this->assertEquals('ZV', $message->pricingOptionGroup[0]->taxInformation[0]->taxType->isoCountry); + $this->assertCount(1, $msg->pricingOptionGroup); + $this->assertEquals(PricingOptionKey::OPTION_EXEMPT_FROM_TAX, $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(1, $msg->pricingOptionGroup[0]->taxInformation); + $this->assertEquals(TaxInformation::QUALIFIER_TAX, $msg->pricingOptionGroup[0]->taxInformation[0]->taxQualifier); + $this->assertEquals('GO', $msg->pricingOptionGroup[0]->taxInformation[0]->taxNature); + $this->assertNull($msg->pricingOptionGroup[0]->taxInformation[0]->taxData); + $this->assertEquals('ZV', $msg->pricingOptionGroup[0]->taxInformation[0]->taxType->isoCountry); } /** @@ -450,20 +451,20 @@ public function testCanDoPricePnrCallWithPaxSegRefs() ] ]); - $message = new PricePNRWithBookingClass13($opt); + $msg = new PricePNRWithBookingClass13($opt); - $this->assertCount(1, $message->pricingOptionGroup); - $this->assertEquals(PricingOptionKey::OPTION_PAX_SEGMENT_TST_SELECTION, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); - $this->assertCount(4, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails); + $this->assertCount(1, $msg->pricingOptionGroup); + $this->assertEquals(PricingOptionKey::OPTION_PAX_SEGMENT_TST_SELECTION, $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(4, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails); - $this->assertEquals(ReferenceDetails::QUALIFIER_PAX_INFANT, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[0]->type); - $this->assertEquals(1, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[0]->value); - $this->assertEquals(ReferenceDetails::QUALIFIER_PAX_ADULT, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[1]->type); - $this->assertEquals(2, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[1]->value); - $this->assertEquals(ReferenceDetails::QUALIFIER_PAX_REFERENCE, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[2]->type); - $this->assertEquals(3, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[2]->value); - $this->assertEquals(ReferenceDetails::QUALIFIER_SEGMENT_REFERENCE, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[3]->type); - $this->assertEquals(1, $message->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[3]->value); + $this->assertEquals(ReferenceDetails::QUALIFIER_PAX_INFANT, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[0]->type); + $this->assertEquals(1, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[0]->value); + $this->assertEquals(ReferenceDetails::QUALIFIER_PAX_ADULT, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[1]->type); + $this->assertEquals(2, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[1]->value); + $this->assertEquals(ReferenceDetails::QUALIFIER_PAX_REFERENCE, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[2]->type); + $this->assertEquals(3, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[2]->value); + $this->assertEquals(ReferenceDetails::QUALIFIER_SEGMENT_REFERENCE, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[3]->type); + $this->assertEquals(1, $msg->pricingOptionGroup[0]->paxSegTstReference->referenceDetails[3]->value); } @@ -484,14 +485,14 @@ public function testCanDoPricePnrCallWithPastDatePricing() ) ]); - $message = new PricePNRWithBookingClass13($opt); + $msg = new PricePNRWithBookingClass13($opt); - $this->assertCount(1, $message->pricingOptionGroup); - $this->assertEquals(PricingOptionKey::OPTION_PAST_DATE_PRICING, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); - $this->assertEquals(DateInformation::OPT_DATE_OVERRIDE, $message->pricingOptionGroup[0]->dateInformation->businessSemantic); - $this->assertEquals("2012", $message->pricingOptionGroup[0]->dateInformation->dateTime->year); - $this->assertEquals("06", $message->pricingOptionGroup[0]->dateInformation->dateTime->month); - $this->assertEquals("27", $message->pricingOptionGroup[0]->dateInformation->dateTime->day); + $this->assertCount(1, $msg->pricingOptionGroup); + $this->assertEquals(PricingOptionKey::OPTION_PAST_DATE_PRICING, $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertEquals(DateInformation::OPT_DATE_OVERRIDE, $msg->pricingOptionGroup[0]->dateInformation->businessSemantic); + $this->assertEquals("2012", $msg->pricingOptionGroup[0]->dateInformation->dateTime->year); + $this->assertEquals("06", $msg->pricingOptionGroup[0]->dateInformation->dateTime->month); + $this->assertEquals("27", $msg->pricingOptionGroup[0]->dateInformation->dateTime->day); } public function testCanDoPricePnrCallWithAwardPricing() @@ -504,20 +505,62 @@ public function testCanDoPricePnrCallWithAwardPricing() ]) ]); - $message = new PricePNRWithBookingClass13($opt); - - $this->assertCount(2, $message->pricingOptionGroup); - $this->assertEquals(PricingOptionKey::OPTION_CORPORATE_UNIFARES, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); - $this->assertCount(2, $message->pricingOptionGroup[0]->optionDetail->criteriaDetails); - $this->assertEquals('012345', $message->pricingOptionGroup[0]->optionDetail->criteriaDetails[0]->attributeType); - $this->assertEquals('456789', $message->pricingOptionGroup[0]->optionDetail->criteriaDetails[1]->attributeType); - - $this->assertEquals(PricingOptionKey::OPTION_AWARD_PRICING, $message->pricingOptionGroup[1]->pricingOptionKey->pricingOptionKey); - $this->assertEquals('6X', $message->pricingOptionGroup[1]->carrierInformation->companyIdentification->otherCompany); - $this->assertCount(1, $message->pricingOptionGroup[1]->frequentFlyerInformation->frequentTravellerDetails); - $this->assertEquals('GOLD', $message->pricingOptionGroup[1]->frequentFlyerInformation->frequentTravellerDetails[0]->tierLevel); - $this->assertNull($message->pricingOptionGroup[1]->frequentFlyerInformation->frequentTravellerDetails[0]->carrier); - $this->assertNull($message->pricingOptionGroup[1]->frequentFlyerInformation->frequentTravellerDetails[0]->number); - $this->assertNull($message->pricingOptionGroup[1]->frequentFlyerInformation->frequentTravellerDetails[0]->priorityCode); + $msg = new PricePNRWithBookingClass13($opt); + + $this->assertCount(2, $msg->pricingOptionGroup); + $this->assertEquals(PricingOptionKey::OPTION_CORPORATE_UNIFARES, $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(2, $msg->pricingOptionGroup[0]->optionDetail->criteriaDetails); + $this->assertEquals('012345', $msg->pricingOptionGroup[0]->optionDetail->criteriaDetails[0]->attributeType); + $this->assertEquals('456789', $msg->pricingOptionGroup[0]->optionDetail->criteriaDetails[1]->attributeType); + + $this->assertEquals(PricingOptionKey::OPTION_AWARD_PRICING, $msg->pricingOptionGroup[1]->pricingOptionKey->pricingOptionKey); + $this->assertEquals('6X', $msg->pricingOptionGroup[1]->carrierInformation->companyIdentification->otherCompany); + $this->assertCount(1, $msg->pricingOptionGroup[1]->frequentFlyerInformation->frequentTravellerDetails); + $this->assertEquals('GOLD', $msg->pricingOptionGroup[1]->frequentFlyerInformation->frequentTravellerDetails[0]->tierLevel); + $this->assertNull($msg->pricingOptionGroup[1]->frequentFlyerInformation->frequentTravellerDetails[0]->carrier); + $this->assertNull($msg->pricingOptionGroup[1]->frequentFlyerInformation->frequentTravellerDetails[0]->number); + $this->assertNull($msg->pricingOptionGroup[1]->frequentFlyerInformation->frequentTravellerDetails[0]->priorityCode); + } + + public function testCanDoPricePnrCallWithFormOfPaymentOverride() + { + $opt = new FarePricePnrWithBookingClassOptions([ + 'formOfPayment' => [ + new FormOfPayment([ + 'type' => FormOfPayment::TYPE_CREDIT_CARD, + 'amount' => 10, + 'creditCardNumber' => '400000' + ]), + new FormOfPayment([ + 'type' => FormOfPayment::TYPE_CASH + ]), + ] + ]); + + $msg = new PricePNRWithBookingClass13($opt); + + $this->assertCount(1, $msg->pricingOptionGroup); + $this->assertEquals(PricingOptionKey::OPTION_FORM_OF_PAYMENT, $msg->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey); + $this->assertEquals(\Amadeus\Client\Struct\Fare\PricePnr13\FormOfPayment::TYPE_CREDIT_CARD, $msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->type); + $this->assertEquals(10, $msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->amount); + $this->assertEquals('400000', $msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->creditCardNumber); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->sourceOfApproval); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->authorisedAmount); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->indicator); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->addressVerification); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->approvalCode); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->customerAccount); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->expiryDate); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->extendedPayment); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->fopFreeText); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->membershipStatus); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->pinCode); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->pinCodeType); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->transactionInfo); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->formOfPayment->vendorCode); + $this->assertCount(1, $msg->pricingOptionGroup[0]->formOfPaymentInformation->otherFormOfPayment); + $this->assertEquals(\Amadeus\Client\Struct\Fare\PricePnr13\FormOfPayment::TYPE_CASH, $msg->pricingOptionGroup[0]->formOfPaymentInformation->otherFormOfPayment[0]->type); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->otherFormOfPayment[0]->amount); + $this->assertNull($msg->pricingOptionGroup[0]->formOfPaymentInformation->otherFormOfPayment[0]->creditCardNumber); } } diff --git a/tests/Amadeus/Client/Struct/Security/AuthenticateTest.php b/tests/Amadeus/Client/Struct/Security/AuthenticateTest.php index a652f407e..56b44679d 100644 --- a/tests/Amadeus/Client/Struct/Security/AuthenticateTest.php +++ b/tests/Amadeus/Client/Struct/Security/AuthenticateTest.php @@ -51,19 +51,19 @@ public function testCanConstructAuthMessage() $reqOpt = new SecurityAuthenticateOptions($authParams); - $message = new Authenticate($reqOpt); + $msg = new Authenticate($reqOpt); - $this->assertEquals('BRUXXXXXX' , $message->userIdentifier->originIdentification->sourceOffice); - $this->assertEquals('U' , $message->userIdentifier->originatorTypeCode); - $this->assertEquals('WSXXXXXX' , $message->userIdentifier->originator); + $this->assertEquals('BRUXXXXXX' , $msg->userIdentifier->originIdentification->sourceOffice); + $this->assertEquals('U' , $msg->userIdentifier->originatorTypeCode); + $this->assertEquals('WSXXXXXX' , $msg->userIdentifier->originator); - $this->assertEquals('DUT' , $message->dutyCode->dutyCodeDetails->referenceQualifier); - $this->assertEquals('SU' , $message->dutyCode->dutyCodeDetails->referenceIdentifier); + $this->assertEquals('DUT' , $msg->dutyCode->dutyCodeDetails->referenceQualifier); + $this->assertEquals('SU' , $msg->dutyCode->dutyCodeDetails->referenceIdentifier); - $this->assertEquals('DUMMY-ORG' , $message->systemDetails->organizationDetails->organizationId); + $this->assertEquals('DUMMY-ORG' , $msg->systemDetails->organizationDetails->organizationId); - $this->assertEquals(PasswordInfo::DATA_TYPE_EDIFACT , $message->passwordInfo->dataType); - $this->assertEquals(4 , $message->passwordInfo->dataLength); - $this->assertEquals(base64_encode('TEST') , $message->passwordInfo->binaryData); + $this->assertEquals(PasswordInfo::DATA_TYPE_EDIFACT , $msg->passwordInfo->dataType); + $this->assertEquals(4 , $msg->passwordInfo->dataLength); + $this->assertEquals(base64_encode('TEST') , $msg->passwordInfo->binaryData); } } diff --git a/tests/Amadeus/Client/Struct/Service/IntegratedPricingTest.php b/tests/Amadeus/Client/Struct/Service/IntegratedPricingTest.php index cb435ad8d..15f418d20 100644 --- a/tests/Amadeus/Client/Struct/Service/IntegratedPricingTest.php +++ b/tests/Amadeus/Client/Struct/Service/IntegratedPricingTest.php @@ -22,6 +22,8 @@ namespace Test\Amadeus\Client\Struct\Service; +use Amadeus\Client\RequestOptions\Service\FormOfPayment; +use Amadeus\Client\RequestOptions\Service\FrequentFlyer; use Amadeus\Client\RequestOptions\Service\PaxSegRef; use Amadeus\Client\RequestOptions\ServiceIntegratedPricingOptions; use Amadeus\Client\Struct\Fare\PricePnr13\DateInformation; @@ -43,20 +45,20 @@ public function testCanMakeMessageNoOptions() { $opt = new ServiceIntegratedPricingOptions(); - $message = new IntegratedPricing($opt); + $msg = new IntegratedPricing($opt); - $this->assertCount(1, $message->pricingOption); - $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_NO_OPTION, $message->pricingOption[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(1, $msg->pricingOption); + $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_NO_OPTION, $msg->pricingOption[0]->pricingOptionKey->pricingOptionKey); - $this->assertNull($message->pricingOption[0]->optionDetail); - $this->assertNull($message->pricingOption[0]->carrierInformation); - $this->assertNull($message->pricingOption[0]->currency); - $this->assertNull($message->pricingOption[0]->dateInformation); - $this->assertNull($message->pricingOption[0]->formOfPaymentInformation); - $this->assertNull($message->pricingOption[0]->frequentFlyerInformation); - $this->assertNull($message->pricingOption[0]->locationInformation); - $this->assertNull($message->pricingOption[0]->paxSegTstReference); - $this->assertNull($message->pricingOption[0]->ticketInformation); + $this->assertNull($msg->pricingOption[0]->optionDetail); + $this->assertNull($msg->pricingOption[0]->carrierInformation); + $this->assertNull($msg->pricingOption[0]->currency); + $this->assertNull($msg->pricingOption[0]->dateInformation); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation); + $this->assertNull($msg->pricingOption[0]->frequentFlyerInformation); + $this->assertNull($msg->pricingOption[0]->locationInformation); + $this->assertNull($msg->pricingOption[0]->paxSegTstReference); + $this->assertNull($msg->pricingOption[0]->ticketInformation); } public function testCanMakeMessageWithAccountCode() @@ -71,26 +73,26 @@ public function testCanMakeMessageWithAccountCode() ] ]); - $message = new IntegratedPricing($opt); + $msg = new IntegratedPricing($opt); - $this->assertCount(1, $message->pricingOption); + $this->assertCount(1, $msg->pricingOption); - $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_ACCOUNT_CODE, $message->pricingOption[0]->pricingOptionKey->pricingOptionKey); - $this->assertCount(1, $message->pricingOption[0]->optionDetail->criteriaDetails); - $this->assertEquals('AAA123456', $message->pricingOption[0]->optionDetail->criteriaDetails[0]->attributeType); - $this->assertNull($message->pricingOption[0]->optionDetail->criteriaDetails[0]->attributeDescription); + $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_ACCOUNT_CODE, $msg->pricingOption[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(1, $msg->pricingOption[0]->optionDetail->criteriaDetails); + $this->assertEquals('AAA123456', $msg->pricingOption[0]->optionDetail->criteriaDetails[0]->attributeType); + $this->assertNull($msg->pricingOption[0]->optionDetail->criteriaDetails[0]->attributeDescription); - $this->assertCount(1, $message->pricingOption[0]->paxSegTstReference->referenceDetails); - $this->assertEquals(1, $message->pricingOption[0]->paxSegTstReference->referenceDetails[0]->value); - $this->assertEquals(ReferenceDetails::QUALIFIER_PAX_REFERENCE, $message->pricingOption[0]->paxSegTstReference->referenceDetails[0]->type); + $this->assertCount(1, $msg->pricingOption[0]->paxSegTstReference->referenceDetails); + $this->assertEquals(1, $msg->pricingOption[0]->paxSegTstReference->referenceDetails[0]->value); + $this->assertEquals(ReferenceDetails::QUALIFIER_PAX_REFERENCE, $msg->pricingOption[0]->paxSegTstReference->referenceDetails[0]->type); - $this->assertNull($message->pricingOption[0]->carrierInformation); - $this->assertNull($message->pricingOption[0]->currency); - $this->assertNull($message->pricingOption[0]->dateInformation); - $this->assertNull($message->pricingOption[0]->formOfPaymentInformation); - $this->assertNull($message->pricingOption[0]->frequentFlyerInformation); - $this->assertNull($message->pricingOption[0]->locationInformation); - $this->assertNull($message->pricingOption[0]->ticketInformation); + $this->assertNull($msg->pricingOption[0]->carrierInformation); + $this->assertNull($msg->pricingOption[0]->currency); + $this->assertNull($msg->pricingOption[0]->dateInformation); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation); + $this->assertNull($msg->pricingOption[0]->frequentFlyerInformation); + $this->assertNull($msg->pricingOption[0]->locationInformation); + $this->assertNull($msg->pricingOption[0]->ticketInformation); } /** @@ -115,30 +117,30 @@ public function testCanMakeMessageWithPaxFlightAndServiceSelection() ] ]); - $message = new IntegratedPricing($opt); + $msg = new IntegratedPricing($opt); - $this->assertCount(1, $message->pricingOption); + $this->assertCount(1, $msg->pricingOption); - $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_PAX_SEG_ELEMENT_SELECTION, $message->pricingOption[0]->pricingOptionKey->pricingOptionKey); + $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_PAX_SEG_ELEMENT_SELECTION, $msg->pricingOption[0]->pricingOptionKey->pricingOptionKey); - $this->assertNull($message->pricingOption[0]->optionDetail); + $this->assertNull($msg->pricingOption[0]->optionDetail); - $this->assertCount(3, $message->pricingOption[0]->paxSegTstReference->referenceDetails); - $this->assertEquals(1, $message->pricingOption[0]->paxSegTstReference->referenceDetails[0]->value); - $this->assertEquals(ReferenceDetails::QUALIFIER_PAX_REFERENCE, $message->pricingOption[0]->paxSegTstReference->referenceDetails[0]->type); - $this->assertEquals(2, $message->pricingOption[0]->paxSegTstReference->referenceDetails[1]->value); - $this->assertEquals(ReferenceDetails::QUALIFIER_SEGMENT_REFERENCE, $message->pricingOption[0]->paxSegTstReference->referenceDetails[1]->type); - $this->assertEquals(16, $message->pricingOption[0]->paxSegTstReference->referenceDetails[2]->value); - $this->assertEquals(ReferenceDetails::QUALIFIER_ELEMENT, $message->pricingOption[0]->paxSegTstReference->referenceDetails[2]->type); + $this->assertCount(3, $msg->pricingOption[0]->paxSegTstReference->referenceDetails); + $this->assertEquals(1, $msg->pricingOption[0]->paxSegTstReference->referenceDetails[0]->value); + $this->assertEquals(ReferenceDetails::QUALIFIER_PAX_REFERENCE, $msg->pricingOption[0]->paxSegTstReference->referenceDetails[0]->type); + $this->assertEquals(2, $msg->pricingOption[0]->paxSegTstReference->referenceDetails[1]->value); + $this->assertEquals(ReferenceDetails::QUALIFIER_SEGMENT_REFERENCE, $msg->pricingOption[0]->paxSegTstReference->referenceDetails[1]->type); + $this->assertEquals(16, $msg->pricingOption[0]->paxSegTstReference->referenceDetails[2]->value); + $this->assertEquals(ReferenceDetails::QUALIFIER_ELEMENT, $msg->pricingOption[0]->paxSegTstReference->referenceDetails[2]->type); - $this->assertNull($message->pricingOption[0]->optionDetail); - $this->assertNull($message->pricingOption[0]->carrierInformation); - $this->assertNull($message->pricingOption[0]->currency); - $this->assertNull($message->pricingOption[0]->dateInformation); - $this->assertNull($message->pricingOption[0]->formOfPaymentInformation); - $this->assertNull($message->pricingOption[0]->frequentFlyerInformation); - $this->assertNull($message->pricingOption[0]->locationInformation); - $this->assertNull($message->pricingOption[0]->ticketInformation); + $this->assertNull($msg->pricingOption[0]->optionDetail); + $this->assertNull($msg->pricingOption[0]->carrierInformation); + $this->assertNull($msg->pricingOption[0]->currency); + $this->assertNull($msg->pricingOption[0]->dateInformation); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation); + $this->assertNull($msg->pricingOption[0]->frequentFlyerInformation); + $this->assertNull($msg->pricingOption[0]->locationInformation); + $this->assertNull($msg->pricingOption[0]->ticketInformation); } public function testCanMakeMessageWithOverrideOptionServicePricingDescription() @@ -149,21 +151,21 @@ public function testCanMakeMessageWithOverrideOptionServicePricingDescription() ] ]); - $message = new IntegratedPricing($opt); + $msg = new IntegratedPricing($opt); - $this->assertCount(1, $message->pricingOption); + $this->assertCount(1, $msg->pricingOption); - $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_SHOW_PRICING_DESCRIPTION, $message->pricingOption[0]->pricingOptionKey->pricingOptionKey); + $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_SHOW_PRICING_DESCRIPTION, $msg->pricingOption[0]->pricingOptionKey->pricingOptionKey); - $this->assertNull($message->pricingOption[0]->optionDetail); - $this->assertNull($message->pricingOption[0]->carrierInformation); - $this->assertNull($message->pricingOption[0]->currency); - $this->assertNull($message->pricingOption[0]->dateInformation); - $this->assertNull($message->pricingOption[0]->formOfPaymentInformation); - $this->assertNull($message->pricingOption[0]->frequentFlyerInformation); - $this->assertNull($message->pricingOption[0]->locationInformation); - $this->assertNull($message->pricingOption[0]->paxSegTstReference); - $this->assertNull($message->pricingOption[0]->ticketInformation); + $this->assertNull($msg->pricingOption[0]->optionDetail); + $this->assertNull($msg->pricingOption[0]->carrierInformation); + $this->assertNull($msg->pricingOption[0]->currency); + $this->assertNull($msg->pricingOption[0]->dateInformation); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation); + $this->assertNull($msg->pricingOption[0]->frequentFlyerInformation); + $this->assertNull($msg->pricingOption[0]->locationInformation); + $this->assertNull($msg->pricingOption[0]->paxSegTstReference); + $this->assertNull($msg->pricingOption[0]->ticketInformation); } public function testCanMakeMessageWithOverridePointOfSale() @@ -172,24 +174,24 @@ public function testCanMakeMessageWithOverridePointOfSale() 'pointOfSaleOverride' => 'MUC' ]); - $message = new IntegratedPricing($opt); + $msg = new IntegratedPricing($opt); - $this->assertCount(1, $message->pricingOption); + $this->assertCount(1, $msg->pricingOption); - $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_POINT_OF_SALE, $message->pricingOption[0]->pricingOptionKey->pricingOptionKey); + $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_POINT_OF_SALE, $msg->pricingOption[0]->pricingOptionKey->pricingOptionKey); - $this->assertEquals(LocationInformation::TYPE_POINT_OF_SALE, $message->pricingOption[0]->locationInformation->locationType); - $this->assertEquals('MUC', $message->pricingOption[0]->locationInformation->firstLocationDetails->code); - $this->assertNull($message->pricingOption[0]->locationInformation->secondLocationDetails); + $this->assertEquals(LocationInformation::TYPE_POINT_OF_SALE, $msg->pricingOption[0]->locationInformation->locationType); + $this->assertEquals('MUC', $msg->pricingOption[0]->locationInformation->firstLocationDetails->code); + $this->assertNull($msg->pricingOption[0]->locationInformation->secondLocationDetails); - $this->assertNull($message->pricingOption[0]->optionDetail); - $this->assertNull($message->pricingOption[0]->carrierInformation); - $this->assertNull($message->pricingOption[0]->currency); - $this->assertNull($message->pricingOption[0]->dateInformation); - $this->assertNull($message->pricingOption[0]->formOfPaymentInformation); - $this->assertNull($message->pricingOption[0]->frequentFlyerInformation); - $this->assertNull($message->pricingOption[0]->paxSegTstReference); - $this->assertNull($message->pricingOption[0]->ticketInformation); + $this->assertNull($msg->pricingOption[0]->optionDetail); + $this->assertNull($msg->pricingOption[0]->carrierInformation); + $this->assertNull($msg->pricingOption[0]->currency); + $this->assertNull($msg->pricingOption[0]->dateInformation); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation); + $this->assertNull($msg->pricingOption[0]->frequentFlyerInformation); + $this->assertNull($msg->pricingOption[0]->paxSegTstReference); + $this->assertNull($msg->pricingOption[0]->ticketInformation); } public function testCanMakeMessageWithPricingDateOverride() @@ -202,14 +204,14 @@ public function testCanMakeMessageWithPricingDateOverride() ) ]); - $message = new IntegratedPricing($opt); + $msg = new IntegratedPricing($opt); - $this->assertCount(1, $message->pricingOption); - $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_PRICING_DATE, $message->pricingOption[0]->pricingOptionKey->pricingOptionKey); - $this->assertEquals(DateInformation::OPT_DATE_OVERRIDE, $message->pricingOption[0]->dateInformation->businessSemantic); - $this->assertEquals("2012", $message->pricingOption[0]->dateInformation->dateTime->year); - $this->assertEquals("06", $message->pricingOption[0]->dateInformation->dateTime->month); - $this->assertEquals("27", $message->pricingOption[0]->dateInformation->dateTime->day); + $this->assertCount(1, $msg->pricingOption); + $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_PRICING_DATE, $msg->pricingOption[0]->pricingOptionKey->pricingOptionKey); + $this->assertEquals(DateInformation::OPT_DATE_OVERRIDE, $msg->pricingOption[0]->dateInformation->businessSemantic); + $this->assertEquals("2012", $msg->pricingOption[0]->dateInformation->dateTime->year); + $this->assertEquals("06", $msg->pricingOption[0]->dateInformation->dateTime->month); + $this->assertEquals("27", $msg->pricingOption[0]->dateInformation->dateTime->day); } public function testCanMakeMessageWithCurrencyOverride() @@ -218,13 +220,13 @@ public function testCanMakeMessageWithCurrencyOverride() 'currencyOverride' => 'EUR' ]); - $message = new IntegratedPricing($opt); + $msg = new IntegratedPricing($opt); - $this->assertCount(1, $message->pricingOption); - $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_CURRENCY, $message->pricingOption[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(1, $msg->pricingOption); + $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_CURRENCY, $msg->pricingOption[0]->pricingOptionKey->pricingOptionKey); - $this->assertEquals(FirstCurrencyDetails::QUAL_CURRENCY_OVERRIDE, $message->pricingOption[0]->currency->firstCurrencyDetails->currencyQualifier); - $this->assertEquals('EUR', $message->pricingOption[0]->currency->firstCurrencyDetails->currencyIsoCode); + $this->assertEquals(FirstCurrencyDetails::QUAL_CURRENCY_OVERRIDE, $msg->pricingOption[0]->currency->firstCurrencyDetails->currencyQualifier); + $this->assertEquals('EUR', $msg->pricingOption[0]->currency->firstCurrencyDetails->currencyIsoCode); } public function testCanMakeMessageWithValidatingCarrierOverride() @@ -233,12 +235,12 @@ public function testCanMakeMessageWithValidatingCarrierOverride() 'validatingCarrier' => 'BA' ]); - $message = new IntegratedPricing($opt); + $msg = new IntegratedPricing($opt); - $this->assertCount(1, $message->pricingOption); - $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_VALIDATING_CARRIER, $message->pricingOption[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(1, $msg->pricingOption); + $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_VALIDATING_CARRIER, $msg->pricingOption[0]->pricingOptionKey->pricingOptionKey); - $this->assertEquals('BA', $message->pricingOption[0]->carrierInformation->companyIdentification->otherCompany); + $this->assertEquals('BA', $msg->pricingOption[0]->carrierInformation->companyIdentification->otherCompany); } public function testCanMakeMessageWithAwardPricing() @@ -247,12 +249,12 @@ public function testCanMakeMessageWithAwardPricing() 'awardPricing' => ServiceIntegratedPricingOptions::AWARDPRICING_MILES ]); - $message = new IntegratedPricing($opt); + $msg = new IntegratedPricing($opt); - $this->assertCount(1, $message->pricingOption); - $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_AWARD, $message->pricingOption[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(1, $msg->pricingOption); + $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_AWARD, $msg->pricingOption[0]->pricingOptionKey->pricingOptionKey); - $this->assertEquals('MIL', $message->pricingOption[0]->optionDetail->criteriaDetails[0]->attributeType); + $this->assertEquals('MIL', $msg->pricingOption[0]->optionDetail->criteriaDetails[0]->attributeType); } public function testCanMakeMessageWithCorporationNumber() @@ -261,12 +263,12 @@ public function testCanMakeMessageWithCorporationNumber() 'corporationNumber' => '123435' ]); - $message = new IntegratedPricing($opt); + $msg = new IntegratedPricing($opt); - $this->assertCount(1, $message->pricingOption); - $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_CORPORATION_NUMBER, $message->pricingOption[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(1, $msg->pricingOption); + $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_CORPORATION_NUMBER, $msg->pricingOption[0]->pricingOptionKey->pricingOptionKey); - $this->assertEquals('123435', $message->pricingOption[0]->optionDetail->criteriaDetails[0]->attributeType); + $this->assertEquals('123435', $msg->pricingOption[0]->optionDetail->criteriaDetails[0]->attributeType); } public function testCanMakeMessageWithTicketDesignator() @@ -275,12 +277,78 @@ public function testCanMakeMessageWithTicketDesignator() 'ticketDesignator' => '3M4J2KM432' ]); - $message = new IntegratedPricing($opt); + $msg = new IntegratedPricing($opt); - $this->assertCount(1, $message->pricingOption); - $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_TICKET_DESIGNATOR, $message->pricingOption[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(1, $msg->pricingOption); + $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_TICKET_DESIGNATOR, $msg->pricingOption[0]->pricingOptionKey->pricingOptionKey); + + $this->assertEquals('3M4J2KM432', $msg->pricingOption[0]->optionDetail->criteriaDetails[0]->attributeType); + } + + public function testCanMakeMessageWithFormOfPaymentOverride() + { + $opt = new ServiceIntegratedPricingOptions([ + 'formOfPayment' => [ + new FormOfPayment([ + 'type' => FormOfPayment::TYPE_CREDIT_CARD, + 'amount' => 10, + 'creditCardNumber' => '400000' + ]), + new FormOfPayment([ + 'type' => FormOfPayment::TYPE_CASH + ]), + ] + ]); + + $msg = new IntegratedPricing($opt); + + $this->assertCount(1, $msg->pricingOption); + $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_FORM_OF_PAYMENT, $msg->pricingOption[0]->pricingOptionKey->pricingOptionKey); + $this->assertEquals(\Amadeus\Client\Struct\Fare\PricePnr13\FormOfPayment::TYPE_CREDIT_CARD, $msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->type); + $this->assertEquals(10, $msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->amount); + $this->assertEquals('400000', $msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->creditCardNumber); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->sourceOfApproval); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->authorisedAmount); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->indicator); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->addressVerification); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->approvalCode); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->customerAccount); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->expiryDate); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->extendedPayment); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->fopFreeText); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->membershipStatus); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->pinCode); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->pinCodeType); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->transactionInfo); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->formOfPayment->vendorCode); + $this->assertCount(1, $msg->pricingOption[0]->formOfPaymentInformation->otherFormOfPayment); + $this->assertEquals(\Amadeus\Client\Struct\Fare\PricePnr13\FormOfPayment::TYPE_CASH, $msg->pricingOption[0]->formOfPaymentInformation->otherFormOfPayment[0]->type); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->otherFormOfPayment[0]->amount); + $this->assertNull($msg->pricingOption[0]->formOfPaymentInformation->otherFormOfPayment[0]->creditCardNumber); + } + + public function testCanMakeMessageWithFrequentFlyerOverride() + { + $opt = new ServiceIntegratedPricingOptions([ + 'frequentFlyers' => [ + new FrequentFlyer([ + 'company' => '6X', + 'number' => '1234567891011', + 'tierLevel' => 'SILVER', + 'priorityCode' => '1' + ]) + ] + ]); + + $msg = new IntegratedPricing($opt); + $this->assertCount(1, $msg->pricingOption); + $this->assertEquals(IntegratedPricing\PricingOptionKey::OVERRIDE_FREQUENT_FLYER_INFORMATION, $msg->pricingOption[0]->pricingOptionKey->pricingOptionKey); + $this->assertCount(1, $msg->pricingOption[0]->frequentFlyerInformation->frequentTravellerDetails); + $this->assertEquals('6X', $msg->pricingOption[0]->frequentFlyerInformation->frequentTravellerDetails[0]->carrier); + $this->assertEquals('1234567891011', $msg->pricingOption[0]->frequentFlyerInformation->frequentTravellerDetails[0]->number); + $this->assertEquals('SILVER', $msg->pricingOption[0]->frequentFlyerInformation->frequentTravellerDetails[0]->tierLevel); + $this->assertEquals('1', $msg->pricingOption[0]->frequentFlyerInformation->frequentTravellerDetails[0]->priorityCode); - $this->assertEquals('3M4J2KM432', $message->pricingOption[0]->optionDetail->criteriaDetails[0]->attributeType); } } diff --git a/tests/Amadeus/Client/Struct/Ticket/CreateTSMFromPricingTest.php b/tests/Amadeus/Client/Struct/Ticket/CreateTSMFromPricingTest.php index 4f18ad1d0..1e0112392 100644 --- a/tests/Amadeus/Client/Struct/Ticket/CreateTSMFromPricingTest.php +++ b/tests/Amadeus/Client/Struct/Ticket/CreateTSMFromPricingTest.php @@ -25,7 +25,7 @@ class CreateTSMFromPricingTest extends BaseTestCase { public function testCanMakeTstFromPricingWithPassengerReference() { - $message = new CreateTSMFromPricing( + $msg = new CreateTSMFromPricing( new TicketCreateTsmFromPricingOptions([ 'pricings' => [ new Pricing([ @@ -41,20 +41,20 @@ public function testCanMakeTstFromPricingWithPassengerReference() ]) ); - $this->assertEquals(1, count($message->psaList)); - $this->assertEquals(2, $message->psaList[0]->itemReference->uniqueReference); - $this->assertEquals(ItemReference::REFTYPE_TSM, $message->psaList[0]->itemReference->referenceType); + $this->assertEquals(1, count($msg->psaList)); + $this->assertEquals(2, $msg->psaList[0]->itemReference->uniqueReference); + $this->assertEquals(ItemReference::REFTYPE_TSM, $msg->psaList[0]->itemReference->referenceType); - $this->assertEquals(1, count($message->psaList[0]->paxReference->refDetails)); - $this->assertEquals(1, $message->psaList[0]->paxReference->refDetails[0]->refNumber); - $this->assertEquals(RefDetails::QUAL_PASSENGER, $message->psaList[0]->paxReference->refDetails[0]->refQualifier); + $this->assertEquals(1, count($msg->psaList[0]->paxReference->refDetails)); + $this->assertEquals(1, $msg->psaList[0]->paxReference->refDetails[0]->refNumber); + $this->assertEquals(RefDetails::QUAL_PASSENGER, $msg->psaList[0]->paxReference->refDetails[0]->refQualifier); } public function testCanMakeTsmFromPricingWithPnrInfo() { // !!! This PNR record locator is used for tracing purpose, no internal retrieve. !!! - $message = new CreateTSMFromPricing( + $msg = new CreateTSMFromPricing( new TicketCreateTsMFromPricingOptions([ 'informationalRecordLocator' => 'ABC123', 'pricings' => [ @@ -65,6 +65,6 @@ public function testCanMakeTsmFromPricingWithPnrInfo() ]) ); - $this->assertEquals('ABC123', $message->pnrLocatorData->reservationInformation->controlNumber); + $this->assertEquals('ABC123', $msg->pnrLocatorData->reservationInformation->controlNumber); } } diff --git a/tests/Amadeus/Client/Struct/Ticket/CreateTSTFromPricingTest.php b/tests/Amadeus/Client/Struct/Ticket/CreateTSTFromPricingTest.php index d41a8d423..04245fc95 100644 --- a/tests/Amadeus/Client/Struct/Ticket/CreateTSTFromPricingTest.php +++ b/tests/Amadeus/Client/Struct/Ticket/CreateTSTFromPricingTest.php @@ -40,7 +40,7 @@ class CreateTSTFromPricingTest extends BaseTestCase { public function testCanMakeTstFromPricingWithPassengerReference() { - $message = new CreateTSTFromPricing( + $msg = new CreateTSTFromPricing( new TicketCreateTstFromPricingOptions([ 'pricings' => [ new Pricing([ @@ -56,20 +56,20 @@ public function testCanMakeTstFromPricingWithPassengerReference() ]) ); - $this->assertEquals(1, count($message->psaList)); - $this->assertEquals(3, $message->psaList[0]->itemReference->uniqueReference); - $this->assertEquals(ItemReference::REFTYPE_TST, $message->psaList[0]->itemReference->referenceType); + $this->assertEquals(1, count($msg->psaList)); + $this->assertEquals(3, $msg->psaList[0]->itemReference->uniqueReference); + $this->assertEquals(ItemReference::REFTYPE_TST, $msg->psaList[0]->itemReference->referenceType); - $this->assertEquals(1, count($message->psaList[0]->paxReference->refDetails)); - $this->assertEquals(1, $message->psaList[0]->paxReference->refDetails[0]->refNumber); - $this->assertEquals(RefDetails::QUAL_ADULT, $message->psaList[0]->paxReference->refDetails[0]->refQualifier); + $this->assertEquals(1, count($msg->psaList[0]->paxReference->refDetails)); + $this->assertEquals(1, $msg->psaList[0]->paxReference->refDetails[0]->refNumber); + $this->assertEquals(RefDetails::QUAL_ADULT, $msg->psaList[0]->paxReference->refDetails[0]->refQualifier); } public function testCanMakeTstFromPricingWithPnrInfo() { // !!! This PNR record locator is used for tracing purpose, no internal retrieve. !!! - $message = new CreateTSTFromPricing( + $msg = new CreateTSTFromPricing( new TicketCreateTstFromPricingOptions([ 'informationalRecordLocator' => 'ABC123', 'pricings' => [ @@ -80,6 +80,6 @@ public function testCanMakeTstFromPricingWithPnrInfo() ]) ); - $this->assertEquals('ABC123', $message->pnrLocatorData->reservationInformation->controlNumber); + $this->assertEquals('ABC123', $msg->pnrLocatorData->reservationInformation->controlNumber); } } diff --git a/tests/Amadeus/Client/Struct/Ticket/DeleteTsmpTest.php b/tests/Amadeus/Client/Struct/Ticket/DeleteTsmpTest.php index 524535840..82d97b26d 100644 --- a/tests/Amadeus/Client/Struct/Ticket/DeleteTsmpTest.php +++ b/tests/Amadeus/Client/Struct/Ticket/DeleteTsmpTest.php @@ -40,13 +40,13 @@ public function testCanBuildMessageWithPaxTattoos() 'paxTattoos' => [1, 2] ]); - $message = new DeleteTSMP($opt); + $msg = new DeleteTSMP($opt); - $this->assertCount(2, $message->criteriaTattoo); - $this->assertEquals(1, $message->criteriaTattoo[0]->referenceDetails->value); - $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_PASSENGER_TATTOO, $message->criteriaTattoo[0]->referenceDetails->type); - $this->assertEquals(2, $message->criteriaTattoo[1]->referenceDetails->value); - $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_PASSENGER_TATTOO, $message->criteriaTattoo[1]->referenceDetails->type); + $this->assertCount(2, $msg->criteriaTattoo); + $this->assertEquals(1, $msg->criteriaTattoo[0]->referenceDetails->value); + $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_PASSENGER_TATTOO, $msg->criteriaTattoo[0]->referenceDetails->type); + $this->assertEquals(2, $msg->criteriaTattoo[1]->referenceDetails->value); + $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_PASSENGER_TATTOO, $msg->criteriaTattoo[1]->referenceDetails->type); } public function testCanBuildMessageWithInfantTattoo() @@ -55,11 +55,11 @@ public function testCanBuildMessageWithInfantTattoo() 'infantTattoos' => [1] ]); - $message = new DeleteTSMP($opt); + $msg = new DeleteTSMP($opt); - $this->assertCount(1, $message->criteriaTattoo); - $this->assertEquals(1, $message->criteriaTattoo[0]->referenceDetails->value); - $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_INFANT_PARENT_TATTOO, $message->criteriaTattoo[0]->referenceDetails->type); + $this->assertCount(1, $msg->criteriaTattoo); + $this->assertEquals(1, $msg->criteriaTattoo[0]->referenceDetails->value); + $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_INFANT_PARENT_TATTOO, $msg->criteriaTattoo[0]->referenceDetails->type); } public function testCanBuildMessageWithTsmTattoos() @@ -68,15 +68,15 @@ public function testCanBuildMessageWithTsmTattoos() 'tsmTattoos' => [14, 16, 17] ]); - $message = new DeleteTSMP($opt); + $msg = new DeleteTSMP($opt); - $this->assertCount(3, $message->criteriaTattoo); - $this->assertEquals(14, $message->criteriaTattoo[0]->referenceDetails->value); - $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_TSM_TATTOO, $message->criteriaTattoo[0]->referenceDetails->type); - $this->assertEquals(16, $message->criteriaTattoo[1]->referenceDetails->value); - $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_TSM_TATTOO, $message->criteriaTattoo[1]->referenceDetails->type); - $this->assertEquals(17, $message->criteriaTattoo[2]->referenceDetails->value); - $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_TSM_TATTOO, $message->criteriaTattoo[2]->referenceDetails->type); + $this->assertCount(3, $msg->criteriaTattoo); + $this->assertEquals(14, $msg->criteriaTattoo[0]->referenceDetails->value); + $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_TSM_TATTOO, $msg->criteriaTattoo[0]->referenceDetails->type); + $this->assertEquals(16, $msg->criteriaTattoo[1]->referenceDetails->value); + $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_TSM_TATTOO, $msg->criteriaTattoo[1]->referenceDetails->type); + $this->assertEquals(17, $msg->criteriaTattoo[2]->referenceDetails->value); + $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_TSM_TATTOO, $msg->criteriaTattoo[2]->referenceDetails->type); } /** @@ -90,14 +90,14 @@ public function testCanBuildMessageWithMixedTattoos() 'paxTattoos' => [3] ]); - $message = new DeleteTSMP($opt); + $msg = new DeleteTSMP($opt); - $this->assertCount(3, $message->criteriaTattoo); - $this->assertEquals(1, $message->criteriaTattoo[0]->referenceDetails->value); - $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_INFANT_PARENT_TATTOO, $message->criteriaTattoo[0]->referenceDetails->type); - $this->assertEquals(3, $message->criteriaTattoo[1]->referenceDetails->value); - $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_PASSENGER_TATTOO, $message->criteriaTattoo[1]->referenceDetails->type); - $this->assertEquals(14, $message->criteriaTattoo[2]->referenceDetails->value); - $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_TSM_TATTOO, $message->criteriaTattoo[2]->referenceDetails->type); + $this->assertCount(3, $msg->criteriaTattoo); + $this->assertEquals(1, $msg->criteriaTattoo[0]->referenceDetails->value); + $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_INFANT_PARENT_TATTOO, $msg->criteriaTattoo[0]->referenceDetails->type); + $this->assertEquals(3, $msg->criteriaTattoo[1]->referenceDetails->value); + $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_PASSENGER_TATTOO, $msg->criteriaTattoo[1]->referenceDetails->type); + $this->assertEquals(14, $msg->criteriaTattoo[2]->referenceDetails->value); + $this->assertEquals(DeleteTSMP\ReferenceDetails::TYPE_TSM_TATTOO, $msg->criteriaTattoo[2]->referenceDetails->type); } }