Skip to content

Commit

Permalink
Implemented message Fare_GetFareRules (issue #63)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerMika committed May 9, 2017
1 parent 621d50c commit 94cf846
Show file tree
Hide file tree
Showing 19 changed files with 852 additions and 4 deletions.
38 changes: 37 additions & 1 deletion docs/samples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,43 @@ Get the fare rules for specific categories for a given pricing in context:
Fare_GetFareRules
-----------------

*coming soon*
Basic request to get Fare Rules:

.. code-block:: php
use Amadeus\Client\RequestOptions\FareGetFareRulesOptions;
$rulesResponse = $client->fareGetFareRules(
new FareGetFareRulesOptions([
'ticketingDate' => \DateTime::createFromFormat('dmY', '23032011'),
'fareBasis' => 'OA21ERD1',
'ticketDesignator' => 'DISC',
'airline' => 'AA',
'origin' => 'DFW',
'destination' => 'MKC'
])
);
Get fare rules providing corporate number and departure date:

.. code-block:: php
use Amadeus\Client\RequestOptions\FareGetFareRulesOptions;
$rulesResponse = $client->fareGetFareRules(
new FareGetFareRulesOptions([
'ticketingDate' => \DateTime::createFromFormat('dmY', '23032011'),
'uniFares' => ['0012345'],
'fareBasis' => 'OA21ERD1',
'ticketDesignator' => 'DISC',
'directionality' => FareGetFareRulesOptions::DIRECTION_ORIGIN_TO_DESTINATION,
'airline' => 'AA',
'origin' => 'DFW',
'destination' => 'MKC',
'travelDate' => \DateTime::createFromFormat('dmY', '25032011')
])
);
--------------------
Fare_ConvertCurrency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,16 @@ class AdditionalFareDetails
* @var string[]
*/
public $secondRateClass;

/**
* AdditionalFareDetails constructor.
*
* @param string|null $rateClass
* @param string|null $commodityCategory
*/
public function __construct($rateClass = null, $commodityCategory = null)
{
$this->rateClass = $rateClass;
$this->commodityCategory = $commodityCategory;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@

namespace Amadeus\Client\Struct\Fare\CheckRules;

use Amadeus\Client\Struct\WsMessageUtility;

/**
* FlightQualificationForRules
*
* @package Amadeus\Client\Struct\Fare\CheckRules
* @author Dieter Devlieghere <dieter.devlieghere@benelux.amadeus.com>
*/
class FlightQualification
class FlightQualification extends WsMessageUtility
{
/**
* 7AP AP - Between Eastern Hemisphere (TC2) and Eastern Hemisphere (TC3) via Atlantic and Pacific
Expand Down Expand Up @@ -83,6 +85,8 @@ class FlightQualification
*/
public function __construct($discountQualifier = null)
{
$this->discountDetails[] = new DiscountDetails($discountQualifier);
if (!is_null($discountQualifier)) {
$this->discountDetails[] = new DiscountDetails($discountQualifier);
}
}
}
60 changes: 60 additions & 0 deletions src/Amadeus/Client/Struct/Fare/GetFareRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
use Amadeus\Client\Struct\BaseWsMessage;
use Amadeus\Client\Struct\Fare\CheckRules\ItemNumber;
use Amadeus\Client\Struct\Fare\ConvertCurrency\ConversionRate;
use Amadeus\Client\Struct\Fare\GetFareRules\FlightQualification;
use Amadeus\Client\Struct\Fare\GetFareRules\MultiCorporate;
use Amadeus\Client\Struct\Fare\GetFareRules\PricingTickInfo;
use Amadeus\Client\Struct\Fare\GetFareRules\TransportInformation;
use Amadeus\Client\Struct\Fare\GetFareRules\TripDescription;

/**
* Fare_GetFareRules request structure
Expand Down Expand Up @@ -121,12 +125,68 @@ public function __construct(FareGetFareRulesOptions $options)
$this->msgType = new MsgType(MessageFunctionDetails::FARE_GET_FARE_RULES);

$this->loadTicketingDate($options->ticketingDate);
$this->loadFlightQualification($options->fareBasis, $options->ticketDesignator, $options->directionality);
$this->loadMultiCorporate($options->uniFares, $options->negoFares);
$this->loadTransportInformation($options->airline);
$this->loadTripDescription($options->origin, $options->destination, $options->travelDate);
}

/**
* @param \DateTime|null $ticketingDate
*/
protected function loadTicketingDate($ticketingDate)
{
if ($ticketingDate instanceof \DateTime) {
$this->pricingTickInfo = new PricingTickInfo($ticketingDate);
}
}

/**
* @param string|null $fareBasis
* @param string|null $ticketDesignator
* @param string|null $directionality
*/
protected function loadFlightQualification($fareBasis, $ticketDesignator, $directionality)
{
if ($this->checkAnyNotEmpty($fareBasis, $ticketDesignator, $directionality)) {
$this->flightQualification[] = new FlightQualification(
$fareBasis,
$ticketDesignator,
$directionality
);
}
}

/**
* @param string[] $uniFares
* @param string[] $negoFares
*/
protected function loadMultiCorporate($uniFares, $negoFares)
{
if ($this->checkAnyNotEmpty($uniFares, $negoFares)) {
$this->multiCorporate = new MultiCorporate($uniFares, $negoFares);
}
}

/**
* @param string|null $airline
*/
protected function loadTransportInformation($airline)
{
if (!empty($airline)) {
$this->transportInformation[] = new TransportInformation($airline);
}
}

/**
* @param string|null $origin
* @param string|null $destination
* @param \DateTime|null $travelDate
*/
protected function loadTripDescription($origin, $destination, $travelDate)
{
if ($this->checkAnyNotEmpty($origin, $destination, $travelDate)) {
$this->tripDescription[] = new TripDescription($origin, $destination, $travelDate);
}
}
}
59 changes: 59 additions & 0 deletions src/Amadeus/Client/Struct/Fare/GetFareRules/CorporateId.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?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\Struct\Fare\GetFareRules;

/**
* CorporateId
*
* @package Amadeus\Client\Struct\Fare\GetFareRules
* @author Dieter Devlieghere <dieter.devlieghere@benelux.amadeus.com>
*/
class CorporateId
{
const QUAL_AMADEUS_NEGO_FARES = "RN";
const QUAL_UNIFARES = "RU";

/**
* self::QUAL_*
*
* @var string
*/
public $corporateQualifier;

/**
* @var string
*/
public $identity;

/**
* CorporateId constructor.
*
* @param string $identity
* @param string $corporateQualifier self::QUAL_*
*/
public function __construct($identity, $corporateQualifier)
{
$this->identity = $identity;
$this->corporateQualifier = $corporateQualifier;
}
}
57 changes: 57 additions & 0 deletions src/Amadeus/Client/Struct/Fare/GetFareRules/DateAndTimeDetails.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\Struct\Fare\GetFareRules;

/**
* DateAndTimeDetails
*
* @package Amadeus\Client\Struct\Fare\GetFareRules
* @author Dieter Devlieghere <dieter.devlieghere@benelux.amadeus.com>
*/
class DateAndTimeDetails
{
/**
* @var int|string
*/
public $qualifier;

/**
* @var string
*/
public $date;

/**
* @var string
*/
public $otherQualifier;

/**
* DateAndTimeDetails constructor.
*
* @param \DateTime $date
*/
public function __construct(\DateTime $date)
{
$this->date = $date->format('dmy');
}
}
47 changes: 47 additions & 0 deletions src/Amadeus/Client/Struct/Fare/GetFareRules/DateFlightMovement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?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\Struct\Fare\GetFareRules;

/**
* DateFlightMovement
*
* @package Amadeus\Client\Struct\Fare\GetFareRules
* @author Dieter Devlieghere <dieter.devlieghere@benelux.amadeus.com>
*/
class DateFlightMovement
{
/**
* @var DateAndTimeDetails[]
*/
public $dateAndTimeDetails = [];

/**
* DateFlightMovement constructor.
*
* @param \DateTime $travelDate
*/
public function __construct(\DateTime $travelDate)
{
$this->dateAndTimeDetails[] = new DateAndTimeDetails($travelDate);
}
}
35 changes: 35 additions & 0 deletions src/Amadeus/Client/Struct/Fare/GetFareRules/FareOptionDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,39 @@
*/
class FareOptionDetails
{
const QUAL_ORIGIN_TO_DESTINATION = "OD";
const QUAL_DESTINATION_TO_ORIGIN = "DO";
const QUAL_BOTH = "BD";

/**
* self::QUAL_*
*
* @var string
*/
public $fareQualifier;

/**
* @var string
*/
public $rateCategory;

/**
* @var string
*/
public $amount;

/**
* @var string
*/
public $percentage;

/**
* FareOptionDetails constructor.
*
* @param string $fareQualifier
*/
public function __construct($fareQualifier)
{
$this->fareQualifier = $fareQualifier;
}
}
Loading

0 comments on commit 94cf846

Please sign in to comment.