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