Completed
Push — master ( 1d0975...18f0a3 )
by Dieter
08:30
created

Client::serviceIntegratedPricing()   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 62
    public function __construct($params)
178
    {
179 62
        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 62
        $this->sessionHandler = $this->loadSessionHandler(
189 62
            $params->sessionHandler,
190 62
            $params->sessionHandlerParams
191 62
        );
192
193 61
        $this->requestCreator = $this->loadRequestCreator(
194 61
            $params->requestCreator,
195 61
            $params->requestCreatorParams,
196 61
            self::RECEIVED_FROM_IDENTIFIER."-".self::VERSION,
197 61
            $this->sessionHandler->getOriginatorOffice(),
198 61
            $this->sessionHandler->getMessagesAndVersions()
199 61
        );
200
201 61
        $this->responseHandler = $this->loadResponseHandler(
202 61
            $params->responseHandler
203 61
        );
204 61
    }
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
     * Queue_List - get a list of all PNR's on a given queue
359
     *
360
     * https://webservices.amadeus.com/extranet/viewService.do?id=52&flavourId=1&menuId=functional
361
     *
362
     * @param RequestOptions\QueueListOptions $options
363
     * @param array $messageOptions (OPTIONAL)
364
     * @return Result
365
     */
366 1
    public function queueList(RequestOptions\QueueListOptions $options, $messageOptions = [])
367
    {
368 1
        $msgName = 'Queue_List';
369
370 1
        return $this->callMessage($msgName, $options, $messageOptions);
371
    }
372
373
    /**
374
     * Queue_PlacePNR - Place a PNR on a given queue
375
     *
376
     * @param RequestOptions\QueuePlacePnrOptions $options
377
     * @param array $messageOptions (OPTIONAL)
378
     * @return Result
379
     */
380 1
    public function queuePlacePnr(RequestOptions\QueuePlacePnrOptions $options, $messageOptions = [])
381
    {
382 1
        $msgName = 'Queue_PlacePNR';
383
384 1
        return $this->callMessage($msgName, $options, $messageOptions);
385
    }
386
387
    /**
388
     * Queue_RemoveItem - remove an item (a PNR) from a given queue
389
     *
390
     * @param RequestOptions\QueueRemoveItemOptions $options
391
     * @param array $messageOptions (OPTIONAL)
392
     * @return Result
393
     */
394 1
    public function queueRemoveItem(RequestOptions\QueueRemoveItemOptions $options, $messageOptions = [])
395
    {
396 1
        $msgName = 'Queue_RemoveItem';
397
398 1
        return $this->callMessage($msgName, $options, $messageOptions);
399
    }
400
401
    /**
402
     * Queue_MoveItem - move an item (a PNR) from one queue to another.
403
     *
404
     * @param RequestOptions\QueueMoveItemOptions $options
405
     * @param array $messageOptions (OPTIONAL)
406
     * @return Result
407
     */
408 1
    public function queueMoveItem(RequestOptions\QueueMoveItemOptions $options, $messageOptions = [])
409
    {
410 1
        $msgName = 'Queue_MoveItem';
411
412 1
        return $this->callMessage($msgName, $options, $messageOptions);
413
    }
414
415
    /**
416
     * Offer_CreateOffer
417
     *
418
     * @param RequestOptions\OfferCreateOptions $options
419
     * @param array $messageOptions (OPTIONAL)
420
     * @return Result
421
     */
422 1
    public function offerCreate(RequestOptions\OfferCreateOptions $options, $messageOptions = [])
423
    {
424 1
        $msgName = 'Offer_CreateOffer';
425
426 1
        return $this->callMessage($msgName, $options, $messageOptions);
427
    }
428
429
    /**
430
     * Offer_VerifyOffer
431
     *
432
     * To be called in the context of an open PNR
433
     *
434
     * @param RequestOptions\OfferVerifyOptions $options
435
     * @param array $messageOptions (OPTIONAL)
436
     * @return Result
437
     */
438 1
    public function offerVerify(RequestOptions\OfferVerifyOptions $options, $messageOptions = [])
439
    {
440 1
        $msgName = 'Offer_VerifyOffer';
441
442 1
        return $this->callMessage($msgName, $options, $messageOptions);
443
    }
444
445
    /**
446
     * Offer_ConfirmAirOffer
447
     *
448
     * @param RequestOptions\OfferConfirmAirOptions $options
449
     * @param array $messageOptions (OPTIONAL)
450
     * @return Result
451
     */
452 1
    public function offerConfirmAir(RequestOptions\OfferConfirmAirOptions $options, $messageOptions = [])
453
    {
454 1
        $msgName = 'Offer_ConfirmAirOffer';
455
456 1
        return $this->callMessage($msgName, $options, $messageOptions);
457
    }
458
459
    /**
460
     * Offer_ConfirmHotelOffer
461
     *
462
     * @param RequestOptions\OfferConfirmHotelOptions $options
463
     * @param array $messageOptions (OPTIONAL)
464
     * @return Result
465
     */
466 1
    public function offerConfirmHotel(RequestOptions\OfferConfirmHotelOptions $options, $messageOptions = [])
467
    {
468 1
        $msgName = 'Offer_ConfirmHotelOffer';
469
470 1
        return $this->callMessage($msgName, $options, $messageOptions);
471
    }
472
473
    /**
474
     * Offer_ConfirmCarOffer
475
     *
476
     * @param RequestOptions\OfferConfirmCarOptions $options
477
     * @param array $messageOptions (OPTIONAL)
478
     * @return Result
479
     */
480 1
    public function offerConfirmCar(RequestOptions\OfferConfirmCarOptions $options, $messageOptions = [])
481
    {
482 1
        $msgName = 'Offer_ConfirmCarOffer';
483
484 1
        return $this->callMessage($msgName, $options, $messageOptions);
485
    }
486
487
    /**
488
     * Fare_MasterPricerTravelBoardSearch
489
     *
490
     * @param RequestOptions\FareMasterPricerTbSearch $options
491
     * @param array $messageOptions (OPTIONAL)
492
     * @return Result
493
     */
494 1
    public function fareMasterPricerTravelBoardSearch(
495
        RequestOptions\FareMasterPricerTbSearch $options,
496
        $messageOptions = []
497
    ) {
498 1
        $msgName = 'Fare_MasterPricerTravelBoardSearch';
499
500 1
        return $this->callMessage($msgName, $options, $messageOptions);
501
    }
502
503
    /**
504
     * Fare_MasterPricerCalendar
505
     *
506
     * @param RequestOptions\FareMasterPricerCalendarOptions $options
507
     * @param array $messageOptions (OPTIONAL)
508
     * @return Result
509
     */
510 1
    public function fareMasterPricerCalendar(
511
        RequestOptions\FareMasterPricerCalendarOptions $options,
512
        $messageOptions = []
513
    ) {
514 1
        $msgName = 'Fare_MasterPricerCalendar';
515
516 1
        return $this->callMessage($msgName, $options, $messageOptions);
517
    }
518
519
    /**
520
     * Fare_PricePnrWithBookingClass
521
     *
522
     * @param RequestOptions\FarePricePnrWithBookingClassOptions $options
523
     * @param array $messageOptions (OPTIONAL)
524
     * @return Result
525
     */
526 2
    public function farePricePnrWithBookingClass(
527
        RequestOptions\FarePricePnrWithBookingClassOptions $options,
528
        $messageOptions = []
529
    ) {
530 2
        $msgName = 'Fare_PricePNRWithBookingClass';
531
532 2
        return $this->callMessage($msgName, $options, $messageOptions);
533
    }
534
535
    /**
536
     * Fare_PricePnrWithLowerFares
537
     *
538
     * @param RequestOptions\FarePricePnrWithLowerFaresOptions $options
539
     * @param array $messageOptions (OPTIONAL)
540
     * @return Result
541
     */
542 2
    public function farePricePnrWithLowerFares(
543
        RequestOptions\FarePricePnrWithLowerFaresOptions $options,
544
        $messageOptions = []
545
    ) {
546 2
        $msgName = 'Fare_PricePNRWithLowerFares';
547
548 2
        return $this->callMessage($msgName, $options, $messageOptions);
549
    }
550
551
    /**
552
     * Fare_PricePnrWithLowestFare
553
     *
554
     * @param RequestOptions\FarePricePnrWithLowestFareOptions $options
555
     * @param array $messageOptions (OPTIONAL)
556
     * @return Result
557
     */
558 2
    public function farePricePnrWithLowestFare(
559
        RequestOptions\FarePricePnrWithLowestFareOptions $options,
560
        $messageOptions = []
561
    ) {
562 2
        $msgName = 'Fare_PricePNRWithLowestFare';
563
564 2
        return $this->callMessage($msgName, $options, $messageOptions);
565
    }
566
567
    /**
568
     * Fare_InformativePricingWithoutPNR
569
     *
570
     * @param RequestOptions\FareInformativePricingWithoutPnrOptions $options
571
     * @param array $messageOptions (OPTIONAL)
572
     * @return Result
573
     */
574 1
    public function fareInformativePricingWithoutPnr(
575
        RequestOptions\FareInformativePricingWithoutPnrOptions $options,
576
        $messageOptions = []
577
    ) {
578 1
        $msgName = 'Fare_InformativePricingWithoutPNR';
579
580 1
        return $this->callMessage($msgName, $options, $messageOptions);
581
    }
582
583
    /**
584
     * Fare_InformativeBestPricingWithoutPNR
585
     *
586
     * @param RequestOptions\FareInformativeBestPricingWithoutPnrOptions $options
587
     * @param array $messageOptions (OPTIONAL)
588
     * @return Result
589
     */
590 1
    public function fareInformativeBestPricingWithoutPnr(
591
        RequestOptions\FareInformativeBestPricingWithoutPnrOptions $options,
592
        $messageOptions = []
593
    ) {
594 1
        $msgName = 'Fare_InformativeBestPricingWithoutPNR';
595
596 1
        return $this->callMessage($msgName, $options, $messageOptions);
597
    }
598
599
    /**
600
     * Fare_CheckRules
601
     *
602
     * @param RequestOptions\FareCheckRulesOptions $options
603
     * @param array $messageOptions (OPTIONAL)
604
     * @return Result
605
     */
606 1
    public function fareCheckRules(RequestOptions\FareCheckRulesOptions $options, $messageOptions = [])
607
    {
608 1
        $msgName = 'Fare_CheckRules';
609
610 1
        return $this->callMessage($msgName, $options, $messageOptions);
611
    }
612
613
    /**
614
     * Fare_ConvertCurrency
615
     *
616
     * @param RequestOptions\FareConvertCurrencyOptions $options
617
     * @param array $messageOptions (OPTIONAL)
618
     * @return Result
619
     */
620 1
    public function fareConvertCurrency(RequestOptions\FareConvertCurrencyOptions $options, $messageOptions = [])
621
    {
622 1
        $msgName = 'Fare_ConvertCurrency';
623
624 1
        return $this->callMessage($msgName, $options, $messageOptions);
625
    }
626
627
    /**
628
     * Air_MultiAvailability
629
     *
630
     * @param RequestOptions\AirMultiAvailabilityOptions $options
631
     * @param array $messageOptions (OPTIONAL)
632
     * @return Result
633
     */
634 1
    public function airMultiAvailability(
635
        RequestOptions\AirMultiAvailabilityOptions $options,
636
        $messageOptions = []
637
    ) {
638 1
        $msgName = 'Air_MultiAvailability';
639
640 1
        return $this->callMessage($msgName, $options, $messageOptions);
641
    }
642
643
    /**
644
     * Air_SellFromRecommendation
645
     *
646
     * @param RequestOptions\AirSellFromRecommendationOptions $options
647
     * @param array $messageOptions (OPTIONAL)
648
     * @return Result
649
     */
650 1
    public function airSellFromRecommendation(
651
        RequestOptions\AirSellFromRecommendationOptions $options,
652
        $messageOptions = []
653
    ) {
654 1
        $msgName = 'Air_SellFromRecommendation';
655
656 1
        return $this->callMessage($msgName, $options, $messageOptions);
657
    }
658
659
    /**
660
     * Air_FlightInfo
661
     *
662
     * @param RequestOptions\AirFlightInfoOptions $options
663
     * @param array $messageOptions (OPTIONAL)
664
     * @return Result
665
     */
666 1
    public function airFlightInfo(RequestOptions\AirFlightInfoOptions $options, $messageOptions = [])
667
    {
668 1
        $msgName = 'Air_FlightInfo';
669
670 1
        return $this->callMessage($msgName, $options, $messageOptions);
671
    }
672
673
    /**
674
     * Air_RetrieveSeatMap
675
     *
676
     * @param RequestOptions\AirRetrieveSeatMapOptions $options
677
     * @param array $messageOptions (OPTIONAL)
678
     * @return Result
679
     */
680 1
    public function airRetrieveSeatMap(RequestOptions\AirRetrieveSeatMapOptions $options, $messageOptions = [])
681
    {
682 1
        $msgName = 'Air_RetrieveSeatMap';
683
684 1
        return $this->callMessage($msgName, $options, $messageOptions);
685
    }
686
687
    /**
688
     * Command_Cryptic
689
     *
690
     * @param RequestOptions\CommandCrypticOptions $options
691
     * @param array $messageOptions (OPTIONAL)
692
     * @return Result
693
     */
694 1
    public function commandCryptic(RequestOptions\CommandCrypticOptions $options, $messageOptions = [])
695
    {
696 1
        $msgName = 'Command_Cryptic';
697
698 1
        return $this->callMessage($msgName, $options, $messageOptions);
699
    }
700
701
    /**
702
     * MiniRule_GetFromPricingRec
703
     *
704
     * @param RequestOptions\MiniRuleGetFromPricingRecOptions $options
705
     * @param array $messageOptions (OPTIONAL)
706
     * @return Result
707
     */
708 1
    public function miniRuleGetFromPricingRec(
709
        RequestOptions\MiniRuleGetFromPricingRecOptions $options,
710
        $messageOptions = []
711
    ) {
712 1
        $msgName = 'MiniRule_GetFromPricingRec';
713
714 1
        return $this->callMessage($msgName, $options, $messageOptions);
715
    }
716
717
    /**
718
     * MiniRule_GetFromPricing
719
     *
720
     * @param RequestOptions\MiniRuleGetFromPricingOptions $options
721
     * @param array $messageOptions (OPTIONAL)
722
     * @return Result
723
     */
724 1
    public function miniRuleGetFromPricing(
725
        RequestOptions\MiniRuleGetFromPricingOptions $options,
726
        $messageOptions = []
727
    ) {
728 1
        $msgName = 'MiniRule_GetFromPricing';
729
730 1
        return $this->callMessage($msgName, $options, $messageOptions);
731
    }
732
733
    /**
734
     * Info_EncodeDecodeCity
735
     *
736
     * @param RequestOptions\InfoEncodeDecodeCityOptions $options
737
     * @param array $messageOptions (OPTIONAL)
738
     * @return Result
739
     */
740 1
    public function infoEncodeDecodeCity(RequestOptions\InfoEncodeDecodeCityOptions $options, $messageOptions = [])
741
    {
742 1
        $msgName = 'Info_EncodeDecodeCity';
743
744 1
        return $this->callMessage($msgName, $options, $messageOptions);
745
    }
746
747
748
    /**
749
     * Ticket_CreateTSTFromPricing
750
     *
751
     * @param RequestOptions\TicketCreateTstFromPricingOptions $options
752
     * @param array $messageOptions (OPTIONAL)
753
     * @return Result
754
     */
755 1
    public function ticketCreateTSTFromPricing(
756
        RequestOptions\TicketCreateTstFromPricingOptions $options,
757
        $messageOptions = []
758
    ) {
759 1
        $msgName = 'Ticket_CreateTSTFromPricing';
760
761 1
        return $this->callMessage($msgName, $options, $messageOptions);
762
    }
763
764
    /**
765
     * Ticket_CreateTSMFromPricing
766
     *
767
     * @param RequestOptions\TicketCreateTsmFromPricingOptions $options
768
     * @param array $messageOptions (OPTIONAL)
769
     * @return Result
770
     */
771 1
    public function ticketCreateTSMFromPricing(
772
        RequestOptions\TicketCreateTsmFromPricingOptions $options,
773
        $messageOptions = []
774
    ) {
775 1
        $msgName = 'Ticket_CreateTSMFromPricing';
776
777 1
        return $this->callMessage($msgName, $options, $messageOptions);
778
    }
779
780
    /**
781
     * Ticket_DeleteTST
782
     *
783
     * @param RequestOptions\TicketDeleteTstOptions $options
784
     * @param array $messageOptions (OPTIONAL)
785
     * @return Result
786
     */
787 1
    public function ticketDeleteTST(RequestOptions\TicketDeleteTstOptions $options, $messageOptions = [])
788
    {
789 1
        $msgName = 'Ticket_DeleteTST';
790
791 1
        return $this->callMessage($msgName, $options, $messageOptions);
792
    }
793
794
    /**
795
     * Ticket_DeleteTSMP
796
     *
797
     * @param RequestOptions\TicketDeleteTsmpOptions $options
798
     * @param array $messageOptions (OPTIONAL)
799
     * @return Result
800
     */
801 1
    public function ticketDeleteTSMP(RequestOptions\TicketDeleteTsmpOptions $options, $messageOptions = [])
802
    {
803 1
        $msgName = 'Ticket_DeleteTSMP';
804
805 1
        return $this->callMessage($msgName, $options, $messageOptions);
806
    }
807
808
    /**
809
     * Ticket_DisplayTST
810
     *
811
     * @param RequestOptions\TicketDisplayTstOptions $options
812
     * @param array $messageOptions (OPTIONAL)
813
     * @return Result
814
     */
815 1
    public function ticketDisplayTST(RequestOptions\TicketDisplayTstOptions $options, $messageOptions = [])
816
    {
817 1
        $msgName = 'Ticket_DisplayTST';
818
819 1
        return $this->callMessage($msgName, $options, $messageOptions);
820
    }
821
822
    /**
823
     * DocIssuance_IssueTicket
824
     *
825
     * @param RequestOptions\DocIssuanceIssueTicketOptions $options
826
     * @param array $messageOptions (OPTIONAL)
827
     * @return Result
828
     */
829 1
    public function docIssuanceIssueTicket(
830
        RequestOptions\DocIssuanceIssueTicketOptions $options,
831
        $messageOptions = []
832
    ) {
833 1
        $msgName = 'DocIssuance_IssueTicket';
834
835 1
        return $this->callMessage($msgName, $options, $messageOptions);
836
    }
837
838
    /**
839
     * DocIssuance_IssueMiscellaneousDocuments
840
     *
841
     * @param RequestOptions\DocIssuanceIssueMiscDocOptions $options
842
     * @param array $messageOptions (OPTIONAL)
843
     * @return Result
844
     */
845 1
    public function docIssuanceIssueMiscellaneousDocuments(
846
        RequestOptions\DocIssuanceIssueMiscDocOptions $options,
847
        $messageOptions = []
848
    ) {
849 1
        $msgName = 'DocIssuance_IssueMiscellaneousDocuments';
850
851 1
        return $this->callMessage($msgName, $options, $messageOptions);
852
    }
853
854
    /**
855
     * PriceXplorer_ExtremeSearch
856
     *
857
     * @param RequestOptions\PriceXplorerExtremeSearchOptions $options
858
     * @param array $messageOptions (OPTIONAL)
859
     * @return Result
860
     */
861 1
    public function priceXplorerExtremeSearch(
862
        RequestOptions\PriceXplorerExtremeSearchOptions $options,
863
        $messageOptions = []
864
    ) {
865 1
        $msgName = 'PriceXplorer_ExtremeSearch';
866
867 1
        return $this->callMessage($msgName, $options, $messageOptions);
868
    }
869
870
    /**
871
     * SalesReports_DisplayQueryReport
872
     *
873
     * @param RequestOptions\SalesReportsDisplayQueryReportOptions $options
874
     * @param array $messageOptions (OPTIONAL)
875
     * @return Result
876
     */
877 1
    public function salesReportsDisplayQueryReport(
878
        RequestOptions\SalesReportsDisplayQueryReportOptions $options,
879
        $messageOptions = []
880
    ) {
881 1
        $msgName = 'SalesReports_DisplayQueryReport';
882
883 1
        return $this->callMessage($msgName, $options, $messageOptions);
884
    }
885
886
    /**
887
     * Service_IntegratedPricing
888
     *
889
     * @param RequestOptions\ServiceIntegratedPricingOptions $options
890
     * @param array $messageOptions (OPTIONAL)
891
     * @return Result
892
     */
893 1
    public function serviceIntegratedPricing(
894
        RequestOptions\ServiceIntegratedPricingOptions $options,
895
        $messageOptions = []
896
    ) {
897 1
        $msgName = 'Service_IntegratedPricing';
898
899 1
        return $this->callMessage($msgName, $options, $messageOptions);
900
    }
901
902
    /**
903
     * Call a message with the given parameters
904
     *
905
     * @param string $messageName
906
     * @param RequestOptions\RequestOptionsInterface $options
907
     * @param array $messageOptions
908
     * @param bool $endSession
909
     * @return Result
910
     * @throws Client\Exception
911
     * @throws Client\Struct\InvalidArgumentException
912
     * @throws Client\InvalidMessageException
913
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
914
     * @throws \RuntimeException
915
     * @throws \InvalidArgumentException
916
     * @throws \SoapFault
917
     */
918 49
    protected function callMessage($messageName, $options, $messageOptions, $endSession = false)
919
    {
920 49
        $messageOptions = $this->makeMessageOptions($messageOptions, $endSession);
921
922 49
        $this->lastMessage = $messageName;
923
924 49
        $sendResult = $this->sessionHandler->sendMessage(
925 49
            $messageName,
926 49
            $this->requestCreator->createRequest(
927 49
                $messageName,
928
                $options
929 49
            ),
930
            $messageOptions
931 49
        );
932
933 49
        return $this->responseHandler->analyzeResponse(
934 49
            $sendResult,
935
            $messageName
936 49
        );
937
    }
938
939
    /**
940
     * Make message options
941
     *
942
     * Message options are meta options when sending a message to the amadeus web services
943
     * - (if stateful) should we end the current session after sending this call?
944
     * - ... ?
945
     *
946
     * @param array $incoming The Message options chosen by the caller - if any.
947
     * @param bool $endSession Switch if you want to terminate the current session after making the call.
948
     * @return array
949
     */
950 54
    protected function makeMessageOptions(array $incoming, $endSession = false)
951
    {
952
        $options = [
953
            'endSession' => $endSession
954 54
        ];
955
956 54
        if (array_key_exists('endSession', $incoming)) {
957 1
            $options['endSession'] = $incoming['endSession'];
958 1
        }
959
960 54
        return $options;
961
    }
962
963
    /**
964
     * Load the session handler
965
     *
966
     * Either load the provided session handler or create one depending on incoming parameters.
967
     *
968
     * @param HandlerInterface|null $sessionHandler
969
     * @param Params\SessionHandlerParams|null $params
970
     * @return HandlerInterface
971
     */
972 62
    protected function loadSessionHandler($sessionHandler, $params)
973
    {
974 62
        if ($sessionHandler instanceof HandlerInterface) {
975 52
            $newSessionHandler = $sessionHandler;
976 52
        } else {
977 10
            $newSessionHandler = HandlerFactory::createHandler($params);
978
        }
979
980 61
        return $newSessionHandler;
981
    }
982
983
    /**
984
     * Load a request creator
985
     *
986
     * A request creator is responsible for generating the correct request to send.
987
     *
988
     * @param RequestCreatorInterface|null $requestCreator
989
     * @param Params\RequestCreatorParams $params
990
     * @param string $libIdentifier Library identifier & version string (for Received From)
991
     * @param string $originatorOffice The Office we are signed in with.
992
     * @param array $mesVer Messages & Versions array of active messages in the WSDL
993
     * @return RequestCreatorInterface
994
     * @throws \RuntimeException
995
     */
996 61
    protected function loadRequestCreator($requestCreator, $params, $libIdentifier, $originatorOffice, $mesVer)
997
    {
998 61
        if ($requestCreator instanceof RequestCreatorInterface) {
999 1
            $newRequestCreator = $requestCreator;
1000 1
        } else {
1001 60
            $params->originatorOfficeId = $originatorOffice;
1002 60
            $params->messagesAndVersions = $mesVer;
1003
1004 60
            $newRequestCreator = RequestCreatorFactory::createRequestCreator(
1005 60
                $params,
1006
                $libIdentifier
1007 60
            );
1008
        }
1009
1010 61
        return $newRequestCreator;
1011
    }
1012
1013
    /**
1014
     * Load a response handler
1015
     *
1016
     * @param ResponseHandlerInterface|null $responseHandler
1017
     * @return ResponseHandlerInterface
1018
     * @throws \RuntimeException
1019
     */
1020 61
    protected function loadResponseHandler($responseHandler)
1021
    {
1022 61
        if ($responseHandler instanceof ResponseHandlerInterface) {
1023 44
            $newResponseHandler = $responseHandler;
1024 44
        } else {
1025 17
            $newResponseHandler = new ResponseHandlerBase();
1026
        }
1027
1028 61
        return $newResponseHandler;
1029
    }
1030
}
1031