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\MPTicketingPriceScheme; |
26
|
|
|
use Amadeus\Client\RequestOptions\Fare\MPFareFamily; |
27
|
|
|
use Amadeus\Client\RequestOptions\Fare\MPItinerary; |
28
|
|
|
use Amadeus\Client\RequestOptions\FareMasterPricerCalendarOptions; |
29
|
|
|
use Amadeus\Client\RequestOptions\FareMasterPricerTbSearch; |
30
|
|
|
use Amadeus\Client\RequestOptions\TicketAtcShopperMpTbSearchOptions; |
31
|
|
|
use Amadeus\Client\Struct\Fare\MasterPricer; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Fare_MasterPricerTravelBoardSearch message structure |
35
|
|
|
* |
36
|
|
|
* Also used for Fare_MasterPricerCalendar and Ticket_ATCShopperMasterPricerTravelBoardSearch |
37
|
|
|
* |
38
|
|
|
* @package Amadeus\Client\Struct\Fare |
39
|
|
|
* @author Dieter Devlieghere <[email protected]> |
40
|
|
|
*/ |
41
|
|
|
class MasterPricerTravelBoardSearch extends BaseMasterPricerMessage |
42
|
|
|
{ |
43
|
|
|
/** |
44
|
|
|
* @var mixed |
45
|
|
|
*/ |
46
|
|
|
public $globalOptions; |
47
|
|
|
/** |
48
|
|
|
* @var MasterPricer\CustomerRef |
49
|
|
|
*/ |
50
|
|
|
public $customerRef; |
51
|
|
|
/** |
52
|
|
|
* @var mixed |
53
|
|
|
*/ |
54
|
|
|
public $formOfPaymentByPassenger; |
55
|
|
|
/** |
56
|
|
|
* @var mixed |
57
|
|
|
*/ |
58
|
|
|
public $solutionFamily; |
59
|
|
|
/** |
60
|
|
|
* @var mixed[] |
61
|
|
|
*/ |
62
|
|
|
public $passengerInfoGrp = []; |
63
|
|
|
/** |
64
|
|
|
* @var MasterPricer\FareFamilies[] |
65
|
|
|
*/ |
66
|
|
|
public $fareFamilies = []; |
67
|
|
|
/** |
68
|
|
|
* @var MasterPricer\PriceToBeat |
69
|
|
|
*/ |
70
|
|
|
public $priceToBeat; |
71
|
|
|
/** |
72
|
|
|
* @var mixed |
73
|
|
|
*/ |
74
|
|
|
public $taxInfo; |
75
|
|
|
/** |
76
|
|
|
* @var MasterPricer\TravelFlightInfo |
77
|
|
|
*/ |
78
|
|
|
public $travelFlightInfo; |
79
|
|
|
/** |
80
|
|
|
* @var array |
81
|
|
|
*/ |
82
|
|
|
public $valueSearch = []; |
83
|
|
|
/** |
84
|
|
|
* Itinerary |
85
|
|
|
* |
86
|
|
|
* @var MasterPricer\Itinerary[] |
87
|
|
|
*/ |
88
|
|
|
public $itinerary = []; |
89
|
|
|
/** |
90
|
|
|
* @var MPTicketingPriceScheme |
91
|
|
|
*/ |
92
|
|
|
public $ticketingPriceScheme; |
93
|
|
|
/** |
94
|
|
|
* @var mixed |
95
|
|
|
*/ |
96
|
|
|
public $ticketChangeInfo; |
97
|
|
|
/** |
98
|
|
|
* @var mixed |
99
|
|
|
*/ |
100
|
|
|
public $combinationFareFamilies; |
101
|
|
|
/** |
102
|
|
|
* @var MasterPricer\FeeOption[] |
103
|
|
|
*/ |
104
|
|
|
public $feeOption; |
105
|
|
|
/** |
106
|
|
|
* @var MasterPricer\OfficeIdDetails[] |
107
|
|
|
*/ |
108
|
|
|
public $officeIdDetails; |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* MasterPricerTravelBoardSearch constructor. |
112
|
|
|
* |
113
|
|
|
* @param FareMasterPricerTbSearch|FareMasterPricerCalendarOptions|TicketAtcShopperMpTbSearchOptions|null $options |
114
|
|
|
*/ |
115
|
210 |
|
public function __construct($options = null) |
116
|
|
|
{ |
117
|
210 |
|
if ($options instanceof FareMasterPricerTbSearch) { |
118
|
210 |
|
$this->loadOptions($options); |
119
|
84 |
|
} |
120
|
210 |
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param FareMasterPricerTbSearch|FareMasterPricerCalendarOptions|TicketAtcShopperMpTbSearchOptions $options |
124
|
|
|
*/ |
125
|
210 |
|
protected function loadOptions($options) |
126
|
|
|
{ |
127
|
210 |
|
$this->loadNumberOfUnits($options); |
128
|
|
|
|
129
|
210 |
|
$this->loadFareOptions($options); |
130
|
|
|
|
131
|
210 |
|
$passengerCounter = 1; |
132
|
210 |
|
$infantCounter = 1; |
133
|
210 |
|
foreach ($options->passengers as $passenger) { |
134
|
190 |
|
$this->loadPassenger($passenger, $passengerCounter, $infantCounter); |
135
|
84 |
|
} |
136
|
|
|
|
137
|
210 |
|
$segmentCounter = 1; |
138
|
210 |
|
foreach ($options->itinerary as $itinerary) { |
139
|
190 |
|
$this->loadItinerary($itinerary, $segmentCounter); |
140
|
84 |
|
} |
141
|
|
|
|
142
|
210 |
|
foreach ($options->officeIds as $officeId) { |
143
|
5 |
|
$this->loadOfficeId($officeId); |
144
|
84 |
|
} |
145
|
|
|
|
146
|
210 |
|
if ($this->checkAnyNotEmpty( |
147
|
210 |
|
$options->cabinClass, |
148
|
210 |
|
$options->cabinOption, |
149
|
210 |
|
$options->requestedFlightTypes, |
150
|
210 |
|
$options->airlineOptions, |
151
|
210 |
|
$options->progressiveLegsMin, |
152
|
210 |
|
$options->progressiveLegsMax, |
153
|
210 |
|
$options->maxLayoverPerConnectionHours, |
154
|
210 |
|
$options->maxLayoverPerConnectionMinutes, |
155
|
210 |
|
$options->noAirportChange, |
156
|
210 |
|
$options->maxElapsedFlyingTime |
157
|
84 |
|
)) { |
158
|
60 |
|
$this->travelFlightInfo = new MasterPricer\TravelFlightInfo( |
159
|
60 |
|
$options->cabinClass, |
160
|
60 |
|
$options->cabinOption, |
161
|
60 |
|
$options->requestedFlightTypes, |
162
|
60 |
|
$options->airlineOptions, |
163
|
60 |
|
$options->progressiveLegsMin, |
164
|
60 |
|
$options->progressiveLegsMax, |
165
|
60 |
|
$options->maxLayoverPerConnectionHours, |
166
|
60 |
|
$options->maxLayoverPerConnectionMinutes, |
167
|
60 |
|
$options->noAirportChange, |
168
|
60 |
|
$options->maxElapsedFlyingTime |
169
|
24 |
|
); |
170
|
24 |
|
} |
171
|
|
|
|
172
|
210 |
|
if (!is_null($options->priceToBeat)) { |
173
|
5 |
|
$this->priceToBeat = new MasterPricer\PriceToBeat( |
174
|
5 |
|
$options->priceToBeat, |
175
|
5 |
|
$options->priceToBeatCurrency |
176
|
2 |
|
); |
177
|
2 |
|
} |
178
|
|
|
|
179
|
210 |
|
$this->loadFareFamilies($options->fareFamilies); |
180
|
|
|
|
181
|
210 |
|
$this->loadCustomerRefs($options->dkNumber); |
182
|
|
|
|
183
|
210 |
|
$this->loadFeeOptions($options->feeOption); |
184
|
210 |
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @param string $officeId |
188
|
|
|
*/ |
189
|
5 |
|
protected function loadOfficeId($officeId) |
190
|
|
|
{ |
191
|
5 |
|
$this->officeIdDetails[] = new MasterPricer\OfficeIdDetails($officeId); |
192
|
5 |
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @param MPItinerary $opt |
196
|
|
|
* @param int $counter BYREF |
197
|
|
|
*/ |
198
|
190 |
|
protected function loadItinerary($opt, &$counter) |
199
|
|
|
{ |
200
|
190 |
|
$segmentRef = $counter; |
201
|
|
|
|
202
|
190 |
|
if (!empty($opt->segmentReference)) { |
203
|
5 |
|
$segmentRef = $opt->segmentReference; |
204
|
2 |
|
} |
205
|
|
|
|
206
|
190 |
|
$tmpItinerary = new MasterPricer\Itinerary($segmentRef); |
207
|
|
|
|
208
|
190 |
|
$tmpItinerary->departureLocalization = new MasterPricer\DepartureLocalization( |
209
|
190 |
|
$opt->departureLocation |
210
|
76 |
|
); |
211
|
190 |
|
|
212
|
190 |
|
if (!empty($opt->anchoredSegments)) { |
213
|
76 |
|
$tmpItinerary->flightInfoPNR = array_map(function ($anchoredSegment) { |
214
|
190 |
|
return new MasterPricer\FlightInfoPNR( |
215
|
|
|
$anchoredSegment |
216
|
190 |
|
); |
217
|
190 |
|
}, $opt->anchoredSegments); |
218
|
190 |
|
} |
219
|
190 |
|
|
220
|
190 |
|
$tmpItinerary->arrivalLocalization = new MasterPricer\ArrivalLocalization( |
221
|
190 |
|
$opt->arrivalLocation |
222
|
190 |
|
); |
223
|
190 |
|
$tmpItinerary->timeDetails = new MasterPricer\TimeDetails($opt->date); |
224
|
190 |
|
|
225
|
76 |
|
if ($this->checkAnyNotEmpty( |
226
|
30 |
|
$opt->airlineOptions, |
227
|
30 |
|
$opt->requestedFlightTypes, |
228
|
30 |
|
$opt->includedConnections, |
229
|
30 |
|
$opt->excludedConnections, |
230
|
30 |
|
$opt->nrOfConnections, |
231
|
30 |
|
$opt->noAirportChange, |
232
|
30 |
|
$opt->cabinClass, |
233
|
30 |
|
$opt->cabinOption |
234
|
30 |
|
)) { |
235
|
12 |
|
$tmpItinerary->flightInfo = new MasterPricer\FlightInfo( |
236
|
12 |
|
$opt->airlineOptions, |
237
|
|
|
$opt->requestedFlightTypes, |
238
|
190 |
|
$opt->includedConnections, |
239
|
|
|
$opt->excludedConnections, |
240
|
190 |
|
$opt->nrOfConnections, |
241
|
190 |
|
$opt->noAirportChange, |
242
|
|
|
$opt->cabinClass, |
243
|
|
|
$opt->cabinOption |
244
|
|
|
); |
245
|
|
|
} |
246
|
210 |
|
|
247
|
|
|
$this->itinerary[] = $tmpItinerary; |
248
|
210 |
|
|
249
|
10 |
|
$counter++; |
250
|
84 |
|
} |
251
|
210 |
|
|
252
|
|
|
/** |
253
|
|
|
* @param MPFareFamily[] $fareFamilies |
254
|
|
|
*/ |
255
|
|
|
protected function loadFareFamilies($fareFamilies) |
256
|
|
|
{ |
257
|
|
|
foreach ($fareFamilies as $fareFamily) { |
258
|
210 |
|
$this->fareFamilies[] = new MasterPricer\FareFamilies($fareFamily); |
259
|
|
|
} |
260
|
210 |
|
} |
261
|
5 |
|
|
262
|
5 |
|
/** |
263
|
5 |
|
* Load Customer references |
264
|
3 |
|
* |
265
|
2 |
|
* @param string $dkNumber |
266
|
2 |
|
*/ |
267
|
210 |
|
protected function loadCustomerRefs($dkNumber) |
268
|
|
|
{ |
269
|
210 |
|
if (!is_null($dkNumber)) { |
|
|
|
|
270
|
|
|
$this->customerRef = new MasterPricer\CustomerRef(); |
271
|
210 |
|
$this->customerRef->customerReferences[] = new MasterPricer\CustomerReferences( |
272
|
210 |
|
$dkNumber, |
273
|
5 |
|
MasterPricer\CustomerReferences::QUAL_AGENCY_GROUPING_ID |
274
|
84 |
|
); |
275
|
84 |
|
} |
276
|
210 |
|
} |
277
|
|
|
|
278
|
|
|
private function loadFeeOptions($feeOptions) |
279
|
|
|
{ |
280
|
|
|
if (!is_null($feeOptions)) { |
281
|
|
|
foreach ($feeOptions as $feeOption) { |
282
|
|
|
$this->feeOption[] = new MasterPricer\FeeOption($feeOption); |
283
|
|
|
} |
284
|
|
|
} |
285
|
|
|
} |
286
|
|
|
} |
287
|
|
|
|