|
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\MPItinerary; |
|
26
|
|
|
use Amadeus\Client\RequestOptions\Fare\MPPassenger; |
|
27
|
|
|
use Amadeus\Client\RequestOptions\FareMasterPricerTbSearch; |
|
28
|
|
|
use Amadeus\Client\Struct\BaseWsMessage; |
|
29
|
|
|
use Amadeus\Client\Struct\Fare\MasterPricer; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Fare_MasterPricerTravelBoardSearch message structure |
|
33
|
|
|
* |
|
34
|
|
|
* @package Amadeus\Client\Struct\Fare |
|
35
|
|
|
* @author Dieter Devlieghere <[email protected]> |
|
36
|
|
|
*/ |
|
37
|
|
|
class MasterPricerTravelBoardSearch extends BaseWsMessage |
|
38
|
|
|
{ |
|
39
|
|
|
/** |
|
40
|
|
|
* Number of seats, recommendations. |
|
41
|
|
|
* |
|
42
|
|
|
* @var MasterPricer\NumberOfUnit |
|
43
|
|
|
*/ |
|
44
|
|
|
public $numberOfUnit; |
|
45
|
|
|
/** |
|
46
|
|
|
* @var mixed |
|
47
|
|
|
*/ |
|
48
|
|
|
public $globalOptions; |
|
49
|
|
|
/** |
|
50
|
|
|
* Traveler Details |
|
51
|
|
|
* |
|
52
|
|
|
* @var MasterPricer\PaxReference[] |
|
53
|
|
|
*/ |
|
54
|
|
|
public $paxReference = []; |
|
55
|
|
|
/** |
|
56
|
|
|
* @var mixed |
|
57
|
|
|
*/ |
|
58
|
|
|
public $customerRef; |
|
59
|
|
|
/** |
|
60
|
|
|
* @var mixed |
|
61
|
|
|
*/ |
|
62
|
|
|
public $formOfPaymentByPassenger; |
|
63
|
|
|
/** |
|
64
|
|
|
* @var mixed |
|
65
|
|
|
*/ |
|
66
|
|
|
public $solutionFamily; |
|
67
|
|
|
/** |
|
68
|
|
|
* @var mixed |
|
69
|
|
|
*/ |
|
70
|
|
|
public $fareFamilies; |
|
71
|
|
|
/** |
|
72
|
|
|
* @var MasterPricer\FareOptions |
|
73
|
|
|
*/ |
|
74
|
|
|
public $fareOptions; |
|
75
|
|
|
/** |
|
76
|
|
|
* @var mixed |
|
77
|
|
|
*/ |
|
78
|
|
|
public $priceToBeat; |
|
79
|
|
|
/** |
|
80
|
|
|
* @var mixed |
|
81
|
|
|
*/ |
|
82
|
|
|
public $taxInfo; |
|
83
|
|
|
/** |
|
84
|
|
|
* @var MasterPricer\TravelFlightInfo |
|
85
|
|
|
*/ |
|
86
|
|
|
public $travelFlightInfo; |
|
87
|
|
|
|
|
88
|
|
|
public $valueSearch = []; |
|
89
|
|
|
/** |
|
90
|
|
|
* Itinerary |
|
91
|
|
|
* |
|
92
|
|
|
* @var MasterPricer\Itinerary[] |
|
93
|
|
|
*/ |
|
94
|
|
|
public $itinerary = []; |
|
95
|
|
|
/** |
|
96
|
|
|
* @var mixed |
|
97
|
|
|
*/ |
|
98
|
|
|
public $ticketChangeInfo; |
|
99
|
|
|
/** |
|
100
|
|
|
* @var mixed |
|
101
|
|
|
*/ |
|
102
|
|
|
public $combinationFareFamilies; |
|
103
|
|
|
/** |
|
104
|
|
|
* @var mixed |
|
105
|
|
|
*/ |
|
106
|
|
|
public $feeOption; |
|
107
|
|
|
/** |
|
108
|
|
|
* @var mixed |
|
109
|
|
|
*/ |
|
110
|
|
|
public $officeIdDetails; |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* MasterPricerTravelBoardSearch constructor. |
|
114
|
|
|
* |
|
115
|
|
|
* @param FareMasterPricerTbSearch|null $options |
|
116
|
|
|
*/ |
|
117
|
|
|
public function __construct(FareMasterPricerTbSearch $options = null) |
|
118
|
|
|
{ |
|
119
|
|
|
if ($options instanceof FareMasterPricerTbSearch) { |
|
120
|
|
|
$this->loadOptions($options); |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @param FareMasterPricerTbSearch $options |
|
126
|
|
|
*/ |
|
127
|
|
|
protected function loadOptions(FareMasterPricerTbSearch $options) |
|
128
|
|
|
{ |
|
129
|
|
|
$this->loadNrOfPaxAndResults($options); |
|
130
|
|
|
|
|
131
|
|
|
if ($options->doTicketabilityPreCheck === true) { |
|
132
|
|
|
$this->fareOptions = new MasterPricer\FareOptions(); |
|
133
|
|
|
$this->fareOptions->pricingTickInfo = new MasterPricer\PricingTickInfo(); |
|
134
|
|
|
$this->fareOptions->pricingTickInfo->pricingTicketing = new MasterPricer\PricingTicketing( |
|
135
|
|
|
MasterPricer\PricingTicketing::PRICETYPE_TICKETABILITY_PRECHECK |
|
136
|
|
|
); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
$passengerCounter = 1; |
|
140
|
|
|
$infantCounter = 1; |
|
141
|
|
|
foreach ($options->passengers as $passenger) { |
|
142
|
|
|
$this->loadPassenger($passenger, $passengerCounter, $infantCounter); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
$segmentCounter = 1; |
|
146
|
|
|
foreach ($options->itinerary as $itinerary) { |
|
147
|
|
|
$this->loadItinerary($itinerary, $segmentCounter); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
if (!empty($options->cabinClass)) { |
|
151
|
|
|
$this->travelFlightInfo = new MasterPricer\TravelFlightInfo($options->cabinClass); |
|
152
|
|
|
} |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @param MPPassenger $passenger |
|
157
|
|
|
* @param int $counter BYREF |
|
158
|
|
|
* @param int $infantCounter BYREF |
|
159
|
|
|
*/ |
|
160
|
|
|
protected function loadPassenger($passenger, &$counter, &$infantCounter) |
|
161
|
|
|
{ |
|
162
|
|
|
$isInfant = ($passenger->type === 'INF'); |
|
163
|
|
|
|
|
164
|
|
|
$paxRef = new MasterPricer\PaxReference( |
|
165
|
|
|
$isInfant ? $infantCounter : $counter, |
|
166
|
|
|
$isInfant, |
|
167
|
|
|
$passenger->type |
|
168
|
|
|
); |
|
169
|
|
|
|
|
170
|
|
|
if ($isInfant) { |
|
171
|
|
|
$infantCounter++; |
|
172
|
|
|
} else { |
|
173
|
|
|
$counter++; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
if ($passenger->count > 1) { |
|
177
|
|
|
for ($i = 2; $i <= $passenger->count; $i++) { |
|
178
|
|
|
$tmpCount = ($isInfant) ? $infantCounter : $counter; |
|
179
|
|
|
$paxRef->traveller[] = new MasterPricer\Traveller($tmpCount, $isInfant); |
|
180
|
|
|
|
|
181
|
|
|
if ($isInfant) { |
|
182
|
|
|
$infantCounter++; |
|
183
|
|
|
} else { |
|
184
|
|
|
$counter++; |
|
185
|
|
|
} |
|
186
|
|
|
} |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
$this->paxReference[] = $paxRef; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* @param MPItinerary $itinerary |
|
194
|
|
|
* @param int $counter BYREF |
|
195
|
|
|
*/ |
|
196
|
|
|
protected function loadItinerary($itinerary, &$counter) |
|
197
|
|
|
{ |
|
198
|
|
|
$tmpItin = new MasterPricer\Itinerary($counter); |
|
199
|
|
|
|
|
200
|
|
|
$tmpItin->departureLocalization = new MasterPricer\DepartureLocalization($itinerary->departureLocation); |
|
201
|
|
|
$tmpItin->arrivalLocalization = new MasterPricer\ArrivalLocalization($itinerary->arrivalLocation); |
|
202
|
|
|
$tmpItin->timeDetails = new MasterPricer\TimeDetails($itinerary->date); |
|
203
|
|
|
|
|
204
|
|
|
$this->itinerary[] = $tmpItin; |
|
205
|
|
|
|
|
206
|
|
|
$counter++; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* @param FareMasterPricerTbSearch $options |
|
211
|
|
|
* @return void |
|
212
|
|
|
*/ |
|
213
|
|
|
protected function loadNrOfPaxAndResults(FareMasterPricerTbSearch $options) |
|
214
|
|
|
{ |
|
215
|
|
|
if (is_int($options->nrOfRequestedPassengers) || is_int($options->nrOfRequestedResults)) { |
|
216
|
|
|
$this->numberOfUnit = new MasterPricer\NumberOfUnit(); |
|
217
|
|
View Code Duplication |
if (is_int($options->nrOfRequestedPassengers)) { |
|
|
|
|
|
|
218
|
|
|
$this->numberOfUnit->unitNumberDetail[] = new MasterPricer\UnitNumberDetail( |
|
219
|
|
|
$options->nrOfRequestedPassengers, |
|
220
|
|
|
MasterPricer\UnitNumberDetail::TYPE_PASS |
|
221
|
|
|
); |
|
222
|
|
|
} |
|
223
|
|
View Code Duplication |
if (is_int($options->nrOfRequestedResults)) { |
|
|
|
|
|
|
224
|
|
|
$this->numberOfUnit->unitNumberDetail[] = new MasterPricer\UnitNumberDetail( |
|
225
|
|
|
$options->nrOfRequestedResults, |
|
226
|
|
|
MasterPricer\UnitNumberDetail::TYPE_RESULTS |
|
227
|
|
|
); |
|
228
|
|
|
} |
|
229
|
|
|
} |
|
230
|
|
|
} |
|
231
|
|
|
} |
|
232
|
|
|
|
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.