Completed
Push — master ( 3eff48...48ab8a )
by Dieter
07:45
created

Client::ticketDisplayTSMP()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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