1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* amadeus-ws-client |
4
|
|
|
* |
5
|
|
|
* Copyright 2015 Amadeus Benelux NV |
6
|
|
|
* |
7
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
8
|
|
|
* you may not use this file except in compliance with the License. |
9
|
|
|
* You may obtain a copy of the License at |
10
|
|
|
* |
11
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
12
|
|
|
* |
13
|
|
|
* Unless required by applicable law or agreed to in writing, software |
14
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
15
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16
|
|
|
* See the License for the specific language governing permissions and |
17
|
|
|
* limitations under the License. |
18
|
|
|
* |
19
|
|
|
* @package Amadeus |
20
|
|
|
* @license https://opensource.org/licenses/Apache-2.0 Apache 2.0 |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace Amadeus\Client\Struct\Fare\MasterPricer; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* FareOptions |
27
|
|
|
* |
28
|
|
|
* @package Amadeus\Client\Struct\Fare\MasterPricer |
29
|
|
|
* @author Dieter Devlieghere <[email protected]> |
30
|
|
|
*/ |
31
|
|
|
class FareOptions |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* @var PricingTickInfo |
35
|
|
|
*/ |
36
|
|
|
public $pricingTickInfo; |
37
|
|
|
/** |
38
|
|
|
* @var Corporate |
39
|
|
|
*/ |
40
|
|
|
public $corporate; |
41
|
|
|
|
42
|
|
|
public $ticketingPriceScheme; |
43
|
|
|
/** |
44
|
|
|
* @var FeeIdDescription |
45
|
|
|
*/ |
46
|
|
|
public $feeIdDescription; |
47
|
|
|
/** |
48
|
|
|
* @var ConversionRate |
49
|
|
|
*/ |
50
|
|
|
public $conversionRate; |
51
|
|
|
|
52
|
|
|
public $formOfPayment; |
53
|
|
|
|
54
|
|
|
public $frequentTravellerInfo; |
55
|
|
|
|
56
|
|
|
public $monetaryCabinInfo; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* FareOptions constructor. |
60
|
|
|
* |
61
|
|
|
* @param array $flightOptions List of flight / fare options |
62
|
|
|
* @param array $corpCodesUniFares list of Corporate codes for Corporate Unifares |
63
|
|
|
* @param bool $tickPreCheck Do Ticketability pre-check? |
64
|
|
|
* @param string|null $currency Override Currency conversion |
65
|
|
|
* @param \Amadeus\Client\RequestOptions\Fare\MPFeeId[]|null $flightOptions List of FeeIds |
66
|
|
|
*/ |
67
|
5 |
|
public function __construct(array $flightOptions, array $corpCodesUniFares, $tickPreCheck, $currency, $feeIds) |
68
|
|
|
{ |
69
|
5 |
|
if ($tickPreCheck === true) { |
70
|
1 |
|
$this->addPriceType(PricingTicketing::PRICETYPE_TICKETABILITY_PRECHECK); |
71
|
1 |
|
} |
72
|
|
|
|
73
|
5 |
|
foreach ($flightOptions as $flightOption) { |
74
|
2 |
|
$this->addPriceType($flightOption); |
75
|
|
|
|
76
|
2 |
|
if ($flightOption === PricingTicketing::PRICETYPE_CORPORATE_UNIFARES) { |
77
|
2 |
|
$this->corporate = new Corporate(); |
78
|
2 |
|
$this->corporate->corporateId[] = new CorporateId($corpCodesUniFares); |
79
|
2 |
|
} |
80
|
5 |
|
} |
81
|
|
|
|
82
|
5 |
|
$this->loadCurrencyOverride($currency); |
83
|
5 |
|
if (!is_null($feeIds)) { |
84
|
1 |
|
$this->loadFeeIds($feeIds); |
85
|
1 |
|
} |
86
|
5 |
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Set fee ids if needed |
90
|
|
|
* |
91
|
|
|
* @param \Amadeus\Client\RequestOptions\Fare\MPFeeId[] $feeIds |
92
|
|
|
*/ |
93
|
1 |
|
protected function loadFeeIds($feeIds) |
94
|
|
|
{ |
95
|
1 |
|
if (is_null($this->feeIdDescription)) { |
96
|
1 |
|
$this->feeIdDescription = new FeeIdDescription(); |
97
|
1 |
|
} |
98
|
1 |
|
foreach ($feeIds as $feeId) { |
99
|
1 |
|
$this->feeIdDescription->feeId[] = new FeeId($feeId->type, $feeId->number); |
100
|
1 |
|
} |
101
|
1 |
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Set currency override code if needed |
105
|
|
|
* |
106
|
|
|
* @param string|null $currency |
107
|
|
|
*/ |
108
|
5 |
|
protected function loadCurrencyOverride($currency) |
109
|
|
|
{ |
110
|
5 |
|
if (is_string($currency) && strlen($currency) === 3) { |
111
|
1 |
|
$this->addPriceType(PricingTicketing::PRICETYPE_OVERRIDE_CURRENCY_CONVERSION); |
112
|
|
|
|
113
|
1 |
|
$this->conversionRate = new ConversionRate($currency); |
114
|
1 |
|
} |
115
|
5 |
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Add PriceType |
119
|
|
|
* |
120
|
|
|
* @param string $type |
121
|
|
|
*/ |
122
|
4 |
|
protected function addPriceType($type) |
123
|
|
|
{ |
124
|
4 |
|
if (is_null($this->pricingTickInfo)) { |
125
|
4 |
|
$this->pricingTickInfo = new PricingTickInfo(); |
126
|
4 |
|
} |
127
|
4 |
|
if (is_null($this->pricingTickInfo->pricingTicketing)) { |
128
|
4 |
|
$this->pricingTickInfo->pricingTicketing = new PricingTicketing(); |
129
|
4 |
|
} |
130
|
|
|
|
131
|
4 |
|
$this->pricingTickInfo->pricingTicketing->priceType[] = $type; |
132
|
4 |
|
} |
133
|
|
|
} |
134
|
|
|
|