Completed
Push — master ( 833351...5fbac6 )
by Dieter
07:24
created

Client::ticketCheckEligibility()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
crap 1
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.2.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
     * Whether to return the response of a message as XML as well as PHP object
109
     *
110
     * @var bool
111
     */
112
    protected $returnResultXml;
113
114
    /**
115
     * Set the session as stateful (true) or stateless (false)
116
     *
117
     * @param bool $newStateful
118
     */
119 1
    public function setStateful($newStateful)
120
    {
121 1
        $this->sessionHandler->setStateful($newStateful);
122 1
    }
123
124
    /**
125
     * @return bool
126
     */
127 3
    public function isStateful()
128
    {
129 3
        return $this->sessionHandler->isStateful();
130
    }
131
132
    /**
133
     * Get the last raw XML message that was sent out
134
     *
135
     * @return string|null
136
     */
137 1
    public function getLastRequest()
138
    {
139 1
        return $this->sessionHandler->getLastRequest($this->lastMessage);
140
    }
141
142
    /**
143
     * Get the last raw XML message that was received
144
     *
145
     * @return string|null
146
     */
147 1
    public function getLastResponse()
148
    {
149 1
        return $this->sessionHandler->getLastResponse($this->lastMessage);
150
    }
151
152
    /**
153
     * Get session information for authenticated session
154
     *
155
     * - sessionId
156
     * - sequenceNr
157
     * - securityToken
158
     *
159
     * @return array|null
160
     */
161 1
    public function getSessionData()
162
    {
163 1
        return $this->sessionHandler->getSessionData();
164
    }
165
166
    /**
167
     * Restore a previously used session
168
     *
169
     * To be used when implementing your own session pooling system on legacy Soap Header 2 applications.
170
     *
171
     * @param array $sessionData
172
     * @return bool
173
     */
174 1
    public function setSessionData(array $sessionData)
175
    {
176 1
        return $this->sessionHandler->setSessionData($sessionData);
177
    }
178
179
    /**
180
     * Construct Amadeus Web Services client
181
     *
182
     * @param Params $params
183
     */
184 72
    public function __construct($params)
185
    {
186 72
        if ($params->authParams instanceof Params\AuthParams) {
187 2
            $this->authParams = $params->authParams;
188 2
            if (isset($params->sessionHandlerParams) &&
189 1
                $params->sessionHandlerParams instanceof Params\SessionHandlerParams
190 2
            ) {
191 1
                $params->sessionHandlerParams->authParams = $this->authParams;
192 1
            }
193 2
        }
194
195 72
        $this->sessionHandler = $this->loadSessionHandler(
196 72
            $params->sessionHandler,
197 72
            $params->sessionHandlerParams
198 72
        );
199
200 71
        $this->requestCreator = $this->loadRequestCreator(
201 71
            $params->requestCreator,
202 71
            $params->requestCreatorParams,
203 71
            self::RECEIVED_FROM_IDENTIFIER."-".self::VERSION,
204 71
            $this->sessionHandler->getOriginatorOffice(),
205 71
            $this->sessionHandler->getMessagesAndVersions()
206 71
        );
207
208 71
        $this->responseHandler = $this->loadResponseHandler(
209 71
            $params->responseHandler
210 71
        );
211
212 71
        $this->returnResultXml = $params->returnXml;
213 71
    }
214
215
    /**
216
     * Authenticate.
217
     *
218
     * Parameters were provided at construction time (sessionhandlerparams)
219
     *
220
     * @return Result
221
     * @throws Exception
222
     */
223 1
    public function securityAuthenticate()
224
    {
225 1
        $msgName = 'Security_Authenticate';
226
227 1
        return $this->callMessage(
228 1
            $msgName,
229 1
            new RequestOptions\SecurityAuthenticateOptions(
230 1
                $this->authParams
231 1
            ),
232 1
            [],
233
            false
234 1
        );
235
    }
236
237
    /**
238
     * Terminate a session - only applicable to non-stateless mode.
239
     *
240
     * @return Result
241
     * @throws Exception
242
     */
243 1
    public function securitySignOut()
244
    {
245 1
        $msgName = 'Security_SignOut';
246
247 1
        return $this->callMessage(
248 1
            $msgName,
249 1
            new RequestOptions\SecuritySignOutOptions(),
250 1
            [],
251
            true
252 1
        );
253
    }
254
255
    /**
256
     * PNR_Retrieve - Retrieve an Amadeus PNR by record locator
257
     *
258
     * @param RequestOptions\PnrRetrieveOptions $options
259
     * @param array $messageOptions (OPTIONAL)
260
     * @return Result
261
     * @throws Exception
262
     */
263 1
    public function pnrRetrieve(RequestOptions\PnrRetrieveOptions $options, $messageOptions = [])
264
    {
265 1
        $msgName = 'PNR_Retrieve';
266
267 1
        return $this->callMessage($msgName, $options, $messageOptions);
268
    }
269
270
    /**
271
     * Create a PNR using PNR_AddMultiElements
272
     *
273
     * @param RequestOptions\PnrCreatePnrOptions $options
274
     * @param array $messageOptions (OPTIONAL)
275
     * @return Result
276
     */
277 1
    public function pnrCreatePnr(RequestOptions\PnrCreatePnrOptions $options, $messageOptions = [])
278
    {
279 1
        $msgName = 'PNR_AddMultiElements';
280
281 1
        return $this->callMessage($msgName, $options, $messageOptions);
282
    }
283
284
    /**
285
     * PNR_AddMultiElements - Create a new PNR or update an existing PNR.
286
     *
287
     * https://webservices.amadeus.com/extranet/viewService.do?id=25&flavourId=1&menuId=functional
288
     *
289
     * @param RequestOptions\PnrAddMultiElementsOptions $options
290
     * @param array $messageOptions (OPTIONAL)
291
     * @return Result
292
     */
293 2
    public function pnrAddMultiElements(RequestOptions\PnrAddMultiElementsOptions $options, $messageOptions = [])
294
    {
295 2
        $msgName = 'PNR_AddMultiElements';
296
297 2
        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)
314
     * @return Result
315
     * @throws Exception
316
     **/
317 1
    public function pnrRetrieveAndDisplay(RequestOptions\PnrRetrieveAndDisplayOptions $options, $messageOptions = [])
318
    {
319 1
        $msgName = 'PNR_RetrieveAndDisplay';
320
321 1
        return $this->callMessage($msgName, $options, $messageOptions);
322
    }
323
324
    /**
325
     * PNR_Cancel
326
     *
327
     * @param RequestOptions\PnrCancelOptions $options
328
     * @param array $messageOptions (OPTIONAL)
329
     * @return Result
330
     */
331 1
    public function pnrCancel(RequestOptions\PnrCancelOptions $options, $messageOptions = [])
332
    {
333 1
        $msgName = 'PNR_Cancel';
334
335 1
        return $this->callMessage($msgName, $options, $messageOptions);
336
    }
337
338
    /**
339
     * PNR_DisplayHistory
340
     *
341
     * @param RequestOptions\PnrDisplayHistoryOptions $options
342
     * @param array $messageOptions (OPTIONAL)
343
     * @return Result
344
     */
345 1
    public function pnrDisplayHistory(RequestOptions\PnrDisplayHistoryOptions $options, $messageOptions = [])
346
    {
347 1
        $msgName = 'PNR_DisplayHistory';
348
349 1
        return $this->callMessage($msgName, $options, $messageOptions);
350
    }
351
352
    /**
353
     * PNR_TransferOwnership
354
     *
355
     * @param RequestOptions\PnrTransferOwnershipOptions $options
356
     * @param array $messageOptions (OPTIONAL)
357
     * @return Result
358
     */
359 1
    public function pnrTransferOwnership(RequestOptions\PnrTransferOwnershipOptions $options, $messageOptions = [])
360
    {
361 1
        $msgName = 'PNR_TransferOwnership';
362
363 1
        return $this->callMessage($msgName, $options, $messageOptions);
364
    }
365
366
    /**
367
     * PNR_NameChange
368
     *
369
     * @param RequestOptions\PnrNameChangeOptions $options
370
     * @param array $messageOptions (OPTIONAL)
371
     * @return Result
372
     */
373 1
    public function pnrNameChange(RequestOptions\PnrNameChangeOptions $options, $messageOptions = [])
374
    {
375 1
        $msgName = 'PNR_NameChange';
376
377 1
        return $this->callMessage($msgName, $options, $messageOptions);
378
    }
379
380
    /**
381
     * Queue_List - get a list of all PNR's on a given queue
382
     *
383
     * https://webservices.amadeus.com/extranet/viewService.do?id=52&flavourId=1&menuId=functional
384
     *
385
     * @param RequestOptions\QueueListOptions $options
386
     * @param array $messageOptions (OPTIONAL)
387
     * @return Result
388
     */
389 1
    public function queueList(RequestOptions\QueueListOptions $options, $messageOptions = [])
390
    {
391 1
        $msgName = 'Queue_List';
392
393 1
        return $this->callMessage($msgName, $options, $messageOptions);
394
    }
395
396
    /**
397
     * Queue_PlacePNR - Place a PNR on a given queue
398
     *
399
     * @param RequestOptions\QueuePlacePnrOptions $options
400
     * @param array $messageOptions (OPTIONAL)
401
     * @return Result
402
     */
403 1
    public function queuePlacePnr(RequestOptions\QueuePlacePnrOptions $options, $messageOptions = [])
404
    {
405 1
        $msgName = 'Queue_PlacePNR';
406
407 1
        return $this->callMessage($msgName, $options, $messageOptions);
408
    }
409
410
    /**
411
     * Queue_RemoveItem - remove an item (a PNR) from a given queue
412
     *
413
     * @param RequestOptions\QueueRemoveItemOptions $options
414
     * @param array $messageOptions (OPTIONAL)
415
     * @return Result
416
     */
417 1
    public function queueRemoveItem(RequestOptions\QueueRemoveItemOptions $options, $messageOptions = [])
418
    {
419 1
        $msgName = 'Queue_RemoveItem';
420
421 1
        return $this->callMessage($msgName, $options, $messageOptions);
422
    }
423
424
    /**
425
     * Queue_MoveItem - move an item (a PNR) from one queue to another.
426
     *
427
     * @param RequestOptions\QueueMoveItemOptions $options
428
     * @param array $messageOptions (OPTIONAL)
429
     * @return Result
430
     */
431 1
    public function queueMoveItem(RequestOptions\QueueMoveItemOptions $options, $messageOptions = [])
432
    {
433 1
        $msgName = 'Queue_MoveItem';
434
435 1
        return $this->callMessage($msgName, $options, $messageOptions);
436
    }
437
438
    /**
439
     * Offer_CreateOffer
440
     *
441
     * @param RequestOptions\OfferCreateOptions $options
442
     * @param array $messageOptions (OPTIONAL)
443
     * @return Result
444
     */
445 1
    public function offerCreate(RequestOptions\OfferCreateOptions $options, $messageOptions = [])
446
    {
447 1
        $msgName = 'Offer_CreateOffer';
448
449 1
        return $this->callMessage($msgName, $options, $messageOptions);
450
    }
451
452
    /**
453
     * Offer_VerifyOffer
454
     *
455
     * To be called in the context of an open PNR
456
     *
457
     * @param RequestOptions\OfferVerifyOptions $options
458
     * @param array $messageOptions (OPTIONAL)
459
     * @return Result
460
     */
461 1
    public function offerVerify(RequestOptions\OfferVerifyOptions $options, $messageOptions = [])
462
    {
463 1
        $msgName = 'Offer_VerifyOffer';
464
465 1
        return $this->callMessage($msgName, $options, $messageOptions);
466
    }
467
468
    /**
469
     * Offer_ConfirmAirOffer
470
     *
471
     * @param RequestOptions\OfferConfirmAirOptions $options
472
     * @param array $messageOptions (OPTIONAL)
473
     * @return Result
474
     */
475 1
    public function offerConfirmAir(RequestOptions\OfferConfirmAirOptions $options, $messageOptions = [])
476
    {
477 1
        $msgName = 'Offer_ConfirmAirOffer';
478
479 1
        return $this->callMessage($msgName, $options, $messageOptions);
480
    }
481
482
    /**
483
     * Offer_ConfirmHotelOffer
484
     *
485
     * @param RequestOptions\OfferConfirmHotelOptions $options
486
     * @param array $messageOptions (OPTIONAL)
487
     * @return Result
488
     */
489 1
    public function offerConfirmHotel(RequestOptions\OfferConfirmHotelOptions $options, $messageOptions = [])
490
    {
491 1
        $msgName = 'Offer_ConfirmHotelOffer';
492
493 1
        return $this->callMessage($msgName, $options, $messageOptions);
494
    }
495
496
    /**
497
     * Offer_ConfirmCarOffer
498
     *
499
     * @param RequestOptions\OfferConfirmCarOptions $options
500
     * @param array $messageOptions (OPTIONAL)
501
     * @return Result
502
     */
503 1
    public function offerConfirmCar(RequestOptions\OfferConfirmCarOptions $options, $messageOptions = [])
504
    {
505 1
        $msgName = 'Offer_ConfirmCarOffer';
506
507 1
        return $this->callMessage($msgName, $options, $messageOptions);
508
    }
509
510
    /**
511
     * Fare_MasterPricerTravelBoardSearch
512
     *
513
     * @param RequestOptions\FareMasterPricerTbSearch $options
514
     * @param array $messageOptions (OPTIONAL)
515
     * @return Result
516
     */
517 1
    public function fareMasterPricerTravelBoardSearch(
518
        RequestOptions\FareMasterPricerTbSearch $options,
519
        $messageOptions = []
520
    ) {
521 1
        $msgName = 'Fare_MasterPricerTravelBoardSearch';
522
523 1
        return $this->callMessage($msgName, $options, $messageOptions);
524
    }
525
526
    /**
527
     * Fare_MasterPricerCalendar
528
     *
529
     * @param RequestOptions\FareMasterPricerCalendarOptions $options
530
     * @param array $messageOptions (OPTIONAL)
531
     * @return Result
532
     */
533 1
    public function fareMasterPricerCalendar(
534
        RequestOptions\FareMasterPricerCalendarOptions $options,
535
        $messageOptions = []
536
    ) {
537 1
        $msgName = 'Fare_MasterPricerCalendar';
538
539 1
        return $this->callMessage($msgName, $options, $messageOptions);
540
    }
541
542
    /**
543
     * Fare_PricePnrWithBookingClass
544
     *
545
     * @param RequestOptions\FarePricePnrWithBookingClassOptions $options
546
     * @param array $messageOptions (OPTIONAL)
547
     * @return Result
548
     */
549 2
    public function farePricePnrWithBookingClass(
550
        RequestOptions\FarePricePnrWithBookingClassOptions $options,
551
        $messageOptions = []
552
    ) {
553 2
        $msgName = 'Fare_PricePNRWithBookingClass';
554
555 2
        return $this->callMessage($msgName, $options, $messageOptions);
556
    }
557
558
    /**
559
     * Fare_PricePnrWithLowerFares
560
     *
561
     * @param RequestOptions\FarePricePnrWithLowerFaresOptions $options
562
     * @param array $messageOptions (OPTIONAL)
563
     * @return Result
564
     */
565 2
    public function farePricePnrWithLowerFares(
566
        RequestOptions\FarePricePnrWithLowerFaresOptions $options,
567
        $messageOptions = []
568
    ) {
569 2
        $msgName = 'Fare_PricePNRWithLowerFares';
570
571 2
        return $this->callMessage($msgName, $options, $messageOptions);
572
    }
573
574
    /**
575
     * Fare_PricePnrWithLowestFare
576
     *
577
     * @param RequestOptions\FarePricePnrWithLowestFareOptions $options
578
     * @param array $messageOptions (OPTIONAL)
579
     * @return Result
580
     */
581 2
    public function farePricePnrWithLowestFare(
582
        RequestOptions\FarePricePnrWithLowestFareOptions $options,
583
        $messageOptions = []
584
    ) {
585 2
        $msgName = 'Fare_PricePNRWithLowestFare';
586
587 2
        return $this->callMessage($msgName, $options, $messageOptions);
588
    }
589
590
    /**
591
     * Fare_InformativePricingWithoutPNR
592
     *
593
     * @param RequestOptions\FareInformativePricingWithoutPnrOptions $options
594
     * @param array $messageOptions (OPTIONAL)
595
     * @return Result
596
     */
597 1
    public function fareInformativePricingWithoutPnr(
598
        RequestOptions\FareInformativePricingWithoutPnrOptions $options,
599
        $messageOptions = []
600
    ) {
601 1
        $msgName = 'Fare_InformativePricingWithoutPNR';
602
603 1
        return $this->callMessage($msgName, $options, $messageOptions);
604
    }
605
606
    /**
607
     * Fare_InformativeBestPricingWithoutPNR
608
     *
609
     * @param RequestOptions\FareInformativeBestPricingWithoutPnrOptions $options
610
     * @param array $messageOptions (OPTIONAL)
611
     * @return Result
612
     */
613 1
    public function fareInformativeBestPricingWithoutPnr(
614
        RequestOptions\FareInformativeBestPricingWithoutPnrOptions $options,
615
        $messageOptions = []
616
    ) {
617 1
        $msgName = 'Fare_InformativeBestPricingWithoutPNR';
618
619 1
        return $this->callMessage($msgName, $options, $messageOptions);
620
    }
621
622
    /**
623
     * Fare_CheckRules
624
     *
625
     * @param RequestOptions\FareCheckRulesOptions $options
626
     * @param array $messageOptions (OPTIONAL)
627
     * @return Result
628
     */
629 1
    public function fareCheckRules(RequestOptions\FareCheckRulesOptions $options, $messageOptions = [])
630
    {
631 1
        $msgName = 'Fare_CheckRules';
632
633 1
        return $this->callMessage($msgName, $options, $messageOptions);
634
    }
635
636
    /**
637
     * Fare_ConvertCurrency
638
     *
639
     * @param RequestOptions\FareConvertCurrencyOptions $options
640
     * @param array $messageOptions (OPTIONAL)
641
     * @return Result
642
     */
643 1
    public function fareConvertCurrency(RequestOptions\FareConvertCurrencyOptions $options, $messageOptions = [])
644
    {
645 1
        $msgName = 'Fare_ConvertCurrency';
646
647 1
        return $this->callMessage($msgName, $options, $messageOptions);
648
    }
649
650
    /**
651
     * Air_MultiAvailability
652
     *
653
     * @param RequestOptions\AirMultiAvailabilityOptions $options
654
     * @param array $messageOptions (OPTIONAL)
655
     * @return Result
656
     */
657 1
    public function airMultiAvailability(
658
        RequestOptions\AirMultiAvailabilityOptions $options,
659
        $messageOptions = []
660
    ) {
661 1
        $msgName = 'Air_MultiAvailability';
662
663 1
        return $this->callMessage($msgName, $options, $messageOptions);
664
    }
665
666
    /**
667
     * Air_SellFromRecommendation
668
     *
669
     * @param RequestOptions\AirSellFromRecommendationOptions $options
670
     * @param array $messageOptions (OPTIONAL)
671
     * @return Result
672
     */
673 1
    public function airSellFromRecommendation(
674
        RequestOptions\AirSellFromRecommendationOptions $options,
675
        $messageOptions = []
676
    ) {
677 1
        $msgName = 'Air_SellFromRecommendation';
678
679 1
        return $this->callMessage($msgName, $options, $messageOptions);
680
    }
681
682
    /**
683
     * Air_FlightInfo
684
     *
685
     * @param RequestOptions\AirFlightInfoOptions $options
686
     * @param array $messageOptions (OPTIONAL)
687
     * @return Result
688
     */
689 1
    public function airFlightInfo(RequestOptions\AirFlightInfoOptions $options, $messageOptions = [])
690
    {
691 1
        $msgName = 'Air_FlightInfo';
692
693 1
        return $this->callMessage($msgName, $options, $messageOptions);
694
    }
695
696
    /**
697
     * Air_RetrieveSeatMap
698
     *
699
     * @param RequestOptions\AirRetrieveSeatMapOptions $options
700
     * @param array $messageOptions (OPTIONAL)
701
     * @return Result
702
     */
703 1
    public function airRetrieveSeatMap(RequestOptions\AirRetrieveSeatMapOptions $options, $messageOptions = [])
704
    {
705 1
        $msgName = 'Air_RetrieveSeatMap';
706
707 1
        return $this->callMessage($msgName, $options, $messageOptions);
708
    }
709
710
    /**
711
     * Command_Cryptic
712
     *
713
     * @param RequestOptions\CommandCrypticOptions $options
714
     * @param array $messageOptions (OPTIONAL)
715
     * @return Result
716
     */
717 1
    public function commandCryptic(RequestOptions\CommandCrypticOptions $options, $messageOptions = [])
718
    {
719 1
        $msgName = 'Command_Cryptic';
720
721 1
        return $this->callMessage($msgName, $options, $messageOptions);
722
    }
723
724
    /**
725
     * MiniRule_GetFromPricingRec
726
     *
727
     * @param RequestOptions\MiniRuleGetFromPricingRecOptions $options
728
     * @param array $messageOptions (OPTIONAL)
729
     * @return Result
730
     */
731 1
    public function miniRuleGetFromPricingRec(
732
        RequestOptions\MiniRuleGetFromPricingRecOptions $options,
733
        $messageOptions = []
734
    ) {
735 1
        $msgName = 'MiniRule_GetFromPricingRec';
736
737 1
        return $this->callMessage($msgName, $options, $messageOptions);
738
    }
739
740
    /**
741
     * MiniRule_GetFromPricing
742
     *
743
     * @param RequestOptions\MiniRuleGetFromPricingOptions $options
744
     * @param array $messageOptions (OPTIONAL)
745
     * @return Result
746
     */
747 1
    public function miniRuleGetFromPricing(
748
        RequestOptions\MiniRuleGetFromPricingOptions $options,
749
        $messageOptions = []
750
    ) {
751 1
        $msgName = 'MiniRule_GetFromPricing';
752
753 1
        return $this->callMessage($msgName, $options, $messageOptions);
754
    }
755
756
    /**
757
     * Info_EncodeDecodeCity
758
     *
759
     * @param RequestOptions\InfoEncodeDecodeCityOptions $options
760
     * @param array $messageOptions (OPTIONAL)
761
     * @return Result
762
     */
763 1
    public function infoEncodeDecodeCity(RequestOptions\InfoEncodeDecodeCityOptions $options, $messageOptions = [])
764
    {
765 1
        $msgName = 'Info_EncodeDecodeCity';
766
767 1
        return $this->callMessage($msgName, $options, $messageOptions);
768
    }
769
770
    /**
771
     * PointOfRef_Search
772
     *
773
     * @param RequestOptions\PointOfRefSearchOptions $options
774
     * @param array $messageOptions (OPTIONAL)
775
     * @return Result
776
     */
777 1
    public function pointOfRefSearch(RequestOptions\PointOfRefSearchOptions $options, $messageOptions = [])
778
    {
779 1
        $msgName = 'PointOfRef_Search';
780
781 1
        return $this->callMessage($msgName, $options, $messageOptions);
782
    }
783
784
785
    /**
786
     * Ticket_CreateTSTFromPricing
787
     *
788
     * @param RequestOptions\TicketCreateTstFromPricingOptions $options
789
     * @param array $messageOptions (OPTIONAL)
790
     * @return Result
791
     */
792 1
    public function ticketCreateTSTFromPricing(
793
        RequestOptions\TicketCreateTstFromPricingOptions $options,
794
        $messageOptions = []
795
    ) {
796 1
        $msgName = 'Ticket_CreateTSTFromPricing';
797
798 1
        return $this->callMessage($msgName, $options, $messageOptions);
799
    }
800
801
    /**
802
     * Ticket_CreateTSMFromPricing
803
     *
804
     * @param RequestOptions\TicketCreateTsmFromPricingOptions $options
805
     * @param array $messageOptions (OPTIONAL)
806
     * @return Result
807
     */
808 1
    public function ticketCreateTSMFromPricing(
809
        RequestOptions\TicketCreateTsmFromPricingOptions $options,
810
        $messageOptions = []
811
    ) {
812 1
        $msgName = 'Ticket_CreateTSMFromPricing';
813
814 1
        return $this->callMessage($msgName, $options, $messageOptions);
815
    }
816
817
    /**
818
     * Ticket_CreateTSMFareElement
819
     *
820
     * @param RequestOptions\TicketCreateTsmFareElOptions $options
821
     * @param array $messageOptions (OPTIONAL)
822
     * @return Result
823
     */
824 1
    public function ticketCreateTSMFareElement(
825
        RequestOptions\TicketCreateTsmFareElOptions $options,
826
        $messageOptions = []
827
    ) {
828 1
        $msgName = 'Ticket_CreateTSMFareElement';
829
830 1
        return $this->callMessage($msgName, $options, $messageOptions);
831
    }
832
833
    /**
834
     * Ticket_DeleteTST
835
     *
836
     * @param RequestOptions\TicketDeleteTstOptions $options
837
     * @param array $messageOptions (OPTIONAL)
838
     * @return Result
839
     */
840 1
    public function ticketDeleteTST(RequestOptions\TicketDeleteTstOptions $options, $messageOptions = [])
841
    {
842 1
        $msgName = 'Ticket_DeleteTST';
843
844 1
        return $this->callMessage($msgName, $options, $messageOptions);
845
    }
846
847
    /**
848
     * Ticket_DeleteTSMP
849
     *
850
     * @param RequestOptions\TicketDeleteTsmpOptions $options
851
     * @param array $messageOptions (OPTIONAL)
852
     * @return Result
853
     */
854 1
    public function ticketDeleteTSMP(RequestOptions\TicketDeleteTsmpOptions $options, $messageOptions = [])
855
    {
856 1
        $msgName = 'Ticket_DeleteTSMP';
857
858 1
        return $this->callMessage($msgName, $options, $messageOptions);
859
    }
860
861
    /**
862
     * Ticket_DisplayTST
863
     *
864
     * @param RequestOptions\TicketDisplayTstOptions $options
865
     * @param array $messageOptions (OPTIONAL)
866
     * @return Result
867
     */
868 1
    public function ticketDisplayTST(RequestOptions\TicketDisplayTstOptions $options, $messageOptions = [])
869
    {
870 1
        $msgName = 'Ticket_DisplayTST';
871
872 1
        return $this->callMessage($msgName, $options, $messageOptions);
873
    }
874
875
    /**
876
     * Ticket_DisplayTSMP
877
     *
878
     * @param RequestOptions\TicketDisplayTsmpOptions $options
879
     * @param array $messageOptions (OPTIONAL)
880
     * @return Result
881
     */
882 1
    public function ticketDisplayTSMP(RequestOptions\TicketDisplayTsmpOptions $options, $messageOptions = [])
883
    {
884 1
        $msgName = 'Ticket_DisplayTSMP';
885
886 1
        return $this->callMessage($msgName, $options, $messageOptions);
887
    }
888
889
    /**
890
     * Ticket_DisplayTSMFareElement
891
     *
892
     * @param RequestOptions\TicketDisplayTsmFareElOptions $options
893
     * @param array $messageOptions (OPTIONAL)
894
     * @return Result
895
     */
896 1
    public function ticketDisplayTSMFareElement(
897
        RequestOptions\TicketDisplayTsmFareElOptions $options,
898
        $messageOptions = []
899
    ) {
900 1
        $msgName = 'Ticket_DisplayTSMFareElement';
901
902 1
        return $this->callMessage($msgName, $options, $messageOptions);
903
    }
904
905
    /**
906
     * Ticket_CheckEligibility
907
     *
908
     * @param RequestOptions\TicketCheckEligibilityOptions $options
909
     * @param array $messageOptions (OPTIONAL)
910
     * @return Result
911
     */
912 1
    public function ticketCheckEligibility(
913
        RequestOptions\TicketCheckEligibilityOptions $options,
914
        $messageOptions = []
915
    ) {
916 1
        $msgName = 'Ticket_CheckEligibility';
917
918 1
        return $this->callMessage($msgName, $options, $messageOptions);
919
    }
920
921
    /**
922
     * DocIssuance_IssueTicket
923
     *
924
     * @param RequestOptions\DocIssuanceIssueTicketOptions $options
925
     * @param array $messageOptions (OPTIONAL)
926
     * @return Result
927
     */
928 1
    public function docIssuanceIssueTicket(
929
        RequestOptions\DocIssuanceIssueTicketOptions $options,
930
        $messageOptions = []
931
    ) {
932 1
        $msgName = 'DocIssuance_IssueTicket';
933
934 1
        return $this->callMessage($msgName, $options, $messageOptions);
935
    }
936
937
    /**
938
     * DocIssuance_IssueMiscellaneousDocuments
939
     *
940
     * @param RequestOptions\DocIssuanceIssueMiscDocOptions $options
941
     * @param array $messageOptions (OPTIONAL)
942
     * @return Result
943
     */
944 1
    public function docIssuanceIssueMiscellaneousDocuments(
945
        RequestOptions\DocIssuanceIssueMiscDocOptions $options,
946
        $messageOptions = []
947
    ) {
948 1
        $msgName = 'DocIssuance_IssueMiscellaneousDocuments';
949
950 1
        return $this->callMessage($msgName, $options, $messageOptions);
951
    }
952
953
    /**
954
     * DocIssuance_IssueCombined
955
     *
956
     * @param RequestOptions\DocIssuanceIssueCombinedOptions $options
957
     * @param array $messageOptions (OPTIONAL)
958
     * @return Result
959
     */
960 2
    public function docIssuanceIssueCombined(
961
        RequestOptions\DocIssuanceIssueCombinedOptions $options,
962
        $messageOptions = []
963
    ) {
964 2
        $msgName = 'DocIssuance_IssueCombined';
965
966 2
        return $this->callMessage($msgName, $options, $messageOptions);
967
    }
968
969
    /**
970
     * FOP_CreateFormOfPayment
971
     *
972
     * @param RequestOptions\FopCreateFopOptions $options
973
     * @param array $messageOptions (OPTIONAL)
974
     * @return Result
975
     */
976 1
    public function fopCreateFormOfPayment(RequestOptions\FopCreateFopOptions $options, $messageOptions = [])
977
    {
978 1
        $msgName = 'FOP_CreateFormOfPayment';
979
980 1
        return $this->callMessage($msgName, $options, $messageOptions);
981
    }
982
983
    /**
984
     * PriceXplorer_ExtremeSearch
985
     *
986
     * @param RequestOptions\PriceXplorerExtremeSearchOptions $options
987
     * @param array $messageOptions (OPTIONAL)
988
     * @return Result
989
     */
990 1
    public function priceXplorerExtremeSearch(
991
        RequestOptions\PriceXplorerExtremeSearchOptions $options,
992
        $messageOptions = []
993
    ) {
994 1
        $msgName = 'PriceXplorer_ExtremeSearch';
995
996 1
        return $this->callMessage($msgName, $options, $messageOptions);
997
    }
998
999
    /**
1000
     * SalesReports_DisplayQueryReport
1001
     *
1002
     * @param RequestOptions\SalesReportsDisplayQueryReportOptions $options
1003
     * @param array $messageOptions (OPTIONAL)
1004
     * @return Result
1005
     */
1006 1
    public function salesReportsDisplayQueryReport(
1007
        RequestOptions\SalesReportsDisplayQueryReportOptions $options,
1008
        $messageOptions = []
1009
    ) {
1010 1
        $msgName = 'SalesReports_DisplayQueryReport';
1011
1012 1
        return $this->callMessage($msgName, $options, $messageOptions);
1013
    }
1014
1015
    /**
1016
     * Service_IntegratedPricing
1017
     *
1018
     * @param RequestOptions\ServiceIntegratedPricingOptions $options
1019
     * @param array $messageOptions (OPTIONAL)
1020
     * @return Result
1021
     */
1022 1
    public function serviceIntegratedPricing(
1023
        RequestOptions\ServiceIntegratedPricingOptions $options,
1024
        $messageOptions = []
1025
    ) {
1026 1
        $msgName = 'Service_IntegratedPricing';
1027
1028 1
        return $this->callMessage($msgName, $options, $messageOptions);
1029
    }
1030
1031
    /**
1032
     * Call a message with the given parameters
1033
     *
1034
     * @param string $messageName
1035
     * @param RequestOptions\RequestOptionsInterface $options
1036
     * @param array $messageOptions
1037
     * @param bool $endSession
1038
     * @return Result
1039
     * @throws Client\Exception
1040
     * @throws Client\Struct\InvalidArgumentException
1041
     * @throws Client\InvalidMessageException
1042
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
1043
     * @throws \RuntimeException
1044
     * @throws \InvalidArgumentException
1045
     * @throws \SoapFault
1046
     */
1047 58
    protected function callMessage($messageName, $options, $messageOptions, $endSession = false)
1048
    {
1049 58
        $messageOptions = $this->makeMessageOptions($messageOptions, $endSession);
1050
1051 58
        $this->lastMessage = $messageName;
1052
1053 58
        $sendResult = $this->sessionHandler->sendMessage(
1054 58
            $messageName,
1055 58
            $this->requestCreator->createRequest(
1056 58
                $messageName,
1057
                $options
1058 58
            ),
1059
            $messageOptions
1060 58
        );
1061
1062 58
        $response = $this->responseHandler->analyzeResponse(
1063 58
            $sendResult,
1064
            $messageName
1065 58
        );
1066
1067 58
        if ($messageOptions['returnXml'] === false) {
1068 1
            $response->responseXml = null;
1069 1
        }
1070
1071 58
        return $response;
1072
    }
1073
1074
    /**
1075
     * Make message options
1076
     *
1077
     * Message options are meta options when sending a message to the amadeus web services
1078
     * - 'endSession' (if stateful) : should we end the current session after sending this call?
1079
     * - 'returnXml' : Should we return the XML string in the Result::responseXml property?
1080
     *   (this overrides the default setting returnXml in the Amadeus\Client\Params for a single message)
1081
     *
1082
     * @param array $incoming The Message options chosen by the caller - if any.
1083
     * @param bool $endSession Switch if you want to terminate the current session after making the call.
1084
     * @return array
1085
     */
1086 64
    protected function makeMessageOptions(array $incoming, $endSession = false)
1087
    {
1088
        $options = [
1089 64
            'endSession' => $endSession,
1090 64
            'returnXml' => $this->returnResultXml
1091 64
        ];
1092
1093 64
        if (array_key_exists('endSession', $incoming)) {
1094 1
            $options['endSession'] = $incoming['endSession'];
1095 1
        }
1096
1097 64
        if (array_key_exists('returnXml', $incoming)) {
1098 3
            $options['returnXml'] = $incoming['returnXml'];
1099 3
        }
1100
1101 64
        return $options;
1102
    }
1103
1104
    /**
1105
     * Load the session handler
1106
     *
1107
     * Either load the provided session handler or create one depending on incoming parameters.
1108
     *
1109
     * @param HandlerInterface|null $sessionHandler
1110
     * @param Params\SessionHandlerParams|null $params
1111
     * @return HandlerInterface
1112
     */
1113 72
    protected function loadSessionHandler($sessionHandler, $params)
1114
    {
1115 72
        if ($sessionHandler instanceof HandlerInterface) {
1116 61
            $newSessionHandler = $sessionHandler;
1117 61
        } else {
1118 11
            $newSessionHandler = HandlerFactory::createHandler($params);
1119
        }
1120
1121 71
        return $newSessionHandler;
1122
    }
1123
1124
    /**
1125
     * Load a request creator
1126
     *
1127
     * A request creator is responsible for generating the correct request to send.
1128
     *
1129
     * @param RequestCreatorInterface|null $requestCreator
1130
     * @param Params\RequestCreatorParams $params
1131
     * @param string $libIdentifier Library identifier & version string (for Received From)
1132
     * @param string $originatorOffice The Office we are signed in with.
1133
     * @param array $mesVer Messages & Versions array of active messages in the WSDL
1134
     * @return RequestCreatorInterface
1135
     * @throws \RuntimeException
1136
     */
1137 71
    protected function loadRequestCreator($requestCreator, $params, $libIdentifier, $originatorOffice, $mesVer)
1138
    {
1139 71
        if ($requestCreator instanceof RequestCreatorInterface) {
1140 1
            $newRequestCreator = $requestCreator;
1141 1
        } else {
1142 70
            $params->originatorOfficeId = $originatorOffice;
1143 70
            $params->messagesAndVersions = $mesVer;
1144
1145 70
            $newRequestCreator = RequestCreatorFactory::createRequestCreator(
1146 70
                $params,
1147
                $libIdentifier
1148 70
            );
1149
        }
1150
1151 71
        return $newRequestCreator;
1152
    }
1153
1154
    /**
1155
     * Load a response handler
1156
     *
1157
     * @param ResponseHandlerInterface|null $responseHandler
1158
     * @return ResponseHandlerInterface
1159
     * @throws \RuntimeException
1160
     */
1161 71
    protected function loadResponseHandler($responseHandler)
1162
    {
1163 71
        if ($responseHandler instanceof ResponseHandlerInterface) {
1164 52
            $newResponseHandler = $responseHandler;
1165 52
        } else {
1166 19
            $newResponseHandler = new ResponseHandlerBase();
1167
        }
1168
1169 71
        return $newResponseHandler;
1170
    }
1171
}
1172