|
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; |
|
24
|
|
|
|
|
25
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef; |
|
26
|
|
|
use Amadeus\Client\RequestOptions\FarePricePnrWithBookingClassOptions; |
|
27
|
|
|
use Amadeus\Client\RequestOptions\FarePricePnrWithLowerFaresOptions as LowerFareOpt; |
|
28
|
|
|
use Amadeus\Client\RequestOptions\FarePricePnrWithLowestFareOptions as LowestFareOpt; |
|
29
|
|
|
use Amadeus\Client\Struct\BaseWsMessage; |
|
30
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\AttributeDetails; |
|
31
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\CarrierAgreements; |
|
32
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\CityDetail; |
|
33
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\CurrencyOverride; |
|
34
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\DateOverride; |
|
35
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\DiscountInformation; |
|
36
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\FrequentFlyerInformation; |
|
37
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\OverrideInformation; |
|
38
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\PenDisInformation; |
|
39
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\PricingFareBase; |
|
40
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\TaxDetails; |
|
41
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\ValidatingCarrier; |
|
42
|
|
|
use Amadeus\Client\Struct\OptionNotSupportedException; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Fare_PricePNRWithBookingClass v 12 and lower structure |
|
46
|
|
|
* |
|
47
|
|
|
* @package Amadeus\Client\Struct\Fare |
|
48
|
|
|
* @author dieter <[email protected]> |
|
49
|
|
|
*/ |
|
50
|
|
|
class PricePNRWithBookingClass12 extends BaseWsMessage |
|
51
|
|
|
{ |
|
52
|
|
|
public $pnrLocatorData; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var PricePnr12\PaxSegReference |
|
56
|
|
|
*/ |
|
57
|
|
|
public $paxSegReference; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var PricePnr12\OverrideInformation |
|
61
|
|
|
*/ |
|
62
|
|
|
public $overrideInformation; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @var PricePnr12\DateOverride |
|
66
|
|
|
*/ |
|
67
|
|
|
public $dateOverride; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @var PricePnr12\ValidatingCarrier |
|
71
|
|
|
*/ |
|
72
|
|
|
public $validatingCarrier; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @var PricePnr12\CityOverride |
|
76
|
|
|
*/ |
|
77
|
|
|
public $cityOverride; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @var PricePnr12\CurrencyOverride |
|
81
|
|
|
*/ |
|
82
|
|
|
public $currencyOverride; |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @var PricePnr12\TaxDetails[] |
|
86
|
|
|
*/ |
|
87
|
|
|
public $taxDetails = []; |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @var PricePnr12\DiscountInformation[] |
|
91
|
|
|
*/ |
|
92
|
|
|
public $discountInformation = []; |
|
93
|
|
|
/** |
|
94
|
|
|
* @var PricePnr12\PricingFareBase[] |
|
95
|
|
|
*/ |
|
96
|
|
|
public $pricingFareBase = []; |
|
97
|
|
|
|
|
98
|
|
|
public $flightInformation; |
|
99
|
|
|
|
|
100
|
|
|
public $openSegmentsInformation; |
|
101
|
|
|
|
|
102
|
|
|
public $bookingClassSelection; |
|
103
|
|
|
|
|
104
|
|
|
public $fopInformation; |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @var CarrierAgreements |
|
108
|
|
|
*/ |
|
109
|
|
|
public $carrierAgreements; |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @var FrequentFlyerInformation |
|
113
|
|
|
*/ |
|
114
|
|
|
public $frequentFlyerInformation; |
|
115
|
|
|
|
|
116
|
|
|
public $instantPricingOption; |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* PricePNRWithBookingClass12 constructor. |
|
120
|
|
|
* |
|
121
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt|null $options |
|
122
|
|
|
*/ |
|
123
|
115 |
|
public function __construct($options) |
|
124
|
|
|
{ |
|
125
|
115 |
|
$this->overrideInformation = new OverrideInformation(); |
|
126
|
|
|
|
|
127
|
115 |
|
if (!is_null($options)) { |
|
128
|
115 |
|
$this->loadPricingOptions($options); |
|
129
|
40 |
|
} |
|
130
|
100 |
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
134
|
|
|
*/ |
|
135
|
115 |
|
protected function loadPricingOptions($options) |
|
136
|
|
|
{ |
|
137
|
115 |
|
$this->checkUnsupportedOptions($options); |
|
138
|
|
|
|
|
139
|
100 |
|
$this->loadOverrideOptionsAndCorpFares($options); |
|
140
|
|
|
|
|
141
|
100 |
|
$this->loadCurrencyOverride($options->currencyOverride); |
|
142
|
|
|
|
|
143
|
100 |
|
$this->loadValidatingCarrier($options); |
|
144
|
|
|
|
|
145
|
100 |
|
$this->loadFareBasis($options); |
|
146
|
|
|
|
|
147
|
100 |
|
$this->loadPaxDiscount($options->paxDiscountCodes, $options->paxDiscountCodeRefs); |
|
148
|
|
|
|
|
149
|
100 |
|
$this->loadOverrideLocations($options); |
|
150
|
|
|
|
|
151
|
100 |
|
$this->loadTaxOptions($options); |
|
152
|
|
|
|
|
153
|
100 |
|
$this->loadReferences($options->references); |
|
154
|
|
|
|
|
155
|
100 |
|
$this->loadPastDate($options->pastDatePricing); |
|
156
|
100 |
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
160
|
|
|
* @throws OptionNotSupportedException |
|
161
|
|
|
*/ |
|
162
|
115 |
|
protected function checkUnsupportedOptions($options) |
|
163
|
|
|
{ |
|
164
|
115 |
|
if (!empty($options->obFees)) { |
|
165
|
5 |
|
throw new OptionNotSupportedException('OB Fees option not supported in version 12 or lower'); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
110 |
|
if (!empty($options->pricingLogic)) { |
|
169
|
5 |
|
throw new OptionNotSupportedException('Pricing Logic option not supported in version 12 or lower'); |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
105 |
|
if (!empty($options->overrideOptionsWithCriteria)) { |
|
173
|
5 |
|
throw new OptionNotSupportedException('Override Options With Criteria are not supported in version 12 or lower'); |
|
174
|
|
|
} |
|
175
|
100 |
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
179
|
|
|
*/ |
|
180
|
100 |
|
protected function loadOverrideOptionsAndCorpFares($options) |
|
181
|
|
|
{ |
|
182
|
100 |
|
foreach ($options->overrideOptions as $overrideOption) { |
|
183
|
25 |
|
$this->overrideInformation->attributeDetails[] = new AttributeDetails($overrideOption); |
|
184
|
40 |
|
} |
|
185
|
|
|
|
|
186
|
100 |
|
if (!empty($options->ticketType)) { |
|
187
|
5 |
|
$this->overrideInformation->attributeDetails[] = new AttributeDetails( |
|
188
|
5 |
|
$this->convertTicketType($options->ticketType) |
|
189
|
2 |
|
); |
|
190
|
2 |
|
} |
|
191
|
|
|
|
|
192
|
100 |
|
if ($options->corporateNegoFare !== null) { |
|
193
|
5 |
|
$this->overrideInformation->attributeDetails[] = new AttributeDetails( |
|
194
|
5 |
|
AttributeDetails::OVERRIDE_FARETYPE_CORPNR, |
|
195
|
5 |
|
$options->corporateNegoFare |
|
196
|
2 |
|
); |
|
197
|
2 |
|
} |
|
198
|
|
|
|
|
199
|
100 |
|
if (!empty($options->corporateUniFares)) { |
|
200
|
10 |
|
$this->loadCorporateUniFares($options->corporateUniFares); |
|
201
|
|
|
|
|
202
|
10 |
|
if (!empty($options->awardPricing)) { |
|
203
|
5 |
|
$this->carrierAgreements = new CarrierAgreements($options->awardPricing->carrier); |
|
204
|
5 |
|
$this->frequentFlyerInformation = new FrequentFlyerInformation($options->awardPricing->tierLevel); |
|
205
|
2 |
|
} |
|
206
|
4 |
|
} |
|
207
|
|
|
|
|
208
|
|
|
//No Options? |
|
209
|
100 |
|
if (empty($this->overrideInformation->attributeDetails)) { |
|
210
|
55 |
|
$this->overrideInformation->attributeDetails[] = new AttributeDetails( |
|
211
|
33 |
|
AttributeDetails::OVERRIDE_NO_OPTION |
|
212
|
22 |
|
); |
|
213
|
22 |
|
} |
|
214
|
100 |
|
} |
|
215
|
|
|
|
|
216
|
|
|
/** |
|
217
|
|
|
* @param string|null $currencyOverride |
|
218
|
|
|
*/ |
|
219
|
100 |
|
protected function loadCurrencyOverride($currencyOverride) |
|
220
|
|
|
{ |
|
221
|
100 |
|
if (!empty($currencyOverride)) { |
|
222
|
20 |
|
$this->currencyOverride = new CurrencyOverride($currencyOverride); |
|
223
|
8 |
|
} |
|
224
|
100 |
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* Convert new codes (Price PNR version 13+) to old format |
|
228
|
|
|
* |
|
229
|
|
|
* @param string $optionsTicketType |
|
230
|
|
|
* @return string|null |
|
231
|
|
|
*/ |
|
232
|
5 |
|
protected function convertTicketType($optionsTicketType) |
|
233
|
|
|
{ |
|
234
|
5 |
|
$converted = null; |
|
235
|
|
|
|
|
236
|
|
|
$map = [ |
|
237
|
5 |
|
FarePricePnrWithBookingClassOptions::TICKET_TYPE_ELECTRONIC => AttributeDetails::OVERRIDE_ELECTRONIC_TICKET, |
|
238
|
5 |
|
FarePricePnrWithBookingClassOptions::TICKET_TYPE_PAPER => AttributeDetails::OVERRIDE_PAPER_TICKET, |
|
239
|
5 |
|
FarePricePnrWithBookingClassOptions::TICKET_TYPE_BOTH => AttributeDetails::OVERRIDE_BOTH_TICKET, |
|
240
|
2 |
|
]; |
|
241
|
|
|
|
|
242
|
5 |
|
if (array_key_exists($optionsTicketType, $map)) { |
|
243
|
5 |
|
$converted = $map[$optionsTicketType]; |
|
244
|
2 |
|
} |
|
245
|
|
|
|
|
246
|
5 |
|
return $converted; |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* @param string[] $corporateUniFares |
|
251
|
|
|
*/ |
|
252
|
10 |
|
protected function loadCorporateUniFares($corporateUniFares) |
|
253
|
|
|
{ |
|
254
|
10 |
|
foreach ($corporateUniFares as $corporateUniFare) { |
|
255
|
10 |
|
$this->overrideInformation->attributeDetails[] = new AttributeDetails( |
|
256
|
10 |
|
AttributeDetails::OVERRIDE_FARETYPE_CORPUNI, |
|
257
|
4 |
|
$corporateUniFare |
|
258
|
4 |
|
); |
|
259
|
4 |
|
} |
|
260
|
10 |
|
} |
|
261
|
|
|
|
|
262
|
|
|
/** |
|
263
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
264
|
|
|
*/ |
|
265
|
100 |
|
protected function loadOverrideLocations($options) |
|
266
|
|
|
{ |
|
267
|
100 |
|
if (!empty($options->pointOfSaleOverride)) { |
|
268
|
5 |
|
$this->cityOverride = new PricePnr12\CityOverride( |
|
269
|
5 |
|
$options->pointOfSaleOverride, |
|
270
|
3 |
|
CityDetail::QUAL_POINT_OF_SALE |
|
271
|
2 |
|
); |
|
272
|
2 |
|
} |
|
273
|
|
|
|
|
274
|
100 |
|
if (!empty($options->pointOfTicketingOverride)) { |
|
275
|
10 |
|
if (empty($this->cityOverride)) { |
|
276
|
5 |
|
$this->cityOverride = new PricePnr12\CityOverride(); |
|
277
|
2 |
|
} |
|
278
|
10 |
|
$this->cityOverride->cityDetail[] = new PricePnr12\CityDetail( |
|
279
|
10 |
|
$options->pointOfTicketingOverride, |
|
280
|
6 |
|
CityDetail::QUAL_POINT_OF_TICKETING |
|
281
|
4 |
|
); |
|
282
|
4 |
|
} |
|
283
|
100 |
|
} |
|
284
|
|
|
|
|
285
|
|
|
/** |
|
286
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
287
|
|
|
*/ |
|
288
|
100 |
|
protected function loadValidatingCarrier($options) |
|
289
|
|
|
{ |
|
290
|
100 |
|
if (is_string($options->validatingCarrier)) { |
|
|
|
|
|
|
291
|
25 |
|
$this->validatingCarrier = new ValidatingCarrier($options->validatingCarrier); |
|
292
|
10 |
|
} |
|
293
|
100 |
|
} |
|
294
|
|
|
|
|
295
|
|
|
/** |
|
296
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
297
|
|
|
* |
|
298
|
|
|
*/ |
|
299
|
100 |
|
protected function loadFareBasis($options) |
|
300
|
|
|
{ |
|
301
|
100 |
|
$short = AttributeDetails::OVERRIDE_FAREBASIS; //Short var name because I get complaints from phpcs. No judging. |
|
302
|
100 |
|
if (in_array($short, $options->overrideOptions) && !empty($options->pricingsFareBasis)) { |
|
303
|
10 |
|
foreach ($options->pricingsFareBasis as $pricingFareBasis) { |
|
304
|
10 |
|
$this->pricingFareBase[] = new PricingFareBase($pricingFareBasis); |
|
305
|
4 |
|
} |
|
306
|
4 |
|
} |
|
307
|
100 |
|
} |
|
308
|
|
|
|
|
309
|
|
|
/** |
|
310
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
311
|
|
|
*/ |
|
312
|
100 |
|
protected function loadTaxOptions($options) |
|
313
|
|
|
{ |
|
314
|
100 |
|
foreach ($options->taxes as $tax) { |
|
315
|
5 |
|
$this->taxDetails[] = new TaxDetails($tax); |
|
316
|
40 |
|
} |
|
317
|
|
|
|
|
318
|
100 |
|
foreach ($options->exemptTaxes as $exemptTax) { |
|
319
|
5 |
|
$this->taxDetails[] = new TaxDetails($exemptTax); |
|
320
|
40 |
|
} |
|
321
|
100 |
|
} |
|
322
|
|
|
|
|
323
|
|
|
/** |
|
324
|
|
|
* @param string[] $paxDiscountCodes |
|
325
|
|
|
* @param PaxSegRef[] $refs |
|
326
|
|
|
*/ |
|
327
|
100 |
|
protected function loadPaxDiscount($paxDiscountCodes, $refs) |
|
328
|
|
|
{ |
|
329
|
100 |
|
if (!empty($paxDiscountCodes)) { |
|
330
|
15 |
|
$this->discountInformation[] = new DiscountInformation( |
|
331
|
15 |
|
PenDisInformation::QUAL_DISCOUNT, |
|
332
|
12 |
|
$paxDiscountCodes, |
|
333
|
6 |
|
$refs |
|
334
|
6 |
|
); |
|
335
|
6 |
|
} |
|
336
|
100 |
|
} |
|
337
|
|
|
|
|
338
|
|
|
/** |
|
339
|
|
|
* @param PaxSegRef[] $references |
|
340
|
|
|
*/ |
|
341
|
100 |
|
protected function loadReferences($references) |
|
342
|
|
|
{ |
|
343
|
100 |
|
if (!empty($references)) { |
|
344
|
5 |
|
$this->paxSegReference = new PricePnr12\PaxSegReference($references); |
|
345
|
2 |
|
} |
|
346
|
100 |
|
} |
|
347
|
|
|
|
|
348
|
|
|
/** |
|
349
|
|
|
* @param \DateTime|null $pastDate |
|
350
|
|
|
*/ |
|
351
|
100 |
|
protected function loadPastDate($pastDate) |
|
352
|
|
|
{ |
|
353
|
100 |
|
if ($pastDate instanceof \DateTime) { |
|
354
|
5 |
|
$this->dateOverride = new DateOverride(DateOverride::OPT_DATE_OVERRIDE, $pastDate); |
|
355
|
2 |
|
} |
|
356
|
100 |
|
} |
|
357
|
|
|
} |
|
358
|
|
|
|