|
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\Pnr\AddMultiElements; |
|
24
|
|
|
|
|
25
|
|
|
use Amadeus\Client\RequestOptions\Pnr\Element; |
|
26
|
|
|
use Amadeus\Client\Struct\InvalidArgumentException; |
|
27
|
|
|
use Amadeus\Client\Struct\WsMessageUtility; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* DataElementsIndiv |
|
31
|
|
|
* |
|
32
|
|
|
* all the others segments |
|
33
|
|
|
* |
|
34
|
|
|
* @package Amadeus\Client\Struct\Pnr\AddMultiElements |
|
35
|
|
|
* @author Dieter Devlieghere <[email protected]> |
|
36
|
|
|
*/ |
|
37
|
|
|
class DataElementsIndiv extends WsMessageUtility |
|
38
|
|
|
{ |
|
39
|
|
|
/** |
|
40
|
|
|
* To specify the PNR segments/elements references and action to apply |
|
41
|
|
|
* |
|
42
|
|
|
* @var ElementManagementData |
|
43
|
|
|
*/ |
|
44
|
|
|
public $elementManagementData; |
|
45
|
|
|
/** |
|
46
|
|
|
* @var PnrSecurity |
|
47
|
|
|
*/ |
|
48
|
|
|
public $pnrSecurity; |
|
49
|
|
|
/** |
|
50
|
|
|
* @var Accounting |
|
51
|
|
|
*/ |
|
52
|
|
|
public $accounting; |
|
53
|
|
|
/** |
|
54
|
|
|
* To specify different kinds of remarks |
|
55
|
|
|
* |
|
56
|
|
|
* @var MiscellaneousRemark |
|
57
|
|
|
*/ |
|
58
|
|
|
public $miscellaneousRemark; |
|
59
|
|
|
/** |
|
60
|
|
|
* @var ServiceRequest |
|
61
|
|
|
*/ |
|
62
|
|
|
public $serviceRequest; |
|
63
|
|
|
public $dateAndTimeInformation; |
|
64
|
|
|
/** |
|
65
|
|
|
* @var TourCode |
|
66
|
|
|
*/ |
|
67
|
|
|
public $tourCode; |
|
68
|
|
|
/** |
|
69
|
|
|
* To specify an Amadeus PNR Ticket element |
|
70
|
|
|
* |
|
71
|
|
|
* @var TicketElement |
|
72
|
|
|
*/ |
|
73
|
|
|
public $ticketElement; |
|
74
|
|
|
/** |
|
75
|
|
|
* To provide free form or coded long text information. |
|
76
|
|
|
* |
|
77
|
|
|
* @var FreetextData |
|
78
|
|
|
*/ |
|
79
|
|
|
public $freetextData; |
|
80
|
|
|
/** |
|
81
|
|
|
* @var StructuredAddress |
|
82
|
|
|
*/ |
|
83
|
|
|
public $structuredAddress; |
|
84
|
|
|
public $optionElement; |
|
85
|
|
|
public $printer; |
|
86
|
|
|
/** |
|
87
|
|
|
* This group handles Seat Request with possibly rail preferences |
|
88
|
|
|
* |
|
89
|
|
|
* @var SeatGroup |
|
90
|
|
|
*/ |
|
91
|
|
|
public $seatGroup; |
|
92
|
|
|
public $entity; |
|
93
|
|
|
public $fareElement; |
|
94
|
|
|
public $fareDiscount; |
|
95
|
|
|
public $manualFareDocument; |
|
96
|
|
|
/** |
|
97
|
|
|
* @var Commission |
|
98
|
|
|
*/ |
|
99
|
|
|
public $commission; |
|
100
|
|
|
public $originalIssue; |
|
101
|
|
|
/** |
|
102
|
|
|
* To convey details describing the form of payment |
|
103
|
|
|
* |
|
104
|
|
|
* @var FormOfPayment |
|
105
|
|
|
*/ |
|
106
|
|
|
public $formOfPayment; |
|
107
|
|
|
/** |
|
108
|
|
|
* To convey additional details of the form of payment |
|
109
|
|
|
* |
|
110
|
|
|
* @var FopExtension[] |
|
111
|
|
|
*/ |
|
112
|
|
|
public $fopExtension = []; |
|
113
|
|
|
/** |
|
114
|
|
|
* To convey: |
|
115
|
|
|
* - The FOP service details |
|
116
|
|
|
* - The Corporate Security option for Remarks |
|
117
|
|
|
* - The Timestamp indicator for Remarks |
|
118
|
|
|
* |
|
119
|
|
|
* @var ServiceDetails[] |
|
120
|
|
|
*/ |
|
121
|
|
|
public $serviceDetails = []; |
|
122
|
|
|
public $frequentTravellerVerification; |
|
123
|
|
|
public $ticketingCarrier; |
|
124
|
|
|
public $farePrintOverride; |
|
125
|
|
|
/** |
|
126
|
|
|
* Frequent Flyer info |
|
127
|
|
|
* |
|
128
|
|
|
* @var FrequentTravellerData |
|
129
|
|
|
*/ |
|
130
|
|
|
public $frequentTravellerData; |
|
131
|
|
|
public $accessLevel; |
|
132
|
|
|
/** |
|
133
|
|
|
* To provide specific reference identification |
|
134
|
|
|
* |
|
135
|
|
|
* @var ReferenceForDataElement |
|
136
|
|
|
*/ |
|
137
|
|
|
public $referenceForDataElement; |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @param Element|string $element Either an element or an element name |
|
141
|
200 |
|
* @param int $tattoo Unique tattoo number for this element |
|
142
|
|
|
* @throws \ReflectionException |
|
143
|
200 |
|
*/ |
|
144
|
200 |
|
public function __construct($element, $tattoo) |
|
145
|
200 |
|
{ |
|
146
|
|
|
if ($element instanceof Element) { |
|
147
|
200 |
|
$reflect = new \ReflectionClass($element); |
|
148
|
200 |
|
$elementType = $reflect->getShortName(); |
|
149
|
80 |
|
|
|
150
|
80 |
|
$this->elementManagementData = new ElementManagementData( |
|
151
|
|
|
$this->makeSegmentNameForRequestElement($elementType, $element), |
|
152
|
200 |
|
$tattoo |
|
153
|
79 |
|
); |
|
154
|
5 |
|
|
|
155
|
5 |
|
$this->loadElement($element, $elementType); |
|
156
|
2 |
|
} elseif (is_string($element)) { |
|
|
|
|
|
|
157
|
2 |
|
$this->elementManagementData = new ElementManagementData( |
|
158
|
2 |
|
$element, |
|
159
|
190 |
|
$tattoo |
|
160
|
|
|
); |
|
161
|
|
|
} |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
200 |
|
* @param Element $element |
|
166
|
|
|
* @param string $elementType |
|
167
|
80 |
|
*/ |
|
168
|
200 |
|
protected function loadElement($element, $elementType) |
|
169
|
|
|
{ |
|
170
|
30 |
|
switch ($elementType) { |
|
171
|
30 |
|
case 'Contact': |
|
172
|
30 |
|
/** @var Element\Contact $element */ |
|
173
|
12 |
|
$this->freetextData = new FreetextData( |
|
174
|
30 |
|
$element->value, |
|
175
|
200 |
|
$element->type |
|
176
|
|
|
); |
|
177
|
30 |
|
break; |
|
178
|
30 |
|
case 'FormOfPayment': |
|
179
|
10 |
|
/** @var Element\FormOfPayment $element */ |
|
180
|
10 |
|
$this->formOfPayment = new FormOfPayment($element->type); |
|
181
|
10 |
|
if ($element->type === Fop::IDENT_CREDITCARD) { |
|
182
|
10 |
|
$this->formOfPayment->fop->creditCardCode = $element->creditCardType; |
|
183
|
10 |
|
$this->formOfPayment->fop->accountNumber = $element->creditCardNumber; |
|
184
|
10 |
|
$this->formOfPayment->fop->expiryDate = $element->creditCardExpiry; |
|
185
|
10 |
|
if ($element->freeText && $element->freeText != "") { |
|
186
|
10 |
|
$this->formOfPayment->fop->freetext = $element->freeText; |
|
187
|
4 |
|
} |
|
188
|
4 |
|
if ($this->checkAnyNotEmpty($element->creditCardCvcCode, $element->creditCardHolder)) { |
|
189
|
24 |
|
$this->fopExtension[] = new FopExtension( |
|
190
|
5 |
|
1, |
|
191
|
17 |
|
$element->creditCardCvcCode, |
|
192
|
5 |
|
$element->creditCardHolder |
|
193
|
12 |
|
); |
|
194
|
5 |
|
} |
|
195
|
|
|
} elseif ($element->type === Fop::IDENT_CASH && $element->freeText != "") { |
|
196
|
|
|
$this->formOfPayment->fop->freetext = $element->freeText; |
|
197
|
25 |
|
} elseif ($element->type === Fop::IDENT_MISC && $element->freeText != "NONREF") { |
|
198
|
5 |
|
$this->formOfPayment->fop->freetext = $element->freeText; |
|
199
|
3 |
|
} elseif ($element->type === Fop::IDENT_MISC && $element->freeText === "NONREF") { |
|
200
|
2 |
|
$this->fopExtension[] = new FopExtension(1); |
|
201
|
2 |
|
} elseif ($element->type === Fop::IDENT_CHECK) { |
|
202
|
25 |
|
throw new \RuntimeException("FOP CHECK NOT YET IMPLEMENTED"); |
|
203
|
195 |
|
} |
|
204
|
|
|
|
|
205
|
5 |
|
if ($element->isServiceFee) { |
|
206
|
5 |
|
$this->serviceDetails[] = new ServiceDetails( |
|
207
|
5 |
|
StatusDetails::IND_SERVICEFEE |
|
208
|
5 |
|
); |
|
209
|
2 |
|
} |
|
210
|
5 |
|
break; |
|
211
|
195 |
|
case 'MiscellaneousRemark': |
|
212
|
|
|
/** @var Element\MiscellaneousRemark $element */ |
|
213
|
165 |
|
$this->miscellaneousRemark = new MiscellaneousRemark( |
|
214
|
165 |
|
$element->text, |
|
215
|
99 |
|
$element->type, |
|
216
|
66 |
|
$element->category |
|
217
|
165 |
|
); |
|
218
|
95 |
|
break; |
|
219
|
|
|
case 'ReceivedFrom': |
|
220
|
5 |
|
/** @var Element\ReceivedFrom $element */ |
|
221
|
5 |
|
$this->freetextData = new FreetextData( |
|
222
|
95 |
|
$element->receivedFrom, |
|
223
|
|
|
FreetextDetail::TYPE_RECEIVE_FROM |
|
224
|
30 |
|
); |
|
225
|
30 |
|
break; |
|
226
|
65 |
|
case 'ServiceRequest': |
|
227
|
|
|
/** @var Element\ServiceRequest $element */ |
|
228
|
5 |
|
$this->serviceRequest = new ServiceRequest($element); |
|
229
|
5 |
|
break; |
|
230
|
60 |
|
case 'Ticketing': |
|
231
|
|
|
/** @var Element\Ticketing $element */ |
|
232
|
15 |
|
$this->ticketElement = new TicketElement($element); |
|
233
|
11 |
|
break; |
|
234
|
6 |
|
case 'AccountingInfo': |
|
235
|
10 |
|
/** @var Element\AccountingInfo $element */ |
|
236
|
10 |
|
$this->accounting = new Accounting($element); |
|
237
|
6 |
|
break; |
|
238
|
4 |
|
case 'Address': |
|
239
|
4 |
|
/** @var Element\Address $element */ |
|
240
|
5 |
|
if ($element->type === ElementManagementData::SEGNAME_ADDRESS_BILLING_UNSTRUCTURED || |
|
241
|
|
|
$element->type === ElementManagementData::SEGNAME_ADDRESS_MAILING_UNSTRUCTURED |
|
242
|
15 |
|
) { |
|
243
|
45 |
|
$this->freetextData = new FreetextData( |
|
244
|
|
|
$element->freeText, |
|
245
|
5 |
|
FreetextDetail::TYPE_MAILING_ADDRESS |
|
246
|
5 |
|
); |
|
247
|
5 |
|
} else { |
|
248
|
5 |
|
$this->structuredAddress = new StructuredAddress($element); |
|
249
|
5 |
|
} |
|
250
|
40 |
|
break; |
|
251
|
|
|
case 'FrequentFlyer': |
|
252
|
5 |
|
/** @var Element\FrequentFlyer $element */ |
|
253
|
5 |
|
$this->serviceRequest = new ServiceRequest(); |
|
254
|
3 |
|
$this->serviceRequest->ssr->type = 'FQTV'; |
|
255
|
2 |
|
$this->serviceRequest->ssr->companyId = $element->airline; |
|
256
|
5 |
|
$this->frequentTravellerData = new FrequentTravellerData($element); |
|
257
|
5 |
|
break; |
|
258
|
5 |
|
case 'OtherServiceInfo': |
|
259
|
35 |
|
/** @var Element\OtherServiceInfo $element */ |
|
260
|
|
|
$this->freetextData = new FreetextData( |
|
261
|
5 |
|
$element->freeText, |
|
262
|
5 |
|
FreetextDetail::TYPE_OSI_ELEMENT |
|
263
|
30 |
|
); |
|
264
|
|
|
$this->freetextData->freetextDetail->companyId = $element->airline; |
|
265
|
15 |
|
$this->freetextData->freetextDetail->subjectQualifier = FreetextDetail::QUALIFIER_LITERALTEXT; |
|
266
|
15 |
|
break; |
|
267
|
15 |
|
case 'ManualCommission': |
|
268
|
|
|
/** @var Element\ManualCommission $element */ |
|
269
|
5 |
|
$this->commission = new Commission($element); |
|
270
|
5 |
|
break; |
|
271
|
10 |
|
case 'SeatRequest': |
|
272
|
|
|
/** @var Element\SeatRequest $element */ |
|
273
|
5 |
|
$this->seatGroup = new SeatGroup($element); |
|
274
|
5 |
|
break; |
|
275
|
5 |
|
case 'TourCode': |
|
276
|
5 |
|
/** @var Element\TourCode $element */ |
|
277
|
2 |
|
$this->tourCode = new TourCode($element); |
|
278
|
5 |
|
break; |
|
279
|
2 |
|
case 'ManualIssuedTicket': |
|
280
|
5 |
|
/** @var Element\ManualIssuedTicket $element */ |
|
281
|
2 |
|
$this->manualFareDocument = new ManualDocumentRegistration( |
|
282
|
190 |
|
$element->passengerType, |
|
283
|
|
|
$element->companyId, |
|
284
|
|
|
$element->ticketNumber |
|
285
|
|
|
); |
|
286
|
|
|
break; |
|
287
|
|
|
case 'ScheduleChange': |
|
288
|
|
|
/** @var Element\ScheduleChange $element */ |
|
289
|
|
|
$this->freetextData = new FreetextData( |
|
290
|
|
|
'SCHGTOOL', |
|
291
|
200 |
|
FreetextDetail::TYPE_RECEIVE_FROM |
|
292
|
|
|
); |
|
293
|
200 |
|
break; |
|
294
|
|
|
case 'FareMiscellaneousInformation': |
|
295
|
|
|
/** @var Element\FareMiscellaneousInformation $element */ |
|
296
|
200 |
|
$this->fareElement = new FareElement($element->indicator, $element->passengerType, $element->freeText, $element->officeId); |
|
297
|
80 |
|
break; |
|
298
|
80 |
|
case 'PnrSecurity': |
|
299
|
80 |
|
/** @var Element\PnrSecurity $element */ |
|
300
|
80 |
|
$this->pnrSecurity = new PnrSecurity($element); |
|
301
|
80 |
|
break; |
|
302
|
80 |
|
default: |
|
303
|
80 |
|
throw new InvalidArgumentException('Element type '.$elementType.' is not supported'); |
|
304
|
80 |
|
} |
|
305
|
80 |
|
} |
|
306
|
80 |
|
|
|
307
|
80 |
|
/** |
|
308
|
80 |
|
* Create the correct element identifier for a given element |
|
309
|
|
|
* |
|
310
|
80 |
|
* @param string $elementType |
|
311
|
|
|
* @param Element $element |
|
312
|
200 |
|
* @return string |
|
313
|
195 |
|
*/ |
|
314
|
|
|
protected function makeSegmentNameForRequestElement($elementType, $element) |
|
315
|
195 |
|
{ |
|
316
|
|
|
$elementName = ''; |
|
317
|
15 |
|
|
|
318
|
6 |
|
$sourceArray = [ |
|
319
|
78 |
|
'Contact' => ElementManagementData::SEGNAME_CONTACT_ELEMENT, |
|
320
|
|
|
'FormOfPayment' => ElementManagementData::SEGNAME_FORM_OF_PAYMENT, |
|
321
|
200 |
|
'MiscellaneousRemark' => ElementManagementData::SEGNAME_GENERAL_REMARK, |
|
322
|
|
|
'ReceivedFrom' => ElementManagementData::SEGNAME_RECEIVE_FROM, |
|
323
|
|
|
'ServiceRequest' => ElementManagementData::SEGNAME_SPECIAL_SERVICE_REQUEST, |
|
324
|
|
|
'Ticketing' => ElementManagementData::SEGNAME_TICKETING_ELEMENT, |
|
325
|
|
|
'AccountingInfo' => ElementManagementData::SEGNAME_ACCOUNTING_INFORMATION, |
|
326
|
|
|
'Address' => null, // Special case - the type is a parameter. |
|
327
|
|
|
'FrequentFlyer' => ElementManagementData::SEGNAME_SPECIAL_SERVICE_REQUEST, |
|
328
|
|
|
'OtherServiceInfo' => ElementManagementData::SEGNAME_OTHER_SERVICE_INFORMATION, |
|
329
|
|
|
'ManualCommission' => ElementManagementData::SEGNAME_COMMISSION, |
|
330
|
|
|
'SeatRequest' => ElementManagementData::SEGNAME_SEAT_REQUEST, |
|
331
|
|
|
'TourCode' => ElementManagementData::SEGNAME_TOUR_CODE, |
|
332
|
|
|
'ManualIssuedTicket' => ElementManagementData::SEGNAME_MANUAL_DOCUMENT_REGISTRATION_WITH_ET_NUMBER, |
|
333
|
|
|
'ScheduleChange' => ElementManagementData::SEGNAME_RECEIVE_FROM, |
|
334
|
|
|
'FareMiscellaneousInformation' => null, // Special case - the type is a parameter. |
|
335
|
|
|
'PnrSecurity' => ElementManagementData::SEGNAME_INDIVIDUAL_SECURITY, |
|
336
|
|
|
]; |
|
337
|
|
|
|
|
338
|
|
|
if (array_key_exists($elementType, $sourceArray)) { |
|
339
|
|
|
$elementName = $sourceArray[$elementType]; |
|
340
|
|
|
|
|
341
|
|
|
if ($elementType === 'Address') { |
|
342
|
|
|
/** @var Element\Address $element */ |
|
343
|
|
|
$elementName = $element->type; |
|
344
|
|
|
} |
|
345
|
|
|
|
|
346
|
|
|
if ($elementType === 'FareMiscellaneousInformation') { |
|
347
|
|
|
/** @var Element\FareMiscellaneousInformation $element */ |
|
348
|
|
|
|
|
349
|
|
|
switch ($element->indicator) { |
|
350
|
|
|
case Element\FareMiscellaneousInformation::GENERAL_INDICATOR_FS: |
|
351
|
|
|
$elementName = ElementManagementData::SEGNAME_MISC_TICKET_INFO; |
|
352
|
|
|
break; |
|
353
|
|
|
case Element\FareMiscellaneousInformation::GENERAL_INDICATOR_FE: |
|
354
|
|
|
$elementName = ElementManagementData::SEGNAME_ENDORSEMENT; |
|
355
|
|
|
break; |
|
356
|
|
|
case Element\FareMiscellaneousInformation::GENERAL_INDICATOR_FK: |
|
357
|
|
|
$elementName = ElementManagementData::SEGNAME_AIR_OFFICE_ID; |
|
358
|
|
|
break; |
|
359
|
|
|
case Element\FareMiscellaneousInformation::GENERAL_INDICATOR_FZ: |
|
360
|
|
|
$elementName = ElementManagementData::SEGNAME_MISC_INFO; |
|
361
|
|
|
break; |
|
362
|
|
|
} |
|
363
|
|
|
} |
|
364
|
|
|
} |
|
365
|
|
|
|
|
366
|
|
|
return $elementName; |
|
367
|
|
|
} |
|
368
|
|
|
} |
|
369
|
|
|
|