Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing PNR_Ignore #198

Merged
merged 3 commits into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/list-of-supported-messages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This is the list of messages that are at least partially supported at this time:
- PNR_TransferOwnership
- PNR_NameChange
- PNR_Split
- PNR_Ignore
- Queue_List
- Queue_PlacePNR
- Queue_RemoveItem
Expand Down
18 changes: 18 additions & 0 deletions src/Amadeus/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,24 @@ public function queuePlacePnr(RequestOptions\QueuePlacePnrOptions $options, $mes
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
*
Expand Down
47 changes: 47 additions & 0 deletions src/Amadeus/Client/RequestCreator/Converter/PNR/IgnoreConv.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?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\Converter\PNR;

use Amadeus\Client\RequestCreator\Converter\BaseConverter;
use Amadeus\Client\RequestOptions\PnrIgnoreOptions;
use Amadeus\Client\Struct;

/**
* PNR_Ignore Request converter
*
* @package Amadeus\Client\RequestCreator\Converter\PNR
* @author Michael Mueller <michael.mueller@invia.de>
*/
class IgnoreConv extends BaseConverter
{
/**
* @param PnrIgnoreOptions $requestOptions
* @param int|string $version
*
* @return Struct\Pnr\Ignore
*/
public function convert($requestOptions, $version)
{
return new Struct\Pnr\Ignore($requestOptions);
}
}
39 changes: 39 additions & 0 deletions src/Amadeus/Client/RequestOptions/PnrIgnoreOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?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;

/**
* Pnr_Cancel Request Options
*
* @package Amadeus\Client\RequestOptions
* @author Michael Mueller <michael.mueller@invia.de>
*/
class PnrIgnoreOptions extends PnrBase
{
/**
* The Action Request used, should be "A" or ClearInformation::CODE_IGNORE
*
* @var string
*/
public $actionRequest;
}
33 changes: 33 additions & 0 deletions src/Amadeus/Client/ResponseHandler/PNR/HandlerIgnore.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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\PNR;

/**
* HandlerIgnore
*
* @package Amadeus\Client\ResponseHandler\PNR
* @author Michael Mueller <michael.mueller@invia.de>
*/
class HandlerIgnore extends HandlerRetrieve
{
}
59 changes: 59 additions & 0 deletions src/Amadeus/Client/Struct/Pnr/Ignore.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?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;

use Amadeus\Client\RequestOptions\PnrIgnoreOptions;
use Amadeus\Client\Struct\BaseWsMessage;
use Amadeus\Client\Struct\Pnr\Ignore\ClearInformation;

/**
* PNR_Ignore message structure
*
* @package Amadeus\Client\Struct\Pnr
* @author Michael Mueller <michael.mueller@invia.de>
*/
class Ignore extends BaseWsMessage
{
/**
* @var ClearInformation
*/
public $clearInformation;

/**
* Ignore constructor.
*
* @param PnrIgnoreOptions $options
*/
public function __construct(PnrIgnoreOptions $options)
{
$this->loadClearInformation($options->actionRequest);
}

/**
* @param $actionRequestCode
*/
public function loadClearInformation($actionRequestCode)
{
$this->clearInformation = new ClearInformation($actionRequestCode);
}
}
51 changes: 51 additions & 0 deletions src/Amadeus/Client/Struct/Pnr/Ignore/ClearInformation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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\Ignore;

use Amadeus\Client\Struct\BaseWsMessage;

/**
* PNR_Ignore message structure
*
* @package Amadeus\Client\Struct\Pnr
* @author Michael Mueller <michael.mueller@invia.de>
*/
class ClearInformation extends BaseWsMessage
{
const CODE_IGNORE = "A";

/**
* @var self::CODE_*
*/
public $actionRequestCode;

/**
* Ignore constructor.
*
* @param string $actionRequestCode self::CODE_*
*/
public function __construct($actionRequestCode)
{
$this->actionRequestCode = $actionRequestCode;
}
}
46 changes: 46 additions & 0 deletions tests/Amadeus/Client/Struct/Pnr/IgnoreTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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 Test\Amadeus\Client\Struct\Pnr;

use Amadeus\Client\RequestOptions\PnrIgnoreOptions;
use Test\Amadeus\BaseTestCase;
use Amadeus\Client\Struct\Pnr\Ignore;

/**
* IgnoreTest
*
* @package Test\Amadeus\Client\Struct\Pnr
*/
class IgnoreTest extends BaseTestCase
{
public function testCanMakeIgnoreMessage()
{
$options = new PnrIgnoreOptions();
$options->actionRequest = Ignore\ClearInformation::CODE_IGNORE;
$message = new Ignore(
$options
);
$this->assertInstanceOf('Amadeus\Client\Struct\Pnr\Ignore\ClearInformation', $message->clearInformation);
$this->assertEquals(Ignore\ClearInformation::CODE_IGNORE, $message->clearInformation->actionRequestCode);
}
}
48 changes: 47 additions & 1 deletion tests/Amadeus/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2024,7 +2024,7 @@ public function testCanDoTicketRetrieveListOfTSM()

$this->assertEquals($messageResult, $response);
}

public function testCanDoTicketDisplayTSMFareElement()
{
$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();
Expand Down Expand Up @@ -5530,6 +5530,52 @@ public function testCanSendAnyMessageRequestNoResponseXml()
$this->assertEquals($expectedMessage, $response);
}

public function testCanDoIgnorePnrCall()
{
$mockedSendResult = new Client\Session\Handler\SendResult();
$mockedSendResult->responseXml = 'A dummy message result'; // Not an actual XML reply.
$mockedSendResult->responseObject = new \stdClass();
$mockedSendResult->responseObject->dummyprop = 'A dummy message result'; // Not an actual response property

$messageResult = new Client\Result($mockedSendResult);

$options = new Client\RequestOptions\PnrIgnoreOptions();
$options->actionRequest = Client\Struct\Pnr\Ignore\ClearInformation::CODE_IGNORE;

$expectedPnrResult = new Client\Struct\Pnr\Ignore($options);

$mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();

$mockSessionHandler
->expects($this->once())
->method('sendMessage')
->with('PNR_Ignore', $expectedPnrResult, ['endSession' => false, 'returnXml' => true])
->will($this->returnValue($mockedSendResult));
$mockSessionHandler
->expects($this->once())
->method('getMessagesAndVersions')
->will($this->returnValue(['PNR_Ignore' => ['version' => "14.2", 'wsdl' => 'dc22e4ee']]));

$mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface')->getMock();

$mockResponseHandler
->expects($this->once())
->method('analyzeResponse')
->with($mockedSendResult, 'PNR_Ignore')
->will($this->returnValue($messageResult));

$par = new Params();
$par->sessionHandler = $mockSessionHandler;
$par->requestCreatorParams = new Params\RequestCreatorParams(['receivedFrom' => 'some RF string', 'originatorOfficeId' => 'BRUXXXXXX']);
$par->responseHandler = $mockResponseHandler;

$client = new Client($par);

$response = $client->pnrIgnore($options);

$this->assertEquals($messageResult, $response);
}

/**
* @return array
*/
Expand Down