|
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\AwardPricing; |
|
26
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\ExemptTax; |
|
27
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef; |
|
28
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\Tax; |
|
29
|
|
|
use Amadeus\Client\RequestOptions\FarePricePnrWithBookingClassOptions; |
|
30
|
|
|
use Amadeus\Client\RequestOptions\FarePricePnrWithLowerFaresOptions as LowerFareOpt; |
|
31
|
|
|
use Amadeus\Client\RequestOptions\FarePricePnrWithLowestFareOptions as LowestFareOpt; |
|
32
|
|
|
use Amadeus\Client\Struct\BaseWsMessage; |
|
33
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\AttributeDetails; |
|
34
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\CarrierAgreements; |
|
35
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\CityDetail; |
|
36
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\CurrencyOverride; |
|
37
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\DateOverride; |
|
38
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\DiscountInformation; |
|
39
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\FrequentFlyerInformation; |
|
40
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\OverrideInformation; |
|
41
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\PenDisData; |
|
42
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\PenDisInformation; |
|
43
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\PricingFareBase; |
|
44
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\RefDetails; |
|
45
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\ReferenceQualifier; |
|
46
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\TaxDetails; |
|
47
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr12\ValidatingCarrier; |
|
48
|
|
|
use Amadeus\Client\Struct\OptionNotSupportedException; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Fare_PricePNRWithBookingClass v 12 and lower structure |
|
52
|
|
|
* |
|
53
|
|
|
* @package Amadeus\Client\Struct\Fare |
|
54
|
|
|
* @author dieter <[email protected]> |
|
55
|
|
|
*/ |
|
56
|
|
|
class PricePNRWithBookingClass12 extends BaseWsMessage |
|
57
|
|
|
{ |
|
58
|
|
|
public $pnrLocatorData; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @var PricePnr12\PaxSegReference |
|
62
|
|
|
*/ |
|
63
|
|
|
public $paxSegReference; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @var PricePnr12\OverrideInformation |
|
67
|
|
|
*/ |
|
68
|
|
|
public $overrideInformation; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @var PricePnr12\DateOverride |
|
72
|
|
|
*/ |
|
73
|
|
|
public $dateOverride; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @var PricePnr12\ValidatingCarrier |
|
77
|
|
|
*/ |
|
78
|
|
|
public $validatingCarrier; |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @var PricePnr12\CityOverride |
|
82
|
|
|
*/ |
|
83
|
|
|
public $cityOverride; |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @var PricePnr12\CurrencyOverride |
|
87
|
|
|
*/ |
|
88
|
|
|
public $currencyOverride; |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @var PricePnr12\TaxDetails[] |
|
92
|
|
|
*/ |
|
93
|
|
|
public $taxDetails = []; |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @var PricePnr12\DiscountInformation[] |
|
97
|
|
|
*/ |
|
98
|
|
|
public $discountInformation = []; |
|
99
|
|
|
/** |
|
100
|
|
|
* @var PricePnr12\PricingFareBase[] |
|
101
|
|
|
*/ |
|
102
|
|
|
public $pricingFareBase = []; |
|
103
|
|
|
|
|
104
|
|
|
public $flightInformation; |
|
105
|
|
|
|
|
106
|
|
|
public $openSegmentsInformation; |
|
107
|
|
|
|
|
108
|
|
|
public $bookingClassSelection; |
|
109
|
|
|
|
|
110
|
|
|
public $fopInformation; |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @var CarrierAgreements |
|
114
|
|
|
*/ |
|
115
|
|
|
public $carrierAgreements; |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @var FrequentFlyerInformation |
|
119
|
|
|
*/ |
|
120
|
|
|
public $frequentFlyerInformation; |
|
121
|
|
|
|
|
122
|
|
|
public $instantPricingOption; |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* PricePNRWithBookingClass12 constructor. |
|
126
|
|
|
* |
|
127
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt|null $options |
|
128
|
|
|
*/ |
|
129
|
|
|
public function __construct($options) |
|
130
|
|
|
{ |
|
131
|
|
|
if (!is_null($options)) { |
|
132
|
|
|
$this->checkUnsupportedOptions($options); |
|
133
|
|
|
|
|
134
|
|
|
$this->overrideInformation = new OverrideInformation(); |
|
135
|
|
|
|
|
136
|
|
|
$this->loadOverrideOptions($options); |
|
137
|
|
|
|
|
138
|
|
|
$this->loadValidatingCarrier($options); |
|
139
|
|
|
|
|
140
|
|
|
$this->loadFareBasis($options); |
|
141
|
|
|
|
|
142
|
|
|
$this->loadCorporateFares($options); |
|
143
|
|
|
|
|
144
|
|
|
$this->loadPaxDiscount($options->paxDiscountCodes, $options->paxDiscountCodeRefs); |
|
145
|
|
|
|
|
146
|
|
|
$this->loadOverrideLocations($options); |
|
147
|
|
|
|
|
148
|
|
|
$this->loadTaxOptions($options); |
|
149
|
|
|
|
|
150
|
|
|
$this->loadReferences($options->references); |
|
151
|
|
|
|
|
152
|
|
|
$this->loadPastDate($options->pastDatePricing); |
|
153
|
|
|
|
|
154
|
|
|
//No Options? |
|
155
|
|
|
if (empty($this->overrideInformation->attributeDetails)) { |
|
156
|
|
|
$this->overrideInformation->attributeDetails[] = new AttributeDetails( |
|
157
|
|
|
AttributeDetails::OVERRIDE_NO_OPTION |
|
158
|
|
|
); |
|
159
|
|
|
} |
|
160
|
|
|
} |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
165
|
|
|
* @throws OptionNotSupportedException |
|
166
|
|
|
*/ |
|
167
|
|
|
protected function checkUnsupportedOptions($options) |
|
168
|
|
|
{ |
|
169
|
|
|
if (!empty($options->obFees)) { |
|
170
|
|
|
throw new OptionNotSupportedException('OB Fees option not supported in version 12 or lower'); |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
if (!empty($options->pricingLogic)) { |
|
174
|
|
|
throw new OptionNotSupportedException('Pricing Logic option not supported in version 12 or lower'); |
|
175
|
|
|
} |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
180
|
|
|
*/ |
|
181
|
|
|
protected function loadOverrideOptions($options) |
|
182
|
|
|
{ |
|
183
|
|
|
if (count($options->overrideOptions) !== 0) { |
|
184
|
|
|
foreach ($options->overrideOptions as $overrideOption) { |
|
185
|
|
|
$this->overrideInformation->attributeDetails[] = new AttributeDetails($overrideOption); |
|
186
|
|
|
} |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
if (!empty($options->currencyOverride)) { |
|
190
|
|
|
$this->currencyOverride = new CurrencyOverride($options->currencyOverride); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
if (!empty($options->ticketType)) { |
|
194
|
|
|
$this->overrideInformation->attributeDetails[] = new AttributeDetails( |
|
195
|
|
|
$this->convertTicketType($options->ticketType) |
|
196
|
|
|
); |
|
197
|
|
|
} |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* Convert new codes (Price PNR version 13+) to old format |
|
202
|
|
|
* |
|
203
|
|
|
* @param string $optionsTicketType |
|
204
|
|
|
* @return string|null |
|
205
|
|
|
*/ |
|
206
|
|
|
protected function convertTicketType($optionsTicketType) |
|
207
|
|
|
{ |
|
208
|
|
|
$converted = null; |
|
209
|
|
|
|
|
210
|
|
|
$map = [ |
|
211
|
|
|
FarePricePnrWithBookingClassOptions::TICKET_TYPE_ELECTRONIC => AttributeDetails::OVERRIDE_ELECTRONIC_TICKET, |
|
212
|
|
|
FarePricePnrWithBookingClassOptions::TICKET_TYPE_PAPER => AttributeDetails::OVERRIDE_PAPER_TICKET, |
|
213
|
|
|
FarePricePnrWithBookingClassOptions::TICKET_TYPE_BOTH => AttributeDetails::OVERRIDE_BOTH_TICKET, |
|
214
|
|
|
]; |
|
215
|
|
|
|
|
216
|
|
|
if (array_key_exists($optionsTicketType, $map)) { |
|
217
|
|
|
$converted = $map[$optionsTicketType]; |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
return $converted; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
/** |
|
224
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
225
|
|
|
*/ |
|
226
|
|
|
protected function loadCorporateFares($options) |
|
227
|
|
|
{ |
|
228
|
|
|
if ($options->corporateNegoFare !== null) { |
|
229
|
|
|
$this->loadCorporateNegoFare($options->corporateNegoFare); |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
if (!empty($options->corporateUniFares)) { |
|
233
|
|
|
$this->loadCorporateUniFares($options->corporateUniFares); |
|
234
|
|
|
|
|
235
|
|
|
if (!empty($options->awardPricing)) { |
|
236
|
|
|
$this->loadAwardPricing($options->awardPricing); |
|
237
|
|
|
} |
|
238
|
|
|
} |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
/** |
|
242
|
|
|
* @param string $corporateNegoFare |
|
243
|
|
|
*/ |
|
244
|
|
|
protected function loadCorporateNegoFare($corporateNegoFare) |
|
245
|
|
|
{ |
|
246
|
|
|
$this->overrideInformation->attributeDetails[] = new AttributeDetails( |
|
247
|
|
|
AttributeDetails::OVERRIDE_FARETYPE_CORPNR, |
|
248
|
|
|
$corporateNegoFare |
|
249
|
|
|
); |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
/** |
|
253
|
|
|
* @param string[] $corporateUniFares |
|
254
|
|
|
*/ |
|
255
|
|
|
protected function loadCorporateUniFares($corporateUniFares) |
|
256
|
|
|
{ |
|
257
|
|
|
foreach ($corporateUniFares as $corporateUniFare) { |
|
258
|
|
|
$this->overrideInformation->attributeDetails[] = new AttributeDetails( |
|
259
|
|
|
AttributeDetails::OVERRIDE_FARETYPE_CORPUNI, |
|
260
|
|
|
$corporateUniFare |
|
261
|
|
|
); |
|
262
|
|
|
} |
|
263
|
|
|
} |
|
264
|
|
|
|
|
265
|
|
|
/** |
|
266
|
|
|
* @param AwardPricing $awardPricing |
|
267
|
|
|
*/ |
|
268
|
|
|
protected function loadAwardPricing($awardPricing) |
|
269
|
|
|
{ |
|
270
|
|
|
$this->carrierAgreements = new CarrierAgreements($awardPricing->carrier); |
|
271
|
|
|
$this->frequentFlyerInformation = new FrequentFlyerInformation($awardPricing->tierLevel); |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
/** |
|
275
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
276
|
|
|
*/ |
|
277
|
|
|
protected function loadOverrideLocations($options) |
|
278
|
|
|
{ |
|
279
|
|
|
if (!empty($options->pointOfSaleOverride)) { |
|
280
|
|
|
$this->cityOverride = new PricePnr12\CityOverride( |
|
281
|
|
|
$options->pointOfSaleOverride, |
|
282
|
|
|
CityDetail::QUAL_POINT_OF_SALE |
|
283
|
|
|
); |
|
284
|
|
|
} |
|
285
|
|
|
|
|
286
|
|
|
if (!empty($options->pointOfTicketingOverride)) { |
|
287
|
|
|
if (empty($this->cityOverride)) { |
|
288
|
|
|
$this->cityOverride = new PricePnr12\CityOverride(); |
|
289
|
|
|
} |
|
290
|
|
|
$this->cityOverride->cityDetail[] = new PricePnr12\CityDetail( |
|
291
|
|
|
$options->pointOfTicketingOverride, |
|
292
|
|
|
CityDetail::QUAL_POINT_OF_TICKETING |
|
293
|
|
|
); |
|
294
|
|
|
} |
|
295
|
|
|
} |
|
296
|
|
|
|
|
297
|
|
|
/** |
|
298
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
299
|
|
|
*/ |
|
300
|
|
|
protected function loadValidatingCarrier($options) |
|
301
|
|
|
{ |
|
302
|
|
|
if (is_string($options->validatingCarrier)) { |
|
303
|
|
|
$this->validatingCarrier = new ValidatingCarrier($options->validatingCarrier); |
|
304
|
|
|
} |
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
/** |
|
308
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
309
|
|
|
* |
|
310
|
|
|
*/ |
|
311
|
|
|
protected function loadFareBasis($options) |
|
312
|
|
|
{ |
|
313
|
|
|
$short = AttributeDetails::OVERRIDE_FAREBASIS; //Short var name because I get complaints from phpcs. No judging. |
|
314
|
|
|
if (in_array($short, $options->overrideOptions) && !empty($options->pricingsFareBasis)) { |
|
315
|
|
|
foreach ($options->pricingsFareBasis as $pricingFareBasis) { |
|
316
|
|
|
$this->pricingFareBase[] = new PricingFareBase($pricingFareBasis); |
|
317
|
|
|
} |
|
318
|
|
|
} |
|
319
|
|
|
} |
|
320
|
|
|
|
|
321
|
|
|
/** |
|
322
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options |
|
323
|
|
|
*/ |
|
324
|
|
|
protected function loadTaxOptions($options) |
|
325
|
|
|
{ |
|
326
|
|
|
if (!empty($options->taxes)) { |
|
327
|
|
|
$this->loadTaxes($options->taxes); |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
if (!empty($options->exemptTaxes)) { |
|
331
|
|
|
$this->loadExemptTaxes($options->exemptTaxes); |
|
332
|
|
|
} |
|
333
|
|
|
} |
|
334
|
|
|
|
|
335
|
|
|
/** |
|
336
|
|
|
* @param Tax[] $taxes |
|
337
|
|
|
*/ |
|
338
|
|
|
protected function loadTaxes($taxes) |
|
339
|
|
|
{ |
|
340
|
|
|
foreach ($taxes as $tax) { |
|
341
|
|
|
$this->taxDetails[] = new TaxDetails($tax); |
|
342
|
|
|
} |
|
343
|
|
|
} |
|
344
|
|
|
|
|
345
|
|
|
/** |
|
346
|
|
|
* @param ExemptTax[] $exemptTaxes |
|
347
|
|
|
*/ |
|
348
|
|
|
protected function loadExemptTaxes($exemptTaxes) |
|
349
|
|
|
{ |
|
350
|
|
|
foreach ($exemptTaxes as $exemptTax) { |
|
351
|
|
|
$this->taxDetails[] = new TaxDetails($exemptTax); |
|
352
|
|
|
} |
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
|
|
/** |
|
356
|
|
|
* @param string[] $paxDiscountCodes |
|
357
|
|
|
* @param PaxSegRef[] $refs |
|
358
|
|
|
*/ |
|
359
|
|
|
protected function loadPaxDiscount($paxDiscountCodes, $refs) |
|
360
|
|
|
{ |
|
361
|
|
|
if (!empty($paxDiscountCodes)) { |
|
362
|
|
|
$tmp = new DiscountInformation(); |
|
363
|
|
|
$tmp->penDisInformation = new PenDisInformation(); |
|
364
|
|
|
$tmp->penDisInformation->infoQualifier = PenDisInformation::QUAL_DISCOUNT; |
|
365
|
|
|
|
|
366
|
|
|
foreach ($paxDiscountCodes as $discountCode) { |
|
367
|
|
|
$tmp->penDisInformation->penDisData[] = new PenDisData($discountCode); |
|
368
|
|
|
} |
|
369
|
|
|
|
|
370
|
|
View Code Duplication |
if (!empty($refs)) { |
|
|
|
|
|
|
371
|
|
|
$tmp->referenceQualifier = new ReferenceQualifier(); |
|
372
|
|
|
|
|
373
|
|
|
foreach ($refs as $ref) { |
|
374
|
|
|
$tmp->referenceQualifier->refDetails[] = new RefDetails($ref->reference, $ref->type); |
|
375
|
|
|
} |
|
376
|
|
|
} |
|
377
|
|
|
|
|
378
|
|
|
$this->discountInformation[] = $tmp; |
|
379
|
|
|
} |
|
380
|
|
|
} |
|
381
|
|
|
|
|
382
|
|
|
/** |
|
383
|
|
|
* @param PaxSegRef[] $references |
|
384
|
|
|
*/ |
|
385
|
|
|
protected function loadReferences($references) |
|
386
|
|
|
{ |
|
387
|
|
View Code Duplication |
if (!empty($references)) { |
|
|
|
|
|
|
388
|
|
|
$this->paxSegReference = new PricePnr12\PaxSegReference(); |
|
389
|
|
|
|
|
390
|
|
|
foreach ($references as $ref) { |
|
391
|
|
|
$this->paxSegReference->refDetails[] = new RefDetails( |
|
392
|
|
|
$ref->reference, |
|
393
|
|
|
$ref->type |
|
394
|
|
|
); |
|
395
|
|
|
} |
|
396
|
|
|
} |
|
397
|
|
|
} |
|
398
|
|
|
|
|
399
|
|
|
/** |
|
400
|
|
|
* @param \DateTime|null $pastDate |
|
401
|
|
|
*/ |
|
402
|
|
|
protected function loadPastDate($pastDate) |
|
403
|
|
|
{ |
|
404
|
|
|
if ($pastDate instanceof \DateTime) { |
|
405
|
|
|
$this->dateOverride = new DateOverride(DateOverride::OPT_DATE_OVERRIDE, $pastDate); |
|
406
|
|
|
} |
|
407
|
|
|
} |
|
408
|
|
|
} |
|
409
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.