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