<?php
/**
 * amadeus-ws-client
 *
 * Copyright 2015 Amadeus Benelux NV
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package Amadeus
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
 */

namespace Amadeus\Client\Struct\Fare;

use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef;
use Amadeus\Client\RequestOptions\FarePricePnrWithBookingClassOptions;
use Amadeus\Client\RequestOptions\FarePricePnrWithLowerFaresOptions as LowerFareOpt;
use Amadeus\Client\RequestOptions\FarePricePnrWithLowestFareOptions as LowestFareOpt;
use Amadeus\Client\Struct\BaseWsMessage;
use Amadeus\Client\Struct\Fare\PricePnr12\AttributeDetails;
use Amadeus\Client\Struct\Fare\PricePnr12\CarrierAgreements;
use Amadeus\Client\Struct\Fare\PricePnr12\CityDetail;
use Amadeus\Client\Struct\Fare\PricePnr12\CurrencyOverride;
use Amadeus\Client\Struct\Fare\PricePnr12\DateOverride;
use Amadeus\Client\Struct\Fare\PricePnr12\DiscountInformation;
use Amadeus\Client\Struct\Fare\PricePnr12\FrequentFlyerInformation;
use Amadeus\Client\Struct\Fare\PricePnr12\OverrideInformation;
use Amadeus\Client\Struct\Fare\PricePnr12\PenDisInformation;
use Amadeus\Client\Struct\Fare\PricePnr12\PricingFareBase;
use Amadeus\Client\Struct\Fare\PricePnr12\TaxDetails;
use Amadeus\Client\Struct\Fare\PricePnr12\ValidatingCarrier;
use Amadeus\Client\Struct\OptionNotSupportedException;

/**
 * Fare_PricePNRWithBookingClass v 12 and lower structure
 *
 * @package Amadeus\Client\Struct\Fare
 * @author dieter <dermikagh@gmail.com>
 */
class PricePNRWithBookingClass12 extends BaseWsMessage
{
    public $pnrLocatorData;

    /**
     * @var PricePnr12\PaxSegReference
     */
    public $paxSegReference;

    /**
     * @var PricePnr12\OverrideInformation
     */
    public $overrideInformation;

    /**
     * @var PricePnr12\DateOverride
     */
    public $dateOverride;

    /**
     * @var PricePnr12\ValidatingCarrier
     */
    public $validatingCarrier;

    /**
     * @var PricePnr12\CityOverride
     */
    public $cityOverride;

    /**
     * @var PricePnr12\CurrencyOverride
     */
    public $currencyOverride;

    /**
     * @var PricePnr12\TaxDetails[]
     */
    public $taxDetails = [];

    /**
     * @var PricePnr12\DiscountInformation[]
     */
    public $discountInformation = [];
    /**
     * @var PricePnr12\PricingFareBase[]
     */
    public $pricingFareBase = [];

    public $flightInformation;

    public $openSegmentsInformation;

    public $bookingClassSelection;

    public $fopInformation;

    /**
     * @var CarrierAgreements
     */
    public $carrierAgreements;

    /**
     * @var FrequentFlyerInformation
     */
    public $frequentFlyerInformation;

    public $instantPricingOption;

    /**
     * PricePNRWithBookingClass12 constructor.
     *
     * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt|null $options
     */
    public function __construct($options)
    {
        $this->overrideInformation = new OverrideInformation();

        if (!is_null($options)) {
            $this->loadPricingOptions($options);
        }
    }

    /**
     * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options
     */
    protected function loadPricingOptions($options)
    {
        $this->checkUnsupportedOptions($options);

        $this->loadOverrideOptionsAndCorpFares($options);

        $this->loadCurrencyOverride($options->currencyOverride);

        $this->loadValidatingCarrier($options);

        $this->loadFareBasis($options);

        $this->loadPaxDiscount($options->paxDiscountCodes, $options->paxDiscountCodeRefs);

        $this->loadOverrideLocations($options);

        $this->loadTaxOptions($options);

        $this->loadReferences($options->references);

        $this->loadPastDate($options->pastDatePricing);
    }

    /**
     * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options
     * @throws OptionNotSupportedException
     */
    protected function checkUnsupportedOptions($options)
    {
        if (!empty($options->obFees)) {
            throw new OptionNotSupportedException('OB Fees option not supported in version 12 or lower');
        }

        if (!empty($options->pricingLogic)) {
            throw new OptionNotSupportedException('Pricing Logic option not supported in version 12 or lower');
        }

        if (!empty($options->overrideOptionsWithCriteria)) {
            throw new OptionNotSupportedException('Override Options With Criteria are not supported in version 12 or lower');
        }
    }

    /**
     * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options
     */
    protected function loadOverrideOptionsAndCorpFares($options)
    {
        foreach ($options->overrideOptions as $overrideOption) {
            $this->overrideInformation->attributeDetails[] = new AttributeDetails($overrideOption);
        }

        if (!empty($options->ticketType)) {
            $this->overrideInformation->attributeDetails[] = new AttributeDetails(
                $this->convertTicketType($options->ticketType)
            );
        }

        if ($options->corporateNegoFare !== null) {
            $this->overrideInformation->attributeDetails[] = new AttributeDetails(
                AttributeDetails::OVERRIDE_FARETYPE_CORPNR,
                $options->corporateNegoFare
            );
        }

        if (!empty($options->corporateUniFares)) {
            $this->loadCorporateUniFares($options->corporateUniFares);

            if (!empty($options->awardPricing)) {
                $this->carrierAgreements = new CarrierAgreements($options->awardPricing->carrier);
                $this->frequentFlyerInformation = new FrequentFlyerInformation($options->awardPricing->tierLevel);
            }
        }

        //No Options?
        if (empty($this->overrideInformation->attributeDetails)) {
            $this->overrideInformation->attributeDetails[] = new AttributeDetails(
                AttributeDetails::OVERRIDE_NO_OPTION
            );
        }
    }

    /**
     * @param string|null $currencyOverride
     */
    protected function loadCurrencyOverride($currencyOverride)
    {
        if (!empty($currencyOverride)) {
            $this->currencyOverride = new CurrencyOverride($currencyOverride);
        }
    }

    /**
     * Convert new codes (Price PNR version 13+) to old format
     *
     * @param string $optionsTicketType
     * @return string|null
     */
    protected function convertTicketType($optionsTicketType)
    {
        $converted = null;

        $map = [
            FarePricePnrWithBookingClassOptions::TICKET_TYPE_ELECTRONIC => AttributeDetails::OVERRIDE_ELECTRONIC_TICKET,
            FarePricePnrWithBookingClassOptions::TICKET_TYPE_PAPER => AttributeDetails::OVERRIDE_PAPER_TICKET,
            FarePricePnrWithBookingClassOptions::TICKET_TYPE_BOTH => AttributeDetails::OVERRIDE_BOTH_TICKET,
        ];

        if (array_key_exists($optionsTicketType, $map)) {
            $converted = $map[$optionsTicketType];
        }

        return $converted;
    }

    /**
     * @param string[] $corporateUniFares
     */
    protected function loadCorporateUniFares($corporateUniFares)
    {
        foreach ($corporateUniFares as $corporateUniFare) {
            $this->overrideInformation->attributeDetails[] = new AttributeDetails(
                AttributeDetails::OVERRIDE_FARETYPE_CORPUNI,
                $corporateUniFare
            );
        }
    }

    /**
     * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options
     */
    protected function loadOverrideLocations($options)
    {
        if (!empty($options->pointOfSaleOverride)) {
            $this->cityOverride = new PricePnr12\CityOverride(
                $options->pointOfSaleOverride,
                CityDetail::QUAL_POINT_OF_SALE
            );
        }

        if (!empty($options->pointOfTicketingOverride)) {
            if (empty($this->cityOverride)) {
                $this->cityOverride = new PricePnr12\CityOverride();
            }
            $this->cityOverride->cityDetail[] = new PricePnr12\CityDetail(
                $options->pointOfTicketingOverride,
                CityDetail::QUAL_POINT_OF_TICKETING
            );
        }
    }

    /**
     * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options
     */
    protected function loadValidatingCarrier($options)
    {
        if (is_string($options->validatingCarrier)) {
            $this->validatingCarrier = new ValidatingCarrier($options->validatingCarrier);
        }
    }

    /**
     * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options
     *
     */
    protected function loadFareBasis($options)
    {
        $short = AttributeDetails::OVERRIDE_FAREBASIS; //Short var name because I get complaints from phpcs. No judging.
        if (in_array($short, $options->overrideOptions) && !empty($options->pricingsFareBasis)) {
            foreach ($options->pricingsFareBasis as $pricingFareBasis) {
                $this->pricingFareBase[] = new PricingFareBase($pricingFareBasis);
            }
        }
    }

    /**
     * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt $options
     */
    protected function loadTaxOptions($options)
    {
        foreach ($options->taxes as $tax) {
            $this->taxDetails[] = new TaxDetails($tax);
        }

        foreach ($options->exemptTaxes as $exemptTax) {
            $this->taxDetails[] = new TaxDetails($exemptTax);
        }
    }

    /**
     * @param string[] $paxDiscountCodes
     * @param PaxSegRef[] $refs
     */
    protected function loadPaxDiscount($paxDiscountCodes, $refs)
    {
        if (!empty($paxDiscountCodes)) {
            $this->discountInformation[] = new DiscountInformation(
                PenDisInformation::QUAL_DISCOUNT,
                $paxDiscountCodes,
                $refs
            );
        }
    }

    /**
     * @param PaxSegRef[] $references
     */
    protected function loadReferences($references)
    {
        if (!empty($references)) {
            $this->paxSegReference = new PricePnr12\PaxSegReference($references);
        }
    }

    /**
     * @param \DateTime|null $pastDate
     */
    protected function loadPastDate($pastDate)
    {
        if ($pastDate instanceof \DateTime) {
            $this->dateOverride = new DateOverride(DateOverride::OPT_DATE_OVERRIDE, $pastDate);
        }
    }
}


<?php
/**
 * amadeus-ws-client
 *
 * Copyright 2015 Amadeus Benelux NV
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package Amadeus
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
 */

namespace Amadeus\Client\Struct\Fop;

use Amadeus\Client\RequestOptions\FopCreateFopOptions;
use Amadeus\Client\Struct\BaseWsMessage;
use Amadeus\Client\Struct\Fop\CreateFormOfPayment\BestEffort;
use Amadeus\Client\Struct\Fop\CreateFormOfPayment\FopGroup14;

/**
 * FOP_CreateFormOfPayment message structure version 15 and up
 *
 * @package Amadeus\Client\Struct\Fop
 * @author Dieter Devlieghere <dermikagh@gmail.com>
 */
class CreateFormOfPayment extends BaseWsMessage
{
    /**
     * @var TransactionContext
     */
    public $transactionContext;

    /**
     * @var BestEffort[]
     */
    public $bestEffort = [];

    /**
     * @var ReservationControlInformation
     */
    public $reservationControlInformation;

    /**
     * @var FopGroup[]
     */
    public $fopGroup = [];

    /**
     * FOP_CreateFormOfPayment constructor.
     *
     * @param FopCreateFopOptions $options
     */
    public function __construct(FopCreateFopOptions $options)
    {
        if ($this->checkAnyNotEmpty($options->transactionCode, $options->obFeeCalculation)) {
            $this->transactionContext = new TransactionContext(
                $options->transactionCode,
                $options->obFeeCalculation
            );
        }

        if ($this->checkAllNotEmpty($options->bestEffortAction, $options->bestEffortIndicator)) {
            $this->bestEffort[] = new BestEffort($options->bestEffortIndicator, $options->bestEffortAction);
        }

        $this->loadFopGroup($options);
    }

    /**
     * Load fopGroup
     *
     * @param FopCreateFopOptions $options
     */
    protected function loadFopGroup(FopCreateFopOptions $options)
    {
        foreach ($options->fopGroup as $group) {
            if ($this instanceof CreateFormOfPayment14) {
                $this->fopGroup[] = new FopGroup14($group);
            } else {
                $this->fopGroup[] = new FopGroup($group);
            }
        }
    }
}


<?php
/**
 * amadeus-ws-client
 *
 * Copyright 2015 Amadeus Benelux NV
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package Amadeus
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
 */

namespace Amadeus\Client\RequestCreator;

use Amadeus\Client\InvalidMessageException;
use Amadeus\Client\Params\RequestCreatorParams;
use Amadeus\Client\RequestCreator\Converter\ConvertInterface;
use Amadeus\Client\RequestOptions\RequestOptionsInterface;
use Amadeus\Client\Struct;

/**
 * Base request creator - the default request creator.
 *
 * In charge of building the request objects that are used by the Soap Client.
 * They are built depending on:
 * - Which message is being created.
 * - Which request options were provided.
 * - What message version is active in the current WSDL?
 *
 * @package Amadeus\Client\RequestCreator
 * @author Dieter Devlieghere <dermikagh@gmail.com>
 */
class Base implements RequestCreatorInterface
{
    /**
     * Parameters
     *
     * @var RequestCreatorParams
     */
    protected $params;

    /**
     * Associative array of messages (as keys) and versions (as values) that are present in the WSDL.
     *
     * @var array
     */
    protected $messagesAndVersions = [];

    /**
     * All message builders already instantiated
     *
     * @var array
     */
    protected $messageBuilders = [];

    /**
     * Base Request Creator constructor.
     *
     * @param RequestCreatorParams $params
     */
    public function __construct(RequestCreatorParams $params)
    {
        $this->params = $params;
        $this->messagesAndVersions = $params->messagesAndVersions;
    }

    /**
     * Create a request message for a given message with a set of options.
     *
     * @param string $messageName the message name as named in the WSDL
     * @param RequestOptionsInterface $params
     * @throws Struct\InvalidArgumentException When invalid input is detected during message creation.
     * @throws InvalidMessageException when trying to create a request for a message that is not in your WSDL.
     * @return mixed the created request
     */
    public function createRequest($messageName, RequestOptionsInterface $params)
    {
        $this->checkMessageIsInWsdl($messageName);

        $builder = $this->findBuilderForMessage($messageName);

        if ($builder instanceof ConvertInterface) {
            return $builder->convert($params, $this->getActiveVersionFor($messageName));
        } else {
            throw new \RuntimeException('No builder found for message '.$messageName);
        }
    }

    /**
     * Check if a given message is in the active WSDL(s). Throws exception if it isn't.
     *
     * @throws InvalidMessageException if message is not in loaded WSDL(s).
     * @param string $messageName
     */
    protected function checkMessageIsInWsdl($messageName)
    {
        if (!array_key_exists($messageName, $this->messagesAndVersions)) {
            throw new InvalidMessageException('Message "'.$messageName.'" is not in WDSL');
        }
    }

    /**
     * Get the version number active in the WSDL for the given message
     *
     * @param string $messageName
     * @return float|string|null
     */
    protected function getActiveVersionFor($messageName)
    {
        $found = null;

        if (isset($this->messagesAndVersions[$messageName]) &&
            isset($this->messagesAndVersions[$messageName]['version'])
        ) {
            $found = $this->messagesAndVersions[$messageName]['version'];
        }

        return $found;
    }

    /**
     * Find the correct builder for a given message
     *
     * Builder classes implement the ConvertInterface and are used to build only one kind of message.
     *
     * The standard converter class is
     * __NAMESPACE__ \ Converter \ Sectionname \ Messagename + "Conv"
     * e.g.
     * Amadeus\Client\RequestCreator\Converter\DocIssuance\IssueTicketConv
     *
     * @param string $messageName
     * @return ConvertInterface|null
     */
    protected function findBuilderForMessage($messageName)
    {
        $builder = null;

        if (array_key_exists($messageName, $this->messageBuilders) &&
            $this->messageBuilders[$messageName] instanceof ConvertInterface
        ) {
            $builder = $this->messageBuilders[$messageName];
        } else {
            $section = substr($messageName, 0, strpos($messageName, '_'));
            $message = substr($messageName, strpos($messageName, '_') + 1);

            $builderClass = __NAMESPACE__.'\\Converter\\'.$section.'\\'.$message."Conv";

            if (class_exists($builderClass)) {
                /** @var ConvertInterface $builder */
                $builder = new $builderClass();
                $builder->setParams($this->params);

                $this->messageBuilders[$messageName] = $builder;
            }
        }

        return $builder;
    }
}


<?php
/**
 * amadeus-ws-client
 *
 * Copyright 2015 Amadeus Benelux NV
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package Amadeus
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
 */

namespace Amadeus\Client\ResponseHandler\FOP;

use Amadeus\Client\Exception;
use Amadeus\Client\ResponseHandler\StandardResponseHandler;
use Amadeus\Client\Result;
use Amadeus\Client\Session\Handler\SendResult;

/**
 * HandlerValidateFOP
 *
 * @package Amadeus\Client\ResponseHandler\FOP
 * @author Mike Hernas <mike@ahoy.io>
 */
class HandlerValidateFOP extends StandardResponseHandler
{
    //General error
    const Q_G_ERR = "//m:transmissionError/m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode";
    const Q_G_CAT = "//m:transmissionError/m:errorOrWarningCodeDetails/m:errorDetails/m:errorCategory";
    const Q_G_MSG = "//m:transmissionError/m:errorWarningDescription/m:freeText";
    //Deficient FOP level:
    const Q_D_ERR = "//m:fopDescription/m:mopDescription/m:paymentModule/m:mopDetailedData//m:transactionStatus/m:errorOrWarningCodeDetails//m:errorCode";
    const Q_D_CAT = "//m:fopDescription/m:mopDescription/m:paymentModule/m:mopDetailedData//m:transactionStatus/m:errorOrWarningCodeDetails//m:errorCategory";
    const Q_D_MSG = "//m:fopDescription/m:mopDescription/m:paymentModule/m:mopDetailedData//m:transactionStatus/m:errorWarningDescription//m:freeText";

    /**
     * FOP_ValidateFormOfPayment Analyze the result from the message operation and check for any error messages
     *
     * @param SendResult $response
     * @return Result
     * @throws Exception
     */
    public function analyze(SendResult $response)
    {
        $analyzeResponse = new Result($response);

        $domXpath = $this->makeDomXpath($response->responseXml);

        //General error level in the transmissionError location:
        $errorCodeNodeList = $domXpath->query(self::Q_G_ERR);
        if ($errorCodeNodeList->length > 0) {
            $errorCatNode = $domXpath->query(self::Q_G_CAT)->item(0);
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));

            $code = $errorCodeNodeList->item(0)->nodeValue;
            $errorTextNodeList = $domXpath->query(self::Q_G_MSG);
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);

            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'general');
        }

        //Deficient FOP level errors:
        $errorCodeNodeList = $domXpath->query(self::Q_D_ERR);

        if ($errorCodeNodeList->length > 0) {
            $errorCatNode = $domXpath->query(self::Q_D_CAT)->item(0);
            $analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));

            $code = $errorCodeNodeList->item(0)->nodeValue;

            $errorTextNodeList = $domXpath->query(self::Q_D_MSG);
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);

            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'deficient_fop');
        }

        return $analyzeResponse;
    }

    /**
     * Make status from a category DOMNode or default status.
     *
     * @param \DOMNode|null $errorCatNode
     * @return string
     */
    protected function makeStatusForPotentiallyNonExistent($errorCatNode)
    {
        if ($errorCatNode instanceof \DOMNode) {
            $status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue);
        } else {
            $status = Result::STATUS_ERROR;
        }

        return $status;
    }
}


<?php
/**
 * amadeus-ws-client
 *
 * Copyright 2015 Amadeus Benelux NV
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package Amadeus
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
 */

namespace Amadeus\Client\Struct\Pnr\AddMultiElements;

use Amadeus\Client\RequestOptions\Pnr\Traveller as TravellerOptions;
use Amadeus\Client\RequestOptions\Pnr\TravellerGroup as TravellerGroupOptions;

/**
 * TravellerInfo
 *
 * @package Amadeus\Client\Struct\Pnr\AddMultiElements
 * @author Dieter Devlieghere <dermikagh@gmail.com>
 */
class TravellerInfo
{
    /**
     * @var ElementManagementPassenger
     */
    public $elementManagementPassenger;
    /**
     * Up to 2 PassengerData elements
     *
     * @var PassengerData[]
     */
    public $passengerData = [];
    /**
     * @todo expand this structure
     * @var array
     */
    public $enhancedPassengerData = [];

    /**
     * TravellerInfo constructor.
     *
     * @param TravellerOptions|null $traveller
     * @param TravellerGroupOptions|null $travellerGroup
     */
    public function __construct($traveller = null, $travellerGroup = null)
    {
        if ($traveller instanceof TravellerOptions) {
            $this->loadTraveller($traveller);
        } elseif ($travellerGroup instanceof TravellerGroupOptions) {
            $this->loadTravellerGroup($travellerGroup);
        }
    }

    /**
     * @param TravellerGroupOptions $group
     */
    protected function loadTravellerGroup($group)
    {
        $this->elementManagementPassenger = new ElementManagementPassenger(
            ElementManagementPassenger::SEG_GROUPNAME
        );

        $this->passengerData[] = new PassengerData($group->name);

        $this->passengerData[0]->travellerInformation->traveller->quantity = $group->nrOfTravellers;
        $this->passengerData[0]->travellerInformation->traveller->qualifier = Traveller::QUAL_GROUP;
    }

    /**
     * @param TravellerOptions $traveller
     */
    protected function loadTraveller(TravellerOptions $traveller)
    {
        $this->elementManagementPassenger = new ElementManagementPassenger(
            ElementManagementPassenger::SEG_NAME
        );

        $this->passengerData[] = new PassengerData($traveller->lastName);

        if (!is_null($traveller->number)) {
            $this->elementManagementPassenger->reference = new Reference(
                Reference::QUAL_PASSENGER,
                $traveller->number
            );
        }

        if ($traveller->firstName !== null || $traveller->travellerType !== null) {
            $this->passengerData[0]->travellerInformation->passenger[] = new Passenger(
                $traveller->firstName,
                $traveller->travellerType
            );
        }

        if ($traveller->withInfant === true || $traveller->infant !== null) {
            $this->addInfant($traveller);
        }

        if ($traveller->dateOfBirth instanceof \DateTime) {
            $this->passengerData[0]->dateOfBirth = new DateOfBirth(
                $this->formatDateOfBirth($traveller->dateOfBirth)
            );
        }
    }

    /**
     * Add infant
     *
     * 3 scenario's:
     * - infant without additional information
     * - infant with only first name provided
     * - infant with first name, last name & date of birth provided.
     *
     * @param TravellerOptions $traveller
     */
    protected function addInfant($traveller)
    {
        $this->passengerData[0]->travellerInformation->traveller->quantity = 2;

        if ($traveller->withInfant && is_null($traveller->infant)) {
            $this->makePassengerIfNeeded();
            $this->passengerData[0]->travellerInformation->passenger[0]->infantIndicator = Passenger::INF_NOINFO;
        } elseif ($traveller->infant instanceof TravellerOptions) {
            if (empty($traveller->infant->lastName)) {
                $this->makePassengerIfNeeded();
                $this->passengerData[0]->travellerInformation->passenger[0]->infantIndicator = Passenger::INF_GIVEN;

                $tmpInfantPassenger = new Passenger(
                    $traveller->infant->firstName,
                    Passenger::PASST_INFANT
                );

                $this->passengerData[0]->travellerInformation->passenger[] = $tmpInfantPassenger;
            } else {
                $this->makePassengerIfNeeded();
                $this->passengerData[0]->travellerInformation->passenger[0]->infantIndicator = Passenger::INF_FULL;

                $tmpInfant = new PassengerData($traveller->infant->lastName);
                $tmpInfant->travellerInformation->passenger[] = new Passenger(
                    $traveller->infant->firstName,
                    Passenger::PASST_INFANT
                );

                if ($traveller->infant->dateOfBirth instanceof \DateTime) {
                    $tmpInfant->dateOfBirth = new DateOfBirth(
                        $this->formatDateOfBirth($traveller->infant->dateOfBirth)
                    );
                }

                $this->passengerData[] = $tmpInfant;
            }
        }
    }

    /**
     * If there is no passenger node at
     * $travellerInfo->passengerData[0]->travellerInformation->passenger[0]
     * create one
     */
    protected function makePassengerIfNeeded()
    {
        if (count($this->passengerData[0]->travellerInformation->passenger) < 1) {
            $this->passengerData[0]->travellerInformation->passenger[0] = new Passenger(null, null);
        }
    }

    protected function formatDateOfBirth(\DateTime $dateOfBirth)
    {
        $day = (int) $dateOfBirth->format('d');
        if ($day < 10) {
            $day = "0$day";
        }

        $monthAndYear = strtoupper($dateOfBirth->format('My'));

        return $day . $monthAndYear;
    }
}


<?php
/**
 * amadeus-ws-client
 *
 * Copyright 2015 Amadeus Benelux NV
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package Amadeus
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
 */

namespace Amadeus\Client;

use Amadeus\Client\Result\NotOk;
use Amadeus\Client\Session\Handler\SendResult;

/**
 * Result object to encapsulate the Web Services response to library users.
 *
 * @package Amadeus\Client
 * @author Dieter Devlieghere <dermikagh@gmail.com>
 */
class Result
{
    /**
     * Status indicator for a success situation
     */
    const STATUS_OK = 'OK';
    /**
     * Status indicator for an informational message situation.
     */
    const STATUS_INFO = 'INFO';
    /**
     * Status indicator for a warning situation.
     */
    const STATUS_WARN = 'WARN';
    /**
     * Status indicator for an error response.
     */
    const STATUS_ERROR = 'ERR';
    /**
     * Status indicator for a FATAL error response.
     */
    const STATUS_FATAL = 'FATAL';
    /**
     * Status indicator for a response which could not be checked for warnings/errors.
     */
    const STATUS_UNKNOWN = 'UNKNOWN';

    /**
     * Status of the result
     *
     * see self::STATUS_*
     *
     * @var string
     */
    public $status;

    /**
     * Array of errors or warnings found
     *
     * @var NotOk[]
     */
    public $messages = [];

    /**
     * The actual result received after performing the web service call.
     *
     * @var \stdClass|array
     */
    public $response;

    /**
     * The raw contents of the Soap Envelope received after performing the web service call.
     *
     * @var string
     */
    public $responseXml;

    /**
     * Result constructor.
     *
     * @param SendResult $sendResult
     * @param string $status
     */
    public function __construct($sendResult, $status = self::STATUS_OK)
    {
        $this->response = $sendResult->responseObject;
        $this->responseXml = $sendResult->responseXml;
        $this->status = $status;
    }

    /**
     * Sets error status.
     *
     * Will not override a more severe status.
     *
     * @param string $newStatus
     */
    public function setStatus($newStatus)
    {
        if ($this->isWorseStatus($newStatus, $this->status)) {
            $this->status = $newStatus;
        }
    }

    /**
     * Checks if new status is worse than current status
     *
     * @param string $newStatus
     * @param string $currentStatus
     * @return bool true if newStatus is worse than old status.
     */
    protected function isWorseStatus($newStatus, $currentStatus)
    {
        $levels = [
            self::STATUS_UNKNOWN => -1,
            self::STATUS_OK => 0,
            self::STATUS_INFO => 2,
            self::STATUS_WARN => 5,
            self::STATUS_ERROR => 10,
            self::STATUS_FATAL => 20,
        ];

        return ($currentStatus === null || $levels[$newStatus] > $levels[$currentStatus]);
    }
}


<?php
/**
 * amadeus-ws-client
 *
 * Copyright 2015 Amadeus Benelux NV
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package Amadeus
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
 */

namespace Amadeus;

use Amadeus\Client\Base;
use Amadeus\Client\Exception;
use Amadeus\Client\Params;
use Amadeus\Client\RequestOptions;
use Amadeus\Client\Result;
use Amadeus\Client\Session\Handler\UnsupportedOperationException;

/**
 * Amadeus Web Service Client.
 *
 * TODO:
 * - support older versions of SoapHeader (1)
 *
 * @package Amadeus
 * @author Dieter Devlieghere <dermikagh@gmail.com>
 */
class Client extends Base
{
    /**
     * Amadeus SOAP header version 1
     */
    const HEADER_V1 = "1";
    /**
     * Amadeus SOAP header version 2
     */
    const HEADER_V2 = "2";
    /**
     * Amadeus SOAP header version 4
     */
    const HEADER_V4 = "4";

    /**
     * Version string
     *
     * @var string
     */
    const VERSION = "1.8.0-dev";

    /**
     * An identifier string for the library (to be used in Received From entries)
     *
     * @var string
     */
    const RECEIVED_FROM_IDENTIFIER = "amabnl-amadeus-ws-client";

    /**
     * @var string
     */
    protected $lastMessage;

    /**
     * Set the session as stateful (true) or stateless (false)
     *
     * @param bool $newStateful
     */
    public function setStateful($newStateful)
    {
        $this->sessionHandler->setStateful($newStateful);
    }

    /**
     * @return bool
     */
    public function isStateful()
    {
        return $this->sessionHandler->isStateful();
    }

    /**
     * Get TransactionFlowLink Consumer Id
     *
     * @return string|null
     */
    public function getConsumerId()
    {
        return $this->sessionHandler->getConsumerId();
    }

    /**
     * Set TransactionFlowLink Consumer Id
     *
     * @throws UnsupportedOperationException when used on unsupported WSAP versions
     * @param string $id
     * @return void
     */
    public function setConsumerId($id)
    {
        $this->sessionHandler->setTransactionFlowLink(true);
        $this->sessionHandler->setConsumerId($id);
    }

    /**
     * Get the last raw XML message that was sent out
     *
     * @return string|null
     */
    public function getLastRequest()
    {
        return $this->sessionHandler->getLastRequest($this->lastMessage);
    }

    /**
     * Get the last raw XML message that was received
     *
     * @return string|null
     */
    public function getLastResponse()
    {
        return $this->sessionHandler->getLastResponse($this->lastMessage);
    }

    /**
     * Get the request headers for the last SOAP message that was sent out
     *
     * @return string|null
     */
    public function getLastRequestHeaders()
    {
        return $this->sessionHandler->getLastRequestHeaders($this->lastMessage);
    }

    /**
     * Get the response headers for the last SOAP message that was received
     *
     * @return string|null
     */
    public function getLastResponseHeaders()
    {
        return $this->sessionHandler->getLastResponseHeaders($this->lastMessage);
    }

    /**
     * Get session information for authenticated session
     *
     * - sessionId
     * - sequenceNr
     * - securityToken
     *
     * @return array|null
     */
    public function getSessionData()
    {
        return $this->sessionHandler->getSessionData();
    }

    /**
     * Restore a previously used session
     *
     * To be used when implementing your own session pooling system on legacy Soap Header 2 applications.
     *
     * @param array $sessionData
     * @return bool
     */
    public function setSessionData(array $sessionData)
    {
        return $this->sessionHandler->setSessionData($sessionData);
    }

    /**
     * Construct Amadeus Web Services client
     *
     * @param Params $params
     */
    public function __construct(Params $params)
    {
        $this->loadClientParams(
            $params,
            self::RECEIVED_FROM_IDENTIFIER,
            self::VERSION
        );
    }

    /**
     * Authenticate.
     *
     * Authentication Parameters were provided at construction time (authParams)
     *
     * @return Result
     * @throws Exception
     */
    public function securityAuthenticate()
    {
        $msgName = 'Security_Authenticate';

        return $this->callMessage(
            $msgName,
            new RequestOptions\SecurityAuthenticateOptions(
                $this->authParams
            ),
            [],
            false
        );
    }

    /**
     * Terminate a session - only applicable to non-stateless mode.
     *
     * @return Result
     * @throws Exception
     */
    public function securitySignOut()
    {
        $msgName = 'Security_SignOut';

        return $this->callMessage(
            $msgName,
            new RequestOptions\SecuritySignOutOptions(),
            [],
            true
        );
    }

    /**
     * PNR_Retrieve - Retrieve an Amadeus PNR by record locator
     *
     * @param RequestOptions\PnrRetrieveOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function pnrRetrieve(RequestOptions\PnrRetrieveOptions $options, $messageOptions = [])
    {
        $msgName = 'PNR_Retrieve';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * PNR_Split
     *
     * @param RequestOptions\PnrSplitOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function pnrSplit(
        RequestOptions\PnrSplitOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'PNR_Split';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Create a PNR using PNR_AddMultiElements
     *
     * @param RequestOptions\PnrCreatePnrOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function pnrCreatePnr(RequestOptions\PnrCreatePnrOptions $options, $messageOptions = [])
    {
        $msgName = 'PNR_AddMultiElements';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * PNR_AddMultiElements - Create a new PNR or update an existing PNR.
     *
     * https://webservices.amadeus.com/extranet/viewService.do?id=25&flavourId=1&menuId=functional
     *
     * @param RequestOptions\PnrAddMultiElementsOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function pnrAddMultiElements(RequestOptions\PnrAddMultiElementsOptions $options, $messageOptions = [])
    {
        $msgName = 'PNR_AddMultiElements';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * PNR_RetrieveAndDisplay - Retrieve an Amadeus PNR by record locator including extra info
     *
     * This extra info is info you cannot see in the regular PNR, like Offers.
     *
     * https://webservices.amadeus.com/extranet/viewService.do?id=1922&flavourId=1&menuId=functional
     *
     * @param RequestOptions\PnrRetrieveAndDisplayOptions $options Amadeus Record Locator for PNR
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     **/
    public function pnrRetrieveAndDisplay(RequestOptions\PnrRetrieveAndDisplayOptions $options, $messageOptions = [])
    {
        $msgName = 'PNR_RetrieveAndDisplay';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * PNR_Cancel
     *
     * @param RequestOptions\PnrCancelOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function pnrCancel(RequestOptions\PnrCancelOptions $options, $messageOptions = [])
    {
        $msgName = 'PNR_Cancel';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * PNR_DisplayHistory
     *
     * @param RequestOptions\PnrDisplayHistoryOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function pnrDisplayHistory(RequestOptions\PnrDisplayHistoryOptions $options, $messageOptions = [])
    {
        $msgName = 'PNR_DisplayHistory';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * PNR_TransferOwnership
     *
     * @param RequestOptions\PnrTransferOwnershipOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function pnrTransferOwnership(RequestOptions\PnrTransferOwnershipOptions $options, $messageOptions = [])
    {
        $msgName = 'PNR_TransferOwnership';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * PNR_NameChange
     *
     * @param RequestOptions\PnrNameChangeOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function pnrNameChange(RequestOptions\PnrNameChangeOptions $options, $messageOptions = [])
    {
        $msgName = 'PNR_NameChange';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Queue_List - get a list of all PNR's on a given queue
     *
     * https://webservices.amadeus.com/extranet/viewService.do?id=52&flavourId=1&menuId=functional
     *
     * @param RequestOptions\QueueListOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function queueList(RequestOptions\QueueListOptions $options, $messageOptions = [])
    {
        $msgName = 'Queue_List';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Queue_PlacePNR - Place a PNR on a given queue
     *
     * @param RequestOptions\QueuePlacePnrOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function queuePlacePnr(RequestOptions\QueuePlacePnrOptions $options, $messageOptions = [])
    {
        $msgName = 'Queue_PlacePNR';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * PNR_Ignore - Ignore an Amadeus PNR by record locator
     *
     * @param RequestOptions\PnrIgnoreOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function pnrIgnore(RequestOptions\PnrIgnoreOptions $options, $messageOptions = [])
    {
        $msgName = 'PNR_Ignore';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Queue_RemoveItem - remove an item (a PNR) from a given queue
     *
     * @param RequestOptions\QueueRemoveItemOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function queueRemoveItem(RequestOptions\QueueRemoveItemOptions $options, $messageOptions = [])
    {
        $msgName = 'Queue_RemoveItem';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Queue_MoveItem - move an item (a PNR) from one queue to another.
     *
     * @param RequestOptions\QueueMoveItemOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function queueMoveItem(RequestOptions\QueueMoveItemOptions $options, $messageOptions = [])
    {
        $msgName = 'Queue_MoveItem';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Offer_CreateOffer
     *
     * @param RequestOptions\OfferCreateOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function offerCreate(RequestOptions\OfferCreateOptions $options, $messageOptions = [])
    {
        $msgName = 'Offer_CreateOffer';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Offer_VerifyOffer
     *
     * To be called in the context of an open PNR
     *
     * @param RequestOptions\OfferVerifyOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function offerVerify(RequestOptions\OfferVerifyOptions $options, $messageOptions = [])
    {
        $msgName = 'Offer_VerifyOffer';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Offer_ConfirmAirOffer
     *
     * @param RequestOptions\OfferConfirmAirOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function offerConfirmAir(RequestOptions\OfferConfirmAirOptions $options, $messageOptions = [])
    {
        $msgName = 'Offer_ConfirmAirOffer';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Offer_ConfirmHotelOffer
     *
     * @param RequestOptions\OfferConfirmHotelOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function offerConfirmHotel(RequestOptions\OfferConfirmHotelOptions $options, $messageOptions = [])
    {
        $msgName = 'Offer_ConfirmHotelOffer';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Offer_ConfirmCarOffer
     *
     * @param RequestOptions\OfferConfirmCarOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function offerConfirmCar(RequestOptions\OfferConfirmCarOptions $options, $messageOptions = [])
    {
        $msgName = 'Offer_ConfirmCarOffer';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Fare_MasterPricerTravelBoardSearch
     *
     * @param RequestOptions\FareMasterPricerTbSearch $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function fareMasterPricerTravelBoardSearch(
        RequestOptions\FareMasterPricerTbSearch $options,
        $messageOptions = []
    ) {
        $msgName = 'Fare_MasterPricerTravelBoardSearch';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Fare_MasterPricerCalendar
     *
     * @param RequestOptions\FareMasterPricerCalendarOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function fareMasterPricerCalendar(
        RequestOptions\FareMasterPricerCalendarOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Fare_MasterPricerCalendar';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Fare_PricePnrWithBookingClass
     *
     * @param RequestOptions\FarePricePnrWithBookingClassOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function farePricePnrWithBookingClass(
        RequestOptions\FarePricePnrWithBookingClassOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Fare_PricePNRWithBookingClass';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Fare_PricePnrWithLowerFares
     *
     * @param RequestOptions\FarePricePnrWithLowerFaresOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function farePricePnrWithLowerFares(
        RequestOptions\FarePricePnrWithLowerFaresOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Fare_PricePNRWithLowerFares';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Fare_PricePnrWithLowestFare
     *
     * @param RequestOptions\FarePricePnrWithLowestFareOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function farePricePnrWithLowestFare(
        RequestOptions\FarePricePnrWithLowestFareOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Fare_PricePNRWithLowestFare';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Fare_InformativePricingWithoutPNR
     *
     * @param RequestOptions\FareInformativePricingWithoutPnrOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function fareInformativePricingWithoutPnr(
        RequestOptions\FareInformativePricingWithoutPnrOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Fare_InformativePricingWithoutPNR';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Fare_InformativeBestPricingWithoutPNR
     *
     * @param RequestOptions\FareInformativeBestPricingWithoutPnrOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function fareInformativeBestPricingWithoutPnr(
        RequestOptions\FareInformativeBestPricingWithoutPnrOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Fare_InformativeBestPricingWithoutPNR';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Fare_CheckRules
     *
     * @param RequestOptions\FareCheckRulesOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function fareCheckRules(RequestOptions\FareCheckRulesOptions $options, $messageOptions = [])
    {
        $msgName = 'Fare_CheckRules';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Fare_GetFareRules
     *
     * @param RequestOptions\FareGetFareRulesOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function fareGetFareRules(RequestOptions\FareGetFareRulesOptions $options, $messageOptions = [])
    {
        $msgName = 'Fare_GetFareRules';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Fare_ConvertCurrency
     *
     * @param RequestOptions\FareConvertCurrencyOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function fareConvertCurrency(RequestOptions\FareConvertCurrencyOptions $options, $messageOptions = [])
    {
        $msgName = 'Fare_ConvertCurrency';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Air_MultiAvailability
     *
     * @param RequestOptions\AirMultiAvailabilityOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function airMultiAvailability(
        RequestOptions\AirMultiAvailabilityOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Air_MultiAvailability';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Air_SellFromRecommendation
     *
     * @param RequestOptions\AirSellFromRecommendationOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function airSellFromRecommendation(
        RequestOptions\AirSellFromRecommendationOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Air_SellFromRecommendation';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Air_FlightInfo
     *
     * @param RequestOptions\AirFlightInfoOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function airFlightInfo(RequestOptions\AirFlightInfoOptions $options, $messageOptions = [])
    {
        $msgName = 'Air_FlightInfo';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Air_RetrieveSeatMap
     *
     * @param RequestOptions\AirRetrieveSeatMapOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function airRetrieveSeatMap(RequestOptions\AirRetrieveSeatMapOptions $options, $messageOptions = [])
    {
        $msgName = 'Air_RetrieveSeatMap';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Air_RebookAirSegment
     *
     * @param RequestOptions\AirRebookAirSegmentOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function airRebookAirSegment(RequestOptions\AirRebookAirSegmentOptions $options, $messageOptions = [])
    {
        $msgName = 'Air_RebookAirSegment';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Command_Cryptic
     *
     * @param RequestOptions\CommandCrypticOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function commandCryptic(RequestOptions\CommandCrypticOptions $options, $messageOptions = [])
    {
        $msgName = 'Command_Cryptic';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * MiniRule_GetFromPricingRec
     *
     * @param RequestOptions\MiniRuleGetFromPricingRecOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function miniRuleGetFromPricingRec(
        RequestOptions\MiniRuleGetFromPricingRecOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'MiniRule_GetFromPricingRec';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * MiniRule_GetFromPricing
     *
     * @param RequestOptions\MiniRuleGetFromPricingOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function miniRuleGetFromPricing(
        RequestOptions\MiniRuleGetFromPricingOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'MiniRule_GetFromPricing';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * MiniRule_GetFromETicket
     *
     * @param RequestOptions\MiniRuleGetFromETicketOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function miniRuleGetFromETicket(
        RequestOptions\MiniRuleGetFromETicketOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'MiniRule_GetFromETicket';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Info_EncodeDecodeCity
     *
     * @param RequestOptions\InfoEncodeDecodeCityOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function infoEncodeDecodeCity(RequestOptions\InfoEncodeDecodeCityOptions $options, $messageOptions = [])
    {
        $msgName = 'Info_EncodeDecodeCity';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * PointOfRef_Search
     *
     * @param RequestOptions\PointOfRefSearchOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function pointOfRefSearch(RequestOptions\PointOfRefSearchOptions $options, $messageOptions = [])
    {
        $msgName = 'PointOfRef_Search';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_CreateTSTFromPricing
     *
     * @param RequestOptions\TicketCreateTstFromPricingOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketCreateTSTFromPricing(
        RequestOptions\TicketCreateTstFromPricingOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_CreateTSTFromPricing';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_CreateTSMFromPricing
     *
     * @param RequestOptions\TicketCreateTsmFromPricingOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketCreateTSMFromPricing(
        RequestOptions\TicketCreateTsmFromPricingOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_CreateTSMFromPricing';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_CreateTSMFareElement
     *
     * @param RequestOptions\TicketCreateTsmFareElOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketCreateTSMFareElement(
        RequestOptions\TicketCreateTsmFareElOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_CreateTSMFareElement';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_CreateTASF
     *
     * @param RequestOptions\TicketCreateTasfOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketCreateTASF(
        RequestOptions\TicketCreateTasfOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_CreateTASF';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_DeleteTST
     *
     * @param RequestOptions\TicketDeleteTstOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketDeleteTST(RequestOptions\TicketDeleteTstOptions $options, $messageOptions = [])
    {
        $msgName = 'Ticket_DeleteTST';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_DeleteTSMP
     *
     * @param RequestOptions\TicketDeleteTsmpOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketDeleteTSMP(RequestOptions\TicketDeleteTsmpOptions $options, $messageOptions = [])
    {
        $msgName = 'Ticket_DeleteTSMP';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_DisplayTST
     *
     * @param RequestOptions\TicketDisplayTstOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketDisplayTST(RequestOptions\TicketDisplayTstOptions $options, $messageOptions = [])
    {
        $msgName = 'Ticket_DisplayTST';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_DisplayTSMP
     *
     * @param RequestOptions\TicketDisplayTsmpOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketDisplayTSMP(RequestOptions\TicketDisplayTsmpOptions $options, $messageOptions = [])
    {
        $msgName = 'Ticket_DisplayTSMP';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_RetrieveListOfTSM
     *
     * @param RequestOptions\TicketRetrieveListOfTSMOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketRetrieveListOfTSM(
        RequestOptions\TicketRetrieveListOfTSMOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_RetrieveListOfTSM';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_DisplayTSMFareElement
     *
     * @param RequestOptions\TicketDisplayTsmFareElOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketDisplayTSMFareElement(
        RequestOptions\TicketDisplayTsmFareElOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_DisplayTSMFareElement';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_CheckEligibility
     *
     * @param RequestOptions\TicketCheckEligibilityOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketCheckEligibility(
        RequestOptions\TicketCheckEligibilityOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_CheckEligibility';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_ATCShopperMasterPricerTravelBoardSearch
     *
     * @param RequestOptions\TicketAtcShopperMpTbSearchOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketAtcShopperMasterPricerTravelBoardSearch(
        RequestOptions\TicketAtcShopperMpTbSearchOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_ATCShopperMasterPricerTravelBoardSearch';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_RepricePNRWithBookingClass
     *
     * @param RequestOptions\TicketRepricePnrWithBookingClassOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketRepricePnrWithBookingClass(
        RequestOptions\TicketRepricePnrWithBookingClassOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_RepricePNRWithBookingClass';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_CancelDocument
     *
     * @param RequestOptions\TicketCancelDocumentOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketCancelDocument(
        RequestOptions\TicketCancelDocumentOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_CancelDocument';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_ReissueConfirmedPricing
     *
     * @param RequestOptions\TicketReissueConfirmedPricingOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketReissueConfirmedPricing(
        RequestOptions\TicketReissueConfirmedPricingOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_ReissueConfirmedPricing';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_ProcessEDoc
     *
     * @param RequestOptions\TicketProcessEDocOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketProcessEDoc(RequestOptions\TicketProcessEDocOptions $options, $messageOptions = [])
    {
        $msgName = 'Ticket_ProcessEDoc';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_ProcessETicket
     *
     * @param RequestOptions\TicketProcessETicketOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketProcessETicket(RequestOptions\TicketProcessETicketOptions $options, $messageOptions = [])
    {
        $msgName = 'Ticket_ProcessETicket';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * DocIssuance_IssueTicket
     *
     * @param RequestOptions\DocIssuanceIssueTicketOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function docIssuanceIssueTicket(
        RequestOptions\DocIssuanceIssueTicketOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'DocIssuance_IssueTicket';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * DocIssuance_IssueMiscellaneousDocuments
     *
     * @param RequestOptions\DocIssuanceIssueMiscDocOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function docIssuanceIssueMiscellaneousDocuments(
        RequestOptions\DocIssuanceIssueMiscDocOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'DocIssuance_IssueMiscellaneousDocuments';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * DocIssuance_IssueCombined
     *
     * @param RequestOptions\DocIssuanceIssueCombinedOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function docIssuanceIssueCombined(
        RequestOptions\DocIssuanceIssueCombinedOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'DocIssuance_IssueCombined';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * DocRefund_InitRefund
     *
     * @param RequestOptions\DocRefundInitRefundOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function docRefundInitRefund(
        RequestOptions\DocRefundInitRefundOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'DocRefund_InitRefund';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * DocRefund_IgnoreRefund
     *
     * @param RequestOptions\DocRefundIgnoreRefundOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function docRefundIgnoreRefund(
        RequestOptions\DocRefundIgnoreRefundOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'DocRefund_IgnoreRefund';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * DocRefund_UpdateRefund
     *
     * @param RequestOptions\DocRefundUpdateRefundOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function docRefundUpdateRefund(
        RequestOptions\DocRefundUpdateRefundOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'DocRefund_UpdateRefund';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * DocRefund_ProcessRefund
     *
     * @param RequestOptions\DocRefundProcessRefundOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function docRefundProcessRefund(
        RequestOptions\DocRefundProcessRefundOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'DocRefund_ProcessRefund';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_InitRefund
     *
     * @param RequestOptions\TicketInitRefundOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketInitRefund(
        RequestOptions\TicketInitRefundOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_InitRefund';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_IgnoreRefund
     *
     * @param RequestOptions\TicketIgnoreRefundOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketIgnoreRefund(
        RequestOptions\TicketIgnoreRefundOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_IgnoreRefund';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Ticket_ProcessRefund
     *
     * @param RequestOptions\TicketProcessRefundOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function ticketProcessRefund(
        RequestOptions\TicketProcessRefundOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Ticket_ProcessRefund';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * FOP_CreateFormOfPayment
     *
     * @param RequestOptions\FopCreateFopOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function fopCreateFormOfPayment(RequestOptions\FopCreateFopOptions $options, $messageOptions = [])
    {
        $msgName = 'FOP_CreateFormOfPayment';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * FOP_CreateFormOfPayment
     *
     * @param RequestOptions\FopValidateFopOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function fopValidateFOP(RequestOptions\FopValidateFopOptions $options, $messageOptions = [])
    {
        $msgName = 'FOP_ValidateFOP';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * PriceXplorer_ExtremeSearch
     *
     * @param RequestOptions\PriceXplorerExtremeSearchOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function priceXplorerExtremeSearch(
        RequestOptions\PriceXplorerExtremeSearchOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'PriceXplorer_ExtremeSearch';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * SalesReports_DisplayQueryReport
     *
     * @param RequestOptions\SalesReportsDisplayQueryReportOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function salesReportsDisplayQueryReport(
        RequestOptions\SalesReportsDisplayQueryReportOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'SalesReports_DisplayQueryReport';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Service_IntegratedPricing
     *
     * @param RequestOptions\ServiceIntegratedPricingOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function serviceIntegratedPricing(
        RequestOptions\ServiceIntegratedPricingOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Service_IntegratedPricing';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Service_IntegratedCatalogue
     *
     * @param RequestOptions\ServiceIntegratedCatalogueOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function serviceIntegratedCatalogue(
        RequestOptions\ServiceIntegratedCatalogueOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'Service_IntegratedCatalogue';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * SalesReports_DisplayorSummarizedReport
     *
     * @param RequestOptions\SalesReportsDisplayDailyOrSummarizedReportOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function salesReportsDisplayDailyOrSummarizedReport(
        RequestOptions\SalesReportsDisplayDailyOrSummarizedReportOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'SalesReports_DisplayDailyOrSummarizedReport';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * SalesReports_DisplayNetRemitReport
     *
     * @param RequestOptions\SalesReportsDisplayNetRemitReportOptions $options
     * @param array $messageOptions (OPTIONAL)
     * @return Result
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws Exception
     */
    public function salesReportsDisplayNetRemitReport(
        RequestOptions\SalesReportsDisplayNetRemitReportOptions $options,
        $messageOptions = []
    ) {
        $msgName = 'SalesReports_DisplayNetRemitReport';

        return $this->callMessage($msgName, $options, $messageOptions);
    }

    /**
     * Call a message with the given parameters
     *
     * @param string $messageName
     * @param RequestOptions\RequestOptionsInterface $options
     * @param array $messageOptions
     * @param bool $endSession
     * @return Result
     * @throws Client\Exception
     * @throws Client\Struct\InvalidArgumentException
     * @throws Client\InvalidMessageException
     * @throws Client\RequestCreator\MessageVersionUnsupportedException
     * @throws \RuntimeException
     * @throws \InvalidArgumentException
     */
    protected function callMessage($messageName, $options, $messageOptions, $endSession = false)
    {
        $messageOptions = $this->makeMessageOptions($messageOptions, $endSession);

        $this->lastMessage = $messageName;

        $sendResult = $this->sessionHandler->sendMessage(
            $messageName,
            $this->requestCreator->createRequest(
                $messageName,
                $options
            ),
            $messageOptions
        );

        $response = $this->responseHandler->analyzeResponse(
            $sendResult,
            $messageName
        );

        if ($messageOptions['returnXml'] === false) {
            $response->responseXml = null;
        }

        return $response;
    }

    /**
     * Make message options
     *
     * Message options are meta options when sending a message to the amadeus web services
     * - 'endSession' (if stateful) : should we end the current session after sending this call?
     * - 'returnXml' : Should we return the XML string in the Result::responseXml property?
     *   (this overrides the default setting returnXml in the Amadeus\Client\Params for a single message)
     *
     * @param array $incoming The Message options chosen by the caller - if any.
     * @param bool $endSession Switch if you want to terminate the current session after making the call.
     * @return array
     */
    protected function makeMessageOptions(array $incoming, $endSession = false)
    {
        $options = [
            'endSession' => $endSession,
            'returnXml' => $this->returnResultXml
        ];

        if (array_key_exists('endSession', $incoming)) {
            $options['endSession'] = $incoming['endSession'];
        }

        if (array_key_exists('returnXml', $incoming)) {
            $options['returnXml'] = $incoming['returnXml'];
        }

        return $options;
    }
}


<?php
/**
 * amadeus-ws-client
 *
 * Copyright 2015 Amadeus Benelux NV
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @package Amadeus
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
 */

namespace Amadeus\Client\RequestOptions;

use Amadeus\Client\Params\AuthParams;

/**
 * Security_Authenticate Request Options
 *
 * @package Amadeus\Client\RequestOptions
 * @author Dieter Devlieghere <dermikagh@gmail.com>
 */
class SecurityAuthenticateOptions extends Base
{
    /**
     * The Amadeus Office ID to sign in to
     *
     * @var string
     */
    public $officeId;

    /**
     * User ID / Originator
     *
     * @var string
     */
    public $userId;

    /**
     * Originator Typecode
     *
     * @var string
     */
    public $originatorTypeCode;

    /**
     * Duty code
     *
     * @var string
     */
    public $dutyCode;

    /**
     * Organization ID
     *
     * @var string
     */
    public $organizationId;

    /**
     * Password Length of plain password.
     *
     * Only for SoapHeader < 4.
     *
     * @var int
     */
    public $passwordLength;

    /**
     * Password Data (base-64 encoded password)
     *
     * @var string
     */
    public $passwordData;

    /**
     * SecurityAuthenticateOptions constructor.
     *
     * @param AuthParams|null $authParams
     */
    public function __construct(AuthParams $authParams = null)
    {
        if ($authParams instanceof AuthParams) {
            $this->loadFromAuthParams($authParams);
        }

        parent::__construct([]);
    }

    /**
     * Load security authenticate options from auth params
     *
     * @param AuthParams $authParams
     */
    protected function loadFromAuthParams(AuthParams $authParams)
    {
        $this->officeId = $authParams->officeId;
        $this->dutyCode = $authParams->dutyCode;
        $this->organizationId = $authParams->organizationId;
        $this->originatorTypeCode = $authParams->originatorTypeCode;
        $this->userId = $authParams->userId;
        $this->passwordLength = $authParams->passwordLength;
        $this->passwordData = $authParams->passwordData;
    }
}