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