Code Monkey home page Code Monkey logo

Comments (3)

jcarriquiry avatar jcarriquiry commented on June 14, 2024

DerMika, I developed a solution to add an infant associated to another passenger.

I had modified de createTraveller funtion in src\Amadeus\Client\Struct\Pnr\AddMultiElements.php:

` protected function createTraveller($traveller)
{
$createdTraveller = new TravellerInfo(
ElementManagementPassenger::SEG_NAME,
$traveller->lastName
);
if (!is_null($traveller->number)) {
$createdTraveller->elementManagementPassenger->reference = new Reference(
Reference::QUAL_PASSENGER,
$traveller->number
);
}
if ($traveller->dateOfBirth instanceof \DateTime) {
$createdTraveller->passengerData[0]->dateOfBirth = new DateOfBirth(
$traveller->dateOfBirth->format('dmY')
);
}
if ($traveller->firstName !== null || $traveller->travellerType !== null) {
$createdTraveller->passengerData[0]->travellerInformation->passenger[] = new Passenger(
$traveller->firstName,
$traveller->travellerType
);
}

    if ($traveller->withInfant === true || ($traveller->infant !== null && count($traveller->infant) > 0 ) ) {
        //throw new \RuntimeException('Adding Infants is not yet supported');

        $createdTraveller->passengerData[0]->travellerInformation->traveller->quantity = 2;
        $createdTraveller->passengerData[0]->travellerInformation->passenger[0]->infantIndicator = 3;

        $createdTraveller->passengerData[1] = new AddMultiElements\PassengerData($traveller->infant->lastName); 
        $createdTraveller->passengerData[1]->travellerInformation->passenger[] = new Passenger(
            $traveller->infant->firstName,
            $traveller->infant->travellerType
        );        

    }


    return $createdTraveller;
}`

To make the call I did this:

$aTravelers[] = array('number' => 1, 'lastName' => 'Doe', 'firstName' => 'John', 'travellerType' => 'ADT', 'withInfant' => true, 'infant' => array('number' => 5,'lastName' => 'Doe', 'firstName' => 'Baby', 'travellerType' => 'INF', 'dateOfBirth' => '03052016') );
And then

` foreach( $aTravelers as $traveler ) {
$traveller_inf = array();
if ($traveler["withInfant"]) {

    $traveller_inf = new Traveller(['lastName' => $traveler["infant"]["lastName"],
                                    'firstName' => $traveler["infant"]["firstName"],
                                    'travellerType' => $traveler["infant"]["travellerType"],
                                    'dateOfBirth' => $traveler["infant"]["dateOfBirth"],
                                    'withInfant' => false 
                                    ]);
}                                                           

$createPnrOptions->travellers[] = new Traveller([
                                        'number' => $traveler["number"],
                                        'lastName' => $traveler["lastName"],
                                        'firstName' => $traveler["firstName"],
                                        'travellerType' => $traveler["travellerType"],
                                        'withInfant' => $traveler["withInfant"],
                                        'infant' => $traveller_inf
                                    ]);

$aReferences[] = new Reference([
                'type' => Reference::TYPE_PASSENGER_TATTOO,
                'id' => $traveler["number"]
            ]); }`

If you wish, I could send you the entire source code.

Best regards

from amadeus-ws-client.

DerMika avatar DerMika commented on June 14, 2024

Hi @jcarriquiry, I was planning to add infant support, but I hadn't gotten around to it yet.

I wanted to make sure I could support all the infant scenarios mentioned in the PNR_AddMultiElements docs. There are different ways to add infants depending on what information you have of them (last name, first name, date of birth,...).

I will add support for infants before I release the first version. Or if you have a pull request, don't hesitate to contribute ;)

from amadeus-ws-client.

DerMika avatar DerMika commented on June 14, 2024

Implemented support for 3 scenario's of Infant passengers (No infant information, only first name, or first name, last name and date of birth).

See the updated docs on how to add them to your requests: https://github.com/amabnl/amadeus-ws-client/blob/develop/docs/samples/pnr-create-modify.rst#passengers-infants

If you find any problems, feel free to open a new ticket!

from amadeus-ws-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.