Skip to content

Commit

Permalink
Merge f0164b9 into 6493d0e
Browse files Browse the repository at this point in the history
  • Loading branch information
suiram2010 committed Mar 22, 2021
2 parents 6493d0e + f0164b9 commit 104bc6b
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Unreleased

* Added support for ``CAB`` Elements in Fare_PricePnrWithLowerFares - suiram2010

## Release 1.12.0 (18 Feb 2021)
* Implemented `MiniRule_GetFromRec` (Amadeus docs emphasize to use `MiniRule_GetFromRec` instead of `MiniRule_GetFromETicket`, `MiniRule_GetFromPricing`, `MiniRule_GetFromPricingRec`) - Aleksandr Kalugin
Expand Down
60 changes: 60 additions & 0 deletions docs/samples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,66 @@ An example of pricing, with options listed below:
])
);
An example of pricing, with options listed below:

- take published fares into account (RP)
- take Unifares into account (RU)
- Search only in the original cabin (the one from the segment)

.. code-block:: php
use Amadeus\Client\RequestOptions\FarePricePnrWithLowerFaresOptions;
use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef;
use Amadeus\Client\RequestOptions\Fare\PricePnr\Cabin;
$pricingResponse = $client->farePricePnrWithLowerFares(
new FarePricePnrWithLowerFaresOptions([
'overrideOptions' => [
FarePricePnrWithLowerFaresOptions::OVERRIDE_FARETYPE_PUB,
FarePricePnrWithLowerFaresOptions::OVERRIDE_FARETYPE_UNI
],
'cabins' => [
new Cabin([
'cabinType' => Cabin::CABIN_TYPE_ORIGINAL_CABIN
])
]
])
);
An example of pricing, with options listed below:

- take published fares into account (RP)
- take Unifares into account (RU)
- Search in cabin F first, then in cabin C and finally in any cabin

.. code-block:: php
use Amadeus\Client\RequestOptions\FarePricePnrWithLowerFaresOptions;
use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef;
use Amadeus\Client\RequestOptions\Fare\PricePnr\Cabin;
$pricingResponse = $client->farePricePnrWithLowerFares(
new FarePricePnrWithLowerFaresOptions([
'overrideOptions' => [
FarePricePnrWithLowerFaresOptions::OVERRIDE_FARETYPE_PUB,
FarePricePnrWithLowerFaresOptions::OVERRIDE_FARETYPE_UNI
],
'cabins' => [
new Cabin([
'cabinType' => Cabin::CABIN_TYPE_FIRST,
'cabinCode' => 'F'
]),
new Cabin([
'cabinType' => Cabin::CABIN_TYPE_SECOND,
'cabinCode' => 'C'
]),
new Cabin([
'cabinType' => Cabin::CABIN_TYPE_ANY_CABIN
])
]
])
);
`More examples of Pricing messages <samples/pricepnr.rst>`_

---------------------------
Expand Down
57 changes: 57 additions & 0 deletions src/Amadeus/Client/RequestOptions/Fare/PricePnr/Cabin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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\PricePnr;

use Amadeus\Client\LoadParamsFromArray;

/**
* Class Cabin
* @package Amadeus\Client\RequestOptions\Fare\PricePnr
* @author Dieter Devlieghere <dermikagh@gmail.com>
*/
class Cabin extends LoadParamsFromArray
{
const CABIN_TYPE_FIRST = 'FC';
const CABIN_TYPE_SECOND = 'SC';
const CABIN_TYPE_THIRD = 'TC';
const CABIN_TYPE_ORIGINAL_CABIN = 'K';
const CABIN_TYPE_ANY_CABIN = 'P';


/**
* Cabin type to search for
*
* self::CABIN_TYPE_*
*
* @var string
*/
public $cabinType;


/**
* Cabin code to search for
*
* @var string
*/
public $cabinCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
namespace Amadeus\Client\RequestOptions;

use Amadeus\Client\RequestOptions\Fare\PricePnr\AwardPricing;
use Amadeus\Client\RequestOptions\Fare\PricePnr\Cabin;
use Amadeus\Client\RequestOptions\Fare\PricePnr\ExemptTax;
use Amadeus\Client\RequestOptions\Fare\PricePnr\FareBasis;
use Amadeus\Client\RequestOptions\Fare\PricePnr\FareFamily;
Expand Down Expand Up @@ -286,4 +287,11 @@ class FarePricePnrWithBookingClassOptions extends Base
* @var ZapOff[]
*/
public $zapOff;

/**
* Cabins to be applied
*
* @var Cabin[]
*/
public $cabins;
}
29 changes: 29 additions & 0 deletions src/Amadeus/Client/Struct/Fare/PricePNRWithBookingClass13.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use Amadeus\Client\RequestCreator\MessageVersionUnsupportedException;
use Amadeus\Client\RequestOptions\Fare\PricePnr\AwardPricing;
use Amadeus\Client\RequestOptions\Fare\PricePnr\Cabin;
use Amadeus\Client\RequestOptions\Fare\PricePnr\ExemptTax;
use Amadeus\Client\RequestOptions\Fare\PricePnr\FareBasis;
use Amadeus\Client\RequestOptions\Fare\PricePnr\FareFamily;
Expand All @@ -37,6 +38,7 @@
use Amadeus\Client\RequestOptions\FarePricePnrWithLowestFareOptions as LowestFareOpt;
use Amadeus\Client\RequestOptions\Fare\InformativePricing\PricingOptions as InformativePriceOpt;
use Amadeus\Client\Struct\Fare\PricePnr13\CarrierInformation;
use Amadeus\Client\Struct\Fare\PricePnr13\CriteriaDetails;
use Amadeus\Client\Struct\Fare\PricePnr13\Currency;
use Amadeus\Client\Struct\Fare\PricePnr13\DateInformation;
use Amadeus\Client\Struct\Fare\PricePnr13\FormOfPaymentInformation;
Expand Down Expand Up @@ -188,6 +190,11 @@ public static function loadPricingOptionsFromRequestOptions($options)
self::loadZapOffs($options->zapOff)
);

$priceOptions = self::mergeOptions(
$priceOptions,
self::loadCabins($options->cabins)
);

// All options processed, no options found:
if (empty($priceOptions)) {
$priceOptions[] = new PricingOptionGroup(PricingOptionKey::OPTION_NO_OPTION);
Expand Down Expand Up @@ -664,4 +671,26 @@ protected static function loadZapOffs($zapOffs)

return $opt;
}

/**
* Load Cabins
*
* @param Cabin[] $cabins
* @return array
*/
protected static function loadCabins($cabins)
{
$opt = [];
if (!empty($cabins)) {
$po = new PricingOptionGroup(PricingOptionKey::OPTION_CABIN);
$criteriaDetails = [];
foreach ($cabins as $cabin) {
$criteriaDetails[] = new CriteriaDetails($cabin->cabinType, $cabin->cabinCode);
}
$po->optionDetail = new OptionDetail($criteriaDetails);
$opt[] = $po;
}

return $opt;
}
}
87 changes: 87 additions & 0 deletions tests/Amadeus/Client/Struct/Fare/PricePNRWithLowerFares13Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionKey;
use Amadeus\Client\Struct\Fare\PricePnr13\ReferenceDetails;
use Amadeus\Client\Struct\Fare\PricePNRWithLowerFares13;
use Amadeus\Client\RequestOptions\Fare\PricePnr\Cabin;
use Test\Amadeus\BaseTestCase;

/**
Expand Down Expand Up @@ -84,4 +85,90 @@ public function test51OperationPricingOptions()

$this->assertEquals(PricingOptionKey::OPTION_UNIFARES, $message->pricingOptionGroup[3]->pricingOptionKey->pricingOptionKey);
}

/**
* 2.8 Operation: Pricing options with cabin options
* 2.8.1 Original Cabin
* Here is a complete example of pricing, with options listed below:
*
* - take published fares into account (RP)
* - take Unifares into account (RU)
* - search only in the original cabin (the one from the segment)
*/
public function test281OperationPricingOptions()
{
$options = new FarePricePnrWithLowerFaresOptions(
[
'overrideOptions' => [
FarePricePnrWithLowerFaresOptions::OVERRIDE_FARETYPE_PUB,
FarePricePnrWithLowerFaresOptions::OVERRIDE_FARETYPE_UNI
],
'cabins' => [
new Cabin([
'cabinType' => Cabin::CABIN_TYPE_ORIGINAL_CABIN
])
]
]
);

$message = new PricePNRWithLowerFares13($options);

$this->assertCount(3, $message->pricingOptionGroup);

$this->assertEquals(PricingOptionKey::OPTION_PUBLISHED_FARES, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey);

$this->assertEquals(PricingOptionKey::OPTION_UNIFARES, $message->pricingOptionGroup[1]->pricingOptionKey->pricingOptionKey);

$this->assertEquals(PricingOptionKey::OPTION_CABIN, $message->pricingOptionGroup[2]->pricingOptionKey->pricingOptionKey);
$this->assertEquals(Cabin::CABIN_TYPE_ORIGINAL_CABIN, $message->pricingOptionGroup[2]->optionDetail->criteriaDetails[0]->attributeType);
}

/**
* 2.8 Operation: Pricing options with cabin options
* 2.8.2
* Here is a complete example of pricing, with options listed below:
*
* - take published fares into account (RP)
* - take Unifares into account (RU)
* - Search in cabin F first, then in cabin C and finally in any cabin
*/
public function test282OperationPricingOptions()
{
$options = new FarePricePnrWithLowerFaresOptions(
[
'overrideOptions' => [
FarePricePnrWithLowerFaresOptions::OVERRIDE_FARETYPE_PUB,
FarePricePnrWithLowerFaresOptions::OVERRIDE_FARETYPE_UNI
],
'cabins' => [
new Cabin([
'cabinType' => Cabin::CABIN_TYPE_FIRST,
'cabinCode' => 'F'
]),
new Cabin([
'cabinType' => Cabin::CABIN_TYPE_SECOND,
'cabinCode' => 'C'
]),
new Cabin([
'cabinType' => Cabin::CABIN_TYPE_ANY_CABIN
])
]
]
);

$message = new PricePNRWithLowerFares13($options);

$this->assertCount(3, $message->pricingOptionGroup);

$this->assertEquals(PricingOptionKey::OPTION_PUBLISHED_FARES, $message->pricingOptionGroup[0]->pricingOptionKey->pricingOptionKey);

$this->assertEquals(PricingOptionKey::OPTION_UNIFARES, $message->pricingOptionGroup[1]->pricingOptionKey->pricingOptionKey);

$this->assertEquals(PricingOptionKey::OPTION_CABIN, $message->pricingOptionGroup[2]->pricingOptionKey->pricingOptionKey);
$this->assertEquals(Cabin::CABIN_TYPE_FIRST, $message->pricingOptionGroup[2]->optionDetail->criteriaDetails[0]->attributeType);
$this->assertEquals('F', $message->pricingOptionGroup[2]->optionDetail->criteriaDetails[0]->attributeDescription);
$this->assertEquals(Cabin::CABIN_TYPE_SECOND, $message->pricingOptionGroup[2]->optionDetail->criteriaDetails[1]->attributeType);
$this->assertEquals('C', $message->pricingOptionGroup[2]->optionDetail->criteriaDetails[1]->attributeDescription);
$this->assertEquals(Cabin::CABIN_TYPE_ANY_CABIN, $message->pricingOptionGroup[2]->optionDetail->criteriaDetails[2]->attributeType);
}
}

0 comments on commit 104bc6b

Please sign in to comment.