|
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\Service; |
|
24
|
|
|
|
|
25
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef; |
|
26
|
|
|
use Amadeus\Client\RequestOptions\Service\FormOfPayment; |
|
27
|
|
|
use Amadeus\Client\RequestOptions\Service\FrequentFlyer; |
|
28
|
|
|
use Amadeus\Client\RequestOptions\ServiceIntegratedCatalogueOptions; |
|
29
|
|
|
use Amadeus\Client\RequestOptions\ServiceIntegratedPricingOptions; |
|
30
|
|
|
use Amadeus\Client\Struct\Fare\BasePricingMessage; |
|
31
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\CarrierInformation; |
|
32
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\Currency; |
|
33
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\DateInformation; |
|
34
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\FormOfPaymentInformation; |
|
35
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\FrequentFlyerInformation; |
|
36
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\LocationInformation; |
|
37
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\OptionDetail; |
|
38
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\PaxSegTstReference; |
|
39
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionGroup; |
|
40
|
|
|
use Amadeus\Client\Struct\Service\IntegratedPricing\PricingOptionKey; |
|
41
|
|
|
use Amadeus\Client\Struct\Service\IntegratedPricing\PricingOption; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Service_IntegratedPricing request structure |
|
45
|
|
|
* |
|
46
|
|
|
* @package Amadeus\Client\Struct\Service |
|
47
|
|
|
* @author Dieter Devlieghere <[email protected]> |
|
48
|
|
|
*/ |
|
49
|
|
|
class IntegratedPricing extends BasePricingMessage |
|
50
|
|
|
{ |
|
51
|
|
|
/** |
|
52
|
|
|
* @var PricingOption[] |
|
53
|
|
|
*/ |
|
54
|
|
|
public $pricingOption = []; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* IntegratedPricing constructor. |
|
58
|
|
|
* |
|
59
|
|
|
* @param ServiceIntegratedPricingOptions|ServiceIntegratedCatalogueOptions|null $options |
|
60
|
|
|
*/ |
|
61
|
64 |
|
public function __construct($options = null) |
|
62
|
|
|
{ |
|
63
|
64 |
|
if (!is_null($options)) { |
|
64
|
64 |
|
$this->pricingOption = $this->loadPricingOptions($options); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param ServiceIntegratedPricingOptions|ServiceIntegratedCatalogueOptions $options |
|
70
|
|
|
* @return PricingOption[] |
|
71
|
|
|
*/ |
|
72
|
64 |
|
public static function loadPricingOptions($options) |
|
73
|
|
|
{ |
|
74
|
64 |
|
$priceOptions = []; |
|
75
|
|
|
|
|
76
|
64 |
|
$priceOptions = self::mergeOptions( |
|
77
|
64 |
|
$priceOptions, |
|
78
|
64 |
|
self::makePricingOptionFareBasisOverride($options->pricingsFareBasis) |
|
|
|
|
|
|
79
|
|
|
); |
|
80
|
|
|
|
|
81
|
|
|
$priceOptions = self::mergeOptions( |
|
82
|
|
|
$priceOptions, |
|
83
|
|
|
self::makePricingOptionForValidatingCarrier($options->validatingCarrier) |
|
84
|
|
|
); |
|
85
|
|
|
|
|
86
|
|
|
$priceOptions = self::mergeOptions( |
|
87
|
|
|
$priceOptions, |
|
88
|
|
|
self::makePricingOptionForCurrencyOverride($options->currencyOverride) |
|
89
|
|
|
); |
|
90
|
|
|
|
|
91
|
|
|
$priceOptions = self::mergeOptions( |
|
92
|
|
|
$priceOptions, |
|
93
|
|
|
self::makePricingOptionWithOptionDetailAndRefs( |
|
94
|
|
|
PricingOptionKey::OVERRIDE_ACCOUNT_CODE, |
|
95
|
|
|
$options->accountCode, |
|
96
|
|
|
$options->accountCodeRefs |
|
97
|
|
|
) |
|
98
|
|
|
); |
|
99
|
|
|
|
|
100
|
|
|
$priceOptions = self::mergeOptions( |
|
101
|
|
|
$priceOptions, |
|
102
|
|
|
self::makePricingOptionWithOptionDetailAndRefs( |
|
103
|
|
|
PricingOptionKey::OVERRIDE_AWARD, |
|
104
|
|
|
$options->awardPricing, |
|
105
|
|
|
[] |
|
106
|
|
|
) |
|
107
|
|
|
); |
|
108
|
|
|
|
|
109
|
|
|
$priceOptions = self::mergeOptions( |
|
110
|
|
|
$priceOptions, |
|
111
|
|
|
self::makePricingOptionWithOptionDetailAndRefs( |
|
112
|
|
|
PricingOptionKey::OVERRIDE_CORPORATION_NUMBER, |
|
113
|
|
|
$options->corporationNumber, |
|
114
|
|
|
[] |
|
115
|
|
|
) |
|
116
|
|
|
); |
|
117
|
|
|
|
|
118
|
|
|
$priceOptions = self::mergeOptions( |
|
119
|
|
|
$priceOptions, |
|
120
|
|
|
self::loadDateOverride($options->overrideDate) |
|
121
|
|
|
); |
|
122
|
|
|
|
|
123
|
|
|
$priceOptions = self::mergeOptions( |
|
124
|
|
|
$priceOptions, |
|
125
|
|
|
self::makePricingOptionWithOptionDetailAndRefs(PricingOptionKey::OVERRIDE_TICKET_DESIGNATOR, $options->ticketDesignator, [])); |
|
|
|
|
|
|
126
|
|
|
|
|
127
|
|
|
$priceOptions = self::mergeOptions($priceOptions, self::loadPointOverrides($options->pointOfSaleOverride)); |
|
128
|
|
|
|
|
129
|
|
|
$priceOptions = self::mergeOptions($priceOptions, self::loadFormOfPaymentOverride($options->formOfPayment)); |
|
130
|
|
|
|
|
131
|
|
|
$priceOptions = self::mergeOptions($priceOptions, self::loadFrequentFlyerOverride($options->frequentFlyers)); |
|
132
|
|
|
|
|
133
|
|
|
$priceOptions = self::mergeOptions($priceOptions, self::loadReferences($options->references)); |
|
134
|
|
|
|
|
135
|
|
|
$priceOptions = self::mergeOptions($priceOptions, self::makeOverrideOptions($options->overrideOptions, $priceOptions) |
|
|
|
|
|
|
136
|
|
|
); |
|
137
|
|
|
|
|
138
|
|
|
// All options processed, no options found: |
|
139
|
|
|
if (empty($priceOptions)) { |
|
140
|
|
|
$priceOptions[] = new PricingOption(PricingOptionKey::OVERRIDE_NO_OPTION); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
return $priceOptions; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* |
|
148
|
|
|
* @param FareBasis[] $pricingsFareBasis |
|
149
|
|
|
* @return PricingOptionGroup[] |
|
150
|
|
|
*/ |
|
151
|
|
View Code Duplication |
protected static function makePricingOptionFareBasisOverride($pricingsFareBasis) |
|
|
|
|
|
|
152
|
|
|
{ |
|
153
|
|
|
$opt = []; |
|
154
|
|
|
if ($pricingsFareBasis !== null) { |
|
155
|
|
|
foreach ($pricingsFareBasis as $pricingFareBasis) { |
|
156
|
|
|
$po = new PricingOptionGroup($pricingFareBasis->overrideType); |
|
157
|
|
|
|
|
158
|
|
|
$po->optionDetail = new OptionDetail($pricingFareBasis->fareBasisCode); |
|
159
|
|
|
|
|
160
|
|
|
$po->paxSegTstReference = new PaxSegTstReference($pricingFareBasis->references); |
|
161
|
|
|
|
|
162
|
|
|
$opt[] = $po; |
|
163
|
|
|
} |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
return $opt; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* @param string|null $validatingCarrier |
|
172
|
|
|
* @return PricingOption[] |
|
173
|
|
|
*/ |
|
174
|
|
View Code Duplication |
protected static function makePricingOptionForValidatingCarrier($validatingCarrier) |
|
|
|
|
|
|
175
|
|
|
{ |
|
176
|
|
|
$opt = []; |
|
177
|
|
|
|
|
178
|
|
|
if ($validatingCarrier !== null) { |
|
179
|
|
|
$po = new PricingOption(PricingOptionKey::OVERRIDE_VALIDATING_CARRIER); |
|
180
|
|
|
|
|
181
|
|
|
$po->carrierInformation = new CarrierInformation($validatingCarrier); |
|
182
|
|
|
|
|
183
|
|
|
$opt[] = $po; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
return $opt; |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
/** |
|
190
|
|
|
* @param string|null $currency |
|
191
|
|
|
* @return PricingOption[] |
|
192
|
|
|
*/ |
|
193
|
|
View Code Duplication |
protected static function makePricingOptionForCurrencyOverride($currency) |
|
|
|
|
|
|
194
|
|
|
{ |
|
195
|
|
|
$opt = []; |
|
196
|
|
|
|
|
197
|
|
|
if ($currency !== null) { |
|
198
|
|
|
$po = new PricingOption(PricingOptionKey::OVERRIDE_CURRENCY); |
|
199
|
|
|
|
|
200
|
|
|
$po->currency = new Currency($currency); |
|
201
|
|
|
|
|
202
|
|
|
$opt[] = $po; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
return $opt; |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
/** |
|
209
|
|
|
* @param string $overrideCode |
|
210
|
|
|
* @param string|array|null $options |
|
211
|
|
|
* @param PaxSegRef[] $references |
|
212
|
|
|
* @return PricingOption[] |
|
213
|
|
|
*/ |
|
214
|
|
|
protected function makePricingOptionWithOptionDetailAndRefs($overrideCode, $options, $references) |
|
215
|
|
|
{ |
|
216
|
|
|
$opt = []; |
|
217
|
|
|
|
|
218
|
|
|
if ($options !== null) { |
|
219
|
|
|
$po = new PricingOption($overrideCode); |
|
220
|
|
|
|
|
221
|
|
|
$po->optionDetail = new OptionDetail($options); |
|
222
|
|
|
|
|
223
|
|
|
if (!empty($references)) { |
|
224
|
|
|
$po->paxSegTstReference = new PaxSegTstReference($references); |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
$opt[] = $po; |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
return $opt; |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
/** |
|
234
|
|
|
* @param \DateTime|null $dateOverride |
|
235
|
|
|
* @return PricingOption[] |
|
236
|
|
|
*/ |
|
237
|
|
View Code Duplication |
protected static function loadDateOverride($dateOverride) |
|
|
|
|
|
|
238
|
|
|
{ |
|
239
|
|
|
$opt = []; |
|
240
|
|
|
|
|
241
|
|
|
if ($dateOverride instanceof \DateTime) { |
|
242
|
|
|
$po = new PricingOption(PricingOptionKey::OVERRIDE_PRICING_DATE); |
|
243
|
|
|
|
|
244
|
|
|
$po->dateInformation = new DateInformation( |
|
245
|
|
|
DateInformation::OPT_DATE_OVERRIDE, |
|
246
|
|
|
$dateOverride |
|
247
|
|
|
); |
|
248
|
|
|
|
|
249
|
|
|
$opt[] = $po; |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
return $opt; |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
/** |
|
256
|
|
|
* @param string|null $posOverride |
|
257
|
|
|
* @return PricingOption[] |
|
258
|
|
|
*/ |
|
259
|
|
View Code Duplication |
protected static function loadPointOverrides($posOverride) |
|
|
|
|
|
|
260
|
|
|
{ |
|
261
|
|
|
$opt = []; |
|
262
|
|
|
|
|
263
|
|
|
if (!empty($posOverride)) { |
|
264
|
|
|
$po = new PricingOption(PricingOptionKey::OVERRIDE_POINT_OF_SALE); |
|
265
|
|
|
|
|
266
|
|
|
$po->locationInformation = new LocationInformation( |
|
267
|
|
|
LocationInformation::TYPE_POINT_OF_SALE, |
|
268
|
|
|
$posOverride |
|
269
|
|
|
); |
|
270
|
|
|
|
|
271
|
|
|
$opt[] = $po; |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
return $opt; |
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
/** |
|
278
|
|
|
* @param FormOfPayment[] $formOfPayment |
|
279
|
|
|
* @return PricingOption[] |
|
280
|
|
|
*/ |
|
281
|
|
View Code Duplication |
protected static function loadFormOfPaymentOverride($formOfPayment) |
|
|
|
|
|
|
282
|
|
|
{ |
|
283
|
|
|
$opt = []; |
|
284
|
|
|
|
|
285
|
|
|
if (!empty($formOfPayment)) { |
|
286
|
|
|
$po = new PricingOption(PricingOptionKey::OVERRIDE_FORM_OF_PAYMENT); |
|
287
|
|
|
|
|
288
|
|
|
$po->formOfPaymentInformation = new FormOfPaymentInformation($formOfPayment); |
|
289
|
|
|
|
|
290
|
|
|
$opt[] = $po; |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
return $opt; |
|
294
|
|
|
} |
|
295
|
|
|
|
|
296
|
|
|
/** |
|
297
|
|
|
* @param FrequentFlyer[] $frequentFlyers |
|
298
|
|
|
* @return PricingOption[] |
|
299
|
|
|
*/ |
|
300
|
|
View Code Duplication |
protected static function loadFrequentFlyerOverride($frequentFlyers) |
|
|
|
|
|
|
301
|
|
|
{ |
|
302
|
|
|
$opt = []; |
|
303
|
|
|
|
|
304
|
|
|
if (!empty($frequentFlyers)) { |
|
305
|
|
|
$po = new PricingOption(PricingOptionKey::OVERRIDE_FREQUENT_FLYER_INFORMATION); |
|
306
|
|
|
|
|
307
|
|
|
$po->frequentFlyerInformation = new FrequentFlyerInformation($frequentFlyers); |
|
308
|
|
|
|
|
309
|
|
|
$opt[] = $po; |
|
310
|
|
|
} |
|
311
|
|
|
|
|
312
|
|
|
return $opt; |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
/** |
|
316
|
|
|
* @param PaxSegRef[] $references |
|
317
|
|
|
* @return PricingOption[] |
|
318
|
|
|
*/ |
|
319
|
|
View Code Duplication |
protected static function loadReferences($references) |
|
|
|
|
|
|
320
|
|
|
{ |
|
321
|
|
|
$opt = []; |
|
322
|
|
|
|
|
323
|
|
|
if (!empty($references)) { |
|
324
|
|
|
$po = new PricingOption(PricingOptionKey::OVERRIDE_PAX_SEG_ELEMENT_SELECTION); |
|
325
|
|
|
|
|
326
|
|
|
$po->paxSegTstReference = new PaxSegTstReference($references); |
|
327
|
|
|
|
|
328
|
|
|
$opt[] = $po; |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
return $opt; |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
/** |
|
335
|
|
|
* @param string[] $overrideOptions |
|
336
|
|
|
* @param PricingOption[] $priceOptions |
|
337
|
|
|
* @return PricingOption[] |
|
338
|
|
|
*/ |
|
339
|
|
View Code Duplication |
protected static function makeOverrideOptions($overrideOptions, $priceOptions) |
|
|
|
|
|
|
340
|
|
|
{ |
|
341
|
|
|
$opt = []; |
|
342
|
|
|
|
|
343
|
|
|
foreach ($overrideOptions as $overrideOption) { |
|
344
|
|
|
if (!self::hasPricingGroup($overrideOption, $priceOptions)) { |
|
345
|
|
|
$opt[] = new PricingOption($overrideOption); |
|
346
|
|
|
} |
|
347
|
|
|
} |
|
348
|
|
|
|
|
349
|
|
|
return $opt; |
|
350
|
|
|
} |
|
351
|
|
|
|
|
352
|
|
|
/** |
|
353
|
|
|
* Merges Pricing options |
|
354
|
|
|
* |
|
355
|
|
|
* @param PricingOption[] $existingOptions |
|
356
|
|
|
* @param PricingOption[] $newOptions |
|
357
|
|
|
* @return PricingOption[] merged array |
|
358
|
|
|
*/ |
|
359
|
|
|
protected static function mergeOptions($existingOptions, $newOptions) |
|
360
|
|
|
{ |
|
361
|
|
|
if (!empty($newOptions)) { |
|
362
|
|
|
$existingOptions = array_merge( |
|
363
|
|
|
$existingOptions, |
|
364
|
|
|
$newOptions |
|
365
|
|
|
); |
|
366
|
|
|
} |
|
367
|
|
|
|
|
368
|
|
|
return $existingOptions; |
|
369
|
|
|
} |
|
370
|
|
|
} |
|
371
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.