Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi Ticket functionality implemented in MasterPricer messages #94

Merged
merged 4 commits into from
Sep 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Added support in PNR_Retrieve for retrieving the PNR active in context (https://github.com/amabnl/amadeus-ws-client/pull/88) - Michal Hernas
* Added support for Tour Code elements in ``PNR_AddMultiElements`` (https://github.com/amabnl/amadeus-ws-client/issues/90)
* Implemented ``FOP_ValidateFOP`` (https://github.com/amabnl/amadeus-ws-client/pull/86) - Michal Hernas
* Added support for Multi-Ticket operation for MasterPricer messages (https://github.com/amabnl/amadeus-ws-client/pull/94) - Michal Hernas

# Release 1.4.0 (15 May 2017)
* Added support for ``Fare_PricePNRWithBookingClass`` errors in message version 7.3 format (https://github.com/amabnl/amadeus-ws-client/issues/57)
Expand Down
49 changes: 49 additions & 0 deletions docs/samples/masterpricertravelboard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -859,3 +859,52 @@ to be taken into consideration by Amadeus when returning Fare Shopping results:
],
'dkNumber' => 'AA1234567890123456789Z01234567890'
]);

Multi-Ticket
============

The Multi-Ticket option allows you to get inbound, outbound and complete flights in one response.
Works only on return trip search.

`multiTicketWeights` is optional. If passed the sum of each weight has to sum up to 100.

.. code-block:: php

use Amadeus\Client\RequestOptions\FareMasterPricerTbSearch;
use Amadeus\Client\RequestOptions\Fare\MPItinerary;
use Amadeus\Client\RequestOptions\Fare\MPLocation;
use Amadeus\Client\RequestOptions\Fare\MasterPricer\MultiTicketWeights;
use Amadeus\Client\RequestOptionsFare\MPPassenger;
use Amadeus\Client\RequestOptionsFare\MPDate;

$opt = new FareMasterPricerTbSearch([
'nrOfRequestedPassengers' => 1,
'passengers' => [
new MPPassenger([
'type' => MPPassenger::TYPE_ADULT,
'count' => 1
])
],
'itinerary' => [
new MPItinerary([
'departureLocation' => new MPLocation(['city' => 'PAR']),
'arrivalLocation' => new MPLocation(['city' => 'PPT']),
'date' => new MPDate([
'dateTime' => new \DateTime('2012-08-10T00:00:00+0000', new \DateTimeZone('UTC'))
])
]),
new MPItinerary([
'departureLocation' => new MPLocation(['city' => 'PPT']),
'arrivalLocation' => new MPLocation(['city' => 'PAR']),
'date' => new MPDate([
'dateTime' => new \DateTime('2012-08-20T00:00:00+0000', new \DateTimeZone('UTC'))
])
])
],
'multiTicket' => true,
'multiTicketWeights' => new MultiTicketWeights([
'oneWayOutbound' => 80,
'oneWayInbound' => 0,
'returnTrip' => 20
])
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* amadeus-ws-client
*
* Copyright 2015 Amadeus Benelux NV
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @package Amadeus
* @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
*/

namespace Amadeus\Client\RequestOptions\Fare\MasterPricer;

use Amadeus\Client\LoadParamsFromArray;

/**
* Multi Ticket Weights
*
* @package Amadeus\Client\RequestOptions\Fare\MasterPricer
* @author Mike Hernas <mike@ahoy.io>
*/
class MultiTicketWeights extends LoadParamsFromArray
{
/**
* Recommendations for outbound (OWO)
*
* @var int
*/
public $oneWayOutbound;
/**
* Recommendations for inbound (OWI)
*
* @var int
*/
public $oneWayInbound;
/**
* Recommendations for complete journey (RT)
*
* @var int
*/
public $returnTrip;
}
14 changes: 14 additions & 0 deletions src/Amadeus/Client/RequestOptions/MpBaseOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,18 @@ class MpBaseOptions extends Base
* @var Fare\MPFeeId[]
*/
public $feeIds;

/**
* Whether to perform a multi ticket search
*
* @var bool
*/
public $multiTicket = false;

/**
* Optional. Weights for Multi Ticket functionality.
*
* @var Fare\MasterPricer\MultiTicketWeights
*/
public $multiTicketWeights;
}
14 changes: 9 additions & 5 deletions src/Amadeus/Client/Struct/Fare/BaseMasterPricerMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Amadeus\Client\RequestOptions\FareMasterPricerCalendarOptions;
use Amadeus\Client\RequestOptions\FareMasterPricerTbSearch;
use Amadeus\Client\RequestOptions\TicketCheckEligibilityOptions;
use Amadeus\Client\RequestOptions\Fare\MasterPricer\MultiTicketWeights;
use Amadeus\Client\Struct\BaseWsMessage;

/**
Expand Down Expand Up @@ -96,12 +97,13 @@ protected function loadPassenger($passenger, &$counter, &$infantCounter)
* @param FareMasterPricerTbSearch|FareMasterPricerCalendarOptions|TicketCheckEligibilityOptions $options
* @return void
*/
protected function loadNrOfPaxAndResults($options)
protected function loadNumberOfUnits($options)
{
if (is_int($options->nrOfRequestedPassengers) || is_int($options->nrOfRequestedResults)) {
if (is_int($options->nrOfRequestedPassengers) || is_int($options->nrOfRequestedResults) || $options->multiTicketWeights instanceof MultiTicketWeights) {
$this->numberOfUnit = new MasterPricer\NumberOfUnit(
$options->nrOfRequestedPassengers,
$options->nrOfRequestedResults
$options->nrOfRequestedResults,
$options->multiTicketWeights
);
}
}
Expand All @@ -116,7 +118,8 @@ protected function loadFareOptions($options)
$options->corporateCodesUnifares,
$options->flightOptions,
$options->currencyOverride,
$options->feeIds
$options->feeIds,
$options->multiTicket
)
) {
$this->fareOptions = new MasterPricer\FareOptions(
Expand All @@ -125,7 +128,8 @@ protected function loadFareOptions($options)
$options->doTicketabilityPreCheck,
$options->currencyOverride,
$options->feeIds,
$options->corporateQualifier
$options->corporateQualifier,
$options->multiTicket
);
}
}
Expand Down
18 changes: 17 additions & 1 deletion src/Amadeus/Client/Struct/Fare/MasterPricer/FareOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class FareOptions

public $monetaryCabinInfo;

public $multiTicket;

/**
* FareOptions constructor.
*
Expand All @@ -73,7 +75,8 @@ public function __construct(
$tickPreCheck,
$currency,
$feeIds,
$corporateQualifier
$corporateQualifier,
$multiTicket
) {
if ($tickPreCheck === true) {
$this->addPriceType(PricingTicketing::PRICETYPE_TICKETABILITY_PRECHECK);
Expand All @@ -89,6 +92,7 @@ public function __construct(
}

$this->loadCurrencyOverride($currency);
$this->loadMultiTicket($multiTicket);
if (!is_null($feeIds)) {
$this->loadFeeIds($feeIds);
}
Expand Down Expand Up @@ -123,6 +127,18 @@ protected function loadCurrencyOverride($currency)
}
}

/**
* Set multi ticket on if needed
*
* @param string|null $currency
*/
protected function loadMultiTicket($multiTicket)
{
if ($multiTicket) {
$this->addPriceType(PricingTicketing::PRICETYPE_MULTI_TICKET);
}
}

/**
* Add PriceType
*
Expand Down
20 changes: 19 additions & 1 deletion src/Amadeus/Client/Struct/Fare/MasterPricer/NumberOfUnit.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

namespace Amadeus\Client\Struct\Fare\MasterPricer;

use Amadeus\Client\RequestOptions\Fare\MasterPricer\MultiTicketWeights;

/**
* NumberOfUnit
*
Expand All @@ -38,8 +40,9 @@ class NumberOfUnit
/**
* @param int|null $requestedPax
* @param int|null $requestedResults
* @param Amadeus\Client\RequestOptions\Fare\MasterPricer\MultiTicketWeights|null $multiTicketWeights
*/
public function __construct($requestedPax, $requestedResults)
public function __construct($requestedPax, $requestedResults, $multiTicketWeights)
{
if (is_int($requestedPax)) {
$this->unitNumberDetail[] = new UnitNumberDetail(
Expand All @@ -53,5 +56,20 @@ public function __construct($requestedPax, $requestedResults)
UnitNumberDetail::TYPE_RESULTS
);
}

if ($multiTicketWeights && $multiTicketWeights instanceof MultiTicketWeights) {
$this->unitNumberDetail[] = new UnitNumberDetail(
$multiTicketWeights->oneWayOutbound,
UnitNumberDetail::TYPE_OUTBOUND_RECOMMENDATION
);
$this->unitNumberDetail[] = new UnitNumberDetail(
$multiTicketWeights->oneWayInbound,
UnitNumberDetail::TYPE_INBBOUND_RECOMMENDATION
);
$this->unitNumberDetail[] = new UnitNumberDetail(
$multiTicketWeights->returnTrip,
UnitNumberDetail::TYPE_COMPLETE_RECOMMENDATION
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class PricingTicketing
const PRICETYPE_NO_SLICE_AND_DICE = "NSD";
const PRICETYPE_DISPLAY_MIN_MAX_STAY = "MST";
const PRICETYPE_OVERRIDE_CURRENCY_CONVERSION = "CUC";
const PRICETYPE_MULTI_TICKET = "MTK";

/**
* self::PRICETYPE_*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class UnitNumberDetail
const TYPE_PERCENTAGE_OF_SHORTEST_ELAPSED_FLYING_TIME = "P";
const TYPE_SHOW_SOLD_OUT = "SOF";
const TYPE_WAITLIST = "WL";
const TYPE_OUTBOUND_RECOMMENDATION = "OWO";
const TYPE_INBBOUND_RECOMMENDATION = "OWI";
const TYPE_COMPLETE_RECOMMENDATION = "RT";

/**
* @var int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function __construct($options = null)
*/
protected function loadOptions($options)
{
$this->loadNrOfPaxAndResults($options);
$this->loadNumberOfUnits($options);

$this->loadFareOptions($options);

Expand Down
2 changes: 1 addition & 1 deletion src/Amadeus/Client/Struct/Ticket/CheckEligibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class CheckEligibility extends BaseMasterPricerMessage
*/
public function __construct(TicketCheckEligibilityOptions $options)
{
$this->loadNrOfPaxAndResults($options);
$this->loadNumberOfUnits($options);

$this->loadFareOptions($options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use Amadeus\Client\RequestOptions\Fare\MasterPricer\FFCriteria;
use Amadeus\Client\RequestOptions\Fare\MasterPricer\FFOtherCriteria;
use Amadeus\Client\RequestOptions\Fare\MasterPricer\MultiTicketWeights;
use Amadeus\Client\RequestOptions\Fare\MPDate;
use Amadeus\Client\RequestOptions\Fare\MPFareFamily;
use Amadeus\Client\RequestOptions\Fare\MPItinerary;
Expand Down Expand Up @@ -1251,4 +1252,38 @@ public function testCanMakeMessageWithDkNumber()
$this->assertEquals('AA1234567890123456789Z01234567890', $message->customerRef->customerReferences[0]->referenceNumber);
$this->assertEquals(CustomerReferences::QUAL_AGENCY_GROUPING_ID, $message->customerRef->customerReferences[0]->referenceQualifier);
}

public function testCanMakeBaseMasterPricerMessageWithMultiTicket()
{
$opt = new FareMasterPricerTbSearch();
$opt->nrOfRequestedResults = 200;
$opt->nrOfRequestedPassengers = 1;
$opt->multiTicket = true;
$opt->multiTicketWeights = new MultiTicketWeights([
'oneWayOutbound' => 30,
'oneWayInbound' => 20,
'returnTrip' => 50
]);

$message = new MasterPricerTravelBoardSearch($opt);

$this->assertCount(5, $message->numberOfUnit->unitNumberDetail);

$this->assertEquals(1, $message->numberOfUnit->unitNumberDetail[0]->numberOfUnits);
$this->assertEquals(UnitNumberDetail::TYPE_PASS, $message->numberOfUnit->unitNumberDetail[0]->typeOfUnit);

$this->assertEquals(200, $message->numberOfUnit->unitNumberDetail[1]->numberOfUnits);
$this->assertEquals(UnitNumberDetail::TYPE_RESULTS, $message->numberOfUnit->unitNumberDetail[1]->typeOfUnit);

$this->assertEquals(30, $message->numberOfUnit->unitNumberDetail[2]->numberOfUnits);
$this->assertEquals(UnitNumberDetail::TYPE_OUTBOUND_RECOMMENDATION, $message->numberOfUnit->unitNumberDetail[2]->typeOfUnit);

$this->assertEquals(20, $message->numberOfUnit->unitNumberDetail[3]->numberOfUnits);
$this->assertEquals(UnitNumberDetail::TYPE_INBBOUND_RECOMMENDATION, $message->numberOfUnit->unitNumberDetail[3]->typeOfUnit);

$this->assertEquals(50, $message->numberOfUnit->unitNumberDetail[4]->numberOfUnits);
$this->assertEquals(UnitNumberDetail::TYPE_COMPLETE_RECOMMENDATION, $message->numberOfUnit->unitNumberDetail[4]->typeOfUnit);

$this->assertEquals("MTK", $message->fareOptions->pricingTickInfo->pricingTicketing->priceType[0]);
}
}