Completed
Push — master ( 659f96...72a295 )
by Dieter
07:40
created

Client::farePricePnrWithLowestFare()   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
     * 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 63
    public function __construct($params)
178
    {
179 63
        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 63
        $this->sessionHandler = $this->loadSessionHandler(
189 63
            $params->sessionHandler,
190 63
            $params->sessionHandlerParams
191 63
        );
192
193 62
        $this->requestCreator = $this->loadRequestCreator(
194 62
            $params->requestCreator,
195 62
            $params->requestCreatorParams,
196 62
            self::RECEIVED_FROM_IDENTIFIER."-".self::VERSION,
197 62
            $this->sessionHandler->getOriginatorOffice(),
198 62
            $this->sessionHandler->getMessagesAndVersions()
199 62
        );
200
201 62
        $this->responseHandler = $this->loadResponseHandler(
202 62
            $params->responseHandler
203 62
        );
204 62
    }
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
    /**
763
     * Ticket_CreateTSTFromPricing
764
     *
765
     * @param RequestOptions\TicketCreateTstFromPricingOptions $options
766
     * @param array $messageOptions (OPTIONAL)
767
     * @return Result
768
     */
769 1
    public function ticketCreateTSTFromPricing(
770
        RequestOptions\TicketCreateTstFromPricingOptions $options,
771
        $messageOptions = []
772
    ) {
773 1
        $msgName = 'Ticket_CreateTSTFromPricing';
774
775 1
        return $this->callMessage($msgName, $options, $messageOptions);
776
    }
777
778
    /**
779
     * Ticket_CreateTSMFromPricing
780
     *
781
     * @param RequestOptions\TicketCreateTsmFromPricingOptions $options
782
     * @param array $messageOptions (OPTIONAL)
783
     * @return Result
784
     */
785 1
    public function ticketCreateTSMFromPricing(
786
        RequestOptions\TicketCreateTsmFromPricingOptions $options,
787
        $messageOptions = []
788
    ) {
789 1
        $msgName = 'Ticket_CreateTSMFromPricing';
790
791 1
        return $this->callMessage($msgName, $options, $messageOptions);
792
    }
793
794
    /**
795
     * Ticket_DeleteTST
796
     *
797
     * @param RequestOptions\TicketDeleteTstOptions $options
798
     * @param array $messageOptions (OPTIONAL)
799
     * @return Result
800
     */
801 1
    public function ticketDeleteTST(RequestOptions\TicketDeleteTstOptions $options, $messageOptions = [])
802
    {
803 1
        $msgName = 'Ticket_DeleteTST';
804
805 1
        return $this->callMessage($msgName, $options, $messageOptions);
806
    }
807
808
    /**
809
     * Ticket_DeleteTSMP
810
     *
811
     * @param RequestOptions\TicketDeleteTsmpOptions $options
812
     * @param array $messageOptions (OPTIONAL)
813
     * @return Result
814
     */
815 1
    public function ticketDeleteTSMP(RequestOptions\TicketDeleteTsmpOptions $options, $messageOptions = [])
816
    {
817 1
        $msgName = 'Ticket_DeleteTSMP';
818
819 1
        return $this->callMessage($msgName, $options, $messageOptions);
820
    }
821
822
    /**
823
     * Ticket_DisplayTST
824
     *
825
     * @param RequestOptions\TicketDisplayTstOptions $options
826
     * @param array $messageOptions (OPTIONAL)
827
     * @return Result
828
     */
829 1
    public function ticketDisplayTST(RequestOptions\TicketDisplayTstOptions $options, $messageOptions = [])
830
    {
831 1
        $msgName = 'Ticket_DisplayTST';
832
833 1
        return $this->callMessage($msgName, $options, $messageOptions);
834
    }
835
836
    /**
837
     * DocIssuance_IssueTicket
838
     *
839
     * @param RequestOptions\DocIssuanceIssueTicketOptions $options
840
     * @param array $messageOptions (OPTIONAL)
841
     * @return Result
842
     */
843 1
    public function docIssuanceIssueTicket(
844
        RequestOptions\DocIssuanceIssueTicketOptions $options,
845
        $messageOptions = []
846
    ) {
847 1
        $msgName = 'DocIssuance_IssueTicket';
848
849 1
        return $this->callMessage($msgName, $options, $messageOptions);
850
    }
851
852
    /**
853
     * DocIssuance_IssueMiscellaneousDocuments
854
     *
855
     * @param RequestOptions\DocIssuanceIssueMiscDocOptions $options
856
     * @param array $messageOptions (OPTIONAL)
857
     * @return Result
858
     */
859 1
    public function docIssuanceIssueMiscellaneousDocuments(
860
        RequestOptions\DocIssuanceIssueMiscDocOptions $options,
861
        $messageOptions = []
862
    ) {
863 1
        $msgName = 'DocIssuance_IssueMiscellaneousDocuments';
864
865 1
        return $this->callMessage($msgName, $options, $messageOptions);
866
    }
867
868
    /**
869
     * PriceXplorer_ExtremeSearch
870
     *
871
     * @param RequestOptions\PriceXplorerExtremeSearchOptions $options
872
     * @param array $messageOptions (OPTIONAL)
873
     * @return Result
874
     */
875 1
    public function priceXplorerExtremeSearch(
876
        RequestOptions\PriceXplorerExtremeSearchOptions $options,
877
        $messageOptions = []
878
    ) {
879 1
        $msgName = 'PriceXplorer_ExtremeSearch';
880
881 1
        return $this->callMessage($msgName, $options, $messageOptions);
882
    }
883
884
    /**
885
     * SalesReports_DisplayQueryReport
886
     *
887
     * @param RequestOptions\SalesReportsDisplayQueryReportOptions $options
888
     * @param array $messageOptions (OPTIONAL)
889
     * @return Result
890
     */
891 1
    public function salesReportsDisplayQueryReport(
892
        RequestOptions\SalesReportsDisplayQueryReportOptions $options,
893
        $messageOptions = []
894
    ) {
895 1
        $msgName = 'SalesReports_DisplayQueryReport';
896
897 1
        return $this->callMessage($msgName, $options, $messageOptions);
898
    }
899
900
    /**
901
     * Service_IntegratedPricing
902
     *
903
     * @param RequestOptions\ServiceIntegratedPricingOptions $options
904
     * @param array $messageOptions (OPTIONAL)
905
     * @return Result
906
     */
907 1
    public function serviceIntegratedPricing(
908
        RequestOptions\ServiceIntegratedPricingOptions $options,
909
        $messageOptions = []
910
    ) {
911 1
        $msgName = 'Service_IntegratedPricing';
912
913 1
        return $this->callMessage($msgName, $options, $messageOptions);
914
    }
915
916
    /**
917
     * Call a message with the given parameters
918
     *
919
     * @param string $messageName
920
     * @param RequestOptions\RequestOptionsInterface $options
921
     * @param array $messageOptions
922
     * @param bool $endSession
923
     * @return Result
924
     * @throws Client\Exception
925
     * @throws Client\Struct\InvalidArgumentException
926
     * @throws Client\InvalidMessageException
927
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
928
     * @throws \RuntimeException
929
     * @throws \InvalidArgumentException
930
     * @throws \SoapFault
931
     */
932 50
    protected function callMessage($messageName, $options, $messageOptions, $endSession = false)
933
    {
934 50
        $messageOptions = $this->makeMessageOptions($messageOptions, $endSession);
935
936 50
        $this->lastMessage = $messageName;
937
938 50
        $sendResult = $this->sessionHandler->sendMessage(
939 50
            $messageName,
940 50
            $this->requestCreator->createRequest(
941 50
                $messageName,
942
                $options
943 50
            ),
944
            $messageOptions
945 50
        );
946
947 50
        return $this->responseHandler->analyzeResponse(
948 50
            $sendResult,
949
            $messageName
950 50
        );
951
    }
952
953
    /**
954
     * Make message options
955
     *
956
     * Message options are meta options when sending a message to the amadeus web services
957
     * - (if stateful) should we end the current session after sending this call?
958
     * - ... ?
959
     *
960
     * @param array $incoming The Message options chosen by the caller - if any.
961
     * @param bool $endSession Switch if you want to terminate the current session after making the call.
962
     * @return array
963
     */
964 55
    protected function makeMessageOptions(array $incoming, $endSession = false)
965
    {
966
        $options = [
967
            'endSession' => $endSession
968 55
        ];
969
970 55
        if (array_key_exists('endSession', $incoming)) {
971 1
            $options['endSession'] = $incoming['endSession'];
972 1
        }
973
974 55
        return $options;
975
    }
976
977
    /**
978
     * Load the session handler
979
     *
980
     * Either load the provided session handler or create one depending on incoming parameters.
981
     *
982
     * @param HandlerInterface|null $sessionHandler
983
     * @param Params\SessionHandlerParams|null $params
984
     * @return HandlerInterface
985
     */
986 63
    protected function loadSessionHandler($sessionHandler, $params)
987
    {
988 63
        if ($sessionHandler instanceof HandlerInterface) {
989 53
            $newSessionHandler = $sessionHandler;
990 53
        } else {
991 10
            $newSessionHandler = HandlerFactory::createHandler($params);
992
        }
993
994 62
        return $newSessionHandler;
995
    }
996
997
    /**
998
     * Load a request creator
999
     *
1000
     * A request creator is responsible for generating the correct request to send.
1001
     *
1002
     * @param RequestCreatorInterface|null $requestCreator
1003
     * @param Params\RequestCreatorParams $params
1004
     * @param string $libIdentifier Library identifier & version string (for Received From)
1005
     * @param string $originatorOffice The Office we are signed in with.
1006
     * @param array $mesVer Messages & Versions array of active messages in the WSDL
1007
     * @return RequestCreatorInterface
1008
     * @throws \RuntimeException
1009
     */
1010 62
    protected function loadRequestCreator($requestCreator, $params, $libIdentifier, $originatorOffice, $mesVer)
1011
    {
1012 62
        if ($requestCreator instanceof RequestCreatorInterface) {
1013 1
            $newRequestCreator = $requestCreator;
1014 1
        } else {
1015 61
            $params->originatorOfficeId = $originatorOffice;
1016 61
            $params->messagesAndVersions = $mesVer;
1017
1018 61
            $newRequestCreator = RequestCreatorFactory::createRequestCreator(
1019 61
                $params,
1020
                $libIdentifier
1021 61
            );
1022
        }
1023
1024 62
        return $newRequestCreator;
1025
    }
1026
1027
    /**
1028
     * Load a response handler
1029
     *
1030
     * @param ResponseHandlerInterface|null $responseHandler
1031
     * @return ResponseHandlerInterface
1032
     * @throws \RuntimeException
1033
     */
1034 62
    protected function loadResponseHandler($responseHandler)
1035
    {
1036 62
        if ($responseHandler instanceof ResponseHandlerInterface) {
1037 45
            $newResponseHandler = $responseHandler;
1038 45
        } else {
1039 17
            $newResponseHandler = new ResponseHandlerBase();
1040
        }
1041
1042 62
        return $newResponseHandler;
1043
    }
1044
}
1045