diff --git a/src/Amadeus/Client/RequestCreator/UnsupportedOptionException.php b/src/Amadeus/Client/RequestCreator/UnsupportedOptionException.php new file mode 100644 index 000000000..95ba4fa8e --- /dev/null +++ b/src/Amadeus/Client/RequestCreator/UnsupportedOptionException.php @@ -0,0 +1,40 @@ + + */ +class UnsupportedOptionException extends Client\Exception +{ + +} diff --git a/src/Amadeus/Client/ResponseHandler/Base.php b/src/Amadeus/Client/ResponseHandler/Base.php index 39e39d16a..7be907de1 100644 --- a/src/Amadeus/Client/ResponseHandler/Base.php +++ b/src/Amadeus/Client/ResponseHandler/Base.php @@ -240,6 +240,59 @@ protected function analyzeQueueListResponse($response) return $analysisResponse; } + + /** + * + * + * + * + * + * 00477 + * EC + * 1A + * + * + * + * INVALID FORMAT + * + * + * + * + * @param SendResult $response Fare_PricePNRWithBookingClass result + * @return Result + * @throws Exception + */ + protected function analyzeFarePricePNRWithBookingClassResponse($response) + { + $analyzeResponse = new Result($response); + + $domXpath = $this->makeDomXpath($response->responseXml); + + $queryErrorCode = "//m:applicationError//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode"; + $queryErrorCategory = "//m:applicationError//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCategory"; + $queryErrorMsg = "//m:applicationError/m:errorWarningDescription/m:freeText"; + + $errorCodeNodeList = $domXpath->query($queryErrorCode); + + if ($errorCodeNodeList->length > 0) { + $errorCatNode = $domXpath->query($queryErrorCategory)->item(0); + if ($errorCatNode instanceof \DOMNode) { + $analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue); + } else { + $analyzeResponse->status = Result::STATUS_ERROR; + } + + $analyzeResponse->messages[] = new Result\NotOk( + $errorCodeNodeList->item(0)->nodeValue, + $this->makeMessageFromMessagesNodeList( + $domXpath->query($queryErrorMsg) + ) + ); + } + + return $analyzeResponse; + } + /** * @param SendResult $response WebService message Send Result * @return Result @@ -255,7 +308,11 @@ protected function analyzeSimpleResponseErrorCodeAndMessage($response) if (!is_null($errorCodeNode)) { $errorCatNode = $domDoc->getElementsByTagName("errorCategory")->item(0); - $analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue); + if ($errorCatNode instanceof \DOMNode) { + $analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue); + } else { + $analyzeResponse->status = Result::STATUS_ERROR; + } $errorCode = $errorCodeNode->nodeValue; $errorTextNodeList = $domDoc->getElementsByTagName("freeText"); diff --git a/src/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass12.php b/src/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass12.php index 29c128a66..264967ce2 100644 --- a/src/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass12.php +++ b/src/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass12.php @@ -22,9 +22,11 @@ namespace Amadeus\Client\Struct\Fare; +use Amadeus\Client\RequestCreator\UnsupportedOptionException; use Amadeus\Client\RequestOptions\FarePricePnrWithBookingClassOptions; use Amadeus\Client\Struct\BaseWsMessage; use Amadeus\Client\Struct\Fare\PricePnr12\AttributeDetails; +use Amadeus\Client\Struct\Fare\PricePnr12\CurrencyOverride; use Amadeus\Client\Struct\Fare\PricePnr12\OverrideInformation; use Amadeus\Client\Struct\Fare\PricePnr12\PricingFareBase; use Amadeus\Client\Struct\Fare\PricePnr12\ValidatingCarrier; @@ -53,6 +55,9 @@ class PricePNRWithBookingClass12 extends BaseWsMessage public $cityOverride; + /** + * @var PricePnr12\CurrencyOverride + */ public $currencyOverride; public $taxDetails; @@ -81,6 +86,7 @@ class PricePNRWithBookingClass12 extends BaseWsMessage * PricePNRWithBookingClass12 constructor. * * @param FarePricePnrWithBookingClassOptions $options + * @throws UnsupportedOptionException */ public function __construct(FarePricePnrWithBookingClassOptions $options) { @@ -94,11 +100,15 @@ public function __construct(FarePricePnrWithBookingClassOptions $options) } } + if (!empty($options->currencyOverride)) { + $this->currencyOverride = new CurrencyOverride($options->currencyOverride); + } + if (is_string($options->validatingCarrier)) { $this->validatingCarrier = new ValidatingCarrier($options->validatingCarrier); } - if (in_array(AttributeDetails::OVERRIDE_FAREBASIS, $options->overrideOptions)) { + if (in_array(AttributeDetails::OVERRIDE_FAREBASIS, $options->overrideOptions) && !empty($options->pricingsFareBasis)) { foreach ($options->pricingsFareBasis as $pricingFareBasis) { $this->pricingFareBase[] = new PricingFareBase($pricingFareBasis); } diff --git a/src/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13.php b/src/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13.php index d8a7b528d..87c4f4032 100644 --- a/src/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13.php +++ b/src/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13.php @@ -23,8 +23,17 @@ namespace Amadeus\Client\Struct\Fare; use Amadeus\Client\RequestCreator\MessageVersionUnsupportedException; +use Amadeus\Client\RequestOptions\Fare\PricePnrBcFareBasis; use Amadeus\Client\RequestOptions\FarePricePnrWithBookingClassOptions; use Amadeus\Client\Struct\BaseWsMessage; +use Amadeus\Client\Struct\Fare\PricePnr13\CarrierInformation; +use Amadeus\Client\Struct\Fare\PricePnr13\CriteriaDetails; +use Amadeus\Client\Struct\Fare\PricePnr13\Currency; +use Amadeus\Client\Struct\Fare\PricePnr13\FirstCurrencyDetails; +use Amadeus\Client\Struct\Fare\PricePnr13\OptionDetail; +use Amadeus\Client\Struct\Fare\PricePnr13\PaxSegTstReference; +use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionGroup; +use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionKey; /** * Fare_PricePNRWithBookingClass v 13 and higher structure @@ -48,9 +57,97 @@ class PricePNRWithBookingClass13 extends BaseWsMessage public function __construct(FarePricePnrWithBookingClassOptions $options) { - throw new MessageVersionUnsupportedException( - 'Fare_PricePNRWithBookingClass message versions 13+ are not yet implemented' + if ($options->validatingCarrier !== null) { + $this->pricingOptionGroup[] = $this->makePricingOptionForValidatingCarrier($options->validatingCarrier); + } + + if ($options->currencyOverride !== null) { + $this->pricingOptionGroup[] = $this->makePricingOptionForCurrencyOverride($options->currencyOverride); + } + + if ($options->pricingsFareBasis !== null) { + foreach ($options->pricingsFareBasis as $pricingFareBasis) { + $this->pricingOptionGroup[] = $this->makePricingOptionFareBasisOverride($pricingFareBasis); + } + } + + if (!empty($options->overrideOptions)) { + foreach ($options->overrideOptions as $overrideOption) { + if (!$this->hasPricingGroup($overrideOption)) { + $this->pricingOptionGroup[] = new PricingOptionGroup($overrideOption); + } + } + } + + // All options processed, no options found: + if (empty($this->pricingOptionGroup)) { + $this->pricingOptionGroup[] = new PricingOptionGroup(PricingOptionKey::OPTION_NO_OPTION); + } + } + + /** + * @param string $validatingCarrier + * @return PricePnr13\PricingOptionGroup + */ + protected function makePricingOptionForValidatingCarrier($validatingCarrier) + { + $po = new PricingOptionGroup(PricingOptionKey::OPTION_VALIDATING_CARRIER); + + $po->carrierInformation = new CarrierInformation($validatingCarrier); + + return $po; + } + + /** + * @param string $currency + * @return PricePnr13\PricingOptionGroup + */ + protected function makePricingOptionForCurrencyOverride($currency) + { + $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_CURRENCY_OVERRIDE); + + $po->currency = new Currency($currency, FirstCurrencyDetails::QUAL_CURRENCY_OVERRIDE); + + return $po; + } + + /** + * @param PricePnrBcFareBasis $pricingFareBasis + * @return PricePnr13\PricingOptionGroup + */ + protected function makePricingOptionFareBasisOverride($pricingFareBasis) + { + $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_BASIS_SIMPLE_OVERRIDE); + + $po->optionDetail = new OptionDetail(); + $po->optionDetail->criteriaDetails[] = new CriteriaDetails( + $pricingFareBasis->fareBasisPrimaryCode . $pricingFareBasis->fareBasisCode ); + + $po->paxSegTstReference = new PaxSegTstReference($pricingFareBasis->segmentReference); + + return $po; } + /** + * Avoid double pricing groups when combining an explicitly provided override option with a specific parameter + * that uses the same override option. + * + * Backwards compatibility with PricePnrWithBookingClass12 + * + * @param string $optionKey + * @return bool + */ + protected function hasPricingGroup($optionKey) + { + $found = false; + + foreach ($this->pricingOptionGroup as $pog) { + if ($pog->pricingOptionKey->pricingOptionKey === $optionKey) { + $found = true; + } + } + + return $found; + } } diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr12/CurrencyOverride.php b/src/Amadeus/Client/Struct/Fare/PricePnr12/CurrencyOverride.php new file mode 100644 index 000000000..49d22959a --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr12/CurrencyOverride.php @@ -0,0 +1,43 @@ + + */ +class CurrencyOverride +{ + public $firstRateDetail; + + /** + * CurrencyOverride constructor. + * @param string $currency + */ + public function __construct($currency) + { + $this->firstRateDetail = new FirstRateDetail($currency); + } +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr12/FirstRateDetail.php b/src/Amadeus/Client/Struct/Fare/PricePnr12/FirstRateDetail.php new file mode 100644 index 000000000..66c9bb302 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr12/FirstRateDetail.php @@ -0,0 +1,47 @@ + + */ +class FirstRateDetail +{ + /** + * @var string + */ + public $currencyCode; + + /** + * FirstRateDetail constructor. + * + * @param string $currency + */ + public function __construct($currency) + { + $this->currencyCode = $currency; + } +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/CarrierInformation.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/CarrierInformation.php new file mode 100644 index 000000000..fa0bef9c3 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/CarrierInformation.php @@ -0,0 +1,48 @@ + + */ +class CarrierInformation +{ + + /** + * @var CompanyIdentification + */ + public $companyIdentification; + + /** + * CarrierInformation constructor. + * + * @param string $airline + */ + public function __construct($airline) + { + $this->companyIdentification = new CompanyIdentification($airline); + } +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/CompanyIdentification.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/CompanyIdentification.php new file mode 100644 index 000000000..371bfb19d --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/CompanyIdentification.php @@ -0,0 +1,47 @@ + + */ +class CompanyIdentification +{ + /** + * @var string + */ + public $otherCompany; + + /** + * CompanyIdentification constructor. + * + * @param string $airline + */ + public function __construct($airline) + { + $this->otherCompany = $airline; + } +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/CriteriaDetails.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/CriteriaDetails.php new file mode 100644 index 000000000..2d3735b45 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/CriteriaDetails.php @@ -0,0 +1,52 @@ + + */ +class CriteriaDetails +{ + /** + * @var string + */ + public $attributeType; + + /** + * @var string + */ + public $attributeDescription; + + /** + * CriteriaDetails constructor. + * + * @param string $type + */ + public function __construct($type) + { + $this->attributeType = $type; + } +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/Currency.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/Currency.php new file mode 100644 index 000000000..77b8c11e5 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/Currency.php @@ -0,0 +1,48 @@ + + */ +class Currency +{ + /** + * @var FirstCurrencyDetails + */ + public $firstCurrencyDetails; + + /** + * Currency constructor. + * + * @param string $currency + * @param string $qualifier + */ + public function __construct($currency, $qualifier = FirstCurrencyDetails::QUAL_CURRENCY_OVERRIDE) + { + $this->firstCurrencyDetails = new FirstCurrencyDetails($currency, $qualifier); + } +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/DateInformation.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/DateInformation.php new file mode 100644 index 000000000..3160682ab --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/DateInformation.php @@ -0,0 +1,34 @@ + + */ +class DateInformation +{ + +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/DiscountPenaltyDetails.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/DiscountPenaltyDetails.php new file mode 100644 index 000000000..ddde29947 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/DiscountPenaltyDetails.php @@ -0,0 +1,66 @@ + + */ +class DiscountPenaltyDetails +{ + /** + * 700 Base fare + * 701 Total fare + * 704 Penalties apply + * EXF EXclude Fee + * INF INclude Fee + * + * @var string + */ + public $function; + + /** + * 707 Fixed whole amount + * 708 Percentage + * + * @var string + */ + public $amountType; + + /** + * @var string + */ + public $amount; + + /** + * @var string + */ + public $rate; + + /** + * @var string + */ + public $currency; +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/FirstCurrencyDetails.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/FirstCurrencyDetails.php new file mode 100644 index 000000000..863fc5ffb --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/FirstCurrencyDetails.php @@ -0,0 +1,58 @@ + + */ +class FirstCurrencyDetails +{ + const QUAL_CURRENCY_OVERRIDE = "FCO"; + + const QUAL_CURRENCY_SELECTION = "FCS"; + + /** + * @var string + */ + public $currencyQualifier; + + /** + * @var string + */ + public $currencyIsoCode; + + /** + * FirstCurrencyDetails constructor. + * + * @param string $currency + * @param string $qualifier + */ + public function __construct($currency, $qualifier = self::QUAL_CURRENCY_OVERRIDE) + { + $this->currencyIsoCode = $currency; + $this->currencyQualifier = $qualifier; + } +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/FormOfPaymentInformation.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/FormOfPaymentInformation.php new file mode 100644 index 000000000..4a4b349f2 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/FormOfPaymentInformation.php @@ -0,0 +1,34 @@ + + */ +class FormOfPaymentInformation +{ + +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/FrequentFlyerInformation.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/FrequentFlyerInformation.php new file mode 100644 index 000000000..6e7bcfb3c --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/FrequentFlyerInformation.php @@ -0,0 +1,34 @@ + + */ +class FrequentFlyerInformation +{ + +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/LocationInformation.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/LocationInformation.php new file mode 100644 index 000000000..2e3c848f1 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/LocationInformation.php @@ -0,0 +1,34 @@ + + */ +class LocationInformation +{ + +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/MonetaryInformation.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/MonetaryInformation.php new file mode 100644 index 000000000..54ec5b105 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/MonetaryInformation.php @@ -0,0 +1,34 @@ + + */ +class MonetaryInformation +{ + +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/OptionDetail.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/OptionDetail.php new file mode 100644 index 000000000..23e6d6121 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/OptionDetail.php @@ -0,0 +1,37 @@ + + */ +class OptionDetail +{ + /** + * @var CriteriaDetails[] + */ + public $criteriaDetails = []; +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/PaxSegTstReference.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/PaxSegTstReference.php new file mode 100644 index 000000000..65a3f0e41 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/PaxSegTstReference.php @@ -0,0 +1,49 @@ + + */ +class PaxSegTstReference +{ + /** + * @var ReferenceDetails[] + */ + public $referenceDetails = []; + + /** + * PaxSegTstReference constructor. + * + * @param array $segmentReference + */ + public function __construct($segmentReference) + { + foreach ($segmentReference as $segNum => $segQual) { + $this->referenceDetails[] = new ReferenceDetails($segNum, $segQual); + } + } +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/PenDisInformation.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/PenDisInformation.php new file mode 100644 index 000000000..51d2a8eb1 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/PenDisInformation.php @@ -0,0 +1,47 @@ + + */ +class PenDisInformation +{ + /** + * 700 Penalty information + * 701 Discount information + * OBF OB Fees Information + * ZAP ZapOff Discount Information + * + * @var string + */ + public $discountPenaltyQualifier; + + /** + * @var DiscountPenaltyDetails + */ + public $discountPenaltyDetails; +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/PricingOptionGroup.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/PricingOptionGroup.php index b97bb89ac..c9a920139 100644 --- a/src/Amadeus/Client/Struct/Fare/PricePnr13/PricingOptionGroup.php +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/PricingOptionGroup.php @@ -30,28 +30,73 @@ */ class PricingOptionGroup { + /** + * @var PricingOptionKey + */ public $pricingOptionKey; + /** + * @var OptionDetail + */ public $optionDetail; + /** + * @var CarrierInformation + */ public $carrierInformation; + /** + * @var Currency + */ public $currency; + /** + * @var PenDisInformation + */ public $penDisInformation; + /** + * @var MonetaryInformation + */ public $monetaryInformation; + /** + * @var TaxInformation + */ public $taxInformation; + /** + * @var DateInformation + */ public $dateInformation; + /** + * @var FrequentFlyerInformation + */ public $frequentFlyerInformation; + /** + * @var FormOfPaymentInformation + */ public $formOfPaymentInformation; + /** + * @var LocationInformation + */ public $locationInformation; + /** + * @var PaxSegTstReference + */ public $paxSegTstReference; + /** + * PricingOptionGroup constructor. + * + * @param string $key + */ + public function __construct($key) + { + $this->pricingOptionKey = new PricingOptionKey($key); + } } diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/PricingOptionKey.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/PricingOptionKey.php new file mode 100644 index 000000000..fe8492000 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/PricingOptionKey.php @@ -0,0 +1,113 @@ + + */ +class PricingOptionKey +{ + const OPTION_NO_OPTION = "NOP"; + + const OPTION_VALIDATING_CARRIER = "VC"; + + const OPTION_FARE_CURRENCY_OVERRIDE = "FCO"; + + const OPTION_PASSENGER_DISCOUNT = "PAX"; + + const OPTION_FARE_BASIS_SIMPLE_OVERRIDE = "FBA"; + + const OPTION_NEGOTIATED_FARES = "RN"; + + /** + * AC Add Country taxes + * AT Add Tax + * AWD AWarD + * BK Booking class override + * BND Bound Input + * CC Controlling Carrier Override + * CMP Companions + * CON Connection + * DAT past DATe pricing + * DIA Diagnostic Tool + * DO booking Date Override + * ET Exempt Taxes + * FBA Fare BAsis simple override + * FBL Fare Basis force override + * FBP Force Break Point + * FCO Fare Currency Override + * FCS Fare Currency Selection + * FOP Form Of Payment + * GRI Global Route Indicator + * IP Instant Pricing + * 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 + * NOP No Option + * OBF OB Fees (include and/or exclude) + * PAX Passenger discount/PTC + * PFF Pricing by Fare Family + * PL Pricing Logic + * POS Point Of Sale + * POT Point Of Ticketing override + * PRM expanded PaRaMeters + * PRO Promo Certificate + * PTA Point of Turnaround + * PTC PTC only + * RC Corporate negociated fares + * RLI Return LIst of fare + * RLO Return LOwest possible fare + * RN Negociated fare + * RP Published Fares + * RU Unifares + * RW Corporate Unifares + * SEL Passenger/Segment/Line/TST selection + * STO Stopover + * TKT TicKet Type + * TRS Transitional Certificate + * VC Validating Carrier + * WC Withold Country taxes + * WQ Withold Q surcharges + * WT Withold Tax + * ZAP ZAP-off + * + * @var string + */ + public $pricingOptionKey; + + /** + * PricingOptionKey constructor. + * + * @param string $key + */ + public function __construct($key) + { + $this->pricingOptionKey = $key; + } +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/ReferenceDetails.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/ReferenceDetails.php new file mode 100644 index 000000000..01b164996 --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/ReferenceDetails.php @@ -0,0 +1,60 @@ + + */ +class ReferenceDetails +{ + /** + * P Passenger/traveller reference number + * PA Adult Passenger + * PI Infant Passenger + * S Segment/service reference number + * T TST + * + * @var string + */ + public $type; + + /** + * @var string + */ + public $value; + + /** + * ReferenceDetails constructor. + * + * @param string $value + * @param string $type + */ + public function __construct($value, $type) + { + $this->value = $value; + $this->type = $type; + } +} diff --git a/src/Amadeus/Client/Struct/Fare/PricePnr13/TaxInformation.php b/src/Amadeus/Client/Struct/Fare/PricePnr13/TaxInformation.php new file mode 100644 index 000000000..3c10cd0af --- /dev/null +++ b/src/Amadeus/Client/Struct/Fare/PricePnr13/TaxInformation.php @@ -0,0 +1,34 @@ + + */ +class TaxInformation +{ + +} diff --git a/tests/Amadeus/Client/ResponseHandler/BaseTest.php b/tests/Amadeus/Client/ResponseHandler/BaseTest.php index 6e491a8bf..8be1f4411 100644 --- a/tests/Amadeus/Client/ResponseHandler/BaseTest.php +++ b/tests/Amadeus/Client/ResponseHandler/BaseTest.php @@ -112,6 +112,19 @@ public function testCanFindErrorInPnrCancel() $this->assertEquals(0, count($result->messages)); } + public function testCanHandleOkPnrRetrieve() + { + $respHandler = new ResponseHandler\Base(); + + $sendResult = new SendResult(); + $sendResult->responseXml = $this->getTestFile('dummyPnrRetrieveReply.txt'); + + $result = $respHandler->analyzeResponse($sendResult, 'PNR_Retrieve'); + + $this->assertEquals(Result::STATUS_OK, $result->status); + $this->assertEquals(0, count($result->messages)); + } + public function testCanSetWarningStatusForEmptyQueue() { $respHandler = new ResponseHandler\Base(); @@ -200,6 +213,23 @@ public function testCanParseSecurityAuthenticateReplyErr() $this->assertEquals('16199', $result->messages[0]->code); } + public function testCanParseSecuritySignOutReplyErr() + { + $respHandler = new ResponseHandler\Base(); + + $sendResult = new SendResult(); + $sendResult->responseXml = $this->getTestFile('dummySecuritySignoutReply.txt'); + $sendResult->messageVersion = '6.1'; + + $result = $respHandler->analyzeResponse($sendResult, 'Security_SignOut'); + + $this->assertEquals(Result::STATUS_ERROR, $result->status); + $this->assertEquals(1, count($result->messages)); + $this->assertEquals('ERROR', $result->messages[0]->text); + $this->assertEquals('', $result->messages[0]->level); + $this->assertEquals('1', $result->messages[0]->code); + } + public function testCanHandleSoapFault() { $respHandler = new ResponseHandler\Base(); @@ -235,4 +265,19 @@ public function testCanHandleSoapFaultSession() $this->assertEquals("Session", $result->messages[0]->level); $this->assertEquals('', $result->messages[0]->text); } + + public function testCanFindFarePricePnrWithBookingClassError() + { + $respHandler = new ResponseHandler\Base(); + + $sendResult = new SendResult(); + $sendResult->responseXml = $this->getTestFile('dummyFarePricePnrWithBookingClassReplyError.txt'); + + $result = $respHandler->analyzeResponse($sendResult, 'Fare_PricePnrWithBookingClass'); + + $this->assertEquals(Result::STATUS_ERROR, $result->status); + $this->assertEquals(1, count($result->messages)); + $this->assertEquals('00477', $result->messages[0]->code); + $this->assertEquals("INVALID FORMAT", $result->messages[0]->text); + } } diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/dummyFarePricePnrWithBookingClassReplyError.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyFarePricePnrWithBookingClassReplyError.txt new file mode 100644 index 000000000..08503d8e2 --- /dev/null +++ b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyFarePricePnrWithBookingClassReplyError.txt @@ -0,0 +1,14 @@ + + + + + 00477 + EC + 1A + + + + INVALID FORMAT + + + \ No newline at end of file diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/dummyPnrRetrieveReply.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyPnrRetrieveReply.txt new file mode 100644 index 000000000..5678290fd --- /dev/null +++ b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyPnrRetrieveReply.txt @@ -0,0 +1 @@ +1AYMUQL9300516RPWSSUBRUXXXXXX00081900BRUXXXXXXEHDBRUXXXXXX9991WS30051600081900213300081900BRUXXXXXXT1ABRUBE00081900BRUXXXXXXT1ABRUBE00081900BRUXXXXXXT1ABRUBE1020161022PT2NM1BOWIE1DAVIDADT1ADTUNYYBOWIEDAVIDST1RU2221016BRU1A321HK3-GENERIC TRAVEL REQUESTOT1AP337+3222222222OT4TK4PAXXL100816BRUXXXXXXOT2RM5RMTID:123456RMTID:123456OT3RM6RM*ACECRM/PP-TESTRM*ACECRM/PP-TEST \ No newline at end of file diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/dummySecuritySignoutReply.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/dummySecuritySignoutReply.txt new file mode 100644 index 000000000..00c1bd9b3 --- /dev/null +++ b/tests/Amadeus/Client/ResponseHandler/testfiles/dummySecuritySignoutReply.txt @@ -0,0 +1,16 @@ + + + + + 1 + + + + + 3 + EN + + ERROR + + + \ No newline at end of file diff --git a/tests/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass12Test.php b/tests/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass12Test.php index 78769c2cd..3ce19793f 100644 --- a/tests/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass12Test.php +++ b/tests/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass12Test.php @@ -56,5 +56,17 @@ public function testCanDoPricePnrCallWithStuff() $this->assertEquals(2, $message->pricingFareBase[0]->fareBasisSegReference[0]->refDetails->refNumber); $this->assertEquals(PricePnrBcFareBasis::SEGREFTYPE_SEGMENT, $message->pricingFareBase[0]->fareBasisSegReference[0]->refDetails->refQualifier); $this->assertEquals('BA', $message->validatingCarrier->carrierInformation->carrierCode); + $this->assertEquals('EUR', $message->currencyOverride->firstRateDetail->currencyCode); + } + + + public function testCanDoPricePnrCallWithNoOptions() + { + $opt = new FarePricePnrWithBookingClassOptions(); + + $message = new PricePNRWithBookingClass12($opt); + + $this->assertCount(1, $message->overrideInformation->attributeDetails); + $this->assertEquals(FarePricePnrWithBookingClassOptions::OVERRIDE_NO_OPTION, $message->overrideInformation->attributeDetails[0]->attributeType); } } diff --git a/tests/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13Test.php b/tests/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13Test.php new file mode 100644 index 000000000..d33dfc310 --- /dev/null +++ b/tests/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13Test.php @@ -0,0 +1,108 @@ + + */ +class PricePNRWithBookingClass13Test extends BaseTestCase +{ + public function testCanDoPricePnrCallWithStuff() + { + $opt = new FarePricePnrWithBookingClassOptions([ + 'overrideOptions' => [FarePricePnrWithBookingClassOptions::OVERRIDE_FARETYPE_NEG], + 'validatingCarrier' => 'BA', + 'currencyOverride' => 'EUR', + 'pricingsFareBasis' => [ + new PricePnrBcFareBasis([ + 'fareBasisPrimaryCode' => 'QNC', + 'fareBasisCode' => '469W2', + 'segmentReference' => [2 => PricePnrBcFareBasis::SEGREFTYPE_SEGMENT] + ]) + ] + ]); + + $message = new PricePNRWithBookingClass13($opt); + + $validatingCarrierPo = new PricingOptionGroup(PricingOptionKey::OPTION_VALIDATING_CARRIER); + $validatingCarrierPo->carrierInformation = new CarrierInformation('BA'); + + $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $validatingCarrierPo)); + + $currencyOverridePo = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_CURRENCY_OVERRIDE); + $currencyOverridePo->currency = new Currency('EUR'); + + $this->assertTrue($this->assertArrayContainsSameObject($message->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([2 => PricePnrBcFareBasis::SEGREFTYPE_SEGMENT]); + + $this->assertTrue($this->assertArrayContainsSameObject($message->pricingOptionGroup, $fareBasisOverridePo)); + + $negofarePo = new PricingOptionGroup(PricingOptionKey::OPTION_NEGOTIATED_FARES); + + $this->assertTrue($this->assertArrayContainsSameObject($message->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); + } + + + /** + * @param $theArray + * @param $theObject + * @return bool + */ + private function assertArrayContainsSameObject($theArray, $theObject) + { + foreach($theArray as $arrayItem) { + if($arrayItem == $theObject) { + return true; + } + } + return false; + } +} diff --git a/tests/Amadeus/ClientTest.php b/tests/Amadeus/ClientTest.php index 29c424bcd..8e5616b6e 100644 --- a/tests/Amadeus/ClientTest.php +++ b/tests/Amadeus/ClientTest.php @@ -1622,15 +1622,24 @@ public function testCanFarePricePnrWithBookingClassVersion12() public function testCanFarePricePnrWithBookingClassVersion14() { - $this->setExpectedException('\Amadeus\Client\RequestCreator\MessageVersionUnsupportedException'); - $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); - //$messageResult = 'dummyfarepricepnrwithbookingclassmessage'; + $mockedSendResult = new Client\Session\Handler\SendResult(); + $mockedSendResult->responseXml = $this->getTestFile('farePricePnrWithBookingClassReply14.txt'); + + $messageResult = new Client\Result($mockedSendResult); + + $expectedMessageResult = new Client\Struct\Fare\PricePNRWithBookingClass13( + new Client\RequestOptions\FarePricePnrWithBookingClassOptions([ + 'validatingCarrier' => 'SN' + ]) + ); $mockSessionHandler - ->expects($this->never()) - ->method('sendMessage'); + ->expects($this->once()) + ->method('sendMessage') + ->with('Fare_PricePNRWithBookingClass', $expectedMessageResult, ['asString' => false, 'endSession' => false]) + ->will($this->returnValue($mockedSendResult));; $mockSessionHandler ->expects($this->never()) ->method('getLastResponse'); @@ -1648,11 +1657,14 @@ public function testCanFarePricePnrWithBookingClassVersion14() $client = new Client($par); - $client->farePricePnrWithBookingClass( + + $response = $client->farePricePnrWithBookingClass( new Client\RequestOptions\FarePricePnrWithBookingClassOptions([ 'validatingCarrier' => 'SN' ]) ); + + $this->assertEquals($messageResult, $response); } public function testCanDoSignOutCall() diff --git a/tests/Amadeus/testfiles/farePricePnrWithBookingClassReply14.txt b/tests/Amadeus/testfiles/farePricePnrWithBookingClassReply14.txt new file mode 100644 index 000000000..14b35690d --- /dev/null +++ b/tests/Amadeus/testfiles/farePricePnrWithBookingClassReply14.txt @@ -0,0 +1,1842 @@ + + + + + F + + N + + + TST + 1 + + + LT + + 2013 + 10 + 13 + + + + + 6X + + + + + PA + 1 + + + + + IT + + + B + 37.00 + EUR + + + E + 50.00 + USD + + + 712 + 262.29 + USD + + + TOF + 40.58 + USD + + + TFT + 221.71 + USD + + + + + 7 + + X + + + YR + + VB + + + + TAX + 62.22 + USD + + + + + + 7 + + X + + + QX + + AP + + + + TAX + 17.50 + USD + + + + + + 7 + + X + + + IZ + + EB + + + + TAX + 1.35 + USD + + + + + + 7 + + X + + + FR + + SE + + + + TAX + 5.83 + USD + + + + + + 7 + + X + + + FR + + TI + + + + TAX + 17.25 + USD + + + + + + 7 + + X + + + GB + + AD + + + + TAX + 21.04 + USD + + + + + + 7 + + X + + + UB + + AS + + + + TAX + 46.52 + USD + + + + + + 1.352631 + + + + PAR + PAR + + + + + O + + + + + AIR + Q + + + + + QSR + FR + ADT + + + + A + + 2013 + 12 + 1 + + + + B + + 2013 + 12 + 1 + + + + + 1 + N + + + + + S + 3 + + + + + 1 + + + + + + + O + + + + + AIR + V + + + + + VRD + 10FR9 + ADT + + + + A + + 2013 + 12 + 10 + + + + B + + 2013 + 12 + 10 + + + + + 0 + N + + + + + S + 4 + + + + + 2 + + + + + + TOU + *F*/TM0000 + + + END + NONREF / NO CHANGE + + + 36 + NONREF /NO CHANGE + + + FCA + PAR 6X LON M/IT 6X PAR M/IT END + + + + + + PEN + WEC + 1A + + + + NON-REFUNDABLE + + + + + + LTD + WEC + 1A + + + + - SEE ADV PURCHASE + + + + + + 0 + WEC + 1A + + + + AIRLINE FEES INCLUDED + + + + + + 0 + WEC + 1A + + + + CAT35 NEGOTIATED FARES + + + + + + 0 + WEC + 1A + + + + TICKET STOCK RESTRICTION + + + + + + 0 + WEC + 1A + + + + BG CXR: 6X/6X + + + + + + 0 + WEC + 1A + + + + PRICED WITH VALIDATING CARRIER 6X - REPRICE IF DIFFERENT VC + + + + + + + + + + + + T01 + + + + + COM + + TKT FEE + + + + TIN + 40.58 + USD + + + + + + + + 1 + + + + + + ST + 3 + + + + + + + + 2 + + + + + + ST + 4 + + + + + + + + + + F + + N + + + TST + 2 + + + LT + + 2013 + 10 + 13 + + + + + 6X + + + + + PA + 2 + + + + + IT + + + B + 29.00 + EUR + + + E + 39.00 + USD + + + 712 + 251.29 + USD + + + TOF + 40.58 + USD + + + TFT + 210.71 + USD + + + + + 7 + + X + + + YR + + VB + + + + TAX + 62.22 + USD + + + + + + 7 + + X + + + QX + + AP + + + + TAX + 17.50 + USD + + + + + + 7 + + X + + + IZ + + EB + + + + TAX + 1.35 + USD + + + + + + 7 + + X + + + FR + + SE + + + + TAX + 5.83 + USD + + + + + + 7 + + X + + + FR + + TI + + + + TAX + 17.25 + USD + + + + + + 7 + + X + + + GB + + AD + + + + TAX + 21.04 + USD + + + + + + 7 + + X + + + UB + + AS + + + + TAX + 46.52 + USD + + + + + + 1.352631 + + + + PAR + PAR + + + + + O + + + + + AIR + Q + + + + + QSR + FR + CH25 + CH + + + + A + + 2013 + 12 + 1 + + + + B + + 2013 + 12 + 1 + + + + + 1 + N + + + + + S + 3 + + + + + 1 + + + + + + + O + + + + + AIR + V + + + + + VRD + 10FR9 + CH0 + CH + + + + A + + 2013 + 12 + 10 + + + + B + + 2013 + 12 + 10 + + + + + 0 + N + + + + + S + 4 + + + + + 2 + + + + + + TOU + *F*/TM0000 + + + END + NONREF / NO CHANGE + + + 36 + NONREF /NO CHANGE + + + FCA + PAR 6X LON M/IT 6X PAR M/IT END + + + + + + PEN + WEC + 1A + + + + NON-REFUNDABLE + + + + + + LTD + WEC + 1A + + + + - SEE ADV PURCHASE + + + + + + 0 + WEC + 1A + + + + AIRLINE FEES INCLUDED + + + + + + 0 + WEC + 1A + + + + CAT35 NEGOTIATED FARES + + + + + + 0 + WEC + 1A + + + + TICKET STOCK RESTRICTION + + + + + + 0 + WEC + 1A + + + + BG CXR: 6X/6X + + + + + + 0 + WEC + 1A + + + + PRICED WITH VALIDATING CARRIER 6X - REPRICE IF DIFFERENT VC + + + + + + + + + + + + T01 + + + + + COM + + TKT FEE + + + + TIN + 40.58 + USD + + + + + + + + 1 + + + + + + ST + 3 + + + + + + + + 2 + + + + + + ST + 4 + + + + + + + + + + I + + 0 + + + TST + 3 + + + LT + + 2013 + 10 + 13 + + + + + 6X + + + + + PA + 2 + + + + + F + + + B + 30.00 + EUR + + + E + 41.00 + USD + + + 712 + 280.35 + USD + + + TOF + 40.58 + USD + + + TFT + 239.77 + USD + + + + + 7 + + X + + + YR + + VB + + + + TAX + 89.28 + USD + + + + + + 7 + + X + + + QX + + AP + + + + TAX + 17.50 + USD + + + + + + 7 + + X + + + IZ + + EB + + + + TAX + 1.35 + USD + + + + + + 7 + + X + + + FR + + SE + + + + TAX + 5.83 + USD + + + + + + 7 + + X + + + FR + + TI + + + + TAX + 17.25 + USD + + + + + + 7 + + X + + + GB + + AD + + + + TAX + 21.04 + USD + + + + + + 7 + + X + + + UB + + AS + + + + TAX + 46.52 + USD + + + + + + 1.352631 + + + + PAR + PAR + + + + + O + + + + + AIR + Q + + + + + QSR + FR + CH25 + CH + + + + A + + 2013 + 12 + 1 + + + + B + + 2013 + 12 + 1 + + + + + 1 + N + + + + + S + 3 + + + + + 1 + + + + + + + O + + + + + AIR + V + + + + + VSR + 5FR + CH0 + CH + + + + A + + 2013 + 12 + 10 + + + + B + + 2013 + 12 + 10 + + + + + 1 + N + + + + + S + 4 + + + + + 2 + + + + + + END + REFUND/CHANGE RESTRICTIONS APPLY + + + FCA + PAR 6X LON32.636X PAR5.93NUC38.56END ROE0.758432 + + + + + + PEN + WEC + 1A + + + + NON-REFUNDABLE + + + + + + LTD + WEC + 1A + + + + - SEE ADV PURCHASE + + + + + + 0 + WEC + 1A + + + + AIRLINE FEES INCLUDED + + + + + + 0 + WEC + 1A + + + + TICKET STOCK RESTRICTION + + + + + + 0 + WEC + 1A + + + + BG CXR: 6X/6X + + + + + + 0 + WEC + 1A + + + + PRICED WITH VALIDATING CARRIER 6X - REPRICE IF DIFFERENT VC + + + + + + + + + + + + T01 + + + + + COM + + TKT FEE + + + + TIN + 40.58 + USD + + + + + + + + 1 + + + + + + ST + 3 + + + + + + + + 2 + + + + + + ST + 4 + + + + + + + + + + I + + 0 + + + TST + 4 + + + LT + + 2013 + 10 + 13 + + + + + 6X + + + + + PA + 1 + + + + + F + + + B + 38.00 + EUR + + + E + 51.00 + USD + + + 712 + 290.35 + USD + + + TOF + 40.58 + USD + + + TFT + 249.77 + USD + + + + + 7 + + X + + + YR + + VB + + + + TAX + 89.28 + USD + + + + + + 7 + + X + + + QX + + AP + + + + TAX + 17.50 + USD + + + + + + 7 + + X + + + IZ + + EB + + + + TAX + 1.35 + USD + + + + + + 7 + + X + + + FR + + SE + + + + TAX + 5.83 + USD + + + + + + 7 + + X + + + FR + + TI + + + + TAX + 17.25 + USD + + + + + + 7 + + X + + + GB + + AD + + + + TAX + 21.04 + USD + + + + + + 7 + + X + + + UB + + AS + + + + TAX + 46.52 + USD + + + + + + 1.352631 + + + + PAR + PAR + + + + + O + + + + + AIR + Q + + + + + QSR + FR + ADT + + + + A + + 2013 + 12 + 1 + + + + B + + 2013 + 12 + 1 + + + + + 1 + N + + + + + S + 3 + + + + + 1 + + + + + + + O + + + + + AIR + V + + + + + VSR + 5FR + ADT + + + + A + + 2013 + 12 + 10 + + + + B + + 2013 + 12 + 10 + + + + + 1 + N + + + + + S + 4 + + + + + 2 + + + + + + END + REFUND/CHANGE RESTRICTIONS APPLY + + + FCA + PAR 6X LON43.516X PAR5.93NUC49.44END ROE0.758432 + + + + + + PEN + WEC + 1A + + + + NON-REFUNDABLE + + + + + + LTD + WEC + 1A + + + + - SEE ADV PURCHASE + + + + + + 0 + WEC + 1A + + + + AIRLINE FEES INCLUDED + + + + + + 0 + WEC + 1A + + + + TICKET STOCK RESTRICTION + + + + + + 0 + WEC + 1A + + + + BG CXR: 6X/6X + + + + + + 0 + WEC + 1A + + + + PRICED WITH VALIDATING CARRIER 6X - REPRICE IF DIFFERENT VC + + + + + + + + + + + + T01 + + + + + COM + + TKT FEE + + + + TIN + 40.58 + USD + + + + + + + + 1 + + + + + + ST + 3 + + + + + + + + 2 + + + + + + ST + 4 + + + + + + + \ No newline at end of file