Example #1
0
 public function testCanDoAuthenticateCall()
 {
     $authParams = new Params\AuthParams(['officeId' => 'BRUXXXXXX', 'originatorTypeCode' => 'U', 'userId' => 'WSXXXXXX', 'passwordData' => base64_encode('TEST'), 'passwordLength' => 4, 'dutyCode' => 'SU', 'organizationId' => 'DUMMY-ORG']);
     $mockedSendResult = new Client\Session\Handler\SendResult();
     $mockedSendResult->responseXml = 'dummy auth response xml';
     $mockedSendResult->responseObject = new \stdClass();
     $mockedSendResult->responseObject->processStatus = new \stdClass();
     $mockedSendResult->responseObject->processStatus->statusCode = 'P';
     $messageResult = new Client\Result($mockedSendResult);
     $expectedMessageResult = new Client\Struct\Security\Authenticate(new Client\RequestOptions\SecurityAuthenticateOptions($authParams));
     $mockSessionHandler = $this->getMockBuilder('Amadeus\\Client\\Session\\Handler\\HandlerInterface')->getMock();
     $mockSessionHandler->expects($this->once())->method('sendMessage')->with('Security_Authenticate', $expectedMessageResult, ['endSession' => false])->will($this->returnValue($mockedSendResult));
     $mockSessionHandler->expects($this->never())->method('getLastResponse');
     $mockSessionHandler->expects($this->once())->method('getMessagesAndVersions')->will($this->returnValue(['Security_Authenticate' => "6.1"]));
     $mockResponseHandler = $this->getMockBuilder('Amadeus\\Client\\ResponseHandler\\ResponseHandlerInterface')->getMock();
     $mockResponseHandler->expects($this->once())->method('analyzeResponse')->with($mockedSendResult, 'Security_Authenticate')->will($this->returnValue($messageResult));
     $par = new Params();
     $par->authParams = $authParams;
     $par->sessionHandler = $mockSessionHandler;
     $par->requestCreatorParams = new Params\RequestCreatorParams(['receivedFrom' => 'some RF string', 'originatorOfficeId' => 'BRUXXXXXX']);
     $par->responseHandler = $mockResponseHandler;
     $client = new Client($par);
     $response = $client->securityAuthenticate();
     $this->assertEquals($messageResult, $response);
 }
Example #2
0
<?php

/**
 * Amadeus Sample client
 */
include 'src/Amadeus/Client.php';
use Amadeus\Client;
// Instantiate the Amadeus class (Debug enabled)
$ws = new Client('AmadeusWebServices.wsdl', true);
// Authenticate
$ws->securityAuthenticate([YOUR_SOURCE], [YOUR_ORIGIN], [YOUR_PASSWORD], [PASSWORD_LENGTH], [ORGANIZATION_ID]);
// Travel from and to locations
$from = 'DEL';
$to = 'BLR';
// Travel Segments
$segments[] = array('dep_date' => '230612', 'dep_location' => 'DEL', 'dest_location' => 'BLR', 'company' => 'IT', 'flight_no' => '201', 'class' => 'Y', 'passengers' => '2');
$segments[] = array('dep_date' => '250612', 'dep_location' => 'BLR', 'dest_location' => 'DEL', 'company' => 'IT', 'flight_no' => '202', 'class' => 'Y', 'passengers' => '2');
// Setup travellers
$travellers['A'] = array(array('surname' => 'DOE', 'first_name' => 'JOHN'));
$travellers['C'] = array(array('surname' => 'DWYNE', 'first_name' => 'JOHNSON'));
$travellers['I'] = array(array('first_name' => 'JANE'));
// Airline Code
$code = 'IT';
// Here 2 types of passengers -> Adult and a Child
$types = 2;
// Make the booking
$ws->airSellFromRecommendation($from, $to, $segments);
$ws->pnrAddMultiElements($travellers);
$ws->farePricePNRWithBookingClass($code);
$ws->ticketCreateTSTFromPricing($types);
$ws->pnrAddMultiElementsFinal();