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\RequestCreator\MessageVersionUnsupportedException; |
26
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\AwardPricing; |
27
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\ExemptTax; |
28
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\FareBasis; |
29
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\FormOfPayment; |
30
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\ObFee; |
31
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef; |
32
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\Tax; |
33
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\ZapOff; |
34
|
|
|
use Amadeus\Client\RequestOptions\FarePricePnrWithBookingClassOptions; |
35
|
|
|
use Amadeus\Client\RequestOptions\FarePricePnrWithLowerFaresOptions as LowerFareOpt; |
36
|
|
|
use Amadeus\Client\RequestOptions\FarePricePnrWithLowestFareOptions as LowestFareOpt; |
37
|
|
|
use Amadeus\Client\RequestOptions\Fare\InformativePricing\PricingOptions as InformativePriceOpt; |
38
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\CarrierInformation; |
39
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\Currency; |
40
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\DateInformation; |
41
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\FormOfPaymentInformation; |
42
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\FrequentFlyerInformation; |
43
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\FrequentTravellerDetails; |
44
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\LocationInformation; |
45
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\OptionDetail; |
46
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\PaxSegTstReference; |
47
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\PenDisInformation; |
48
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionGroup; |
49
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionKey; |
50
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\TaxData; |
51
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\TaxInformation; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Fare_PricePNRWithBookingClass v 13 and higher structure |
55
|
|
|
* |
56
|
|
|
* @package Amadeus\Client\Struct\Fare |
57
|
|
|
* @author dieter <[email protected]> |
58
|
|
|
*/ |
59
|
|
|
class PricePNRWithBookingClass13 extends BasePricingMessage |
60
|
|
|
{ |
61
|
|
|
/** |
62
|
|
|
* @var PricePnr13\PricingOptionGroup[] |
63
|
|
|
*/ |
64
|
|
|
public $pricingOptionGroup = []; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* PricePNRWithBookingClass13 constructor. |
68
|
|
|
* |
69
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt|InformativePriceOpt|null $options |
70
|
|
|
* @throws MessageVersionUnsupportedException |
71
|
120 |
|
*/ |
72
|
|
|
public function __construct($options) |
73
|
120 |
|
{ |
74
|
120 |
|
if (!is_null($options)) { |
75
|
48 |
|
$this->pricingOptionGroup = $this->loadPricingOptionsFromRequestOptions($options); |
76
|
120 |
|
} |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Load an array of PricingOptionGroup objects from the Pricing request options. |
81
|
|
|
* |
82
|
|
|
* Extracted because this method is also used in the InformativePricingWithoutPnr messages. |
83
|
|
|
* |
84
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt|InformativePriceOpt $options |
85
|
|
|
* @return PricingOptionGroup[] |
86
|
155 |
|
*/ |
87
|
|
|
public static function loadPricingOptionsFromRequestOptions($options) |
88
|
155 |
|
{ |
89
|
|
|
$priceOptions = []; |
90
|
155 |
|
|
91
|
155 |
|
$priceOptions = self::mergeOptions( |
92
|
155 |
|
$priceOptions, |
93
|
62 |
|
self::makePricingOptionForValidatingCarrier($options->validatingCarrier) |
94
|
|
|
); |
95
|
155 |
|
|
96
|
155 |
|
$priceOptions = self::mergeOptions( |
97
|
155 |
|
$priceOptions, |
98
|
62 |
|
self::makePricingOptionForCurrencyOverride($options->currencyOverride) |
99
|
|
|
); |
100
|
155 |
|
|
101
|
155 |
|
$priceOptions = self::mergeOptions( |
102
|
155 |
|
$priceOptions, |
103
|
62 |
|
self::makePricingOptionFareBasisOverride($options->pricingsFareBasis) |
104
|
|
|
); |
105
|
155 |
|
|
106
|
155 |
|
$priceOptions = self::mergeOptions( |
107
|
155 |
|
$priceOptions, |
108
|
62 |
|
self::makePricingOptionFareFamilyOverride($options->fareFamily) |
109
|
|
|
); |
110
|
155 |
|
|
111
|
155 |
|
$priceOptions = self::mergeOptions( |
112
|
155 |
|
$priceOptions, |
113
|
62 |
|
self::loadCorpNegoFare($options->corporateNegoFare) |
114
|
|
|
); |
115
|
155 |
|
|
116
|
155 |
|
$priceOptions = self::mergeOptions( |
117
|
155 |
|
$priceOptions, |
118
|
62 |
|
self::loadCorpUniFares($options->corporateUniFares, $options->awardPricing) |
119
|
|
|
); |
120
|
155 |
|
|
121
|
155 |
|
$priceOptions = self::mergeOptions( |
122
|
155 |
|
$priceOptions, |
123
|
62 |
|
self::loadObFees($options->obFees, $options->obFeeRefs) |
124
|
|
|
); |
125
|
155 |
|
|
126
|
155 |
|
$priceOptions = self::mergeOptions( |
127
|
155 |
|
$priceOptions, |
128
|
62 |
|
self::loadPaxDiscount($options->paxDiscountCodes, $options->paxDiscountCodeRefs) |
129
|
|
|
); |
130
|
155 |
|
|
131
|
155 |
|
$priceOptions = self::mergeOptions( |
132
|
155 |
|
$priceOptions, |
133
|
155 |
|
self::loadPointOverrides( |
134
|
155 |
|
$options->pointOfSaleOverride, |
135
|
62 |
|
$options->pointOfTicketingOverride |
136
|
62 |
|
) |
137
|
|
|
); |
138
|
155 |
|
|
139
|
155 |
|
$priceOptions = self::mergeOptions( |
140
|
155 |
|
$priceOptions, |
141
|
62 |
|
self::loadPricingLogic($options->pricingLogic) |
142
|
|
|
); |
143
|
155 |
|
|
144
|
155 |
|
$priceOptions = self::mergeOptions( |
145
|
155 |
|
$priceOptions, |
146
|
62 |
|
self::loadTicketType($options->ticketType) |
147
|
|
|
); |
148
|
155 |
|
|
149
|
155 |
|
$priceOptions = self::mergeOptions( |
150
|
155 |
|
$priceOptions, |
151
|
62 |
|
self::loadTaxes($options->taxes) |
152
|
|
|
); |
153
|
155 |
|
|
154
|
155 |
|
$priceOptions = self::mergeOptions( |
155
|
155 |
|
$priceOptions, |
156
|
62 |
|
self::loadExemptTaxes($options->exemptTaxes) |
157
|
|
|
); |
158
|
155 |
|
|
159
|
155 |
|
$priceOptions = self::mergeOptions( |
160
|
155 |
|
$priceOptions, |
161
|
62 |
|
self::loadPastDate($options->pastDatePricing) |
162
|
|
|
); |
163
|
|
|
|
164
|
155 |
|
|
165
|
155 |
|
$priceOptions = self::mergeOptions( |
166
|
155 |
|
$priceOptions, |
167
|
62 |
|
self::loadFormOfPayment($options->formOfPayment) |
168
|
|
|
); |
169
|
155 |
|
|
170
|
155 |
|
$priceOptions = self::mergeOptions( |
171
|
155 |
|
$priceOptions, |
172
|
62 |
|
self::loadReferences($options->references) |
173
|
|
|
); |
174
|
155 |
|
|
175
|
155 |
|
$priceOptions = self::mergeOptions( |
176
|
155 |
|
$priceOptions, |
177
|
62 |
|
self::makeOverrideOptions($options->overrideOptions, $priceOptions) |
178
|
|
|
); |
179
|
155 |
|
|
180
|
155 |
|
$priceOptions = self::mergeOptions( |
181
|
155 |
|
$priceOptions, |
182
|
62 |
|
self::makeOverrideOptionsWithCriteria($options->overrideOptionsWithCriteria, $priceOptions) |
183
|
|
|
); |
184
|
|
|
|
185
|
155 |
|
$priceOptions = self::mergeOptions( |
186
|
30 |
|
$priceOptions, |
187
|
12 |
|
self::loadZapOffs($options->zapOff) |
188
|
|
|
); |
189
|
155 |
|
|
190
|
|
|
// All options processed, no options found: |
191
|
|
|
if (empty($priceOptions)) { |
192
|
|
|
$priceOptions[] = new PricingOptionGroup(PricingOptionKey::OPTION_NO_OPTION); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
return $priceOptions; |
196
|
|
|
} |
197
|
155 |
|
|
198
|
|
|
/** |
199
|
155 |
|
* @param string[] $overrideOptions |
200
|
|
|
* @param PricingOptionGroup[] $priceOptions |
201
|
155 |
|
* @return PricingOptionGroup[] |
202
|
40 |
|
*/ |
203
|
40 |
View Code Duplication |
protected static function makeOverrideOptions($overrideOptions, $priceOptions) |
|
|
|
|
204
|
16 |
|
{ |
205
|
62 |
|
$opt = []; |
206
|
|
|
|
207
|
155 |
|
foreach ($overrideOptions as $overrideOption) { |
208
|
|
|
if (!self::hasPricingGroup($overrideOption, $priceOptions)) { |
209
|
|
|
$opt[] = new PricingOptionGroup($overrideOption); |
210
|
|
|
} |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
return $opt; |
214
|
|
|
} |
215
|
155 |
|
|
216
|
|
|
/** |
217
|
155 |
|
* @param string[] $overrideOptionsWithCriteria |
218
|
|
|
* @param PricingOptionGroup[] $priceOptions |
219
|
155 |
|
* @return PricingOptionGroup[] |
220
|
5 |
|
*/ |
221
|
5 |
|
protected static function makeOverrideOptionsWithCriteria($overrideOptionsWithCriteria, $priceOptions) |
222
|
2 |
|
{ |
223
|
62 |
|
$opt = []; |
224
|
|
|
|
225
|
155 |
|
foreach ($overrideOptionsWithCriteria as $overrideOptionWithCriteria) { |
226
|
|
|
if (!self::hasPricingGroup($overrideOptionWithCriteria["key"], $priceOptions)) { |
227
|
|
|
$opt[] = new PricingOptionGroup($overrideOptionWithCriteria["key"], $overrideOptionWithCriteria["optionDetail"]); |
228
|
|
|
} |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
return $opt; |
232
|
155 |
|
} |
233
|
|
|
|
234
|
155 |
|
/** |
235
|
|
|
* @param string|null $validatingCarrier |
236
|
155 |
|
* @return PricePnr13\PricingOptionGroup[] |
237
|
40 |
|
*/ |
238
|
|
View Code Duplication |
protected static function makePricingOptionForValidatingCarrier($validatingCarrier) |
|
|
|
|
239
|
40 |
|
{ |
240
|
|
|
$opt = []; |
241
|
40 |
|
|
242
|
16 |
|
if ($validatingCarrier !== null) { |
243
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_VALIDATING_CARRIER); |
244
|
155 |
|
|
245
|
|
|
$po->carrierInformation = new CarrierInformation($validatingCarrier); |
246
|
|
|
|
247
|
|
|
$opt[] = $po; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
return $opt; |
251
|
155 |
|
} |
252
|
|
|
|
253
|
155 |
|
/** |
254
|
|
|
* @param string|null $currency |
255
|
155 |
|
* @return PricePnr13\PricingOptionGroup[] |
256
|
40 |
|
*/ |
257
|
|
View Code Duplication |
protected static function makePricingOptionForCurrencyOverride($currency) |
|
|
|
|
258
|
40 |
|
{ |
259
|
|
|
$opt = []; |
260
|
40 |
|
|
261
|
16 |
|
if ($currency !== null) { |
262
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_CURRENCY_OVERRIDE); |
263
|
155 |
|
|
264
|
|
|
$po->currency = new Currency($currency); |
265
|
|
|
|
266
|
|
|
$opt[] = $po; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
return $opt; |
270
|
|
|
} |
271
|
155 |
|
|
272
|
|
|
|
273
|
155 |
|
/** |
274
|
|
|
* @param FareBasis[] $pricingsFareBasis |
275
|
155 |
|
* @return PricePnr13\PricingOptionGroup[] |
276
|
155 |
|
*/ |
277
|
20 |
View Code Duplication |
protected static function makePricingOptionFareBasisOverride($pricingsFareBasis) |
|
|
|
|
278
|
|
|
{ |
279
|
|
|
$opt = []; |
280
|
20 |
|
|
281
|
20 |
|
if ($pricingsFareBasis !== null) { |
282
|
8 |
|
foreach ($pricingsFareBasis as $pricingFareBasis) { |
283
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_BASIS_SIMPLE_OVERRIDE); |
284
|
|
|
|
285
|
20 |
|
//Support for legacy fareBasisPrimaryCode to be removed when breaking BC: |
286
|
20 |
|
$po->optionDetail = new OptionDetail( |
287
|
20 |
|
$pricingFareBasis->fareBasisPrimaryCode.$pricingFareBasis->fareBasisCode |
|
|
|
|
288
|
8 |
|
); |
289
|
|
|
|
290
|
20 |
|
//Support for legacy segmentReference to be removed when breaking BC: |
291
|
62 |
|
$po->paxSegTstReference = new PaxSegTstReference( |
292
|
62 |
|
$pricingFareBasis->references, |
293
|
|
|
$pricingFareBasis->segmentReference |
|
|
|
|
294
|
155 |
|
); |
295
|
|
|
|
296
|
|
|
$opt[] = $po; |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
return $opt; |
301
|
|
|
} |
302
|
|
|
|
303
|
155 |
|
/** |
304
|
|
|
* Load fare-family pricing option and return it. |
305
|
155 |
|
* |
306
|
|
|
* @param string $fareFamily input fare-family, e.g. "CLASSIC" |
307
|
155 |
|
* @return PricePnr13\PricingOptionGroup[] |
308
|
5 |
|
*/ |
309
|
5 |
|
protected static function makePricingOptionFareFamilyOverride($fareFamily) |
310
|
|
|
{ |
311
|
5 |
|
$opt = []; |
312
|
2 |
|
|
313
|
|
|
if ($fareFamily !== null) { |
314
|
155 |
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_FAMILY); |
315
|
|
|
$po->optionDetail = new OptionDetail([['FF' => $fareFamily]]); |
316
|
|
|
|
317
|
|
|
$opt[] = $po; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
return $opt; |
321
|
|
|
} |
322
|
|
|
|
323
|
155 |
|
/** |
324
|
|
|
* Load corporate negofare |
325
|
155 |
|
* |
326
|
|
|
* @param string|null $corporateNegoFare |
327
|
155 |
|
* @return PricingOptionGroup[] |
328
|
5 |
|
*/ |
329
|
|
View Code Duplication |
protected static function loadCorpNegoFare($corporateNegoFare) |
|
|
|
|
330
|
5 |
|
{ |
331
|
|
|
$opt = []; |
332
|
5 |
|
|
333
|
2 |
|
if ($corporateNegoFare !== null) { |
334
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_NEGOTIATED_FARES); |
335
|
155 |
|
|
336
|
|
|
$po->optionDetail = new OptionDetail($corporateNegoFare); |
337
|
|
|
|
338
|
|
|
$opt[] = $po; |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
return $opt; |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
/** |
345
|
155 |
|
* Load corporate unifares |
346
|
|
|
* |
347
|
155 |
|
* @param string[] $corporateUniFares |
348
|
|
|
* @param AwardPricing|null $awardPricing |
349
|
155 |
|
* @return PricingOptionGroup[] |
350
|
10 |
|
*/ |
351
|
10 |
|
protected static function loadCorpUniFares($corporateUniFares, $awardPricing) |
352
|
10 |
|
{ |
353
|
|
|
$opt = []; |
354
|
10 |
|
|
355
|
5 |
|
if (!empty($corporateUniFares)) { |
356
|
2 |
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_UNIFARES); |
357
|
4 |
|
$po->optionDetail = new OptionDetail($corporateUniFares); |
358
|
|
|
$opt[] = $po; |
359
|
155 |
|
|
360
|
|
|
if (!empty($awardPricing)) { |
361
|
|
|
$opt[] = self::loadAwardPricing($awardPricing); |
362
|
|
|
} |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
return $opt; |
366
|
5 |
|
} |
367
|
|
|
|
368
|
5 |
|
/** |
369
|
|
|
* @param AwardPricing $awardPricing |
370
|
5 |
|
* @return PricingOptionGroup |
371
|
|
|
*/ |
372
|
5 |
View Code Duplication |
protected static function loadAwardPricing($awardPricing) |
|
|
|
|
373
|
5 |
|
{ |
374
|
5 |
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_AWARD_PRICING); |
375
|
2 |
|
|
376
|
|
|
$po->carrierInformation = new CarrierInformation($awardPricing->carrier); |
377
|
5 |
|
|
378
|
|
|
$po->frequentFlyerInformation = new FrequentFlyerInformation(); |
379
|
|
|
$po->frequentFlyerInformation->frequentTravellerDetails[] = new FrequentTravellerDetails( |
380
|
|
|
$awardPricing->tierLevel |
381
|
|
|
); |
382
|
|
|
|
383
|
|
|
return $po; |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
/** |
387
|
155 |
|
* Load OB Fees |
388
|
|
|
* |
389
|
155 |
|
* @param ObFee[] $obFees |
390
|
|
|
* @param PaxSegRef[] $obFeeRefs |
391
|
155 |
|
* @return PricingOptionGroup[] |
392
|
5 |
|
*/ |
393
|
|
View Code Duplication |
protected static function loadObFees($obFees, $obFeeRefs) |
|
|
|
|
394
|
5 |
|
{ |
395
|
5 |
|
$opt = []; |
396
|
2 |
|
|
397
|
2 |
|
if (!empty($obFees)) { |
398
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_OB_FEES); |
399
|
5 |
|
|
400
|
5 |
|
$po->penDisInformation = new PenDisInformation( |
401
|
2 |
|
PenDisInformation::QUAL_OB_FEES, |
402
|
|
|
$obFees |
403
|
5 |
|
); |
404
|
2 |
|
|
405
|
|
|
if (!empty($obFeeRefs)) { |
406
|
155 |
|
$po->paxSegTstReference = new PaxSegTstReference($obFeeRefs); |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
$opt[] = $po; |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
return $opt; |
413
|
|
|
} |
414
|
155 |
|
|
415
|
|
|
/** |
416
|
155 |
|
* @param string[] $paxDiscount |
417
|
|
|
* @param PaxSegRef[] $paxDiscountCodeRefs |
418
|
155 |
|
* @return PricingOptionGroup[] |
419
|
20 |
|
*/ |
420
|
|
View Code Duplication |
protected static function loadPaxDiscount($paxDiscount, $paxDiscountCodeRefs) |
|
|
|
|
421
|
20 |
|
{ |
422
|
20 |
|
$opt = []; |
423
|
8 |
|
|
424
|
8 |
|
if (!empty($paxDiscount)) { |
425
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_PASSENGER_DISCOUNT_PTC); |
426
|
20 |
|
|
427
|
20 |
|
$po->penDisInformation = new PenDisInformation( |
428
|
8 |
|
PenDisInformation::QUAL_DISCOUNT, |
429
|
|
|
$paxDiscount |
430
|
20 |
|
); |
431
|
8 |
|
|
432
|
|
|
if (!empty($paxDiscountCodeRefs)) { |
433
|
155 |
|
$po->paxSegTstReference = new PaxSegTstReference($paxDiscountCodeRefs); |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
$opt[] = $po; |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
return $opt; |
440
|
|
|
} |
441
|
155 |
|
|
442
|
|
|
/** |
443
|
155 |
|
* @param string|null $posOverride |
444
|
|
|
* @param string|null $potOverride |
445
|
155 |
|
* @return PricingOptionGroup[] |
446
|
5 |
|
*/ |
447
|
|
View Code Duplication |
protected static function loadPointOverrides($posOverride, $potOverride) |
|
|
|
|
448
|
5 |
|
{ |
449
|
5 |
|
$opt = []; |
450
|
2 |
|
|
451
|
2 |
|
if (!empty($posOverride)) { |
452
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_SALE_OVERRIDE); |
453
|
5 |
|
|
454
|
2 |
|
$po->locationInformation = new LocationInformation( |
455
|
|
|
LocationInformation::TYPE_POINT_OF_SALE, |
456
|
155 |
|
$posOverride |
457
|
5 |
|
); |
458
|
|
|
|
459
|
5 |
|
$opt[] = $po; |
460
|
5 |
|
} |
461
|
2 |
|
|
462
|
2 |
|
if (!empty($potOverride)) { |
463
|
|
|
$po2 = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_TICKETING_OVERRIDE); |
464
|
5 |
|
|
465
|
2 |
|
$po2->locationInformation = new LocationInformation( |
466
|
|
|
LocationInformation::TYPE_POINT_OF_TICKETING, |
467
|
155 |
|
$potOverride |
468
|
|
|
); |
469
|
|
|
|
470
|
|
|
$opt[] = $po2; |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
return $opt; |
474
|
155 |
|
} |
475
|
|
|
|
476
|
155 |
|
/** |
477
|
|
|
* @param string|null $pricingLogic |
478
|
155 |
|
* @return PricingOptionGroup[] |
479
|
5 |
|
*/ |
480
|
5 |
View Code Duplication |
protected static function loadPricingLogic($pricingLogic) |
|
|
|
|
481
|
5 |
|
{ |
482
|
2 |
|
$opt = []; |
483
|
|
|
|
484
|
155 |
|
if (!empty($pricingLogic)) { |
485
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_PRICING_LOGIC); |
486
|
|
|
$po->optionDetail = new OptionDetail($pricingLogic); |
487
|
|
|
$opt[] = $po; |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
return $opt; |
491
|
155 |
|
} |
492
|
|
|
|
493
|
155 |
|
/** |
494
|
|
|
* @param string|null $ticketType |
495
|
155 |
|
* @return PricingOptionGroup[] |
496
|
5 |
|
*/ |
497
|
|
View Code Duplication |
protected static function loadTicketType($ticketType) |
|
|
|
|
498
|
5 |
|
{ |
499
|
|
|
$opt = []; |
500
|
5 |
|
|
501
|
2 |
|
if (!empty($ticketType)) { |
502
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_TICKET_TYPE); |
503
|
155 |
|
|
504
|
|
|
$po->optionDetail = new OptionDetail($ticketType); |
505
|
|
|
|
506
|
|
|
$opt[] = $po; |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
return $opt; |
510
|
155 |
|
} |
511
|
|
|
|
512
|
155 |
|
/** |
513
|
|
|
* @param Tax[] $taxes |
514
|
155 |
|
* @return PricingOptionGroup[] |
515
|
5 |
|
*/ |
516
|
|
View Code Duplication |
protected static function loadTaxes($taxes) |
|
|
|
|
517
|
5 |
|
{ |
518
|
5 |
|
$opt = []; |
519
|
5 |
|
|
520
|
|
|
if (!empty($taxes)) { |
521
|
5 |
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_ADD_TAX); |
522
|
5 |
|
|
523
|
5 |
|
foreach ($taxes as $tax) { |
524
|
4 |
|
$qualifier = (!empty($tax->amount)) ? TaxData::QUALIFIER_AMOUNT : TaxData::QUALIFIER_PERCENTAGE; |
525
|
2 |
|
$rate = (!empty($tax->amount)) ? $tax->amount : $tax->percentage; |
526
|
2 |
|
|
527
|
2 |
|
$po->taxInformation[] = new TaxInformation( |
528
|
5 |
|
$tax->countryCode, |
529
|
2 |
|
$tax->taxNature, |
530
|
|
|
$qualifier, |
531
|
155 |
|
$rate |
532
|
|
|
); |
533
|
|
|
} |
534
|
|
|
$opt[] = $po; |
535
|
|
|
} |
536
|
|
|
|
537
|
|
|
return $opt; |
538
|
155 |
|
} |
539
|
|
|
|
540
|
155 |
|
/** |
541
|
|
|
* @param ExemptTax[] $exemptTaxes |
542
|
155 |
|
* @return PricingOptionGroup[] |
543
|
5 |
|
*/ |
544
|
|
View Code Duplication |
protected static function loadExemptTaxes($exemptTaxes) |
|
|
|
|
545
|
5 |
|
{ |
546
|
5 |
|
$opt = []; |
547
|
5 |
|
|
548
|
5 |
|
if (!empty($exemptTaxes)) { |
549
|
2 |
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_EXEMPT_FROM_TAX); |
550
|
2 |
|
|
551
|
|
|
foreach ($exemptTaxes as $tax) { |
552
|
5 |
|
$po->taxInformation[] = new TaxInformation( |
553
|
2 |
|
$tax->countryCode, |
554
|
|
|
$tax->taxNature |
555
|
155 |
|
); |
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
$opt[] = $po; |
559
|
|
|
} |
560
|
|
|
|
561
|
|
|
return $opt; |
562
|
155 |
|
} |
563
|
|
|
|
564
|
155 |
|
/** |
565
|
|
|
* @param \DateTime|null $pastDate |
566
|
155 |
|
* @return PricingOptionGroup[] |
567
|
5 |
|
*/ |
568
|
|
View Code Duplication |
protected static function loadPastDate($pastDate) |
|
|
|
|
569
|
5 |
|
{ |
570
|
5 |
|
$opt = []; |
571
|
2 |
|
|
572
|
2 |
|
if ($pastDate instanceof \DateTime) { |
573
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_PAST_DATE_PRICING); |
574
|
5 |
|
|
575
|
2 |
|
$po->dateInformation = new DateInformation( |
576
|
|
|
DateInformation::OPT_DATE_OVERRIDE, |
577
|
155 |
|
$pastDate |
578
|
|
|
); |
579
|
|
|
|
580
|
|
|
$opt[] = $po; |
581
|
|
|
} |
582
|
|
|
|
583
|
|
|
return $opt; |
584
|
|
|
} |
585
|
155 |
|
|
586
|
|
|
|
587
|
155 |
|
/** |
588
|
|
|
* @param FormOfPayment[] $formOfPayment |
589
|
155 |
|
* @return PricingOptionGroup[] |
590
|
5 |
|
*/ |
591
|
|
View Code Duplication |
protected static function loadFormOfPayment($formOfPayment) |
|
|
|
|
592
|
5 |
|
{ |
593
|
|
|
$opt = []; |
594
|
5 |
|
|
595
|
2 |
|
if (!empty($formOfPayment)) { |
596
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_FORM_OF_PAYMENT); |
597
|
155 |
|
|
598
|
|
|
$po->formOfPaymentInformation = new FormOfPaymentInformation($formOfPayment); |
599
|
|
|
|
600
|
|
|
$opt[] = $po; |
601
|
|
|
} |
602
|
|
|
|
603
|
|
|
return $opt; |
604
|
155 |
|
} |
605
|
|
|
|
606
|
155 |
|
/** |
607
|
|
|
* @param PaxSegRef[] $references |
608
|
155 |
|
* @return PricingOptionGroup[] |
609
|
5 |
|
*/ |
610
|
|
View Code Duplication |
protected static function loadReferences($references) |
|
|
|
|
611
|
5 |
|
{ |
612
|
|
|
$opt = []; |
613
|
5 |
|
|
614
|
2 |
|
if (!empty($references)) { |
615
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_PAX_SEGMENT_TST_SELECTION); |
616
|
155 |
|
|
617
|
|
|
$po->paxSegTstReference = new PaxSegTstReference($references); |
618
|
|
|
|
619
|
|
|
$opt[] = $po; |
620
|
|
|
} |
621
|
|
|
|
622
|
|
|
return $opt; |
623
|
|
|
} |
624
|
|
|
|
625
|
|
|
/** |
626
|
|
|
* Load ZAP-Off |
627
|
|
|
* |
628
|
|
|
* @param ZapOff[] $zapOffs |
629
|
|
|
* @return PricingOptionGroup[] |
630
|
|
|
*/ |
631
|
|
|
protected static function loadZapOffs($zapOffs) |
632
|
|
|
{ |
633
|
|
|
$opt = []; |
634
|
|
|
if (!empty($zapOffs)) { |
635
|
|
|
foreach ($zapOffs as $zapOff) { |
636
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_ZAP_OFF); |
637
|
|
|
|
638
|
|
|
$po->penDisInformation = new PenDisInformation( |
639
|
|
|
PenDisInformation::QUAL_ZAPOFF_DISCOUNT, |
640
|
|
|
[$zapOff] |
641
|
|
|
); |
642
|
|
|
|
643
|
|
|
if (!empty($zapOff->paxSegRefs)) { |
644
|
|
|
$po->paxSegTstReference = new PaxSegTstReference($zapOff->paxSegRefs); |
645
|
|
|
} |
646
|
|
|
|
647
|
|
|
$opt[] = $po; |
648
|
|
|
} |
649
|
|
|
} |
650
|
|
|
|
651
|
|
|
return $opt; |
652
|
|
|
} |
653
|
|
|
} |
654
|
|
|
|
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.