diff --git a/CHANGELOG.md b/CHANGELOG.md index de141611a..83ea86e2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * 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) * Implemented ``DocRefund_InitRefund`` (https://github.com/amabnl/amadeus-ws-client/issues/56) +* Implemented ``DocRefund_UpdateRefund`` (https://github.com/amabnl/amadeus-ws-client/issues/56) * Fixed a bug with building the correct version of a message (https://github.com/amabnl/amadeus-ws-client/issues/71) # Release 1.3.0 (5 April 2017) diff --git a/docs/list-of-supported-messages.rst b/docs/list-of-supported-messages.rst index 94b100395..bfdc59aee 100644 --- a/docs/list-of-supported-messages.rst +++ b/docs/list-of-supported-messages.rst @@ -47,6 +47,7 @@ This is the list of messages that are at least partially supported at this time: - DocIssuance_IssueMiscellaneousDocuments - DocIssuance_IssueCombined - DocRefund_InitRefund +- DocRefund_UpdateRefund - Service_IntegratedPricing - Offer_CreateOffer - Offer_VerifyOffer @@ -81,7 +82,6 @@ These messages will be implemented at some point in the future. *Pull requests a - Ticket_RetrieveListOfTSM - Ticket_AddDocNumber - TTR_DisplayTrip -- DocRefund_UpdateRefund - DocRefund_ProcessRefund - Media_GetMedia - Service_IntegratedCatalogue diff --git a/docs/samples.rst b/docs/samples.rst index 249237d4b..0488876a6 100644 --- a/docs/samples.rst +++ b/docs/samples.rst @@ -1927,6 +1927,207 @@ Refund with item number and coupon number: ); +---------------------- +DocRefund_UpdateRefund +---------------------- + +Example how to perform a ticket conjunction: + +.. code-block:: php + + use Amadeus\Client\RequestOptions\DocRefundUpdateRefundOptions; + use Amadeus\Client\RequestOptions\DocRefund\Reference; + use Amadeus\Client\RequestOptions\DocRefund\Ticket; + use Amadeus\Client\RequestOptions\DocRefund\TickGroupOpt; + use Amadeus\Client\RequestOptions\DocRefund\MonetaryData; + use Amadeus\Client\RequestOptions\DocRefund\TaxData; + use Amadeus\Client\RequestOptions\DocRefund\FopOpt; + use Amadeus\Client\RequestOptions\DocRefund\FreeTextOpt; + + $refundResponse = $client->docRefundUpdateRefund( + new DocRefundUpdateRefundOptions([ + 'originator' => '0001AA', + 'originatorId' => '23491193', + 'refundDate' => \DateTime::createFromFormat('Ymd', '20031125'), + 'ticketedDate' => \DateTime::createFromFormat('Ymd', '20030522'), + 'references' => [ + new Reference([ + 'type' => Reference::TYPE_TKT_INDICATOR, + 'value' => 'Y' + ]), + new Reference([ + 'type' => Reference::TYPE_DATA_SOURCE, + 'value' => 'F' + ]) + ], + 'tickets' => [ + new Ticket([ + 'number' => '22021541124593', + 'ticketGroup' => [ + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_1, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_2, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_3, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_4, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]) + ] + ]), + new Ticket([ + 'number' => '22021541124604', + 'ticketGroup' => [ + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_1, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_2, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]) + ] + ]) + ], + 'travellerPrioDateOfJoining' => \DateTime::createFromFormat('Ymd', '20070101'), + 'travellerPrioReference' => '0077701F', + 'monetaryData' => [ + new MonetaryData([ + 'type' => MonetaryData::TYPE_BASE_FARE, + 'amount' => 401.00, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_FARE_USED, + 'amount' => 0.00, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_FARE_REFUND, + 'amount' => 401.00, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_REFUND_TOTAL, + 'amount' => 457.74, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_TOTAL_TAXES, + 'amount' => 56.74, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => 'TP', + 'amount' => 56.74, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => 'OBP', + 'amount' => 0.00, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => 'TGV', + 'amount' => 374.93, + 'currency' => 'EUR' + ]) + ], + 'taxData' => [ + new TaxData([ + 'category' => 'H', + 'rate' => 16.14, + 'currencyCode' => 'EUR', + 'type' => 'DE' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 3.45, + 'currencyCode' => 'EUR', + 'type' => 'YC' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 9.67, + 'currencyCode' => 'EUR', + 'type' => 'US' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 9.67, + 'currencyCode' => 'EUR', + 'type' => 'US' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 3.14, + 'currencyCode' => 'EUR', + 'type' => 'XA' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 4.39, + 'currencyCode' => 'EUR', + 'type' => 'XY' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 6.28, + 'currencyCode' => 'EUR', + 'type' => 'AY' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 4.00, + 'currencyCode' => 'EUR', + 'type' => 'DU' + ]), + new TaxData([ + 'category' => '701', + 'rate' => 56.74, + 'currencyCode' => 'EUR', + 'type' => TaxData::TYPE_EXTENDED_TAXES + ]) + ], + 'formOfPayment' => [ + new FopOpt([ + 'fopType' => FopOpt::TYPE_MISCELLANEOUS, + 'fopAmount' => 457.74, + 'freeText' => [ + new FreeTextOpt([ + 'type' => 'CFP', + 'freeText' => '##0##' + ]), + new FreeTextOpt([ + 'type' => 'CFP', + 'freeText' => 'IDBANK' + ]) + ] + ]) + ], + 'refundedRouteStations' => [ + 'FRA', + 'MUC', + 'JFK', + 'BKK', + 'FRA' + ] + ]) + ); + ******* Service ******* @@ -2470,3 +2671,4 @@ Request a sales report from a certain date to another date, issued in all office $salesReportResult = $client->salesReportsDisplayQueryReport($opt); + diff --git a/src/Amadeus/Client.php b/src/Amadeus/Client.php index d6b1381a6..143de5bf3 100644 --- a/src/Amadeus/Client.php +++ b/src/Amadeus/Client.php @@ -983,6 +983,22 @@ public function docRefundInitRefund( return $this->callMessage($msgName, $options, $messageOptions); } + /** + * DocRefund_UpdateRefund + * + * @param RequestOptions\DocRefundUpdateRefundOptions $options + * @param array $messageOptions (OPTIONAL) + * @return Result + */ + public function docRefundUpdateRefund( + RequestOptions\DocRefundUpdateRefundOptions $options, + $messageOptions = [] + ) { + $msgName = 'DocRefund_UpdateRefund'; + + return $this->callMessage($msgName, $options, $messageOptions); + } + /** * FOP_CreateFormOfPayment * diff --git a/src/Amadeus/Client/RequestCreator/Base.php b/src/Amadeus/Client/RequestCreator/Base.php index 1fbaf0cdb..f9b616898 100644 --- a/src/Amadeus/Client/RequestCreator/Base.php +++ b/src/Amadeus/Client/RequestCreator/Base.php @@ -25,17 +25,7 @@ use Amadeus\Client\InvalidMessageException; use Amadeus\Client\Params\RequestCreatorParams; use Amadeus\Client\RequestCreator\Converter\ConvertInterface; -use Amadeus\Client\RequestOptions\CommandCrypticOptions; -use Amadeus\Client\RequestOptions\DocIssuanceIssueMiscDocOptions; -use Amadeus\Client\RequestOptions\DocIssuanceIssueTicketOptions; -use Amadeus\Client\RequestOptions\InfoEncodeDecodeCityOptions; -use Amadeus\Client\RequestOptions\MiniRuleGetFromPricingOptions; -use Amadeus\Client\RequestOptions\MiniRuleGetFromPricingRecOptions; -use Amadeus\Client\RequestOptions\PriceXplorerExtremeSearchOptions; use Amadeus\Client\RequestOptions\RequestOptionsInterface; -use Amadeus\Client\RequestOptions\SalesReportsDisplayQueryReportOptions; -use Amadeus\Client\RequestOptions\SecurityAuthenticateOptions; -use Amadeus\Client\RequestOptions\ServiceIntegratedPricingOptions; use Amadeus\Client\Struct; /** diff --git a/src/Amadeus/Client/RequestCreator/Converter/DocRefund/UpdateRefundConv.php b/src/Amadeus/Client/RequestCreator/Converter/DocRefund/UpdateRefundConv.php new file mode 100644 index 000000000..d0258509b --- /dev/null +++ b/src/Amadeus/Client/RequestCreator/Converter/DocRefund/UpdateRefundConv.php @@ -0,0 +1,46 @@ + + */ +class UpdateRefundConv extends BaseConverter +{ + /** + * @param DocRefundUpdateRefundOptions $requestOptions + * @param int|string $version + * @return Struct\DocRefund\UpdateRefund + */ + public function convert($requestOptions, $version) + { + return new Struct\DocRefund\UpdateRefund($requestOptions); + } +} diff --git a/src/Amadeus/Client/RequestOptions/DocRefund/AddressOpt.php b/src/Amadeus/Client/RequestOptions/DocRefund/AddressOpt.php new file mode 100644 index 000000000..da94a9d05 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/DocRefund/AddressOpt.php @@ -0,0 +1,88 @@ + + */ +class AddressOpt extends LoadParamsFromArray +{ + const TYPE_BILLING_ADDRESS = "AB"; + + /** + * self::TYPE_* + * + * @var string + */ + public $type = self::TYPE_BILLING_ADDRESS; + + /** + * @var string + */ + public $name; + + /** + * @var string + */ + public $company; + + /** + * @var string + */ + public $addressLine1; + + /** + * @var string + */ + public $addressLine2; + + /** + * @var string + */ + public $city; + + /** + * @var string + */ + public $postalCode; + + /** + * @var string + */ + public $poBox; + + /** + * @var string + */ + public $state; + + /** + * @var string + */ + public $country; +} diff --git a/src/Amadeus/Client/RequestOptions/DocRefund/CommissionOpt.php b/src/Amadeus/Client/RequestOptions/DocRefund/CommissionOpt.php new file mode 100644 index 000000000..b1d98bdc4 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/DocRefund/CommissionOpt.php @@ -0,0 +1,72 @@ + + */ +class CommissionOpt extends LoadParamsFromArray +{ + const TYPE_CANCELLATION_PENALTY = "CP"; + const TYPE_CANCELLATION_PENALTY_IN_MILES = "CPM"; + const TYPE_AIRLINE_COMMISSION_A = "FMA"; + const TYPE_AIRLINE_COMMISSION_B = "FMB"; + const TYPE_NEW_COMMISSION = "NEW"; + const TYPE_OLD_COMMISSION = "OLD"; + const TYPE_COMMISSION_ON_CANCELLATION_PENALTY = "XLP"; + + /** + * Commission Type + * + * self::TYPE_* + * + * @var string + */ + public $type; + + /** + * Commission Amount + * + * @var float|int + */ + public $amount; + + /** + * Free text + * + * @var string + */ + public $freeText; + + /** + * Commission Rate + * + * @var float|int + */ + public $rate; +} diff --git a/src/Amadeus/Client/RequestOptions/DocRefund/FopOpt.php b/src/Amadeus/Client/RequestOptions/DocRefund/FopOpt.php new file mode 100644 index 000000000..0a403a9e8 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/DocRefund/FopOpt.php @@ -0,0 +1,86 @@ + + */ +class FopOpt 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"; + + const SOURCE_IRU = "MIL"; + + /** + * Form of Payment Type + * + * self::TYPE_* + * + * @var string + */ + public $fopType; + + /** + * Amount + * + * @var int|float + */ + public $fopAmount; + + /** + * Source of Approval + * + * self::SOURCE_* + * + * @var string + */ + public $fopSourceOfApproval; + + /** + * Authorized amount + * + * @var int|float + */ + public $fopAuthorizedAmount; + + /** + * Interactive Free Text + * + * @var FreeTextOpt[] + */ + public $freeText = []; +} diff --git a/src/Amadeus/Client/RequestOptions/DocRefund/FreeTextOpt.php b/src/Amadeus/Client/RequestOptions/DocRefund/FreeTextOpt.php new file mode 100644 index 000000000..1016d22b3 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/DocRefund/FreeTextOpt.php @@ -0,0 +1,50 @@ + + */ +class FreeTextOpt extends LoadParamsFromArray +{ + const TYPE_ORIGINAL_ISSUE_INFORMATION = "45"; + const TYPE_REMARK = "REM"; + const TYPE_WAIVER_CODE = "WAV"; + + /** + * self::TYPE_* + * + * @var string + */ + public $type; + + /** + * @var string + */ + public $freeText; +} diff --git a/src/Amadeus/Client/RequestOptions/DocRefund/MonetaryData.php b/src/Amadeus/Client/RequestOptions/DocRefund/MonetaryData.php new file mode 100644 index 000000000..8b5925f21 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/DocRefund/MonetaryData.php @@ -0,0 +1,85 @@ + + */ +class MonetaryData extends LoadParamsFromArray +{ + const TYPE_AMOUNT_ENTERED_BY_AGENT = "AEA"; + const TYPE_BASE_FARE = "B"; + const TYPE_CANCELLATION_PENALTY = "CP"; + const TYPE_CURENCY_CONVERSION_AMOUNT = "CUR"; + const TYPE_DISCOUNT_AMOUNT_STORED_IN_REFUND_PANEL = "DA"; + const TYPE_DISCOUNT_AMOUNT_COMPUTED_BY_ATC_REFUND = "DAA"; + const TYPE_FARE_REFUND = "FRF"; + const TYPE_GST_TAX_AMOUNT = "GST"; + const TYPE_FARE_PAID_IN_MILES = "MFP"; + const TYPE_FARE_REFUND_IN_MILES = "MFR"; + const TYPE_FARE_USED_IN_MILES = "MFU"; + const TYPE_REFUND_TOTAL_IN_MILES = "MRT"; + const TYPE_NET_FARE_PAID = "NFP"; + const TYPE_NET_FARE_REFUND = "NFR"; + const TYPE_NET_FARE_USED = "NFU"; + const TYPE_NET_REMIT_TOTAL_AMOUNT = "NR"; + const TYPE_NO_SHOW_FEE = "NSF"; + const TYPE_PUBLISHED_FARE_PAID = "PFP"; + const TYPE_PUBLISHED_FARE_REFUND = "PFR"; + const TYPE_PUBLISHED_FARE_USED = "PFU"; + const TYPE_REFUND_TOTAL = "RFT"; + const TYPE_FARE_USED = "RFU"; + const TYPE_MISCELLANEOUS_FEE = "RMF"; + const TYPE_SELLING_FARE_PAID = "SFP"; + const TYPE_SELLING_FARE_REFUND = "SFR"; + const TYPE_SELLING_FARE_USED = "SFU"; + const TYPE_TOTAL_TAXES = "TXT"; + + /** + * Type of Monetary information + * + * self::TYPE_* + * + * @var string + */ + public $type; + + /** + * The amount + * + * @var float|int + */ + public $amount; + + /** + * 3-character ISO currency string + * + * @var string + */ + public $currency; +} diff --git a/src/Amadeus/Client/RequestOptions/DocRefund/Reference.php b/src/Amadeus/Client/RequestOptions/DocRefund/Reference.php new file mode 100644 index 000000000..926fd5a18 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/DocRefund/Reference.php @@ -0,0 +1,51 @@ + + */ +class Reference extends LoadParamsFromArray +{ + const TYPE_DATA_SOURCE = "DIS"; + const TYPE_FZ_REVENUE_ATTRIBUTION_NUMBER = "FZR"; + const TYPE_INVOICE_NUMBER = "INV"; + const TYPE_TKT_INDICATOR = "TKT"; + + /** + * self::TYPE_* + * + * @var string + */ + public $type; + + /** + * @var string + */ + public $value; +} diff --git a/src/Amadeus/Client/RequestOptions/DocRefund/RefundItinOpt.php b/src/Amadeus/Client/RequestOptions/DocRefund/RefundItinOpt.php new file mode 100644 index 000000000..b379f475b --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/DocRefund/RefundItinOpt.php @@ -0,0 +1,51 @@ + + */ +class RefundItinOpt extends LoadParamsFromArray +{ + /** + * Airline code + * + * @var string + */ + public $company; + + /** + * @var string + */ + public $origin; + + /** + * @var string + */ + public $destination; +} diff --git a/src/Amadeus/Client/RequestOptions/DocRefund/TaxData.php b/src/Amadeus/Client/RequestOptions/DocRefund/TaxData.php new file mode 100644 index 000000000..bae04ff67 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/DocRefund/TaxData.php @@ -0,0 +1,87 @@ + + */ +class TaxData extends LoadParamsFromArray +{ + const CATEGORY_ADDITIONAL_COLLECTION = "700"; + const CATEGORY_PAID = "701"; + const CATEGORY_CURRENT = "702"; + const CATEGORY_TOTAL_AMOUNT_OF_ALL_PASSENGER_FACILITY_CHARGES = "703"; + const CATEGORY_TOTAL_TAXES = "704"; + const CATEGORY_INCLUDE_DEPARTURE_TAXES_ONLY = "D"; + const CATEGORY_TAX_EXEMPT = "E"; + const CATEGORY_TAXES_INCLUDED = "I"; + const CATEGORY_TAXES_NOT_APPLICABLE = "N"; + const CATEGORY_EXEMPT_SECURITY_SURCHARGE = "Q"; + const CATEGORY_DOMESTIC_TAX_NOT_APPLICABLE = "T"; + + const TYPE_EXTENDED_TAXES = "XT"; + + /** + * Tax Category + * + * self::CATEGORY_* + * + * @var string + */ + public $category; + + /** + * Tax rate + * + * @var float + */ + public $rate; + + /** + * 2-character ISO country code + * + * @var string + */ + public $countryCode; + + /** + * 3-character ISO currency string + * + * @var string + */ + public $currencyCode; + + /** + * Tax Type + * + * self::TYPE_* + * + * @var string + */ + public $type; +} diff --git a/src/Amadeus/Client/RequestOptions/DocRefund/TickGroupOpt.php b/src/Amadeus/Client/RequestOptions/DocRefund/TickGroupOpt.php new file mode 100644 index 000000000..4d1a0a432 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/DocRefund/TickGroupOpt.php @@ -0,0 +1,74 @@ + + */ +class TickGroupOpt extends LoadParamsFromArray +{ + const COUPON_1 = 1; + const COUPON_2 = 2; + const COUPON_3 = 3; + const COUPON_4 = 4; + + const STATUS_CONFIRMED = "OK"; + const STATUS_OPEN = "OPE"; + const STATUS_REFUNDED = "RF"; + const STATUS_TICKETED = "T"; + const STATUS_VOID = "V"; + + /** + * self::COUPON_* + * + * @var string|int + */ + public $couponNumber; + + /** + * self::STATUS_* + * + * @var string + */ + public $couponStatus; + + /** + * @var string + */ + public $boardingPriority; + + /** + * @var string + */ + public $actionRequestCode; + + /** + * @var string[] + */ + public $references = []; +} diff --git a/src/Amadeus/Client/RequestOptions/DocRefund/TickGroupRef.php b/src/Amadeus/Client/RequestOptions/DocRefund/TickGroupRef.php new file mode 100644 index 000000000..04677f93c --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/DocRefund/TickGroupRef.php @@ -0,0 +1,35 @@ + + */ +class TickGroupRef extends LoadParamsFromArray +{ +} diff --git a/src/Amadeus/Client/RequestOptions/DocRefund/Ticket.php b/src/Amadeus/Client/RequestOptions/DocRefund/Ticket.php new file mode 100644 index 000000000..68ce2ee34 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/DocRefund/Ticket.php @@ -0,0 +1,62 @@ + + */ +class Ticket extends LoadParamsFromArray +{ + const TYPE_ALL_OTHER_DOCUMENT_TYPES = "700"; + const TYPE_EXCESS_BAGGAGE = "E"; + const TYPE_MISCELLANEOUS_CHARGE_ORDER = "M"; + const TYPE_TOUR_ORDER = "O"; + const TYPE_SPECIAL_SERVICE_TICKET = "S"; + const TYPE_TICKET = "T"; + + /** + * Ticket number + * + * @var string + */ + public $number; + + /** + * Ticket type + * + * self::TYPE_* + * + * @var string + */ + public $type; + + /** + * @var TickGroupOpt + */ + public $ticketGroup = []; +} diff --git a/src/Amadeus/Client/RequestOptions/DocRefundUpdateRefundOptions.php b/src/Amadeus/Client/RequestOptions/DocRefundUpdateRefundOptions.php new file mode 100644 index 000000000..7e8de2667 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/DocRefundUpdateRefundOptions.php @@ -0,0 +1,171 @@ + + */ +class DocRefundUpdateRefundOptions extends Base +{ + const PRICING_IND_DOMESTIC_ITINERARY = "D"; + const PRICING_IND_INTERNATIONAL_ITINERARY = "I"; + + /** + * @var string + */ + public $originator; + + /** + * @var string + */ + public $originatorId; + + /** + * @var string + */ + public $ticketNumber; + + /** + * @var string + */ + public $ticketType; + + /** + * @var \DateTime + */ + public $ticketedDate; + + /** + * @var \DateTime + */ + public $refundDate; + + /** + * @var DocRefund\Reference[] + */ + public $references = []; + + /** + * @var string + */ + public $passengerSurName; + + /** + * @var DocRefund\Ticket[] + */ + public $tickets = []; + + /** + * Traveller Priority Company + * + * @var string + */ + public $travellerPrioCompany; + + /** + * Traveller Priority Date of Joining + * + * @var \DateTime + */ + public $travellerPrioDateOfJoining; + + /** + * Traveller Priority: Traveller Reference + * + * @var string + */ + public $travellerPrioReference; + + /** + * Monetary information + * + * @var DocRefund\MonetaryData[] + */ + public $monetaryData = []; + + /** + * @var DocRefund\TaxData[] + */ + public $taxData = []; + + /** + * Pricing Ticket Indicator + * + * self::PRICING_IND_* + * + * @var string + */ + public $pricingTicketIndicator; + + /** + * Commissions + * + * @var DocRefund\CommissionOpt[] + */ + public $commission = []; + + /** + * Tour Code + * + * @var string + */ + public $tourCode; + + /** + * Interactive Free Text + * + * @var DocRefund\FreeTextOpt[] + */ + public $freeText = []; + + /** + * Form of payment information + * + * @var DocRefund\FopOpt[] + */ + public $formOfPayment = []; + + /** + * Refunded itinerary information + * + * @var DocRefund\RefundItinOpt[] + */ + public $refundedItinerary = []; + + /** + * Refunded route stations + * + * @var string[] + */ + public $refundedRouteStations = []; + + /** + * Billing Address + * + * @var DocRefund\AddressOpt + */ + public $address; +} diff --git a/src/Amadeus/Client/ResponseHandler/DocRefund/HandlerUpdateRefund.php b/src/Amadeus/Client/ResponseHandler/DocRefund/HandlerUpdateRefund.php new file mode 100644 index 000000000..33aabe7e3 --- /dev/null +++ b/src/Amadeus/Client/ResponseHandler/DocRefund/HandlerUpdateRefund.php @@ -0,0 +1,50 @@ + + */ +class HandlerUpdateRefund extends StandardResponseHandler +{ + /** + * @param SendResult $response + * @return Result + */ + public function analyze(SendResult $response) + { + return $this->analyzeWithErrCodeCategoryMsgQuery( + $response, + '//m:applicationErrorValue/m:dataValue', + '//m:applicationErrorGroup//m:freeTextDetails/m:informationType', + '//m:applicationErrorGroup/m:errorText/m:freeText' + ); + } +} diff --git a/src/Amadeus/Client/ResponseHandler/StandardResponseHandler.php b/src/Amadeus/Client/ResponseHandler/StandardResponseHandler.php index 9152ea4bf..e03b8d598 100644 --- a/src/Amadeus/Client/ResponseHandler/StandardResponseHandler.php +++ b/src/Amadeus/Client/ResponseHandler/StandardResponseHandler.php @@ -252,9 +252,11 @@ protected function makeStatusFromErrorQualifier($qualifier, $defaultStatus = Res 'WA' => Result::STATUS_WARN, //Info line Warning - PNR_AddMultiElements 'W' => Result::STATUS_WARN, 'EC' => Result::STATUS_ERROR, + 'ERR' => Result::STATUS_ERROR, //DocRefund_UpdateRefund 'X' => Result::STATUS_ERROR, '001' => Result::STATUS_ERROR, //Air_MultiAvailability 'O' => Result::STATUS_OK, + 'STA' => Result::STATUS_OK, 'ZZZ' => Result::STATUS_UNKNOWN ]; diff --git a/src/Amadeus/Client/Struct/DocRefund/DocumentDetails.php b/src/Amadeus/Client/Struct/DocRefund/DocumentDetails.php index 0ed818953..dd2e1afad 100644 --- a/src/Amadeus/Client/Struct/DocRefund/DocumentDetails.php +++ b/src/Amadeus/Client/Struct/DocRefund/DocumentDetails.php @@ -30,18 +30,32 @@ */ class DocumentDetails { + const TYPE_ALL_OTHER_DOCUMENT_TYPES = "700"; + const TYPE_EXCESS_BAGGAGE = "E"; + const TYPE_MISCELLANEOUS_CHARGE_ORDER = "M"; + const TYPE_TOUR_ORDER = "O"; + const TYPE_SPECIAL_SERVICE_TICKET = "S"; + const TYPE_TICKET = "T"; + /** * @var string */ public $number; + /** + * @var string + */ + public $type; + /** * DocumentDetails constructor. * * @param string $number + * @param string|null $type */ - public function __construct($number) + public function __construct($number, $type = null) { $this->number = $number; + $this->type = $type; } } diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund.php new file mode 100644 index 000000000..3ff863047 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund.php @@ -0,0 +1,354 @@ + + */ +class UpdateRefund extends BaseWsMessage +{ + /** + * @var UpdateRefund\UserIdentification + */ + public $userIdentification; + + /** + * @var UpdateRefund\TicketNumber + */ + public $ticketNumber; + + /** + * @var UpdateRefund\DateTimeInformation[] + */ + public $dateTimeInformation = []; + + /** + * @var UpdateRefund\ReferenceInformation + */ + public $referenceInformation; + + /** + * @var UpdateRefund\TravellerInformation + */ + public $travellerInformation; + + /** + * @var UpdateRefund\Ticket[] + */ + public $ticket = []; + + /** + * @var UpdateRefund\TravellerPriorityInfo + */ + public $travellerPriorityInfo; + + /** + * @var UpdateRefund\MonetaryInformation + */ + public $monetaryInformation; + + /** + * @var UpdateRefund\PricingDetails + */ + public $pricingDetails; + + /** + * @var UpdateRefund\Commission + */ + public $commission; + + /** + * @var UpdateRefund\TaxDetailsInformation[] + */ + public $taxDetailsInformation = []; + + /** + * @var UpdateRefund\TourInformation + */ + public $tourInformation; + + /** + * @var UpdateRefund\InteractiveFreeText[] + */ + public $interactiveFreeText = []; + + /** + * @var UpdateRefund\FopGroup[] + */ + public $fopGroup = []; + + /** + * @var UpdateRefund\TransactionContext + */ + public $transactionContext; + + /** + * @var UpdateRefund\FirstAndLastSegmentDates + */ + public $firstAndLastSegmentDates; + + /** + * @var UpdateRefund\OriginAndDestination + */ + public $originAndDestination; + + /** + * @var UpdateRefund\RefundedItinerary[] + */ + public $refundedItinerary = []; + + /** + * @var UpdateRefund\RefundedRoute + */ + public $refundedRoute; + + /** + * @var UpdateRefund\StructuredAddress + */ + public $structuredAddress; + + /** + * @var UpdateRefund\FeeGroup + */ + public $feeGroup; + + /** + * UpdateRefund constructor. + * + * @param DocRefundUpdateRefundOptions $options + */ + public function __construct(DocRefundUpdateRefundOptions $options) + { + if ($this->checkAnyNotEmpty($options->originator, $options->originatorId)) { + $this->userIdentification = new UserIdentification( + $options->originatorId, + $options->originator + ); + } + + if ($this->checkAnyNotEmpty($options->ticketNumber, $options->ticketType)) { + $this->ticketNumber = new TicketNumber($options->ticketNumber, $options->ticketType); + } + + $this->loadDateTimeInfo($options->refundDate, $options->ticketedDate); + + $this->loadReferences($options->references); + + if (!empty($options->passengerSurName)) { + $this->travellerInformation = new TravellerInformation($options->passengerSurName); + } + + $this->loadTickets($options->tickets); + + $this->loadPassengerPriority($options); + + $this->loadMonetaryInfo($options->monetaryData, $options->taxData); + + if (!empty($options->pricingTicketIndicator)) { + $this->pricingDetails = new PricingDetails($options->pricingTicketIndicator); + } + + $this->loadCommissions($options->commission); + + if (!empty($options->tourCode)) { + $this->tourInformation = new TourInformation($options->tourCode); + } + + $this->loadFreeText($options->freeText); + + $this->loadFop($options->formOfPayment); + + $this->loadRefundedItinerary($options->refundedItinerary); + + $this->loadRefundedRoute($options->refundedRouteStations); + + $this->loadAddress($options->address); + } + + /** + * @param \DateTime|null $refundDate + * @param \DateTime|null $ticketedDate + */ + protected function loadDateTimeInfo($refundDate, $ticketedDate) + { + if ($refundDate instanceof \DateTime) { + $this->dateTimeInformation[] = new DateTimeInformation( + DateTimeInformation::OPT_DATE_OF_REFUND, + $refundDate + ); + } + + if ($ticketedDate instanceof \DateTime) { + $this->dateTimeInformation[] = new DateTimeInformation( + DateTimeInformation::OPT_DATE_TICKETED, + $ticketedDate + ); + } + } + + /** + * @param Reference[] $references + */ + protected function loadReferences($references) + { + if (!empty($references)) { + $this->referenceInformation = new ReferenceInformation($references); + } + } + + /** + * @param TicketOpt[] $tickets + */ + protected function loadTickets($tickets) + { + foreach ($tickets as $ticket) { + $this->ticket[] = new Ticket($ticket); + } + } + + /** + * @param DocRefundUpdateRefundOptions $options + */ + protected function loadPassengerPriority($options) + { + if ($this->checkAnyNotEmpty( + $options->travellerPrioCompany, + $options->travellerPrioDateOfJoining, + $options->travellerPrioReference + ) + ) { + $this->travellerPriorityInfo = new TravellerPriorityInfo( + $options->travellerPrioCompany, + $options->travellerPrioDateOfJoining, + $options->travellerPrioReference + ); + } + } + + /** + * @param MonetaryData[] $monetaryData + * @param TaxData[] $taxData + */ + protected function loadMonetaryInfo($monetaryData, $taxData) + { + if (!empty($monetaryData)) { + $this->monetaryInformation = new MonetaryInformation($monetaryData); + } + + foreach ($taxData as $tax) { + $this->taxDetailsInformation[] = new TaxDetailsInformation($tax); + } + } + + /** + * @param CommissionOpt[] $commission + */ + protected function loadCommissions($commission) + { + if (!empty($commission)) { + $this->commission = new Commission($commission); + } + } + + /** + * @param FreeTextOpt[] $freeText + */ + protected function loadFreeText($freeText) + { + foreach ($freeText as $opt) { + $this->interactiveFreeText[] = new InteractiveFreeText($opt); + } + } + + /** + * @param FopOpt[] $formOfPayment + */ + protected function loadFop($formOfPayment) + { + foreach ($formOfPayment as $fop) { + $this->fopGroup[] = new FopGroup($fop); + } + } + + /** + * @param RefundItinOpt[] $refundedItinerary + */ + protected function loadRefundedItinerary($refundedItinerary) + { + foreach ($refundedItinerary as $itin) { + $this->refundedItinerary[] = new RefundedItinerary($itin); + } + } + + /** + * @param string[] $refundedRouteStations + */ + protected function loadRefundedRoute($refundedRouteStations) + { + if (!empty($refundedRouteStations)) { + $this->refundedRoute = new RefundedRoute($refundedRouteStations); + } + } + + /** + * @param AddressOpt|null $address + */ + protected function loadAddress($address) + { + if ($address instanceof AddressOpt) { + $this->structuredAddress = new StructuredAddress($address); + } + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/Address.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/Address.php new file mode 100644 index 000000000..6b3264738 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/Address.php @@ -0,0 +1,66 @@ + + */ +class Address +{ + const OPTION_CITY = "CI"; + const OPTION_COUNTRY = "CO"; + const OPTION_COMPANY = "CY"; + const OPTION_ADDRESS_LINE_1 = "L1"; + const OPTION_ADDRESS_LINE_2 = "L2"; + const OPTION_NAME = "NA"; + const OPTION_PO_BOX = "PO"; + const OPTION_STATE = "ST"; + const OPTION_POSTAL_CODE = "ZP"; + + /** + * self::OPTION_* + * + * @var string + */ + public $option; + + /** + * @var string + */ + public $optionText; + + /** + * Address constructor. + * + * @param string $option self::OPTION_* + * @param string $optionText + */ + public function __construct($option, $optionText) + { + $this->option = $option; + $this->optionText = $optionText; + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/AirlineCodeRfndItinerary.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/AirlineCodeRfndItinerary.php new file mode 100644 index 000000000..b11084363 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/AirlineCodeRfndItinerary.php @@ -0,0 +1,48 @@ + + */ +class AirlineCodeRfndItinerary +{ + /** + * @var CompanyIdentification + */ + public $companyIdentification; + + + /** + * AirlineCodeRfndItinerary constructor. + * + * @param string $operatingCompany + */ + public function __construct($operatingCompany) + { + $this->companyIdentification = new CompanyIdentification($operatingCompany); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/BoardingPriority.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/BoardingPriority.php new file mode 100644 index 000000000..930b5cc32 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/BoardingPriority.php @@ -0,0 +1,47 @@ + + */ +class BoardingPriority +{ + /** + * @var PriorityDetails + */ + public $priorityDetails; + + /** + * BoardingPriority constructor. + * + * @param string $boardingPriority + */ + public function __construct($boardingPriority) + { + $this->priorityDetails = new PriorityDetails($boardingPriority); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/Commission.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/Commission.php new file mode 100644 index 000000000..6dec87547 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/Commission.php @@ -0,0 +1,60 @@ + + */ +class Commission +{ + /** + * @var CommissionDetails + */ + public $commissionDetails; + + /** + * @var CommissionDetails[] + */ + public $otherCommissionDetails = []; + + /** + * Commission constructor. + * + * @param CommissionOpt[] $commissions + */ + public function __construct($commissions) + { + foreach ($commissions as $key => $commission) { + if ($key === 0) { + $this->commissionDetails = new CommissionDetails($commission); + } else { + $this->otherCommissionDetails[] = new CommissionDetails($commission); + } + } + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/CommissionDetails.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/CommissionDetails.php new file mode 100644 index 000000000..408c6a691 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/CommissionDetails.php @@ -0,0 +1,77 @@ + + */ +class CommissionDetails +{ + const TYPE_CANCELLATION_PENALTY = "CP"; + const TYPE_CANCELLATION_PENALTY_IN_MILES = "CPM"; + const TYPE_AIRLINE_COMMISSION_A = "FMA"; + const TYPE_AIRLINE_COMMISSION_B = "FMB"; + const TYPE_NEW_COMMISSION = "NEW"; + const TYPE_OLD_COMMISSION = "OLD"; + const TYPE_COMMISSION_ON_CANCELLATION_PENALTY = "XLP"; + + /** + * self::TYPE_* + * + * @var string + */ + public $type; + + /** + * @var int|float + */ + public $amount; + + /** + * @var string + */ + public $freeText; + + /** + * @var int|float + */ + public $rate; + + /** + * CommissionDetails constructor. + * + * @param CommissionOpt $opt + */ + public function __construct(CommissionOpt $opt) + { + $this->type = $opt->type; + $this->amount = $opt->amount; + $this->rate = $opt->rate; + $this->freeText = $opt->freeText; + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/CompanyIdentification.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/CompanyIdentification.php new file mode 100644 index 000000000..b9f3673b6 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/CompanyIdentification.php @@ -0,0 +1,47 @@ + + */ +class CompanyIdentification +{ + /** + * @var string + */ + public $operatingCompany; + + /** + * CompanyIdentification constructor. + * + * @param string $operatingCompany + */ + public function __construct($operatingCompany) + { + $this->operatingCompany = $operatingCompany; + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/CouponDetails.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/CouponDetails.php new file mode 100644 index 000000000..d817288ab --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/CouponDetails.php @@ -0,0 +1,69 @@ + + */ +class CouponDetails extends RepriceCouponDetails +{ + const COUPON_1 = 1; + const COUPON_2 = 2; + const COUPON_3 = 3; + const COUPON_4 = 4; + + const STATUS_CONFIRMED = "OK"; + const STATUS_OPEN = "OPE"; + const STATUS_REFUNDED = "RF"; + const STATUS_TICKETED = "T"; + const STATUS_VOID = "V"; + + /** + * self::STATUS_* + * + * @var string + */ + public $cpnStatus; + + /** + * @var string + */ + public $settlementAuthorization; + + /** + * CouponDetails constructor. + * + * @param int|string|null $cpnNumber self::COUPON_* + * @param string|null $cpnStatus self::STATUS_* + */ + public function __construct($cpnNumber = null, $cpnStatus = null) + { + $this->cpnStatus = $cpnStatus; + parent::__construct($cpnNumber); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/CouponInformationDetails.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/CouponInformationDetails.php new file mode 100644 index 000000000..09943f980 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/CouponInformationDetails.php @@ -0,0 +1,48 @@ + + */ +class CouponInformationDetails +{ + /** + * @var CouponDetails + */ + public $couponDetails; + + /** + * CouponInformationDetails constructor. + * + * @param int|string|null $number + * @param string|null $status + */ + public function __construct($number, $status) + { + $this->couponDetails = new CouponDetails($number, $status); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/DateTimeInformation.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/DateTimeInformation.php new file mode 100644 index 000000000..f491c2701 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/DateTimeInformation.php @@ -0,0 +1,61 @@ + + */ +class DateTimeInformation +{ + const OPT_DATE_TICKETED = "710"; + const OPT_DATE_OF_REFUND = "DR"; + + /** + * self::OPT_* + * + * @var string + */ + public $businessSemantic; + + /** + * @var DateTime + */ + public $dateTime; + + /** + * DateTimeInformation constructor. + * + * @param string $option self::OPT_* + * @param \DateTime $date + */ + public function __construct($option, $date) + { + $this->businessSemantic = $option; + $this->dateTime = new DateTime($date); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FeeGroup.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FeeGroup.php new file mode 100644 index 000000000..4d1fd6c5a --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FeeGroup.php @@ -0,0 +1,33 @@ + + */ +class FeeGroup +{ +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FirstAndLastSegmentDates.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FirstAndLastSegmentDates.php new file mode 100644 index 000000000..2024a10ea --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FirstAndLastSegmentDates.php @@ -0,0 +1,33 @@ + + */ +class FirstAndLastSegmentDates +{ +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FopGroup.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FopGroup.php new file mode 100644 index 000000000..0348d61f6 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FopGroup.php @@ -0,0 +1,63 @@ + + */ +class FopGroup +{ + /** + * @var FormOfPaymentInformation + */ + public $formOfPaymentInformation; + + /** + * @var InteractiveFreeText[] + */ + public $interactiveFreeText = []; + + /** + * FopGroup constructor. + * + * @param FopOpt $opt + */ + public function __construct(FopOpt $opt) + { + $this->formOfPaymentInformation = new FormOfPaymentInformation( + $opt->fopType, + $opt->fopAmount, + $opt->fopSourceOfApproval, + $opt->fopAuthorizedAmount + ); + + foreach ($opt->freeText as $freeTextOpt) { + $this->interactiveFreeText[] = new InteractiveFreeText($freeTextOpt); + } + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FormOfPayment.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FormOfPayment.php new file mode 100644 index 000000000..262d147e9 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FormOfPayment.php @@ -0,0 +1,85 @@ + + */ +class FormOfPayment +{ + 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"; + + const SOURCE_IRU = "MIL"; + + /** + * self::TYPE_* + * + * @var string + */ + public $type; + + /** + * @var int|float + */ + public $amount; + + /** + * self::SOURCE_* + * + * @var string + */ + public $sourceOfApproval; + + /** + * @var int|float + */ + public $authorisedAmount; + + /** + * FormOfPayment constructor. + * + * @param string $type + * @param int|float $amount + * @param string $sourceOfApproval + * @param int|float $authorisedAmount + */ + public function __construct($type, $amount, $sourceOfApproval, $authorisedAmount) + { + $this->type = $type; + $this->amount = $amount; + $this->sourceOfApproval = $sourceOfApproval; + $this->authorisedAmount = $authorisedAmount; + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FormOfPaymentInformation.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FormOfPaymentInformation.php new file mode 100644 index 000000000..f36351544 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FormOfPaymentInformation.php @@ -0,0 +1,50 @@ + + */ +class FormOfPaymentInformation +{ + /** + * @var FormOfPayment + */ + public $formOfPayment; + + /** + * FormOfPaymentInformation constructor. + * + * @param $type + * @param $amount + * @param $source + * @param $authorizedAmount + */ + public function __construct($type, $amount, $source, $authorizedAmount) + { + $this->formOfPayment = new FormOfPayment($type, $amount, $source, $authorizedAmount); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FreeTextQualification.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FreeTextQualification.php new file mode 100644 index 000000000..b14b37af8 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/FreeTextQualification.php @@ -0,0 +1,64 @@ + + */ +class FreeTextQualification +{ + const QUAL_CODED_AND_LITERAL_TEXT = 4; + + const TYPE_ORIGINAL_ISSUE_INFORMATION = "45"; + const TYPE_REMARK = "REM"; + const TYPE_WAIVER_CODE = "WAV"; + + /** + * self::QUAL_* + * + * @var string|int + */ + public $textSubjectQualifier; + + /** + * self::TYPE_* + * + * @var string + */ + public $informationType; + + /** + * FreeTextQualification constructor. + * + * @param string $informationType + * @param int|string $textSubjectQualifier + */ + public function __construct($informationType, $textSubjectQualifier) + { + $this->textSubjectQualifier = $textSubjectQualifier; + $this->informationType = $informationType; + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/InteractiveFreeText.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/InteractiveFreeText.php new file mode 100644 index 000000000..80fff7a07 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/InteractiveFreeText.php @@ -0,0 +1,59 @@ + + */ +class InteractiveFreeText +{ + /** + * @var FreeTextQualification + */ + public $freeTextQualification; + + /** + * @var string + */ + public $freeText; + + /** + * InteractiveFreeText constructor. + * + * @param FreeTextOpt $opt + */ + public function __construct(FreeTextOpt $opt) + { + $this->freeTextQualification = new FreeTextQualification( + $opt->type, + FreeTextQualification::QUAL_CODED_AND_LITERAL_TEXT + ); + + $this->freeText = $opt->freeText; + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/MonetaryDetails.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/MonetaryDetails.php new file mode 100644 index 000000000..d2f1a9378 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/MonetaryDetails.php @@ -0,0 +1,73 @@ + + */ +class MonetaryDetails extends FopMonetaryDetails +{ + const TYPE_AMOUNT_ENTERED_BY_AGENT = "AEA"; + const TYPE_BASE_FARE = "B"; + const TYPE_CANCELLATION_PENALTY = "CP"; + const TYPE_CURENCY_CONVERSION_AMOUNT = "CUR"; + const TYPE_DISCOUNT_AMOUNT_STORED_IN_REFUND_PANEL = "DA"; + const TYPE_DISCOUNT_AMOUNT_COMPUTED_BY_ATC_REFUND = "DAA"; + const TYPE_FARE_REFUND = "FRF"; + const TYPE_GST_TAX_AMOUNT = "GST"; + const TYPE_FARE_PAID_IN_MILES = "MFP"; + const TYPE_FARE_REFUND_IN_MILES = "MFR"; + const TYPE_FARE_USED_IN_MILES = "MFU"; + const TYPE_REFUND_TOTAL_IN_MILES = "MRT"; + const TYPE_NET_FARE_PAID = "NFP"; + const TYPE_NET_FARE_REFUND = "NFR"; + const TYPE_NET_FARE_USED = "NFU"; + const TYPE_NET_REMIT_TOTAL_AMOUNT = "NR"; + const TYPE_NO_SHOW_FEE = "NSF"; + const TYPE_PUBLISHED_FARE_PAID = "PFP"; + const TYPE_PUBLISHED_FARE_REFUND = "PFR"; + const TYPE_PUBLISHED_FARE_USED = "PFU"; + const TYPE_REFUND_TOTAL = "RFT"; + const TYPE_FARE_USED = "RFU"; + const TYPE_MISCELLANEOUS_FEE = "RMF"; + const TYPE_SELLING_FARE_PAID = "SFP"; + const TYPE_SELLING_FARE_REFUND = "SFR"; + const TYPE_SELLING_FARE_USED = "SFU"; + const TYPE_TOTAL_TAXES = "TXT"; + + /** + * MonetaryDetails constructor. + * + * @param MonetaryData $data + */ + public function __construct(MonetaryData $data) + { + parent::__construct($data->amount, $data->currency, $data->type); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/MonetaryInformation.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/MonetaryInformation.php new file mode 100644 index 000000000..aa0baf290 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/MonetaryInformation.php @@ -0,0 +1,60 @@ + + */ +class MonetaryInformation +{ + /** + * @var MonetaryDetails + */ + public $monetaryDetails; + + /** + * @var MonetaryDetails[] + */ + public $otherMonetaryDetails = []; + + /** + * MonetaryInformation constructor. + * + * @param MonetaryData[] $data + */ + public function __construct($data) + { + foreach ($data as $key => $single) { + if ($key === 0) { + $this->monetaryDetails = new MonetaryDetails($single); + } else { + $this->otherMonetaryDetails[] = new MonetaryDetails($single); + } + } + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/OriginAndDestination.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/OriginAndDestination.php new file mode 100644 index 000000000..fbbaefc6d --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/OriginAndDestination.php @@ -0,0 +1,33 @@ + + */ +class OriginAndDestination +{ +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/OriginDestinationRfndItinerary.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/OriginDestinationRfndItinerary.php new file mode 100644 index 000000000..7966eff4c --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/OriginDestinationRfndItinerary.php @@ -0,0 +1,35 @@ + + */ +class OriginDestinationRfndItinerary extends OriginDestination +{ +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/PriceTicketDetails.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/PriceTicketDetails.php new file mode 100644 index 000000000..8120a8104 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/PriceTicketDetails.php @@ -0,0 +1,52 @@ + + */ +class PriceTicketDetails +{ + const INDICATOR_DOMESTIC_ITINERARY = "D"; + const INDICATOR_INTERNATIONAL_ITINERARY = "I"; + + /** + * self::INDICATOR_* + * + * @var string + */ + public $indicators; + + /** + * PriceTicketDetails constructor. + * + * @param string $indicators + */ + public function __construct($indicators) + { + $this->indicators = $indicators; + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/PricingDetails.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/PricingDetails.php new file mode 100644 index 000000000..ca1e3c681 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/PricingDetails.php @@ -0,0 +1,52 @@ + + */ +class PricingDetails +{ + /** + * @var PriceTicketDetails + */ + public $priceTicketDetails; + + /** + * @var string + */ + public $priceTariffType; + + /** + * PricingDetails constructor. + * + * @param string $indicator + */ + public function __construct($indicator) + { + $this->priceTicketDetails = new PriceTicketDetails($indicator); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/PriorityDetails.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/PriorityDetails.php new file mode 100644 index 000000000..8ff9a1f06 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/PriorityDetails.php @@ -0,0 +1,47 @@ + + */ +class PriorityDetails +{ + /** + * @var string + */ + public $description; + + /** + * PriorityDetails constructor. + * + * @param string $description + */ + public function __construct($description) + { + $this->description = $description; + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/ReferenceDetails.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/ReferenceDetails.php new file mode 100644 index 000000000..25cc46099 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/ReferenceDetails.php @@ -0,0 +1,63 @@ + + */ +class ReferenceDetails +{ + const TYPE_DATA_SOURCE = "DIS"; + const TYPE_FZ_REVENUE_ATTRIBUTION_NUMBER = "FZR"; + const TYPE_INVOICE_NUMBER = "INV"; + const TYPE_TKT_INDICATOR = "TKT"; + + const TYPE_VALIDATION_CERTIFICATE_USED_FOR_STAFF = "VAC"; + + /** + * self::TYPE_* + * + * @var string + */ + public $type; + + /** + * @var string + */ + public $value; + + /** + * ReferenceDetails constructor. + * + * @param string $value + * @param string $type self::TYPE_* + */ + public function __construct($value, $type) + { + $this->type = $type; + $this->value = $value; + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/ReferenceInformation.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/ReferenceInformation.php new file mode 100644 index 000000000..9f8f9fd60 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/ReferenceInformation.php @@ -0,0 +1,56 @@ + + */ +class ReferenceInformation +{ + /** + * @var ReferenceDetails[] + */ + public $referenceDetails = []; + + /** + * ReferenceInformation constructor. + * + * @param Reference[]|string[] $references + * @param string|null $type Optional reference type if providing array of strings + */ + public function __construct($references, $type = null) + { + foreach ($references as $reference) { + if ($reference instanceof Reference) { + $this->referenceDetails[] = new ReferenceDetails($reference->value, $reference->type); + } else { + $this->referenceDetails[] = new ReferenceDetails($reference, $type); + } + } + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/RefundedItinerary.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/RefundedItinerary.php new file mode 100644 index 000000000..82912b919 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/RefundedItinerary.php @@ -0,0 +1,59 @@ + + */ +class RefundedItinerary +{ + /** + * @var AirlineCodeRfndItinerary + */ + public $airlineCodeRfndItinerary; + + /** + * @var OriginDestinationRfndItinerary + */ + public $originDestinationRfndItinerary; + + /** + * RefundedItinerary constructor. + * + * @param RefundItinOpt $opt + */ + public function __construct(RefundItinOpt $opt) + { + $this->airlineCodeRfndItinerary = new AirlineCodeRfndItinerary($opt->company); + + $this->originDestinationRfndItinerary = new OriginDestinationRfndItinerary( + $opt->origin, + $opt->destination + ); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/RefundedRoute.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/RefundedRoute.php new file mode 100644 index 000000000..ea86ff018 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/RefundedRoute.php @@ -0,0 +1,49 @@ + + */ +class RefundedRoute +{ + /** + * @var RoutingDetails[] + */ + public $routingDetails = []; + + /** + * RefundedRoute constructor. + * + * @param string[] $stations + */ + public function __construct($stations) + { + foreach ($stations as $station) { + $this->routingDetails[] = new RoutingDetails($station); + } + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/RoutingDetails.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/RoutingDetails.php new file mode 100644 index 000000000..20142fad2 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/RoutingDetails.php @@ -0,0 +1,47 @@ + + */ +class RoutingDetails +{ + /** + * @var string + */ + public $station; + + /** + * RoutingDetails constructor. + * + * @param string $station + */ + public function __construct($station) + { + $this->station = $station; + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/StructuredAddress.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/StructuredAddress.php new file mode 100644 index 000000000..787979da7 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/StructuredAddress.php @@ -0,0 +1,121 @@ + + */ +class StructuredAddress +{ + const TYPE_BILLING_ADDRESS = "AB"; + + /** + * self::TYPE_* + * + * @var string + */ + public $informationType; + + /** + * @var Address[] + */ + public $address = []; + + /** + * StructuredAddress constructor. + * + * @param AddressOpt $opt + */ + public function __construct(AddressOpt $opt) + { + $this->informationType = $opt->type; + + $this->loadAddress($opt); + } + + /** + * @param AddressOpt $opt + */ + protected function loadAddress($opt) + { + if (!empty($opt->company)) { + $this->address[] = new Address( + Address::OPTION_COMPANY, + $opt->company + ); + } + if (!empty($opt->name)) { + $this->address[] = new Address( + Address::OPTION_NAME, + $opt->name + ); + } + if (!empty($opt->addressLine1)) { + $this->address[] = new Address( + Address::OPTION_ADDRESS_LINE_1, + $opt->addressLine1 + ); + } + if (!empty($opt->addressLine2)) { + $this->address[] = new Address( + Address::OPTION_ADDRESS_LINE_2, + $opt->addressLine2 + ); + } + if (!empty($opt->city)) { + $this->address[] = new Address( + Address::OPTION_CITY, + $opt->city + ); + } + if (!empty($opt->country)) { + $this->address[] = new Address( + Address::OPTION_COUNTRY, + $opt->country + ); + } + if (!empty($opt->poBox)) { + $this->address[] = new Address( + Address::OPTION_PO_BOX, + $opt->poBox + ); + } + if (!empty($opt->postalCode)) { + $this->address[] = new Address( + Address::OPTION_POSTAL_CODE, + $opt->postalCode + ); + } + if (!empty($opt->state)) { + $this->address[] = new Address( + Address::OPTION_STATE, + $opt->state + ); + } + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TaxDetails.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TaxDetails.php new file mode 100644 index 000000000..b262dcc4f --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TaxDetails.php @@ -0,0 +1,72 @@ + + */ +class TaxDetails +{ + const TYPE_EXTENDED_TAXES = "XT"; + + /** + * @var string + */ + public $rate; + + /** + * @var string + */ + public $countryCode; + + /** + * @var string + */ + public $currencyCode; + + /** + * self::TYPE_* + * + * @var string + */ + public $type; + + /** + * TaxDetails constructor. + * + * @param string $rate + * @param string $countryCode + * @param string $currencyCode + * @param string $type + */ + public function __construct($rate, $countryCode, $currencyCode, $type) + { + $this->rate = $rate; + $this->countryCode = $countryCode; + $this->currencyCode = $currencyCode; + $this->type = $type; + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TaxDetailsInformation.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TaxDetailsInformation.php new file mode 100644 index 000000000..b87d9eef0 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TaxDetailsInformation.php @@ -0,0 +1,75 @@ + + */ +class TaxDetailsInformation +{ + const CATEGORY_ADDITIONAL_COLLECTION = "700"; + const CATEGORY_PAID = "701"; + const CATEGORY_CURRENT = "702"; + const CATEGORY_TOTAL_AMOUNT_OF_ALL_PASSENGER_FACILITY_CHARGES = "703"; + const CATEGORY_TOTAL_TAXES = "704"; + const CATEGORY_INCLUDE_DEPARTURE_TAXES_ONLY = "D"; + const CATEGORY_TAX_EXEMPT = "E"; + const CATEGORY_TAXES_INCLUDED = "I"; + const CATEGORY_TAXES_NOT_APPLICABLE = "N"; + const CATEGORY_EXEMPT_SECURITY_SURCHARGE = "Q"; + const CATEGORY_DOMESTIC_TAX_NOT_APPLICABLE = "T"; + + /** + * self::CATEGORY_* + * + * @var string + */ + public $taxCategory; + + /** + * @var TaxDetails[] + */ + public $taxDetails = []; + + /** + * TaxDetailsInformation constructor. + * + * @param TaxData $taxData + */ + public function __construct(TaxData $taxData) + { + $this->taxCategory = $taxData->category; + + $this->taxDetails[] = new TaxDetails( + $taxData->rate, + $taxData->countryCode, + $taxData->currencyCode, + $taxData->type + ); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/Ticket.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/Ticket.php new file mode 100644 index 000000000..f5f83fc31 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/Ticket.php @@ -0,0 +1,61 @@ + + */ +class Ticket +{ + /** + * @var TicketInformation + */ + public $ticketInformation; + + /** + * @var TicketGroup[] + */ + public $ticketGroup = []; + + /** + * Ticket constructor. + * + * @param TicketOpt $opt + */ + public function __construct(TicketOpt $opt) + { + $this->ticketInformation = new TicketInformation( + $opt->type, + $opt->number + ); + + foreach ($opt->ticketGroup as $ticketGroup) { + $this->ticketGroup[] = new TicketGroup($ticketGroup); + } + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TicketGroup.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TicketGroup.php new file mode 100644 index 000000000..c06e403de --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TicketGroup.php @@ -0,0 +1,86 @@ + + */ +class TicketGroup extends WsMessageUtility +{ + /** + * @var CouponInformationDetails + */ + public $couponInformationDetails; + + /** + * @var BoardingPriority + */ + public $boardingPriority; + + /** + * @var ActionIdentification + */ + public $actionIdentification; + + /** + * @var ReferenceInformation + */ + public $referenceInformation; + + /** + * TicketGroup constructor. + * + * @param TickGroupOpt $opt + */ + public function __construct(TickGroupOpt $opt) + { + if ($this->checkAnyNotEmpty($opt->couponNumber, $opt->couponStatus)) { + $this->couponInformationDetails = new CouponInformationDetails( + $opt->couponNumber, + $opt->couponStatus + ); + } + + if (!empty($opt->boardingPriority)) { + $this->boardingPriority = new BoardingPriority($opt->boardingPriority); + } + + if (!empty($opt->actionRequestCode)) { + $this->actionIdentification = new ActionIdentification($opt->actionRequestCode); + } + + if (!empty($opt->references)) { + $this->referenceInformation = new ReferenceInformation( + $opt->references, + ReferenceDetails::TYPE_VALIDATION_CERTIFICATE_USED_FOR_STAFF + ); + } + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TicketInformation.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TicketInformation.php new file mode 100644 index 000000000..1a61e3647 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TicketInformation.php @@ -0,0 +1,50 @@ + + */ +class TicketInformation +{ + /** + * @var DocumentDetails + */ + public $documentDetails; + + /** + * TicketInformation constructor. + * + * @param string $type + * @param string $number + */ + public function __construct($type, $number) + { + $this->documentDetails = new DocumentDetails($number, $type); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TicketNumber.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TicketNumber.php new file mode 100644 index 000000000..793bb1d89 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TicketNumber.php @@ -0,0 +1,50 @@ + + */ +class TicketNumber +{ + /** + * @var DocumentDetails + */ + public $documentDetails; + + /** + * TicketNumber constructor. + * + * @param string $number + * @param string|null $type + */ + public function __construct($number, $type) + { + $this->documentDetails = new DocumentDetails($number, $type = null); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TourInformation.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TourInformation.php new file mode 100644 index 000000000..47d1cd333 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TourInformation.php @@ -0,0 +1,47 @@ + + */ +class TourInformation +{ + /** + * @var TourInformationDetails + */ + public $tourInformationDetails; + + /** + * TourInformation constructor. + * + * @param string $tourCode + */ + public function __construct($tourCode) + { + $this->tourInformationDetails = new TourInformationDetails($tourCode); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TourInformationDetails.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TourInformationDetails.php new file mode 100644 index 000000000..8c687b3c2 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TourInformationDetails.php @@ -0,0 +1,47 @@ + + */ +class TourInformationDetails +{ + /** + * @var string + */ + public $tourCode; + + /** + * TourInformationDetails constructor. + * + * @param string $tourCode + */ + public function __construct($tourCode) + { + $this->tourCode = $tourCode; + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TransactionContext.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TransactionContext.php new file mode 100644 index 000000000..f4d86f161 --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TransactionContext.php @@ -0,0 +1,33 @@ + + */ +class TransactionContext +{ +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TravellerInformation.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TravellerInformation.php new file mode 100644 index 000000000..cafcd9d1b --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TravellerInformation.php @@ -0,0 +1,49 @@ + + */ +class TravellerInformation +{ + /** + * @var PaxDetails + */ + public $paxDetails; + + /** + * TravellerInformation constructor. + * + * @param string $surName + */ + public function __construct($surName) + { + $this->paxDetails = new PaxDetails($surName); + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TravellerPriorityInfo.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TravellerPriorityInfo.php new file mode 100644 index 000000000..0559786aa --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/TravellerPriorityInfo.php @@ -0,0 +1,81 @@ + + */ +class TravellerPriorityInfo +{ + const COMPANY_INDUSTRY_CAR_RENTAL = "7CC"; + const COMPANY_INDUSTRY_HOTEL_CHAINS = "7HH"; + + /** + * @var string + */ + public $company; + + /** + * @var string + */ + public $dateOfJoining; + + /** + * @var string + */ + public $travellerReference; + + /** + * TravellerPriorityInfo constructor. + * + * @param string|null $company + * @param \DateTime|string|null $dateOfJoining + * @param string|null $travellerReference + */ + public function __construct($company = null, $dateOfJoining = null, $travellerReference = null) + { + $this->company = $company; + $this->dateOfJoining = $this->loadDate($dateOfJoining); + $this->travellerReference = $travellerReference; + } + + /** + * @param \DateTime|string|null $dateOfJoining + * @return string|null + */ + protected function loadDate($dateOfJoining) + { + $str = null; + + if ($dateOfJoining instanceof \DateTime) { + $str = strtoupper($dateOfJoining->format('dMy')); + } elseif (!empty($dateOfJoining)) { + $str = $dateOfJoining; + } + + return $str; + } +} diff --git a/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/UserIdentification.php b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/UserIdentification.php new file mode 100644 index 000000000..319def75b --- /dev/null +++ b/src/Amadeus/Client/Struct/DocRefund/UpdateRefund/UserIdentification.php @@ -0,0 +1,58 @@ + + */ +class UserIdentification +{ + /** + * @var OriginIdentification + */ + public $originIdentification; + + /** + * @var string + */ + public $originator; + + /** + * UserIdentification constructor. + * + * @param string|null $originatorId + * @param string|null $originator + */ + public function __construct($originatorId, $originator) + { + if (!empty($originatorId)) { + $this->originIdentification = new OriginIdentification($originatorId); + } + $this->originator = $originator; + } +} diff --git a/src/Amadeus/Client/Struct/Ticket/CheckEligibility/ActionIdentification.php b/src/Amadeus/Client/Struct/Ticket/CheckEligibility/ActionIdentification.php index 3cda97d42..e2b1a681e 100644 --- a/src/Amadeus/Client/Struct/Ticket/CheckEligibility/ActionIdentification.php +++ b/src/Amadeus/Client/Struct/Ticket/CheckEligibility/ActionIdentification.php @@ -38,6 +38,9 @@ class ActionIdentification const REQ_IGNORE_OTHER = "O"; const REQ_REMOVE = "R"; + /** DocRefund_UpdateRefund */ + const REQ_UPDATE_STAFF_PROFILE_FLAG = "STF"; + /** * self::REQ_* * diff --git a/tests/Amadeus/Client/ResponseHandler/BaseTest.php b/tests/Amadeus/Client/ResponseHandler/BaseTest.php index 4e3c61fd8..3e80e531f 100644 --- a/tests/Amadeus/Client/ResponseHandler/BaseTest.php +++ b/tests/Amadeus/Client/ResponseHandler/BaseTest.php @@ -1017,6 +1017,22 @@ public function testCanHandleDocRefundInitRefundErrorResponse() $this->assertEquals("ATC REFUND NOT AUTHORIZED", $result->messages[0]->text); } + + public function testCanHandleDocRefundUpdateRefundErrorResponse() + { + $respHandler = new ResponseHandler\Base(); + + $sendResult = new SendResult(); + $sendResult->responseXml = $this->getTestFile('dummyDocRefundUpdateRefundErrorResponse.txt'); + + $result = $respHandler->analyzeResponse($sendResult, 'DocRefund_UpdateRefund'); + + $this->assertEquals(Result::STATUS_ERROR, $result->status); + $this->assertEquals(1, count($result->messages)); + $this->assertEquals('2213', $result->messages[0]->code); + $this->assertEquals("INVALID FORM OF PAYMENT", $result->messages[0]->text); + } + public function testCanHandleTicketCreateTSTFromPricingErrResponse() { $respHandler = new ResponseHandler\Base(); diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/dummyDocRefundUpdateRefundErrorResponse.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyDocRefundUpdateRefundErrorResponse.txt new file mode 100644 index 000000000..c4bbba79c --- /dev/null +++ b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyDocRefundUpdateRefundErrorResponse.txt @@ -0,0 +1,191 @@ + + + + FOP + 1 + 2213 + + + + 4 + ERR + M + ZZZ + + INVALID FORM OF PAYMENT + + + + + + 81203172 + + 4924MS + + + + RID + 514 + + + + + TKTT + + + + DR + + 2008 + 6 + 20 + + + + 710 + + 2008 + 5 + 2 + + + + + TKT + Y + + + DIS + M + + + + + FRANZA/SARAMRS + + + + + + 07646527091445 + + + + + + 1 + RF + + + + + + + 2 + RF + + + + + + + B + 950.00 + CHF + + + RFU + 0.00 + CHF + + + FRF + 950.00 + CHF + + + RFT + 1075.00 + CHF + + + TXT + 200.00 + CHF + + + + + I + + + + + NEW + 85.50 + P + 9.00 + + + CP + 75.00 + A + 7.89 + + + + H + + 20.50 + CHF + CH + + + + H + + 36.00 + CHF + LB + + + + H + + 3.50 + CHF + VL + + + + H + + 140.00 + CHF + YQ + + + + + + UNKNOWN + 1075.00 + + + + + 4 + CFP + + ##0## + + + + 4 + CFP + + INV/FLEX1111 + + + + diff --git a/tests/Amadeus/Client/Struct/DocRefund/DocRefund/StructuredAddressTest.php b/tests/Amadeus/Client/Struct/DocRefund/DocRefund/StructuredAddressTest.php new file mode 100644 index 000000000..4a81b62b0 --- /dev/null +++ b/tests/Amadeus/Client/Struct/DocRefund/DocRefund/StructuredAddressTest.php @@ -0,0 +1,75 @@ + + */ +class StructuredAddressTest extends BaseTestCase +{ + public function testCanMakeAddressWithPoBoxAndState() + { + $opt = new AddressOpt([ + 'company' => 'GREAT COMPANY', + 'name' => 'MR SMITH', + 'addressLine1' => '12 LONG STREET', + 'addressLine2' => 'something', + 'postalCode' => 'BS7890', + 'city' => 'LOS ANGELES', + 'country' => 'US', + 'state' => 'CA', + 'poBox' => 2123 + ]); + + $address = new StructuredAddress($opt); + + $this->assertEquals(StructuredAddress::TYPE_BILLING_ADDRESS, $address->informationType); + $this->assertCount(9, $address->address); + $this->assertEquals(Address::OPTION_COMPANY, $address->address[0]->option); + $this->assertEquals('GREAT COMPANY', $address->address[0]->optionText); + $this->assertEquals(Address::OPTION_NAME, $address->address[1]->option); + $this->assertEquals('MR SMITH', $address->address[1]->optionText); + $this->assertEquals(Address::OPTION_ADDRESS_LINE_1, $address->address[2]->option); + $this->assertEquals('12 LONG STREET', $address->address[2]->optionText); + $this->assertEquals(Address::OPTION_ADDRESS_LINE_2, $address->address[3]->option); + $this->assertEquals('something', $address->address[3]->optionText); + $this->assertEquals(Address::OPTION_CITY, $address->address[4]->option); + $this->assertEquals('LOS ANGELES', $address->address[4]->optionText); + $this->assertEquals(Address::OPTION_COUNTRY, $address->address[5]->option); + $this->assertEquals('US', $address->address[5]->optionText); + $this->assertEquals(Address::OPTION_PO_BOX, $address->address[6]->option); + $this->assertEquals(2123, $address->address[6]->optionText); + $this->assertEquals(Address::OPTION_POSTAL_CODE, $address->address[7]->option); + $this->assertEquals('BS7890', $address->address[7]->optionText); + $this->assertEquals(Address::OPTION_STATE, $address->address[8]->option); + $this->assertEquals('CA', $address->address[8]->optionText); + } +} diff --git a/tests/Amadeus/Client/Struct/DocRefund/DocRefund/TravellerPriorityInfoTest.php b/tests/Amadeus/Client/Struct/DocRefund/DocRefund/TravellerPriorityInfoTest.php new file mode 100644 index 000000000..f8db30ee6 --- /dev/null +++ b/tests/Amadeus/Client/Struct/DocRefund/DocRefund/TravellerPriorityInfoTest.php @@ -0,0 +1,44 @@ + + */ +class TravellerPriorityInfoTest extends BaseTestCase +{ + public function testCanMakeWithStringAsDate() + { + $tpi = new TravellerPriorityInfo('DL', '10MAY17', 'ABC123321321'); + + $this->assertEquals('DL', $tpi->company); + $this->assertEquals('10MAY17', $tpi->dateOfJoining); + $this->assertEquals('ABC123321321', $tpi->travellerReference); + } +} diff --git a/tests/Amadeus/Client/Struct/DocRefund/UpdateRefundTest.php b/tests/Amadeus/Client/Struct/DocRefund/UpdateRefundTest.php new file mode 100644 index 000000000..ca8e60937 --- /dev/null +++ b/tests/Amadeus/Client/Struct/DocRefund/UpdateRefundTest.php @@ -0,0 +1,933 @@ + + */ +class UpdateRefundTest extends BaseTestCase +{ + /** + * 5.1 Operation: Conjunction ticket + */ + public function testCanMakeMessageConjunctionTicket() + { + $opt = new DocRefundUpdateRefundOptions([ + 'originator' => '0001AA', + 'originatorId' => '23491193', + 'refundDate' => \DateTime::createFromFormat('Ymd', '20031125'), + 'ticketedDate' => \DateTime::createFromFormat('Ymd', '20030522'), + 'references' => [ + new Reference([ + 'type' => Reference::TYPE_TKT_INDICATOR, + 'value' => 'Y' + ]), + new Reference([ + 'type' => Reference::TYPE_DATA_SOURCE, + 'value' => 'F' + ]) + ], + 'tickets' => [ + new Ticket([ + 'number' => '22021541124593', + 'ticketGroup' => [ + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_1, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_2, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_3, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_4, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]) + ] + ]), + new Ticket([ + 'number' => '22021541124604', + 'ticketGroup' => [ + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_1, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_2, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]) + ] + ]) + ], + 'travellerPrioDateOfJoining' => \DateTime::createFromFormat('Ymd', '20070101'), + 'travellerPrioReference' => '0077701F', + 'monetaryData' => [ + new MonetaryData([ + 'type' => MonetaryData::TYPE_BASE_FARE, + 'amount' => 401.00, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_FARE_USED, + 'amount' => 0.00, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_FARE_REFUND, + 'amount' => 401.00, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_REFUND_TOTAL, + 'amount' => 457.74, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_TOTAL_TAXES, + 'amount' => 56.74, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => 'TP', + 'amount' => 56.74, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => 'OBP', + 'amount' => 0.00, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => 'TGV', + 'amount' => 374.93, + 'currency' => 'EUR' + ]) + ], + 'taxData' => [ + new TaxData([ + 'category' => 'H', + 'rate' => 16.14, + 'currencyCode' => 'EUR', + 'type' => 'DE' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 3.45, + 'currencyCode' => 'EUR', + 'type' => 'YC' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 9.67, + 'currencyCode' => 'EUR', + 'type' => 'US' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 9.67, + 'currencyCode' => 'EUR', + 'type' => 'US' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 3.14, + 'currencyCode' => 'EUR', + 'type' => 'XA' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 4.39, + 'currencyCode' => 'EUR', + 'type' => 'XY' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 6.28, + 'currencyCode' => 'EUR', + 'type' => 'AY' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 4.00, + 'currencyCode' => 'EUR', + 'type' => 'DU' + ]), + new TaxData([ + 'category' => '701', + 'rate' => 56.74, + 'currencyCode' => 'EUR', + 'type' => TaxData::TYPE_EXTENDED_TAXES + ]) + ], + 'formOfPayment' => [ + new FopOpt([ + 'fopType' => FopOpt::TYPE_MISCELLANEOUS, + 'fopAmount' => 457.74, + 'freeText' => [ + new FreeTextOpt([ + 'type' => 'CFP', + 'freeText' => '##0##' + ]), + new FreeTextOpt([ + 'type' => 'CFP', + 'freeText' => 'IDBANK' + ]) + ] + ]) + ], + 'refundedRouteStations' => [ + 'FRA', + 'MUC', + 'JFK', + 'BKK', + 'FRA' + ] + ]); + + $msg = new UpdateRefund($opt); + + $this->assertNull($msg->ticketNumber); + $this->assertNull($msg->structuredAddress); + $this->assertEmpty($msg->refundedItinerary); + $this->assertNull($msg->tourInformation); + $this->assertNull($msg->commission); + $this->assertNull($msg->pricingDetails); + $this->assertNull($msg->travellerInformation); + $this->assertEmpty($msg->interactiveFreeText); + + $this->assertEquals('0001AA', $msg->userIdentification->originator); + $this->assertEquals('23491193', $msg->userIdentification->originIdentification->originatorId); + + $this->assertCount(2, $msg->dateTimeInformation); + $this->assertEquals(UpdateRefund\DateTimeInformation::OPT_DATE_OF_REFUND, $msg->dateTimeInformation[0]->businessSemantic); + $this->assertEquals('25', $msg->dateTimeInformation[0]->dateTime->day); + $this->assertEquals('11', $msg->dateTimeInformation[0]->dateTime->month); + $this->assertEquals('2003', $msg->dateTimeInformation[0]->dateTime->year); + + $this->assertEquals(UpdateRefund\DateTimeInformation::OPT_DATE_TICKETED, $msg->dateTimeInformation[1]->businessSemantic); + $this->assertEquals('22', $msg->dateTimeInformation[1]->dateTime->day); + $this->assertEquals('5', $msg->dateTimeInformation[1]->dateTime->month); + $this->assertEquals('2003', $msg->dateTimeInformation[1]->dateTime->year); + + $this->assertCount(2, $msg->referenceInformation->referenceDetails); + $this->assertEquals('Y', $msg->referenceInformation->referenceDetails[0]->value); + $this->assertEquals(UpdateRefund\ReferenceDetails::TYPE_TKT_INDICATOR, $msg->referenceInformation->referenceDetails[0]->type); + $this->assertEquals('F', $msg->referenceInformation->referenceDetails[1]->value); + $this->assertEquals(UpdateRefund\ReferenceDetails::TYPE_DATA_SOURCE, $msg->referenceInformation->referenceDetails[1]->type); + + $this->assertCount(2, $msg->ticket); + + $this->assertEquals('22021541124593', $msg->ticket[0]->ticketInformation->documentDetails->number); + $this->assertNull($msg->ticket[0]->ticketInformation->documentDetails->type); + $this->assertCount(4, $msg->ticket[0]->ticketGroup); + $this->assertEquals(UpdateRefund\CouponDetails::COUPON_1, $msg->ticket[0]->ticketGroup[0]->couponInformationDetails->couponDetails->cpnNumber); + $this->assertEquals(UpdateRefund\CouponDetails::STATUS_REFUNDED, $msg->ticket[0]->ticketGroup[0]->couponInformationDetails->couponDetails->cpnStatus); + $this->assertEquals('LH07A', $msg->ticket[0]->ticketGroup[0]->boardingPriority->priorityDetails->description); + $this->assertNull($msg->ticket[0]->ticketGroup[0]->referenceInformation); + $this->assertNull($msg->ticket[0]->ticketGroup[0]->actionIdentification); + + $this->assertEquals(UpdateRefund\CouponDetails::COUPON_2, $msg->ticket[0]->ticketGroup[1]->couponInformationDetails->couponDetails->cpnNumber); + $this->assertEquals(UpdateRefund\CouponDetails::STATUS_REFUNDED, $msg->ticket[0]->ticketGroup[1]->couponInformationDetails->couponDetails->cpnStatus); + $this->assertEquals('LH07A', $msg->ticket[0]->ticketGroup[1]->boardingPriority->priorityDetails->description); + $this->assertNull($msg->ticket[0]->ticketGroup[1]->referenceInformation); + $this->assertNull($msg->ticket[0]->ticketGroup[1]->actionIdentification); + + $this->assertEquals(UpdateRefund\CouponDetails::COUPON_3, $msg->ticket[0]->ticketGroup[2]->couponInformationDetails->couponDetails->cpnNumber); + $this->assertEquals(UpdateRefund\CouponDetails::STATUS_REFUNDED, $msg->ticket[0]->ticketGroup[2]->couponInformationDetails->couponDetails->cpnStatus); + $this->assertEquals('LH07A', $msg->ticket[0]->ticketGroup[2]->boardingPriority->priorityDetails->description); + $this->assertNull($msg->ticket[0]->ticketGroup[2]->referenceInformation); + $this->assertNull($msg->ticket[0]->ticketGroup[2]->actionIdentification); + + $this->assertEquals(UpdateRefund\CouponDetails::COUPON_4, $msg->ticket[0]->ticketGroup[3]->couponInformationDetails->couponDetails->cpnNumber); + $this->assertEquals(UpdateRefund\CouponDetails::STATUS_REFUNDED, $msg->ticket[0]->ticketGroup[3]->couponInformationDetails->couponDetails->cpnStatus); + $this->assertEquals('LH07A', $msg->ticket[0]->ticketGroup[3]->boardingPriority->priorityDetails->description); + $this->assertNull($msg->ticket[0]->ticketGroup[3]->referenceInformation); + $this->assertNull($msg->ticket[0]->ticketGroup[3]->actionIdentification); + + $this->assertEquals('22021541124604', $msg->ticket[1]->ticketInformation->documentDetails->number); + $this->assertNull($msg->ticket[1]->ticketInformation->documentDetails->type); + $this->assertCount(2, $msg->ticket[1]->ticketGroup); + $this->assertEquals(UpdateRefund\CouponDetails::COUPON_1, $msg->ticket[1]->ticketGroup[0]->couponInformationDetails->couponDetails->cpnNumber); + $this->assertEquals(UpdateRefund\CouponDetails::STATUS_REFUNDED, $msg->ticket[1]->ticketGroup[0]->couponInformationDetails->couponDetails->cpnStatus); + $this->assertEquals('LH07A', $msg->ticket[1]->ticketGroup[0]->boardingPriority->priorityDetails->description); + $this->assertNull($msg->ticket[1]->ticketGroup[0]->referenceInformation); + $this->assertNull($msg->ticket[1]->ticketGroup[0]->actionIdentification); + + $this->assertEquals(UpdateRefund\CouponDetails::COUPON_2, $msg->ticket[1]->ticketGroup[1]->couponInformationDetails->couponDetails->cpnNumber); + $this->assertEquals(UpdateRefund\CouponDetails::STATUS_REFUNDED, $msg->ticket[1]->ticketGroup[1]->couponInformationDetails->couponDetails->cpnStatus); + $this->assertEquals('LH07A', $msg->ticket[1]->ticketGroup[1]->boardingPriority->priorityDetails->description); + $this->assertNull($msg->ticket[1]->ticketGroup[1]->referenceInformation); + $this->assertNull($msg->ticket[1]->ticketGroup[1]->actionIdentification); + + $this->assertEquals('01JAN07', $msg->travellerPriorityInfo->dateOfJoining); + $this->assertEquals('0077701F', $msg->travellerPriorityInfo->travellerReference); + $this->assertNull($msg->travellerPriorityInfo->company); + + $this->assertEquals(UpdateRefund\MonetaryDetails::TYPE_BASE_FARE, $msg->monetaryInformation->monetaryDetails->typeQualifier); + $this->assertEquals(401.00, $msg->monetaryInformation->monetaryDetails->amount); + $this->assertEquals('EUR', $msg->monetaryInformation->monetaryDetails->currency); + + $this->assertCount(7, $msg->monetaryInformation->otherMonetaryDetails); + + $this->assertEquals('RFU', $msg->monetaryInformation->otherMonetaryDetails[0]->typeQualifier); + $this->assertEquals(0.00, $msg->monetaryInformation->otherMonetaryDetails[0]->amount); + $this->assertEquals('EUR', $msg->monetaryInformation->otherMonetaryDetails[0]->currency); + $this->assertEquals('FRF', $msg->monetaryInformation->otherMonetaryDetails[1]->typeQualifier); + $this->assertEquals(401.00, $msg->monetaryInformation->otherMonetaryDetails[1]->amount); + $this->assertEquals('EUR', $msg->monetaryInformation->otherMonetaryDetails[1]->currency); + $this->assertEquals('RFT', $msg->monetaryInformation->otherMonetaryDetails[2]->typeQualifier); + $this->assertEquals(457.74, $msg->monetaryInformation->otherMonetaryDetails[2]->amount); + $this->assertEquals('EUR', $msg->monetaryInformation->otherMonetaryDetails[2]->currency); + $this->assertEquals('TXT', $msg->monetaryInformation->otherMonetaryDetails[3]->typeQualifier); + $this->assertEquals(56.74, $msg->monetaryInformation->otherMonetaryDetails[3]->amount); + $this->assertEquals('EUR', $msg->monetaryInformation->otherMonetaryDetails[3]->currency); + $this->assertEquals('TP', $msg->monetaryInformation->otherMonetaryDetails[4]->typeQualifier); + $this->assertEquals(56.74, $msg->monetaryInformation->otherMonetaryDetails[4]->amount); + $this->assertEquals('EUR', $msg->monetaryInformation->otherMonetaryDetails[4]->currency); + $this->assertEquals('OBP', $msg->monetaryInformation->otherMonetaryDetails[5]->typeQualifier); + $this->assertEquals(0.00, $msg->monetaryInformation->otherMonetaryDetails[5]->amount); + $this->assertEquals('EUR', $msg->monetaryInformation->otherMonetaryDetails[5]->currency); + $this->assertEquals('TGV', $msg->monetaryInformation->otherMonetaryDetails[6]->typeQualifier); + $this->assertEquals(374.93, $msg->monetaryInformation->otherMonetaryDetails[6]->amount); + $this->assertEquals('EUR', $msg->monetaryInformation->otherMonetaryDetails[6]->currency); + + $this->assertCount(9, $msg->taxDetailsInformation); + + $this->assertEquals('H', $msg->taxDetailsInformation[0]->taxCategory); + $this->assertCount(1, $msg->taxDetailsInformation[0]->taxDetails); + $this->assertEquals('DE', $msg->taxDetailsInformation[0]->taxDetails[0]->type); + $this->assertEquals('16.14', $msg->taxDetailsInformation[0]->taxDetails[0]->rate); + $this->assertEquals('EUR', $msg->taxDetailsInformation[0]->taxDetails[0]->currencyCode); + $this->assertNull($msg->taxDetailsInformation[0]->taxDetails[0]->countryCode); + + $this->assertEquals('H', $msg->taxDetailsInformation[1]->taxCategory); + $this->assertCount(1, $msg->taxDetailsInformation[1]->taxDetails); + $this->assertEquals('YC', $msg->taxDetailsInformation[1]->taxDetails[0]->type); + $this->assertEquals(3.45, $msg->taxDetailsInformation[1]->taxDetails[0]->rate); + $this->assertEquals('EUR', $msg->taxDetailsInformation[1]->taxDetails[0]->currencyCode); + $this->assertNull($msg->taxDetailsInformation[1]->taxDetails[0]->countryCode); + + $this->assertEquals('H', $msg->taxDetailsInformation[2]->taxCategory); + $this->assertCount(1, $msg->taxDetailsInformation[2]->taxDetails); + $this->assertEquals('US', $msg->taxDetailsInformation[2]->taxDetails[0]->type); + $this->assertEquals(9.67, $msg->taxDetailsInformation[2]->taxDetails[0]->rate); + $this->assertEquals('EUR', $msg->taxDetailsInformation[2]->taxDetails[0]->currencyCode); + $this->assertNull($msg->taxDetailsInformation[2]->taxDetails[0]->countryCode); + + $this->assertEquals('H', $msg->taxDetailsInformation[3]->taxCategory); + $this->assertCount(1, $msg->taxDetailsInformation[3]->taxDetails); + $this->assertEquals('US', $msg->taxDetailsInformation[3]->taxDetails[0]->type); + $this->assertEquals(9.67, $msg->taxDetailsInformation[3]->taxDetails[0]->rate); + $this->assertEquals('EUR', $msg->taxDetailsInformation[3]->taxDetails[0]->currencyCode); + $this->assertNull($msg->taxDetailsInformation[3]->taxDetails[0]->countryCode); + + $this->assertEquals('H', $msg->taxDetailsInformation[4]->taxCategory); + $this->assertCount(1, $msg->taxDetailsInformation[4]->taxDetails); + $this->assertEquals('XA', $msg->taxDetailsInformation[4]->taxDetails[0]->type); + $this->assertEquals(3.14, $msg->taxDetailsInformation[4]->taxDetails[0]->rate); + $this->assertEquals('EUR', $msg->taxDetailsInformation[4]->taxDetails[0]->currencyCode); + $this->assertNull($msg->taxDetailsInformation[4]->taxDetails[0]->countryCode); + + $this->assertEquals('H', $msg->taxDetailsInformation[5]->taxCategory); + $this->assertCount(1, $msg->taxDetailsInformation[5]->taxDetails); + $this->assertEquals('XY', $msg->taxDetailsInformation[5]->taxDetails[0]->type); + $this->assertEquals(4.39, $msg->taxDetailsInformation[5]->taxDetails[0]->rate); + $this->assertEquals('EUR', $msg->taxDetailsInformation[5]->taxDetails[0]->currencyCode); + $this->assertNull($msg->taxDetailsInformation[5]->taxDetails[0]->countryCode); + + $this->assertEquals('H', $msg->taxDetailsInformation[6]->taxCategory); + $this->assertCount(1, $msg->taxDetailsInformation[6]->taxDetails); + $this->assertEquals('AY', $msg->taxDetailsInformation[6]->taxDetails[0]->type); + $this->assertEquals(6.28, $msg->taxDetailsInformation[6]->taxDetails[0]->rate); + $this->assertEquals('EUR', $msg->taxDetailsInformation[6]->taxDetails[0]->currencyCode); + $this->assertNull($msg->taxDetailsInformation[6]->taxDetails[0]->countryCode); + + $this->assertEquals('H', $msg->taxDetailsInformation[7]->taxCategory); + $this->assertCount(1, $msg->taxDetailsInformation[7]->taxDetails); + $this->assertEquals('DU', $msg->taxDetailsInformation[7]->taxDetails[0]->type); + $this->assertEquals(4.00, $msg->taxDetailsInformation[7]->taxDetails[0]->rate); + $this->assertEquals('EUR', $msg->taxDetailsInformation[7]->taxDetails[0]->currencyCode); + $this->assertNull($msg->taxDetailsInformation[7]->taxDetails[0]->countryCode); + + $this->assertEquals('701', $msg->taxDetailsInformation[8]->taxCategory); + $this->assertCount(1, $msg->taxDetailsInformation[8]->taxDetails); + $this->assertEquals(UpdateRefund\TaxDetails::TYPE_EXTENDED_TAXES, $msg->taxDetailsInformation[8]->taxDetails[0]->type); + $this->assertEquals(56.74, $msg->taxDetailsInformation[8]->taxDetails[0]->rate); + $this->assertEquals('EUR', $msg->taxDetailsInformation[8]->taxDetails[0]->currencyCode); + $this->assertNull($msg->taxDetailsInformation[8]->taxDetails[0]->countryCode); + + $this->assertCount(1, $msg->fopGroup); + $this->assertEquals(FormOfPayment::TYPE_MISCELLANEOUS, $msg->fopGroup[0]->formOfPaymentInformation->formOfPayment->type); + $this->assertEquals(457.74, $msg->fopGroup[0]->formOfPaymentInformation->formOfPayment->amount); + $this->assertNull($msg->fopGroup[0]->formOfPaymentInformation->formOfPayment->authorisedAmount); + $this->assertNull($msg->fopGroup[0]->formOfPaymentInformation->formOfPayment->sourceOfApproval); + $this->assertCount(2, $msg->fopGroup[0]->interactiveFreeText); + $this->assertEquals('##0##', $msg->fopGroup[0]->interactiveFreeText[0]->freeText); + $this->assertEquals('CFP', $msg->fopGroup[0]->interactiveFreeText[0]->freeTextQualification->informationType); + $this->assertEquals(UpdateRefund\FreeTextQualification::QUAL_CODED_AND_LITERAL_TEXT, $msg->fopGroup[0]->interactiveFreeText[0]->freeTextQualification->textSubjectQualifier); + $this->assertEquals('IDBANK', $msg->fopGroup[0]->interactiveFreeText[1]->freeText); + $this->assertEquals('CFP', $msg->fopGroup[0]->interactiveFreeText[1]->freeTextQualification->informationType); + $this->assertEquals(UpdateRefund\FreeTextQualification::QUAL_CODED_AND_LITERAL_TEXT, $msg->fopGroup[0]->interactiveFreeText[1]->freeTextQualification->textSubjectQualifier); + + $this->assertCount(5, $msg->refundedRoute->routingDetails); + $this->assertEquals('FRA', $msg->refundedRoute->routingDetails[0]->station); + $this->assertEquals('MUC', $msg->refundedRoute->routingDetails[1]->station); + $this->assertEquals('JFK', $msg->refundedRoute->routingDetails[2]->station); + $this->assertEquals('BKK', $msg->refundedRoute->routingDetails[3]->station); + $this->assertEquals('FRA', $msg->refundedRoute->routingDetails[4]->station); + } + + /** + * 5.2 Operation: Currency conversion + */ + public function testCanMakeMessageWithCurrencyConversion() + { + $opt = new DocRefundUpdateRefundOptions([ + 'originator' => '0001AA', + 'originatorId' => '92490300', + 'refundDate' => \DateTime::createFromFormat('Ymd', '20031125'), + 'ticketedDate' => \DateTime::createFromFormat('Ymd', '20030522'), + 'references' => [ + new Reference([ + 'type' => Reference::TYPE_TKT_INDICATOR, + 'value' => 'Y' + ]), + new Reference([ + 'type' => Reference::TYPE_DATA_SOURCE, + 'value' => 'F' + ]) + ], + 'passengerSurName' => 'AMADEUSTEST JAN MR', + 'tickets' => [ + new Ticket([ + 'number' => '22021542207795', + 'ticketGroup' => [ + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_1, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH05A', + 'actionRequestCode' => 'STF', + 'references' => ['12345678901234567890'] + ]) + ] + ]) + ], + 'monetaryData' => [ + new MonetaryData([ + 'type' => MonetaryData::TYPE_BASE_FARE, + 'amount' => 10660, + 'currency' => 'RUB' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_CURENCY_CONVERSION_AMOUNT, + 'amount' => 0.027094, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_FARE_USED, + 'amount' => 0, + 'currency' => 'RUB' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_FARE_REFUND, + 'amount' => 10660, + 'currency' => 'RUB' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_REFUND_TOTAL, + 'amount' => 13020, + 'currency' => 'RUB' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_TOTAL_TAXES, + 'amount' => 2360, + 'currency' => 'RUB' + ]), + new MonetaryData([ + 'type' => 'TP', + 'amount' => 2360, + 'currency' => 'RUB' + ]), + new MonetaryData([ + 'type' => 'OBP', + 'amount' => 555, + 'currency' => 'RUB' + ]) + ], + 'taxData' => [ + new TaxData([ + 'category' => 'H', + 'rate' => 1295.00, + 'currencyCode' => 'RUB', + 'type' => 'YQ' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 776.00, + 'currencyCode' => 'RUB', + 'type' => 'RD' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 289.00, + 'currencyCode' => 'RUB', + 'type' => 'DE' + ]), + new TaxData([ + 'category' => '701', + 'rate' => 2360, + 'currencyCode' => 'RUB', + 'type' => TaxData::TYPE_EXTENDED_TAXES + ]) + ], + 'formOfPayment' => [ + new FopOpt([ + 'fopType' => FopOpt::TYPE_CASH, + 'fopAmount' => 13020, + 'freeText' => [ + new FreeTextOpt([ + 'type' => 'CFP', + 'freeText' => '##0##' + ]), + new FreeTextOpt([ + 'type' => 'CFP', + 'freeText' => 'CASH' + ]) + ] + ]) + ], + 'refundedRouteStations' => [ + 'FRA', + 'HAM' + ], + 'address' => new AddressOpt([ + 'company' => 'GREAT COMPANY', + 'name' => 'MR SMITH', + 'addressLine1' => '12 LONG STREET', + 'postalCode' => 'BS7890', + 'city' => 'NICE', + 'country' => 'FR' + ]) + ]); + + $msg = new UpdateRefund($opt); + + $this->assertNull($msg->ticketNumber); + $this->assertEmpty($msg->refundedItinerary); + $this->assertNull($msg->tourInformation); + $this->assertNull($msg->commission); + $this->assertNull($msg->pricingDetails); + $this->assertEmpty($msg->interactiveFreeText); + + $this->assertEquals('0001AA', $msg->userIdentification->originator); + $this->assertEquals('92490300', $msg->userIdentification->originIdentification->originatorId); + + $this->assertCount(2, $msg->dateTimeInformation); + $this->assertCount(2, $msg->referenceInformation->referenceDetails); + + $this->assertCount(1, $msg->ticket); + $this->assertEquals('22021542207795', $msg->ticket[0]->ticketInformation->documentDetails->number); + $this->assertNull($msg->ticket[0]->ticketInformation->documentDetails->type); + $this->assertCount(1, $msg->ticket[0]->ticketGroup); + $this->assertEquals(UpdateRefund\CouponDetails::COUPON_1, $msg->ticket[0]->ticketGroup[0]->couponInformationDetails->couponDetails->cpnNumber); + $this->assertEquals(UpdateRefund\CouponDetails::STATUS_REFUNDED, $msg->ticket[0]->ticketGroup[0]->couponInformationDetails->couponDetails->cpnStatus); + $this->assertEquals('LH05A', $msg->ticket[0]->ticketGroup[0]->boardingPriority->priorityDetails->description); + $this->assertCount(1, $msg->ticket[0]->ticketGroup[0]->referenceInformation->referenceDetails); + $this->assertEquals(UpdateRefund\ReferenceDetails::TYPE_VALIDATION_CERTIFICATE_USED_FOR_STAFF, $msg->ticket[0]->ticketGroup[0]->referenceInformation->referenceDetails[0]->type); + $this->assertEquals('12345678901234567890', $msg->ticket[0]->ticketGroup[0]->referenceInformation->referenceDetails[0]->value); + $this->assertEquals('STF', $msg->ticket[0]->ticketGroup[0]->actionIdentification->actionRequestCode); + $this->assertNull($msg->ticket[0]->ticketGroup[0]->actionIdentification->productDetails); + + + $this->assertEquals(UpdateRefund\MonetaryDetails::TYPE_BASE_FARE, $msg->monetaryInformation->monetaryDetails->typeQualifier); + $this->assertEquals(10660, $msg->monetaryInformation->monetaryDetails->amount); + $this->assertEquals('RUB', $msg->monetaryInformation->monetaryDetails->currency); + + $this->assertCount(7, $msg->monetaryInformation->otherMonetaryDetails); + //Ehh, i don't feel like asserting them again, effort + + $this->assertCount(4, $msg->taxDetailsInformation); + $this->assertEquals('H', $msg->taxDetailsInformation[0]->taxCategory); + $this->assertCount(1, $msg->taxDetailsInformation[0]->taxDetails); + $this->assertEquals('YQ', $msg->taxDetailsInformation[0]->taxDetails[0]->type); + $this->assertEquals(1295, $msg->taxDetailsInformation[0]->taxDetails[0]->rate); + $this->assertEquals('RUB', $msg->taxDetailsInformation[0]->taxDetails[0]->currencyCode); + $this->assertNull($msg->taxDetailsInformation[0]->taxDetails[0]->countryCode); + + $this->assertEquals('H', $msg->taxDetailsInformation[1]->taxCategory); + $this->assertCount(1, $msg->taxDetailsInformation[1]->taxDetails); + $this->assertEquals('RD', $msg->taxDetailsInformation[1]->taxDetails[0]->type); + $this->assertEquals(776, $msg->taxDetailsInformation[1]->taxDetails[0]->rate); + $this->assertEquals('RUB', $msg->taxDetailsInformation[1]->taxDetails[0]->currencyCode); + $this->assertNull($msg->taxDetailsInformation[1]->taxDetails[0]->countryCode); + + $this->assertEquals('H', $msg->taxDetailsInformation[2]->taxCategory); + $this->assertCount(1, $msg->taxDetailsInformation[2]->taxDetails); + $this->assertEquals('DE', $msg->taxDetailsInformation[2]->taxDetails[0]->type); + $this->assertEquals(289, $msg->taxDetailsInformation[2]->taxDetails[0]->rate); + $this->assertEquals('RUB', $msg->taxDetailsInformation[2]->taxDetails[0]->currencyCode); + $this->assertNull($msg->taxDetailsInformation[2]->taxDetails[0]->countryCode); + + $this->assertEquals('701', $msg->taxDetailsInformation[3]->taxCategory); + $this->assertCount(1, $msg->taxDetailsInformation[3]->taxDetails); + $this->assertEquals(UpdateRefund\TaxDetails::TYPE_EXTENDED_TAXES, $msg->taxDetailsInformation[3]->taxDetails[0]->type); + $this->assertEquals(2360, $msg->taxDetailsInformation[3]->taxDetails[0]->rate); + $this->assertEquals('RUB', $msg->taxDetailsInformation[3]->taxDetails[0]->currencyCode); + $this->assertNull($msg->taxDetailsInformation[3]->taxDetails[0]->countryCode); + + $this->assertEquals(UpdateRefund\StructuredAddress::TYPE_BILLING_ADDRESS, $msg->structuredAddress->informationType); + $this->assertCount(6, $msg->structuredAddress->address); + $this->assertEquals(UpdateRefund\Address::OPTION_COMPANY, $msg->structuredAddress->address[0]->option); + $this->assertEquals('GREAT COMPANY', $msg->structuredAddress->address[0]->optionText); + $this->assertEquals(UpdateRefund\Address::OPTION_NAME, $msg->structuredAddress->address[1]->option); + $this->assertEquals('MR SMITH', $msg->structuredAddress->address[1]->optionText); + $this->assertEquals(UpdateRefund\Address::OPTION_ADDRESS_LINE_1, $msg->structuredAddress->address[2]->option); + $this->assertEquals('12 LONG STREET', $msg->structuredAddress->address[2]->optionText); + $this->assertEquals(UpdateRefund\Address::OPTION_CITY, $msg->structuredAddress->address[3]->option); + $this->assertEquals('NICE', $msg->structuredAddress->address[3]->optionText); + $this->assertEquals(UpdateRefund\Address::OPTION_COUNTRY, $msg->structuredAddress->address[4]->option); + $this->assertEquals('FR', $msg->structuredAddress->address[4]->optionText); + $this->assertEquals(UpdateRefund\Address::OPTION_POSTAL_CODE, $msg->structuredAddress->address[5]->option); + $this->assertEquals('BS7890', $msg->structuredAddress->address[5]->optionText); + + $this->assertEquals('AMADEUSTEST JAN MR', $msg->travellerInformation->paxDetails->surname); + $this->assertNull($msg->travellerInformation->paxDetails->type); + $this->assertNull($msg->travellerInformation->paxDetails->quantity); + $this->assertNull($msg->travellerInformation->paxDetails->status); + } + + public function testCanMakeMessageNoShowFeeUpdate() + { + $opt = new DocRefundUpdateRefundOptions([ + 'originator' => '0001AA', + 'originatorId' => '28055300', + 'refundDate' => \DateTime::createFromFormat('Ymd', '20111116'), + 'ticketedDate' => \DateTime::createFromFormat('Ymd', '20111115'), + 'references' => [ + new Reference([ + 'type' => Reference::TYPE_TKT_INDICATOR, + 'value' => 'Y' + ]), + new Reference([ + 'type' => Reference::TYPE_DATA_SOURCE, + 'value' => 'F' + ]) + ], + 'passengerSurName' => 'NOSHOW/REFUND', + 'tickets' => [ + new Ticket([ + 'number' => '17246548165754', + 'ticketGroup' => [ + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_1, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + ]), + new TickGroupOpt([ + 'couponNumber' => TickGroupOpt::COUPON_2, + 'couponStatus' => TickGroupOpt::STATUS_REFUNDED, + ]), + ] + ]) + ], + 'monetaryData' => [ + new MonetaryData([ + 'type' => MonetaryData::TYPE_BASE_FARE, + 'amount' => 54.00, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_FARE_USED, + 'amount' => 0, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_FARE_REFUND, + 'amount' => 54.00, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_REFUND_TOTAL, + 'amount' => 138.53, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_TOTAL_TAXES, + 'amount' => 84.53, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => 'TP', + 'amount' => 84.53, + 'currency' => 'EUR' + ]), + new MonetaryData([ + 'type' => MonetaryData::TYPE_NO_SHOW_FEE, + 'amount' => 20, + 'currency' => 'EUR' + ]) + ], + 'pricingTicketIndicator' => DocRefundUpdateRefundOptions::PRICING_IND_INTERNATIONAL_ITINERARY, + 'commission' => [ + new CommissionOpt([ + 'type' => CommissionOpt::TYPE_NEW_COMMISSION, + 'amount' => 0.00, + 'freeText' => 'P', + 'rate' => 0.00, + ]) + ], + 'taxData' => [ + new TaxData([ + 'category' => 'H', + 'rate' => 2.00, + 'currencyCode' => 'EUR', + 'type' => 'YQ' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 17.86, + 'currencyCode' => 'EUR', + 'type' => 'OY' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 50.75, + 'currencyCode' => 'EUR', + 'type' => 'RD' + ]), + new TaxData([ + 'category' => 'H', + 'rate' => 13.92, + 'currencyCode' => 'EUR', + 'type' => 'DE' + ]) + ], + 'formOfPayment' => [ + new FopOpt([ + 'fopType' => FopOpt::TYPE_CASH, + 'fopAmount' => 138.53, + 'freeText' => [ + new FreeTextOpt([ + 'type' => 'CFP', + 'freeText' => '##0##' + ]), + new FreeTextOpt([ + 'type' => 'CFP', + 'freeText' => 'CASH' + ]) + ] + ]) + ] + ]); + + $msg = new UpdateRefund($opt); + + $this->assertNull($msg->ticketNumber); + $this->assertEmpty($msg->refundedItinerary); + $this->assertNull($msg->tourInformation); + + $this->assertEquals('0001AA', $msg->userIdentification->originator); + $this->assertEquals('28055300', $msg->userIdentification->originIdentification->originatorId); + + $this->assertCount(2, $msg->dateTimeInformation); + $this->assertEquals(UpdateRefund\DateTimeInformation::OPT_DATE_OF_REFUND, $msg->dateTimeInformation[0]->businessSemantic); + $this->assertEquals('16', $msg->dateTimeInformation[0]->dateTime->day); + $this->assertEquals('11', $msg->dateTimeInformation[0]->dateTime->month); + $this->assertEquals('2011', $msg->dateTimeInformation[0]->dateTime->year); + + $this->assertEquals(UpdateRefund\DateTimeInformation::OPT_DATE_TICKETED, $msg->dateTimeInformation[1]->businessSemantic); + $this->assertEquals('15', $msg->dateTimeInformation[1]->dateTime->day); + $this->assertEquals('11', $msg->dateTimeInformation[1]->dateTime->month); + $this->assertEquals('2011', $msg->dateTimeInformation[1]->dateTime->year); + + $this->assertCount(2, $msg->referenceInformation->referenceDetails); + + $this->assertCount(1, $msg->ticket); + $this->assertEquals('17246548165754', $msg->ticket[0]->ticketInformation->documentDetails->number); + $this->assertNull($msg->ticket[0]->ticketInformation->documentDetails->type); + $this->assertCount(2, $msg->ticket[0]->ticketGroup); + $this->assertEquals(UpdateRefund\CouponDetails::COUPON_1, $msg->ticket[0]->ticketGroup[0]->couponInformationDetails->couponDetails->cpnNumber); + $this->assertEquals(UpdateRefund\CouponDetails::STATUS_REFUNDED, $msg->ticket[0]->ticketGroup[0]->couponInformationDetails->couponDetails->cpnStatus); + $this->assertNull($msg->ticket[0]->ticketGroup[0]->boardingPriority); + $this->assertEmpty($msg->ticket[0]->ticketGroup[0]->referenceInformation); + $this->assertNull($msg->ticket[0]->ticketGroup[0]->actionIdentification); + + $this->assertNull($msg->structuredAddress); + + $this->assertEquals('NOSHOW/REFUND', $msg->travellerInformation->paxDetails->surname); + $this->assertNull($msg->travellerInformation->paxDetails->type); + $this->assertNull($msg->travellerInformation->paxDetails->quantity); + $this->assertNull($msg->travellerInformation->paxDetails->status); + + $this->assertEquals(UpdateRefund\PriceTicketDetails::INDICATOR_INTERNATIONAL_ITINERARY, $msg->pricingDetails->priceTicketDetails->indicators); + $this->assertNull($msg->pricingDetails->priceTariffType); + + $this->assertEquals(UpdateRefund\CommissionDetails::TYPE_NEW_COMMISSION, $msg->commission->commissionDetails->type); + $this->assertEquals('P', $msg->commission->commissionDetails->freeText); + $this->assertEquals(0.00, $msg->commission->commissionDetails->rate); + $this->assertEquals(0.00, $msg->commission->commissionDetails->amount); + + $this->assertEmpty($msg->commission->otherCommissionDetails); + } + + /** + * 5.4 Operation: Partial refund + * + * Not all parameters are included in this example, just the ones that aren't covered by another unittest yet + */ + public function testCanMakePartialRefundMessage() + { + $opt = new DocRefundUpdateRefundOptions([ + //Other parameters omitted + 'references' => [ + new Reference([ + 'type' => Reference::TYPE_TKT_INDICATOR, + 'value' => 'Y' + ]), + new Reference([ + 'type' => Reference::TYPE_DATA_SOURCE, + 'value' => 'F' + ]), + new Reference([ + 'type' => 'RA', + 'value' => '0044444' + ]), + new Reference([ + 'type' => Reference::TYPE_INVOICE_NUMBER, + 'value' => '123456' + ]) + ], + 'travellerPrioCompany' => '01111111111', + 'travellerPrioDateOfJoining' => \DateTime::createFromFormat('Ymd', '20030529'), //29MAY03 + 'travellerPrioReference' => '000222222F', + 'freeText' => [ + new FreeTextOpt([ + 'type' => FreeTextOpt::TYPE_REMARK, + 'freeText' => 'TEST' + ]) + ] + ]); + + $msg = new UpdateRefund($opt); + + $this->assertEquals('29MAY03', $msg->travellerPriorityInfo->dateOfJoining); + $this->assertEquals('01111111111', $msg->travellerPriorityInfo->company); + $this->assertEquals('000222222F', $msg->travellerPriorityInfo->travellerReference); + + $this->assertCount(1, $msg->interactiveFreeText); + $this->assertEquals('TEST', $msg->interactiveFreeText[0]->freeText); + $this->assertEquals(UpdateRefund\FreeTextQualification::TYPE_REMARK, $msg->interactiveFreeText[0]->freeTextQualification->informationType); + $this->assertEquals(UpdateRefund\FreeTextQualification::QUAL_CODED_AND_LITERAL_TEXT, $msg->interactiveFreeText[0]->freeTextQualification->textSubjectQualifier); + + $this->assertCount(4, $msg->referenceInformation->referenceDetails); + $this->assertEquals('Y', $msg->referenceInformation->referenceDetails[0]->value); + $this->assertEquals(UpdateRefund\ReferenceDetails::TYPE_TKT_INDICATOR, $msg->referenceInformation->referenceDetails[0]->type); + $this->assertEquals('F', $msg->referenceInformation->referenceDetails[1]->value); + $this->assertEquals(UpdateRefund\ReferenceDetails::TYPE_DATA_SOURCE, $msg->referenceInformation->referenceDetails[1]->type); + $this->assertEquals('0044444', $msg->referenceInformation->referenceDetails[2]->value); + $this->assertEquals('RA', $msg->referenceInformation->referenceDetails[2]->type); + $this->assertEquals('123456', $msg->referenceInformation->referenceDetails[3]->value); + $this->assertEquals(UpdateRefund\ReferenceDetails::TYPE_INVOICE_NUMBER, $msg->referenceInformation->referenceDetails[3]->type); + } + + /** + * 5.5 Operation: Update a refund + * + * Not all parameters are included in this example, just the ones that aren't covered by another unittest yet + */ + public function testCanMakeUpdateRefundMessage() + { + $opt = new DocRefundUpdateRefundOptions([ + //Other parameters omitted + 'ticketNumber' => '17246548165740', + 'tourCode' => '01JUL86LH11A', + 'refundedItinerary' => [ + new RefundItinOpt([ + 'company' => 'AF', + 'origin' => 'NCE', + 'destination' => 'PAR' + ]) + ] + ]); + + $msg = new UpdateRefund($opt); + + $this->assertEquals('17246548165740', $msg->ticketNumber->documentDetails->number); + $this->assertNull($msg->ticketNumber->documentDetails->type); + + $this->assertEquals('01JUL86LH11A', $msg->tourInformation->tourInformationDetails->tourCode); + + $this->assertCount(1, $msg->refundedItinerary); + $this->assertEquals('AF', $msg->refundedItinerary[0]->airlineCodeRfndItinerary->companyIdentification->operatingCompany); + $this->assertEquals('NCE', $msg->refundedItinerary[0]->originDestinationRfndItinerary->origin); + $this->assertEquals('PAR', $msg->refundedItinerary[0]->originDestinationRfndItinerary->destination); + + $this->assertEmpty($msg->ticket); + $this->assertEmpty($msg->interactiveFreeText); + $this->assertEmpty($msg->fopGroup); + $this->assertEmpty($msg->taxDetailsInformation); + $this->assertEmpty($msg->dateTimeInformation); + $this->assertNull($msg->referenceInformation); + $this->assertNull($msg->travellerPriorityInfo); + $this->assertNull($msg->refundedRoute); + $this->assertNull($msg->travellerInformation); + $this->assertNull($msg->monetaryInformation); + $this->assertNull($msg->pricingDetails); + $this->assertNull($msg->commission); + $this->assertNull($msg->structuredAddress); + $this->assertNull($msg->userIdentification); + $this->assertNull($msg->feeGroup); + $this->assertNull($msg->firstAndLastSegmentDates); + $this->assertNull($msg->originAndDestination); + $this->assertNull($msg->transactionContext); + + } +} + diff --git a/tests/Amadeus/ClientTest.php b/tests/Amadeus/ClientTest.php index 99829b93b..90a7c6118 100644 --- a/tests/Amadeus/ClientTest.php +++ b/tests/Amadeus/ClientTest.php @@ -4047,6 +4047,417 @@ public function testCanSendDocRefundInitRefund() $this->assertEquals($messageResult, $response); } + public function testCanSendDocRefundUpdateRefund() + { + $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); + + $mockedSendResult = new Client\Session\Handler\SendResult(); + $mockedSendResult->responseXml = 'dummydocrefundupdaterefundresponse'; + + $messageResult = new Client\Result($mockedSendResult); + + $expectedMessageResult = new Client\Struct\DocRefund\UpdateRefund( + new Client\RequestOptions\DocRefundUpdateRefundOptions([ + 'originator' => '0001AA', + 'originatorId' => '23491193', + 'refundDate' => \DateTime::createFromFormat('Ymd', '20031125'), + 'ticketedDate' => \DateTime::createFromFormat('Ymd', '20030522'), + 'references' => [ + new Client\RequestOptions\DocRefund\Reference([ + 'type' => Client\RequestOptions\DocRefund\Reference::TYPE_TKT_INDICATOR, + 'value' => 'Y' + ]), + new Client\RequestOptions\DocRefund\Reference([ + 'type' => Client\RequestOptions\DocRefund\Reference::TYPE_DATA_SOURCE, + 'value' => 'F' + ]) + ], + 'tickets' => [ + new Client\RequestOptions\DocRefund\Ticket([ + 'number' => '22021541124593', + 'ticketGroup' => [ + new Client\RequestOptions\DocRefund\TickGroupOpt([ + 'couponNumber' => Client\RequestOptions\DocRefund\TickGroupOpt::COUPON_1, + 'couponStatus' => Client\RequestOptions\DocRefund\TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new Client\RequestOptions\DocRefund\TickGroupOpt([ + 'couponNumber' => Client\RequestOptions\DocRefund\TickGroupOpt::COUPON_2, + 'couponStatus' => Client\RequestOptions\DocRefund\TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new Client\RequestOptions\DocRefund\TickGroupOpt([ + 'couponNumber' => Client\RequestOptions\DocRefund\TickGroupOpt::COUPON_3, + 'couponStatus' => Client\RequestOptions\DocRefund\TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new Client\RequestOptions\DocRefund\TickGroupOpt([ + 'couponNumber' => Client\RequestOptions\DocRefund\TickGroupOpt::COUPON_4, + 'couponStatus' => Client\RequestOptions\DocRefund\TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]) + ] + ]), + new Client\RequestOptions\DocRefund\Ticket([ + 'number' => '22021541124604', + 'ticketGroup' => [ + new Client\RequestOptions\DocRefund\TickGroupOpt([ + 'couponNumber' => Client\RequestOptions\DocRefund\TickGroupOpt::COUPON_1, + 'couponStatus' => Client\RequestOptions\DocRefund\TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new Client\RequestOptions\DocRefund\TickGroupOpt([ + 'couponNumber' => Client\RequestOptions\DocRefund\TickGroupOpt::COUPON_2, + 'couponStatus' => Client\RequestOptions\DocRefund\TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]) + ] + ]) + ], + 'travellerPrioDateOfJoining' => \DateTime::createFromFormat('Ymd', '20070101'), + 'travellerPrioReference' => '0077701F', + 'monetaryData' => [ + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => Client\RequestOptions\DocRefund\MonetaryData::TYPE_BASE_FARE, + 'amount' => 401.00, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => Client\RequestOptions\DocRefund\MonetaryData::TYPE_FARE_USED, + 'amount' => 0.00, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => Client\RequestOptions\DocRefund\MonetaryData::TYPE_FARE_REFUND, + 'amount' => 401.00, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => Client\RequestOptions\DocRefund\MonetaryData::TYPE_REFUND_TOTAL, + 'amount' => 457.74, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => Client\RequestOptions\DocRefund\MonetaryData::TYPE_TOTAL_TAXES, + 'amount' => 56.74, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => 'TP', + 'amount' => 56.74, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => 'OBP', + 'amount' => 0.00, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => 'TGV', + 'amount' => 374.93, + 'currency' => 'EUR' + ]) + ], + 'taxData' => [ + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 16.14, + 'currencyCode' => 'EUR', + 'type' => 'DE' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 3.45, + 'currencyCode' => 'EUR', + 'type' => 'YC' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 9.67, + 'currencyCode' => 'EUR', + 'type' => 'US' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 9.67, + 'currencyCode' => 'EUR', + 'type' => 'US' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 3.14, + 'currencyCode' => 'EUR', + 'type' => 'XA' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 4.39, + 'currencyCode' => 'EUR', + 'type' => 'XY' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 6.28, + 'currencyCode' => 'EUR', + 'type' => 'AY' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 4.00, + 'currencyCode' => 'EUR', + 'type' => 'DU' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => '701', + 'rate' => 56.74, + 'currencyCode' => 'EUR', + 'type' => Client\RequestOptions\DocRefund\TaxData::TYPE_EXTENDED_TAXES + ]) + ], + 'formOfPayment' => [ + new Client\RequestOptions\DocRefund\FopOpt([ + 'fopType' => Client\RequestOptions\DocRefund\FopOpt::TYPE_MISCELLANEOUS, + 'fopAmount' => 457.74, + 'freeText' => [ + new Client\RequestOptions\DocRefund\FreeTextOpt([ + 'type' => 'CFP', + 'freeText' => '##0##' + ]), + new Client\RequestOptions\DocRefund\FreeTextOpt([ + 'type' => 'CFP', + 'freeText' => 'IDBANK' + ]) + ] + ]) + ], + 'refundedRouteStations' => [ + 'FRA', + 'MUC', + 'JFK', + 'BKK', + 'FRA' + ] + ]) + ); + + $mockSessionHandler + ->expects($this->once()) + ->method('sendMessage') + ->with('DocRefund_UpdateRefund', $expectedMessageResult, ['endSession' => false, 'returnXml' => true]) + ->will($this->returnValue($mockedSendResult)); + $mockSessionHandler + ->expects($this->never()) + ->method('getLastResponse'); + $mockSessionHandler + ->expects($this->once()) + ->method('getMessagesAndVersions') + ->will($this->returnValue(['DocRefund_UpdateRefund' => ['version' => "14.1", 'wsdl' => 'dc22e4ee']])); + + $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock(); + + $mockResponseHandler + ->expects($this->once()) + ->method('analyzeResponse') + ->with($mockedSendResult, 'DocRefund_UpdateRefund') + ->will($this->returnValue($messageResult)); + + $par = new Params(); + $par->sessionHandler = $mockSessionHandler; + $par->requestCreatorParams = new Params\RequestCreatorParams([ + 'receivedFrom' => 'some RF string', + 'originatorOfficeId' => 'BRUXXXXXX' + ]); + $par->responseHandler = $mockResponseHandler; + + $client = new Client($par); + + $response = $client->docRefundUpdateRefund( + new Client\RequestOptions\DocRefundUpdateRefundOptions([ + 'originator' => '0001AA', + 'originatorId' => '23491193', + 'refundDate' => \DateTime::createFromFormat('Ymd', '20031125'), + 'ticketedDate' => \DateTime::createFromFormat('Ymd', '20030522'), + 'references' => [ + new Client\RequestOptions\DocRefund\Reference([ + 'type' => Client\RequestOptions\DocRefund\Reference::TYPE_TKT_INDICATOR, + 'value' => 'Y' + ]), + new Client\RequestOptions\DocRefund\Reference([ + 'type' => Client\RequestOptions\DocRefund\Reference::TYPE_DATA_SOURCE, + 'value' => 'F' + ]) + ], + 'tickets' => [ + new Client\RequestOptions\DocRefund\Ticket([ + 'number' => '22021541124593', + 'ticketGroup' => [ + new Client\RequestOptions\DocRefund\TickGroupOpt([ + 'couponNumber' => Client\RequestOptions\DocRefund\TickGroupOpt::COUPON_1, + 'couponStatus' => Client\RequestOptions\DocRefund\TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new Client\RequestOptions\DocRefund\TickGroupOpt([ + 'couponNumber' => Client\RequestOptions\DocRefund\TickGroupOpt::COUPON_2, + 'couponStatus' => Client\RequestOptions\DocRefund\TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new Client\RequestOptions\DocRefund\TickGroupOpt([ + 'couponNumber' => Client\RequestOptions\DocRefund\TickGroupOpt::COUPON_3, + 'couponStatus' => Client\RequestOptions\DocRefund\TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new Client\RequestOptions\DocRefund\TickGroupOpt([ + 'couponNumber' => Client\RequestOptions\DocRefund\TickGroupOpt::COUPON_4, + 'couponStatus' => Client\RequestOptions\DocRefund\TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]) + ] + ]), + new Client\RequestOptions\DocRefund\Ticket([ + 'number' => '22021541124604', + 'ticketGroup' => [ + new Client\RequestOptions\DocRefund\TickGroupOpt([ + 'couponNumber' => Client\RequestOptions\DocRefund\TickGroupOpt::COUPON_1, + 'couponStatus' => Client\RequestOptions\DocRefund\TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]), + new Client\RequestOptions\DocRefund\TickGroupOpt([ + 'couponNumber' => Client\RequestOptions\DocRefund\TickGroupOpt::COUPON_2, + 'couponStatus' => Client\RequestOptions\DocRefund\TickGroupOpt::STATUS_REFUNDED, + 'boardingPriority' => 'LH07A' + ]) + ] + ]) + ], + 'travellerPrioDateOfJoining' => \DateTime::createFromFormat('Ymd', '20070101'), + 'travellerPrioReference' => '0077701F', + 'monetaryData' => [ + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => Client\RequestOptions\DocRefund\MonetaryData::TYPE_BASE_FARE, + 'amount' => 401.00, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => Client\RequestOptions\DocRefund\MonetaryData::TYPE_FARE_USED, + 'amount' => 0.00, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => Client\RequestOptions\DocRefund\MonetaryData::TYPE_FARE_REFUND, + 'amount' => 401.00, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => Client\RequestOptions\DocRefund\MonetaryData::TYPE_REFUND_TOTAL, + 'amount' => 457.74, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => Client\RequestOptions\DocRefund\MonetaryData::TYPE_TOTAL_TAXES, + 'amount' => 56.74, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => 'TP', + 'amount' => 56.74, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => 'OBP', + 'amount' => 0.00, + 'currency' => 'EUR' + ]), + new Client\RequestOptions\DocRefund\MonetaryData([ + 'type' => 'TGV', + 'amount' => 374.93, + 'currency' => 'EUR' + ]) + ], + 'taxData' => [ + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 16.14, + 'currencyCode' => 'EUR', + 'type' => 'DE' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 3.45, + 'currencyCode' => 'EUR', + 'type' => 'YC' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 9.67, + 'currencyCode' => 'EUR', + 'type' => 'US' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 9.67, + 'currencyCode' => 'EUR', + 'type' => 'US' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 3.14, + 'currencyCode' => 'EUR', + 'type' => 'XA' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 4.39, + 'currencyCode' => 'EUR', + 'type' => 'XY' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 6.28, + 'currencyCode' => 'EUR', + 'type' => 'AY' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => 'H', + 'rate' => 4.00, + 'currencyCode' => 'EUR', + 'type' => 'DU' + ]), + new Client\RequestOptions\DocRefund\TaxData([ + 'category' => '701', + 'rate' => 56.74, + 'currencyCode' => 'EUR', + 'type' => Client\RequestOptions\DocRefund\TaxData::TYPE_EXTENDED_TAXES + ]) + ], + 'formOfPayment' => [ + new Client\RequestOptions\DocRefund\FopOpt([ + 'fopType' => Client\RequestOptions\DocRefund\FopOpt::TYPE_MISCELLANEOUS, + 'fopAmount' => 457.74, + 'freeText' => [ + new Client\RequestOptions\DocRefund\FreeTextOpt([ + 'type' => 'CFP', + 'freeText' => '##0##' + ]), + new Client\RequestOptions\DocRefund\FreeTextOpt([ + 'type' => 'CFP', + 'freeText' => 'IDBANK' + ]) + ] + ]) + ], + 'refundedRouteStations' => [ + 'FRA', + 'MUC', + 'JFK', + 'BKK', + 'FRA' + ] + ]) + ); + + $this->assertEquals($messageResult, $response); + } + /** * Testing the scenario where a user requests no responseXML string in the Result object. */