Passed
Branch fopcreatefop (fcebe7)
by Dieter
08:14
created

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