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; |
24
|
|
|
|
25
|
|
|
use Amadeus\Client\Exception; |
26
|
|
|
use Amadeus\Client\Params; |
27
|
|
|
use Amadeus\Client\RequestCreator\RequestCreatorInterface; |
28
|
|
|
use Amadeus\Client\RequestOptions; |
29
|
|
|
use Amadeus\Client\ResponseHandler\ResponseHandlerInterface; |
30
|
|
|
use Amadeus\Client\Result; |
31
|
|
|
use Amadeus\Client\Session\Handler\HandlerFactory; |
32
|
|
|
use Amadeus\Client\RequestCreator\Factory as RequestCreatorFactory; |
33
|
|
|
use Amadeus\Client\Session\Handler\HandlerInterface; |
34
|
|
|
use Amadeus\Client\ResponseHandler\Base as ResponseHandlerBase; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Amadeus Web Service Client. |
38
|
|
|
* |
39
|
|
|
* TODO: |
40
|
|
|
* - support older versions of SoapHeader (1) |
41
|
|
|
* |
42
|
|
|
* @package Amadeus |
43
|
|
|
* @author Dieter Devlieghere <[email protected]> |
44
|
|
|
*/ |
45
|
|
|
class Client |
46
|
|
|
{ |
47
|
|
|
/** |
48
|
|
|
* Amadeus SOAP header version 1 |
49
|
|
|
*/ |
50
|
|
|
const HEADER_V1 = "1"; |
51
|
|
|
/** |
52
|
|
|
* Amadeus SOAP header version 2 |
53
|
|
|
*/ |
54
|
|
|
const HEADER_V2 = "2"; |
55
|
|
|
/** |
56
|
|
|
* Amadeus SOAP header version 4 |
57
|
|
|
*/ |
58
|
|
|
const HEADER_V4 = "4"; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Version string |
62
|
|
|
* |
63
|
|
|
* @var string |
64
|
|
|
*/ |
65
|
|
|
const VERSION = "1.1.0-dev"; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* An identifier string for the library (to be used in Received From entries) |
69
|
|
|
* |
70
|
|
|
* @var string |
71
|
|
|
*/ |
72
|
|
|
const RECEIVED_FROM_IDENTIFIER = "amabnl-amadeus-ws-client"; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Session Handler will be sending all the messages and handling all session-related things. |
76
|
|
|
* |
77
|
|
|
* @var HandlerInterface |
78
|
|
|
*/ |
79
|
|
|
protected $sessionHandler; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Request Creator is will create the correct message structure to send to the SOAP server. |
83
|
|
|
* |
84
|
|
|
* @var RequestCreatorInterface |
85
|
|
|
*/ |
86
|
|
|
protected $requestCreator; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Response Handler will check the received response for errors. |
90
|
|
|
* |
91
|
|
|
* @var ResponseHandlerInterface |
92
|
|
|
*/ |
93
|
|
|
protected $responseHandler; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Authentication parameters |
97
|
|
|
* |
98
|
|
|
* @var Params\AuthParams |
99
|
|
|
*/ |
100
|
|
|
protected $authParams; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @var string |
104
|
|
|
*/ |
105
|
|
|
protected $lastMessage; |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Set the session as stateful (true) or stateless (false) |
109
|
|
|
* |
110
|
|
|
* @param bool $newStateful |
111
|
|
|
*/ |
112
|
|
|
public function setStateful($newStateful) |
113
|
|
|
{ |
114
|
|
|
$this->sessionHandler->setStateful($newStateful); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return bool |
119
|
|
|
*/ |
120
|
|
|
public function isStateful() |
121
|
|
|
{ |
122
|
|
|
return $this->sessionHandler->isStateful(); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Get the last raw XML message that was sent out |
127
|
|
|
* |
128
|
|
|
* @return string|null |
129
|
|
|
*/ |
130
|
|
|
public function getLastRequest() |
131
|
|
|
{ |
132
|
|
|
return $this->sessionHandler->getLastRequest($this->lastMessage); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Get the last raw XML message that was received |
137
|
|
|
* |
138
|
|
|
* @return string|null |
139
|
|
|
*/ |
140
|
|
|
public function getLastResponse() |
141
|
|
|
{ |
142
|
|
|
return $this->sessionHandler->getLastResponse($this->lastMessage); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Get session information for authenticated session |
147
|
|
|
* |
148
|
|
|
* - sessionId |
149
|
|
|
* - sequenceNr |
150
|
|
|
* - securityToken |
151
|
|
|
* |
152
|
|
|
* @return array|null |
153
|
|
|
*/ |
154
|
|
|
public function getSessionData() |
155
|
|
|
{ |
156
|
|
|
return $this->sessionHandler->getSessionData(); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Restore a previously used session |
161
|
|
|
* |
162
|
|
|
* To be used when implementing your own session pooling system on legacy Soap Header 2 applications. |
163
|
|
|
* |
164
|
|
|
* @param array $sessionData |
165
|
|
|
* @return bool |
166
|
|
|
*/ |
167
|
|
|
public function setSessionData(array $sessionData) |
168
|
|
|
{ |
169
|
|
|
return $this->sessionHandler->setSessionData($sessionData); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Construct Amadeus Web Services client |
174
|
|
|
* |
175
|
|
|
* @param Params $params |
176
|
|
|
*/ |
177
|
|
|
public function __construct($params) |
178
|
|
|
{ |
179
|
|
|
if ($params->authParams instanceof Params\AuthParams) { |
180
|
|
|
$this->authParams = $params->authParams; |
181
|
|
|
if (isset($params->sessionHandlerParams) && |
182
|
|
|
$params->sessionHandlerParams instanceof Params\SessionHandlerParams |
183
|
|
|
) { |
184
|
|
|
$params->sessionHandlerParams->authParams = $this->authParams; |
185
|
|
|
} |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
$this->sessionHandler = $this->loadSessionHandler( |
189
|
|
|
$params->sessionHandler, |
190
|
|
|
$params->sessionHandlerParams |
191
|
|
|
); |
192
|
|
|
|
193
|
|
|
$this->requestCreator = $this->loadRequestCreator( |
194
|
|
|
$params->requestCreator, |
195
|
|
|
$params->requestCreatorParams, |
196
|
|
|
self::RECEIVED_FROM_IDENTIFIER."-".self::VERSION, |
197
|
|
|
$this->sessionHandler->getOriginatorOffice(), |
198
|
|
|
$this->sessionHandler->getMessagesAndVersions() |
199
|
|
|
); |
200
|
|
|
|
201
|
|
|
$this->responseHandler = $this->loadResponseHandler( |
202
|
|
|
$params->responseHandler |
203
|
|
|
); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* Authenticate. |
208
|
|
|
* |
209
|
|
|
* Parameters were provided at construction time (sessionhandlerparams) |
210
|
|
|
* |
211
|
|
|
* @return Result |
212
|
|
|
* @throws Exception |
213
|
|
|
*/ |
214
|
|
|
public function securityAuthenticate() |
215
|
|
|
{ |
216
|
|
|
$msgName = 'Security_Authenticate'; |
217
|
|
|
|
218
|
|
|
return $this->callMessage( |
219
|
|
|
$msgName, |
220
|
|
|
new RequestOptions\SecurityAuthenticateOptions( |
221
|
|
|
$this->authParams |
222
|
|
|
), |
223
|
|
|
[], |
224
|
|
|
false |
225
|
|
|
); |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* Terminate a session - only applicable to non-stateless mode. |
230
|
|
|
* |
231
|
|
|
* @return Result |
232
|
|
|
* @throws Exception |
233
|
|
|
*/ |
234
|
|
|
public function securitySignOut() |
235
|
|
|
{ |
236
|
|
|
$msgName = 'Security_SignOut'; |
237
|
|
|
|
238
|
|
|
return $this->callMessage( |
239
|
|
|
$msgName, |
240
|
|
|
new RequestOptions\SecuritySignOutOptions(), |
241
|
|
|
[], |
242
|
|
|
true |
243
|
|
|
); |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* PNR_Retrieve - Retrieve an Amadeus PNR by record locator |
248
|
|
|
* |
249
|
|
|
* @param RequestOptions\PnrRetrieveOptions $options |
250
|
|
|
* @param array $messageOptions (OPTIONAL) |
251
|
|
|
* @return Result |
252
|
|
|
* @throws Exception |
253
|
|
|
*/ |
254
|
|
|
public function pnrRetrieve(RequestOptions\PnrRetrieveOptions $options, $messageOptions = []) |
255
|
|
|
{ |
256
|
|
|
$msgName = 'PNR_Retrieve'; |
257
|
|
|
|
258
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* Create a PNR using PNR_AddMultiElements |
263
|
|
|
* |
264
|
|
|
* @param RequestOptions\PnrCreatePnrOptions $options |
265
|
|
|
* @param array $messageOptions (OPTIONAL) |
266
|
|
|
* @return Result |
267
|
|
|
*/ |
268
|
|
|
public function pnrCreatePnr(RequestOptions\PnrCreatePnrOptions $options, $messageOptions = []) |
269
|
|
|
{ |
270
|
|
|
$msgName = 'PNR_AddMultiElements'; |
271
|
|
|
|
272
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* PNR_AddMultiElements - Create a new PNR or update an existing PNR. |
277
|
|
|
* |
278
|
|
|
* https://webservices.amadeus.com/extranet/viewService.do?id=25&flavourId=1&menuId=functional |
279
|
|
|
* |
280
|
|
|
* @param RequestOptions\PnrAddMultiElementsOptions $options |
281
|
|
|
* @param array $messageOptions (OPTIONAL) |
282
|
|
|
* @return Result |
283
|
|
|
*/ |
284
|
|
|
public function pnrAddMultiElements(RequestOptions\PnrAddMultiElementsOptions $options, $messageOptions = []) |
285
|
|
|
{ |
286
|
|
|
$msgName = 'PNR_AddMultiElements'; |
287
|
|
|
|
288
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* PNR_RetrieveAndDisplay - Retrieve an Amadeus PNR by record locator including extra info |
293
|
|
|
* |
294
|
|
|
* This extra info is info you cannot see in the regular PNR, like Offers. |
295
|
|
|
* |
296
|
|
|
* By default, the result will be the PNR_RetrieveAndDisplayReply XML as string. |
297
|
|
|
* That way you can easily parse the PNR's contents with XPath. |
298
|
|
|
* |
299
|
|
|
* Set $messageOptions['asString'] = FALSE to get the response as a PHP object. |
300
|
|
|
* |
301
|
|
|
* https://webservices.amadeus.com/extranet/viewService.do?id=1922&flavourId=1&menuId=functional |
302
|
|
|
* |
303
|
|
|
* @param RequestOptions\PnrRetrieveAndDisplayOptions $options Amadeus Record Locator for PNR |
304
|
|
|
* @param array $messageOptions (OPTIONAL) |
305
|
|
|
* @return Result |
306
|
|
|
* @throws Exception |
307
|
|
|
**/ |
308
|
|
|
public function pnrRetrieveAndDisplay(RequestOptions\PnrRetrieveAndDisplayOptions $options, $messageOptions = []) |
309
|
|
|
{ |
310
|
|
|
$msgName = 'PNR_RetrieveAndDisplay'; |
311
|
|
|
|
312
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* PNR_Cancel |
317
|
|
|
* |
318
|
|
|
* @param RequestOptions\PnrCancelOptions $options |
319
|
|
|
* @param array $messageOptions (OPTIONAL) |
320
|
|
|
* @return Result |
321
|
|
|
*/ |
322
|
|
|
public function pnrCancel(RequestOptions\PnrCancelOptions $options, $messageOptions = []) |
323
|
|
|
{ |
324
|
|
|
$msgName = 'PNR_Cancel'; |
325
|
|
|
|
326
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
/** |
330
|
|
|
* PNR_DisplayHistory |
331
|
|
|
* |
332
|
|
|
* @param RequestOptions\PnrDisplayHistoryOptions $options |
333
|
|
|
* @param array $messageOptions (OPTIONAL) |
334
|
|
|
* @return Result |
335
|
|
|
*/ |
336
|
|
|
public function pnrDisplayHistory(RequestOptions\PnrDisplayHistoryOptions $options, $messageOptions = []) |
337
|
|
|
{ |
338
|
|
|
$msgName = 'PNR_DisplayHistory'; |
339
|
|
|
|
340
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
/** |
344
|
|
|
* PNR_TransferOwnership |
345
|
|
|
* |
346
|
|
|
* @param RequestOptions\PnrTransferOwnershipOptions $options |
347
|
|
|
* @param array $messageOptions (OPTIONAL) |
348
|
|
|
* @return Result |
349
|
|
|
*/ |
350
|
|
|
public function pnrTransferOwnership(RequestOptions\PnrTransferOwnershipOptions $options, $messageOptions = []) |
351
|
|
|
{ |
352
|
|
|
$msgName = 'PNR_TransferOwnership'; |
353
|
|
|
|
354
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
/** |
358
|
|
|
* Queue_List - get a list of all PNR's on a given queue |
359
|
|
|
* |
360
|
|
|
* https://webservices.amadeus.com/extranet/viewService.do?id=52&flavourId=1&menuId=functional |
361
|
|
|
* |
362
|
|
|
* @param RequestOptions\QueueListOptions $options |
363
|
|
|
* @param array $messageOptions (OPTIONAL) |
364
|
|
|
* @return Result |
365
|
|
|
*/ |
366
|
|
|
public function queueList(RequestOptions\QueueListOptions $options, $messageOptions = []) |
367
|
|
|
{ |
368
|
|
|
$msgName = 'Queue_List'; |
369
|
|
|
|
370
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
/** |
374
|
|
|
* Queue_PlacePNR - Place a PNR on a given queue |
375
|
|
|
* |
376
|
|
|
* @param RequestOptions\QueuePlacePnrOptions $options |
377
|
|
|
* @param array $messageOptions (OPTIONAL) |
378
|
|
|
* @return Result |
379
|
|
|
*/ |
380
|
|
|
public function queuePlacePnr(RequestOptions\QueuePlacePnrOptions $options, $messageOptions = []) |
381
|
|
|
{ |
382
|
|
|
$msgName = 'Queue_PlacePNR'; |
383
|
|
|
|
384
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* Queue_RemoveItem - remove an item (a PNR) from a given queue |
389
|
|
|
* |
390
|
|
|
* @param RequestOptions\QueueRemoveItemOptions $options |
391
|
|
|
* @param array $messageOptions (OPTIONAL) |
392
|
|
|
* @return Result |
393
|
|
|
*/ |
394
|
|
|
public function queueRemoveItem(RequestOptions\QueueRemoveItemOptions $options, $messageOptions = []) |
395
|
|
|
{ |
396
|
|
|
$msgName = 'Queue_RemoveItem'; |
397
|
|
|
|
398
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
399
|
|
|
} |
400
|
|
|
|
401
|
|
|
/** |
402
|
|
|
* Queue_MoveItem - move an item (a PNR) from one queue to another. |
403
|
|
|
* |
404
|
|
|
* @param RequestOptions\QueueMoveItemOptions $options |
405
|
|
|
* @param array $messageOptions (OPTIONAL) |
406
|
|
|
* @return Result |
407
|
|
|
*/ |
408
|
|
|
public function queueMoveItem(RequestOptions\QueueMoveItemOptions $options, $messageOptions = []) |
409
|
|
|
{ |
410
|
|
|
$msgName = 'Queue_MoveItem'; |
411
|
|
|
|
412
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
/** |
416
|
|
|
* Offer_CreateOffer |
417
|
|
|
* |
418
|
|
|
* @param RequestOptions\OfferCreateOptions $options |
419
|
|
|
* @param array $messageOptions (OPTIONAL) |
420
|
|
|
* @return Result |
421
|
|
|
*/ |
422
|
|
|
public function offerCreate(RequestOptions\OfferCreateOptions $options, $messageOptions = []) |
423
|
|
|
{ |
424
|
|
|
$msgName = 'Offer_CreateOffer'; |
425
|
|
|
|
426
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* Offer_VerifyOffer |
431
|
|
|
* |
432
|
|
|
* To be called in the context of an open PNR |
433
|
|
|
* |
434
|
|
|
* @param RequestOptions\OfferVerifyOptions $options |
435
|
|
|
* @param array $messageOptions (OPTIONAL) |
436
|
|
|
* @return Result |
437
|
|
|
*/ |
438
|
|
|
public function offerVerify(RequestOptions\OfferVerifyOptions $options, $messageOptions = []) |
439
|
|
|
{ |
440
|
|
|
$msgName = 'Offer_VerifyOffer'; |
441
|
|
|
|
442
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
443
|
|
|
} |
444
|
|
|
|
445
|
|
|
/** |
446
|
|
|
* Offer_ConfirmAirOffer |
447
|
|
|
* |
448
|
|
|
* @param RequestOptions\OfferConfirmAirOptions $options |
449
|
|
|
* @param array $messageOptions (OPTIONAL) |
450
|
|
|
* @return Result |
451
|
|
|
*/ |
452
|
|
|
public function offerConfirmAir(RequestOptions\OfferConfirmAirOptions $options, $messageOptions = []) |
453
|
|
|
{ |
454
|
|
|
$msgName = 'Offer_ConfirmAirOffer'; |
455
|
|
|
|
456
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
/** |
460
|
|
|
* Offer_ConfirmHotelOffer |
461
|
|
|
* |
462
|
|
|
* @param RequestOptions\OfferConfirmHotelOptions $options |
463
|
|
|
* @param array $messageOptions (OPTIONAL) |
464
|
|
|
* @return Result |
465
|
|
|
*/ |
466
|
|
|
public function offerConfirmHotel(RequestOptions\OfferConfirmHotelOptions $options, $messageOptions = []) |
467
|
|
|
{ |
468
|
|
|
$msgName = 'Offer_ConfirmHotelOffer'; |
469
|
|
|
|
470
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
/** |
474
|
|
|
* Offer_ConfirmCarOffer |
475
|
|
|
* |
476
|
|
|
* @param RequestOptions\OfferConfirmCarOptions $options |
477
|
|
|
* @param array $messageOptions (OPTIONAL) |
478
|
|
|
* @return Result |
479
|
|
|
*/ |
480
|
|
|
public function offerConfirmCar(RequestOptions\OfferConfirmCarOptions $options, $messageOptions = []) |
481
|
|
|
{ |
482
|
|
|
$msgName = 'Offer_ConfirmCarOffer'; |
483
|
|
|
|
484
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
/** |
488
|
|
|
* Fare_MasterPricerTravelBoardSearch |
489
|
|
|
* |
490
|
|
|
* @param RequestOptions\FareMasterPricerTbSearch $options |
491
|
|
|
* @param array $messageOptions (OPTIONAL) |
492
|
|
|
* @return Result |
493
|
|
|
*/ |
494
|
|
|
public function fareMasterPricerTravelBoardSearch( |
495
|
|
|
RequestOptions\FareMasterPricerTbSearch $options, |
496
|
|
|
$messageOptions = [] |
497
|
|
|
) { |
498
|
|
|
$msgName = 'Fare_MasterPricerTravelBoardSearch'; |
499
|
|
|
|
500
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
/** |
504
|
|
|
* Fare_MasterPricerCalendar |
505
|
|
|
* |
506
|
|
|
* @param RequestOptions\FareMasterPricerCalendarOptions $options |
507
|
|
|
* @param array $messageOptions (OPTIONAL) |
508
|
|
|
* @return Result |
509
|
|
|
*/ |
510
|
|
|
public function fareMasterPricerCalendar( |
511
|
|
|
RequestOptions\FareMasterPricerCalendarOptions $options, |
512
|
|
|
$messageOptions = [] |
513
|
|
|
) { |
514
|
|
|
$msgName = 'Fare_MasterPricerCalendar'; |
515
|
|
|
|
516
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
/** |
520
|
|
|
* Fare_PricePnrWithBookingClass |
521
|
|
|
* |
522
|
|
|
* @param RequestOptions\FarePricePnrWithBookingClassOptions $options |
523
|
|
|
* @param array $messageOptions (OPTIONAL) |
524
|
|
|
* @return Result |
525
|
|
|
*/ |
526
|
|
|
public function farePricePnrWithBookingClass( |
527
|
|
|
RequestOptions\FarePricePnrWithBookingClassOptions $options, |
528
|
|
|
$messageOptions = [] |
529
|
|
|
) { |
530
|
|
|
$msgName = 'Fare_PricePNRWithBookingClass'; |
531
|
|
|
|
532
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
/** |
536
|
|
|
* Fare_PricePnrWithLowerFares |
537
|
|
|
* |
538
|
|
|
* @param RequestOptions\FarePricePnrWithLowerFaresOptions $options |
539
|
|
|
* @param array $messageOptions (OPTIONAL) |
540
|
|
|
* @return Result |
541
|
|
|
*/ |
542
|
|
|
public function farePricePnrWithLowerFares( |
543
|
|
|
RequestOptions\FarePricePnrWithLowerFaresOptions $options, |
544
|
|
|
$messageOptions = [] |
545
|
|
|
) { |
546
|
|
|
$msgName = 'Fare_PricePNRWithLowerFares'; |
547
|
|
|
|
548
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
549
|
|
|
} |
550
|
|
|
|
551
|
|
|
/** |
552
|
|
|
* Fare_PricePnrWithLowestFare |
553
|
|
|
* |
554
|
|
|
* @param RequestOptions\FarePricePnrWithLowestFareOptions $options |
555
|
|
|
* @param array $messageOptions (OPTIONAL) |
556
|
|
|
* @return Result |
557
|
|
|
*/ |
558
|
|
|
public function farePricePnrWithLowestFare( |
559
|
|
|
RequestOptions\FarePricePnrWithLowestFareOptions $options, |
560
|
|
|
$messageOptions = [] |
561
|
|
|
) { |
562
|
|
|
$msgName = 'Fare_PricePNRWithLowestFare'; |
563
|
|
|
|
564
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
565
|
|
|
} |
566
|
|
|
|
567
|
|
|
/** |
568
|
|
|
* Fare_InformativePricingWithoutPNR |
569
|
|
|
* |
570
|
|
|
* @param RequestOptions\FareInformativePricingWithoutPnrOptions $options |
571
|
|
|
* @param array $messageOptions (OPTIONAL) |
572
|
|
|
* @return Result |
573
|
|
|
*/ |
574
|
|
|
public function fareInformativePricingWithoutPnr( |
575
|
|
|
RequestOptions\FareInformativePricingWithoutPnrOptions $options, |
576
|
|
|
$messageOptions = [] |
577
|
|
|
) { |
578
|
|
|
$msgName = 'Fare_InformativePricingWithoutPNR'; |
579
|
|
|
|
580
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
581
|
|
|
} |
582
|
|
|
|
583
|
|
|
/** |
584
|
|
|
* Fare_InformativeBestPricingWithoutPNR |
585
|
|
|
* |
586
|
|
|
* @param RequestOptions\FareInformativeBestPricingWithoutPnrOptions $options |
587
|
|
|
* @param array $messageOptions (OPTIONAL) |
588
|
|
|
* @return Result |
589
|
|
|
*/ |
590
|
|
|
public function fareInformativeBestPricingWithoutPnr( |
591
|
|
|
RequestOptions\FareInformativeBestPricingWithoutPnrOptions $options, |
592
|
|
|
$messageOptions = [] |
593
|
|
|
) { |
594
|
|
|
$msgName = 'Fare_InformativeBestPricingWithoutPNR'; |
595
|
|
|
|
596
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
597
|
|
|
} |
598
|
|
|
|
599
|
|
|
/** |
600
|
|
|
* Fare_CheckRules |
601
|
|
|
* |
602
|
|
|
* @param RequestOptions\FareCheckRulesOptions $options |
603
|
|
|
* @param array $messageOptions (OPTIONAL) |
604
|
|
|
* @return Result |
605
|
|
|
*/ |
606
|
|
|
public function fareCheckRules(RequestOptions\FareCheckRulesOptions $options, $messageOptions = []) |
607
|
|
|
{ |
608
|
|
|
$msgName = 'Fare_CheckRules'; |
609
|
|
|
|
610
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
611
|
|
|
} |
612
|
|
|
|
613
|
|
|
/** |
614
|
|
|
* Fare_ConvertCurrency |
615
|
|
|
* |
616
|
|
|
* @param RequestOptions\FareConvertCurrencyOptions $options |
617
|
|
|
* @param array $messageOptions (OPTIONAL) |
618
|
|
|
* @return Result |
619
|
|
|
*/ |
620
|
|
|
public function fareConvertCurrency(RequestOptions\FareConvertCurrencyOptions $options, $messageOptions = []) |
621
|
|
|
{ |
622
|
|
|
$msgName = 'Fare_ConvertCurrency'; |
623
|
|
|
|
624
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
625
|
|
|
} |
626
|
|
|
|
627
|
|
|
/** |
628
|
|
|
* Air_MultiAvailability |
629
|
|
|
* |
630
|
|
|
* @param RequestOptions\AirMultiAvailabilityOptions $options |
631
|
|
|
* @param array $messageOptions (OPTIONAL) |
632
|
|
|
* @return Result |
633
|
|
|
*/ |
634
|
|
|
public function airMultiAvailability( |
635
|
|
|
RequestOptions\AirMultiAvailabilityOptions $options, |
636
|
|
|
$messageOptions = [] |
637
|
|
|
) { |
638
|
|
|
$msgName = 'Air_MultiAvailability'; |
639
|
|
|
|
640
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
641
|
|
|
} |
642
|
|
|
|
643
|
|
|
/** |
644
|
|
|
* Air_SellFromRecommendation |
645
|
|
|
* |
646
|
|
|
* @param RequestOptions\AirSellFromRecommendationOptions $options |
647
|
|
|
* @param array $messageOptions (OPTIONAL) |
648
|
|
|
* @return Result |
649
|
|
|
*/ |
650
|
|
|
public function airSellFromRecommendation( |
651
|
|
|
RequestOptions\AirSellFromRecommendationOptions $options, |
652
|
|
|
$messageOptions = [] |
653
|
|
|
) { |
654
|
|
|
$msgName = 'Air_SellFromRecommendation'; |
655
|
|
|
|
656
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
657
|
|
|
} |
658
|
|
|
|
659
|
|
|
/** |
660
|
|
|
* Air_FlightInfo |
661
|
|
|
* |
662
|
|
|
* @param RequestOptions\AirFlightInfoOptions $options |
663
|
|
|
* @param array $messageOptions (OPTIONAL) |
664
|
|
|
* @return Result |
665
|
|
|
*/ |
666
|
|
|
public function airFlightInfo(RequestOptions\AirFlightInfoOptions $options, $messageOptions = []) |
667
|
|
|
{ |
668
|
|
|
$msgName = 'Air_FlightInfo'; |
669
|
|
|
|
670
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
671
|
|
|
} |
672
|
|
|
|
673
|
|
|
/** |
674
|
|
|
* Air_RetrieveSeatMap |
675
|
|
|
* |
676
|
|
|
* @param RequestOptions\AirRetrieveSeatMapOptions $options |
677
|
|
|
* @param array $messageOptions (OPTIONAL) |
678
|
|
|
* @return Result |
679
|
|
|
*/ |
680
|
|
|
public function airRetrieveSeatMap(RequestOptions\AirRetrieveSeatMapOptions $options, $messageOptions = []) |
681
|
|
|
{ |
682
|
|
|
$msgName = 'Air_RetrieveSeatMap'; |
683
|
|
|
|
684
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
685
|
|
|
} |
686
|
|
|
|
687
|
|
|
/** |
688
|
|
|
* Command_Cryptic |
689
|
|
|
* |
690
|
|
|
* @param RequestOptions\CommandCrypticOptions $options |
691
|
|
|
* @param array $messageOptions (OPTIONAL) |
692
|
|
|
* @return Result |
693
|
|
|
*/ |
694
|
|
|
public function commandCryptic(RequestOptions\CommandCrypticOptions $options, $messageOptions = []) |
695
|
|
|
{ |
696
|
|
|
$msgName = 'Command_Cryptic'; |
697
|
|
|
|
698
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
699
|
|
|
} |
700
|
|
|
|
701
|
|
|
/** |
702
|
|
|
* MiniRule_GetFromPricingRec |
703
|
|
|
* |
704
|
|
|
* @param RequestOptions\MiniRuleGetFromPricingRecOptions $options |
705
|
|
|
* @param array $messageOptions (OPTIONAL) |
706
|
|
|
* @return Result |
707
|
|
|
*/ |
708
|
|
|
public function miniRuleGetFromPricingRec( |
709
|
|
|
RequestOptions\MiniRuleGetFromPricingRecOptions $options, |
710
|
|
|
$messageOptions = [] |
711
|
|
|
) { |
712
|
|
|
$msgName = 'MiniRule_GetFromPricingRec'; |
713
|
|
|
|
714
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
715
|
|
|
} |
716
|
|
|
|
717
|
|
|
/** |
718
|
|
|
* MiniRule_GetFromPricing |
719
|
|
|
* |
720
|
|
|
* @param RequestOptions\MiniRuleGetFromPricingOptions $options |
721
|
|
|
* @param array $messageOptions (OPTIONAL) |
722
|
|
|
* @return Result |
723
|
|
|
*/ |
724
|
|
|
public function miniRuleGetFromPricing( |
725
|
|
|
RequestOptions\MiniRuleGetFromPricingOptions $options, |
726
|
|
|
$messageOptions = [] |
727
|
|
|
) { |
728
|
|
|
$msgName = 'MiniRule_GetFromPricing'; |
729
|
|
|
|
730
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
731
|
|
|
} |
732
|
|
|
|
733
|
|
|
/** |
734
|
|
|
* Info_EncodeDecodeCity |
735
|
|
|
* |
736
|
|
|
* @param RequestOptions\InfoEncodeDecodeCityOptions $options |
737
|
|
|
* @param array $messageOptions (OPTIONAL) |
738
|
|
|
* @return Result |
739
|
|
|
*/ |
740
|
|
|
public function infoEncodeDecodeCity(RequestOptions\InfoEncodeDecodeCityOptions $options, $messageOptions = []) |
741
|
|
|
{ |
742
|
|
|
$msgName = 'Info_EncodeDecodeCity'; |
743
|
|
|
|
744
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
745
|
|
|
} |
746
|
|
|
|
747
|
|
|
|
748
|
|
|
/** |
749
|
|
|
* Ticket_CreateTSTFromPricing |
750
|
|
|
* |
751
|
|
|
* @param RequestOptions\TicketCreateTstFromPricingOptions $options |
752
|
|
|
* @param array $messageOptions (OPTIONAL) |
753
|
|
|
* @return Result |
754
|
|
|
*/ |
755
|
|
|
public function ticketCreateTSTFromPricing( |
756
|
|
|
RequestOptions\TicketCreateTstFromPricingOptions $options, |
757
|
|
|
$messageOptions = [] |
758
|
|
|
) { |
759
|
|
|
$msgName = 'Ticket_CreateTSTFromPricing'; |
760
|
|
|
|
761
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
762
|
|
|
} |
763
|
|
|
|
764
|
|
|
/** |
765
|
|
|
* Ticket_CreateTSMFromPricing |
766
|
|
|
* |
767
|
|
|
* @param RequestOptions\TicketCreateTsmFromPricingOptions $options |
768
|
|
|
* @param array $messageOptions (OPTIONAL) |
769
|
|
|
* @return Result |
770
|
|
|
*/ |
771
|
|
|
public function ticketCreateTSMFromPricing( |
772
|
|
|
RequestOptions\TicketCreateTsmFromPricingOptions $options, |
773
|
|
|
$messageOptions = [] |
774
|
|
|
) { |
775
|
|
|
$msgName = 'Ticket_CreateTSMFromPricing'; |
776
|
|
|
|
777
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
778
|
|
|
} |
779
|
|
|
|
780
|
|
|
/** |
781
|
|
|
* Ticket_DeleteTST |
782
|
|
|
* |
783
|
|
|
* @param RequestOptions\TicketDeleteTstOptions $options |
784
|
|
|
* @param array $messageOptions (OPTIONAL) |
785
|
|
|
* @return Result |
786
|
|
|
*/ |
787
|
|
|
public function ticketDeleteTST(RequestOptions\TicketDeleteTstOptions $options, $messageOptions = []) |
788
|
|
|
{ |
789
|
|
|
$msgName = 'Ticket_DeleteTST'; |
790
|
|
|
|
791
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
792
|
|
|
} |
793
|
|
|
|
794
|
|
|
/** |
795
|
|
|
* Ticket_DisplayTST |
796
|
|
|
* |
797
|
|
|
* @param RequestOptions\TicketDisplayTstOptions $options |
798
|
|
|
* @param array $messageOptions (OPTIONAL) |
799
|
|
|
* @return Result |
800
|
|
|
*/ |
801
|
|
|
public function ticketDisplayTST(RequestOptions\TicketDisplayTstOptions $options, $messageOptions = []) |
802
|
|
|
{ |
803
|
|
|
$msgName = 'Ticket_DisplayTST'; |
804
|
|
|
|
805
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
806
|
|
|
} |
807
|
|
|
|
808
|
|
|
/** |
809
|
|
|
* DocIssuance_IssueTicket |
810
|
|
|
* |
811
|
|
|
* @param RequestOptions\DocIssuanceIssueTicketOptions $options |
812
|
|
|
* @param array $messageOptions (OPTIONAL) |
813
|
|
|
* @return Result |
814
|
|
|
*/ |
815
|
|
|
public function docIssuanceIssueTicket( |
816
|
|
|
RequestOptions\DocIssuanceIssueTicketOptions $options, |
817
|
|
|
$messageOptions = [] |
818
|
|
|
) { |
819
|
|
|
$msgName = 'DocIssuance_IssueTicket'; |
820
|
|
|
|
821
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
822
|
|
|
} |
823
|
|
|
|
824
|
|
|
/** |
825
|
|
|
* PriceXplorer_ExtremeSearch |
826
|
|
|
* |
827
|
|
|
* @param RequestOptions\PriceXplorerExtremeSearchOptions $options |
828
|
|
|
* @param array $messageOptions (OPTIONAL) |
829
|
|
|
* @return Result |
830
|
|
|
*/ |
831
|
|
|
public function priceXplorerExtremeSearch( |
832
|
|
|
RequestOptions\PriceXplorerExtremeSearchOptions $options, |
833
|
|
|
$messageOptions = [] |
834
|
|
|
) { |
835
|
|
|
$msgName = 'PriceXplorer_ExtremeSearch'; |
836
|
|
|
|
837
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
838
|
|
|
} |
839
|
|
|
|
840
|
|
|
/** |
841
|
|
|
* SalesReports_DisplayQueryReport |
842
|
|
|
* |
843
|
|
|
* @param RequestOptions\SalesReportsDisplayQueryReportOptions $options |
844
|
|
|
* @param array $messageOptions (OPTIONAL) |
845
|
|
|
* @return Result |
846
|
|
|
*/ |
847
|
|
|
public function salesReportsDisplayQueryReport( |
848
|
|
|
RequestOptions\SalesReportsDisplayQueryReportOptions $options, |
849
|
|
|
$messageOptions = [] |
850
|
|
|
) { |
851
|
|
|
$msgName = 'SalesReports_DisplayQueryReport'; |
852
|
|
|
|
853
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
854
|
|
|
} |
855
|
|
|
|
856
|
|
|
/** |
857
|
|
|
* Service_IntegratedPricing |
858
|
|
|
* |
859
|
|
|
* @param RequestOptions\ServiceIntegratedPricingOptions $options |
860
|
|
|
* @param array $messageOptions (OPTIONAL) |
861
|
|
|
* @return Result |
862
|
|
|
*/ |
863
|
|
|
public function serviceIntegratedPricing( |
864
|
|
|
RequestOptions\ServiceIntegratedPricingOptions $options, |
865
|
|
|
$messageOptions = [] |
866
|
|
|
) { |
867
|
|
|
$msgName = 'Service_IntegratedPricing'; |
868
|
|
|
|
869
|
|
|
return $this->callMessage($msgName, $options, $messageOptions); |
870
|
|
|
} |
871
|
|
|
|
872
|
|
|
/** |
873
|
|
|
* Call a message with the given parameters |
874
|
|
|
* |
875
|
|
|
* @param string $messageName |
876
|
|
|
* @param RequestOptions\RequestOptionsInterface $options |
877
|
|
|
* @param array $messageOptions |
878
|
|
|
* @param bool $endSession |
879
|
|
|
* @return Result |
880
|
|
|
* @throws Client\Exception |
881
|
|
|
* @throws Client\Struct\InvalidArgumentException |
882
|
|
|
* @throws Client\InvalidMessageException |
883
|
|
|
* @throws Client\RequestCreator\MessageVersionUnsupportedException |
884
|
|
|
* @throws \RuntimeException |
885
|
|
|
* @throws \InvalidArgumentException |
886
|
|
|
* @throws \SoapFault |
887
|
|
|
*/ |
888
|
|
|
protected function callMessage($messageName, $options, $messageOptions, $endSession = false) |
889
|
|
|
{ |
890
|
|
|
$messageOptions = $this->makeMessageOptions($messageOptions, $endSession); |
891
|
|
|
|
892
|
|
|
$this->lastMessage = $messageName; |
893
|
|
|
|
894
|
|
|
$sendResult = $this->sessionHandler->sendMessage( |
895
|
|
|
$messageName, |
896
|
|
|
$this->requestCreator->createRequest( |
897
|
|
|
$messageName, |
898
|
|
|
$options |
899
|
|
|
), |
900
|
|
|
$messageOptions |
901
|
|
|
); |
902
|
|
|
|
903
|
|
|
return $this->responseHandler->analyzeResponse( |
904
|
|
|
$sendResult, |
905
|
|
|
$messageName |
906
|
|
|
); |
907
|
|
|
} |
908
|
|
|
|
909
|
|
|
/** |
910
|
|
|
* Make message options |
911
|
|
|
* |
912
|
|
|
* Message options are meta options when sending a message to the amadeus web services |
913
|
|
|
* - (if stateful) should we end the current session after sending this call? |
914
|
|
|
* - ... ? |
915
|
|
|
* |
916
|
|
|
* @param array $incoming The Message options chosen by the caller - if any. |
917
|
|
|
* @param bool $endSession Switch if you want to terminate the current session after making the call. |
918
|
|
|
* @return array |
919
|
|
|
*/ |
920
|
|
|
protected function makeMessageOptions(array $incoming, $endSession = false) |
921
|
|
|
{ |
922
|
|
|
$options = [ |
923
|
|
|
'endSession' => $endSession |
924
|
|
|
]; |
925
|
|
|
|
926
|
|
|
if (array_key_exists('endSession', $incoming)) { |
927
|
|
|
$options['endSession'] = $incoming['endSession']; |
928
|
|
|
} |
929
|
|
|
|
930
|
|
|
return $options; |
931
|
|
|
} |
932
|
|
|
|
933
|
|
|
/** |
934
|
|
|
* Load the session handler |
935
|
|
|
* |
936
|
|
|
* Either load the provided session handler or create one depending on incoming parameters. |
937
|
|
|
* |
938
|
|
|
* @param HandlerInterface|null $sessionHandler |
939
|
|
|
* @param Params\SessionHandlerParams|null $params |
940
|
|
|
* @return HandlerInterface |
941
|
|
|
*/ |
942
|
|
|
protected function loadSessionHandler($sessionHandler, $params) |
943
|
|
|
{ |
944
|
|
|
if ($sessionHandler instanceof HandlerInterface) { |
945
|
|
|
$newSessionHandler = $sessionHandler; |
946
|
|
|
} else { |
947
|
|
|
$newSessionHandler = HandlerFactory::createHandler($params); |
948
|
|
|
} |
949
|
|
|
|
950
|
|
|
return $newSessionHandler; |
951
|
|
|
} |
952
|
|
|
|
953
|
|
|
/** |
954
|
|
|
* Load a request creator |
955
|
|
|
* |
956
|
|
|
* A request creator is responsible for generating the correct request to send. |
957
|
|
|
* |
958
|
|
|
* @param RequestCreatorInterface|null $requestCreator |
959
|
|
|
* @param Params\RequestCreatorParams $params |
960
|
|
|
* @param string $libIdentifier Library identifier & version string (for Received From) |
961
|
|
|
* @param string $originatorOffice The Office we are signed in with. |
962
|
|
|
* @param array $mesVer Messages & Versions array of active messages in the WSDL |
963
|
|
|
* @return RequestCreatorInterface |
964
|
|
|
* @throws \RuntimeException |
965
|
|
|
*/ |
966
|
|
|
protected function loadRequestCreator($requestCreator, $params, $libIdentifier, $originatorOffice, $mesVer) |
967
|
|
|
{ |
968
|
|
|
if ($requestCreator instanceof RequestCreatorInterface) { |
969
|
|
|
$newRequestCreator = $requestCreator; |
970
|
|
|
} else { |
971
|
|
|
$params->originatorOfficeId = $originatorOffice; |
972
|
|
|
$params->messagesAndVersions = $mesVer; |
973
|
|
|
|
974
|
|
|
$newRequestCreator = RequestCreatorFactory::createRequestCreator( |
975
|
|
|
$params, |
976
|
|
|
$libIdentifier |
977
|
|
|
); |
978
|
|
|
} |
979
|
|
|
|
980
|
|
|
return $newRequestCreator; |
981
|
|
|
} |
982
|
|
|
|
983
|
|
|
/** |
984
|
|
|
* Load a response handler |
985
|
|
|
* |
986
|
|
|
* @param ResponseHandlerInterface|null $responseHandler |
987
|
|
|
* @return ResponseHandlerInterface |
988
|
|
|
* @throws \RuntimeException |
989
|
|
|
*/ |
990
|
|
|
protected function loadResponseHandler($responseHandler) |
991
|
|
|
{ |
992
|
|
|
if ($responseHandler instanceof ResponseHandlerInterface) { |
993
|
|
|
$newResponseHandler = $responseHandler; |
994
|
|
|
} else { |
995
|
|
|
$newResponseHandler = new ResponseHandlerBase(); |
996
|
|
|
} |
997
|
|
|
|
998
|
|
|
return $newResponseHandler; |
999
|
|
|
} |
1000
|
|
|
} |
1001
|
|
|
|