diff --git a/CHANGELOG.md b/CHANGELOG.md index a55c5e9b5..5c988eed2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ https://github.com/amabnl/amadeus-ws-client/pull/344: * Added support to add freeText for payment type Cash and CC in ``Pnr_AddMultiElements`` * Added support for "ZapOff" in ``Fare_PricePnrWithBookingClass`` * Added support for "Fare Misc TKT Information", "Fare Endorsement", "Fare Endorsement" , "Fare Misc Information" in ``Pnr_AddMultiElements`` +* Implemented ``Ticket_UpdateRefund`` (https://github.com/amabnl/amadeus-ws-client/pull/407) - Vladimir Kikot # Release 1.10.0 (27 May 2020) * Bugfix for a SOAP-ERROR in ``DocIssuance_IssueMiscellaneousDocuments`` (https://github.com/amabnl/amadeus-ws-client/pull/359) - Artem Zakharchenko diff --git a/docs/list-of-supported-messages.rst b/docs/list-of-supported-messages.rst index 4394599d9..2a9f27db2 100644 --- a/docs/list-of-supported-messages.rst +++ b/docs/list-of-supported-messages.rst @@ -57,6 +57,7 @@ This is the list of messages that are at least partially supported at this time: - Ticket_ProcessEDoc - Ticket_ProcessETicket - Ticket_InitRefund +- Ticket_UpdateRefund - Ticket_IgnoreRefund - Ticket_ProcessRefund - DocIssuance_IssueTicket diff --git a/docs/samples.rst b/docs/samples.rst index 611e6a1b6..cb66ce934 100644 --- a/docs/samples.rst +++ b/docs/samples.rst @@ -2580,6 +2580,22 @@ Initiate Automated Refund: ]) ); +--------------------------- +Ticket_UpdateRefund +--------------------------- + +Apply waiver code (for now only waiver codes are supported): + +.. code-block:: php + + use Amadeus\Client\RequestOptions\TicketUpdateRefundOptions; + + $response = $client->ticketUpdateRefund( + new TicketUpdateRefundOptions([ + 'waiverCode' => 'TESTWAIVER11', + 'contractBundleId' => 1, + ]) + ); --------------------------- Ticket_IgnoreRefund diff --git a/src/Amadeus/Client.php b/src/Amadeus/Client.php index c495b7227..d869e7c14 100644 --- a/src/Amadeus/Client.php +++ b/src/Amadeus/Client.php @@ -1530,6 +1530,25 @@ public function ticketProcessRefund( return $this->callMessage($msgName, $options, $messageOptions); } + /** + * Ticket_UpdateRefund + * + * @param RequestOptions\TicketUpdateRefundOptions $options + * @param array $messageOptions (OPTIONAL) + * @return Result + * @throws Client\InvalidMessageException + * @throws Client\RequestCreator\MessageVersionUnsupportedException + * @throws Exception + */ + public function ticketUpdateRefund( + RequestOptions\TicketUpdateRefundOptions $options, + $messageOptions = [] + ) { + $msgName = 'Ticket_UpdateRefund'; + + return $this->callMessage($msgName, $options, $messageOptions); + } + /** * FOP_CreateFormOfPayment * diff --git a/src/Amadeus/Client/RequestCreator/Converter/Ticket/UpdateRefundConv.php b/src/Amadeus/Client/RequestCreator/Converter/Ticket/UpdateRefundConv.php new file mode 100644 index 000000000..a519c295a --- /dev/null +++ b/src/Amadeus/Client/RequestCreator/Converter/Ticket/UpdateRefundConv.php @@ -0,0 +1,46 @@ + + */ +class UpdateRefundConv extends BaseConverter +{ + /** + * @param TicketUpdateRefundOptions $requestOptions + * @param int|string $version + * @return Struct\Ticket\UpdateRefund + */ + public function convert($requestOptions, $version) + { + return new Struct\Ticket\UpdateRefund($requestOptions); + } +} diff --git a/src/Amadeus/Client/RequestOptions/TicketUpdateRefundOptions.php b/src/Amadeus/Client/RequestOptions/TicketUpdateRefundOptions.php new file mode 100644 index 000000000..ba8ef11a2 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/TicketUpdateRefundOptions.php @@ -0,0 +1,41 @@ + + */ +class TicketUpdateRefundOptions extends Base +{ + /** @var int */ + public $contractBundleId; + + /** @var string */ + public $waiverCode; + + /** @var string */ + public $version = '3.000'; +} diff --git a/src/Amadeus/Client/ResponseHandler/Ticket/HandlerUpdateRefund.php b/src/Amadeus/Client/ResponseHandler/Ticket/HandlerUpdateRefund.php new file mode 100644 index 000000000..b799a3979 --- /dev/null +++ b/src/Amadeus/Client/ResponseHandler/Ticket/HandlerUpdateRefund.php @@ -0,0 +1,33 @@ + + */ +class HandlerUpdateRefund extends HandlerInitRefund +{ +} diff --git a/src/Amadeus/Client/Struct/Ticket/UpdateRefund.php b/src/Amadeus/Client/Struct/Ticket/UpdateRefund.php new file mode 100644 index 000000000..cd8178f24 --- /dev/null +++ b/src/Amadeus/Client/Struct/Ticket/UpdateRefund.php @@ -0,0 +1,53 @@ + + */ +class UpdateRefund extends BaseWsMessage +{ + /** @var ContractBundle $ContractBundle */ + public $ContractBundle; + + /** @var string */ + public $Version; + + /** + * UpdateRefund constructor. + * + * @param TicketUpdateRefundOptions $options + */ + public function __construct($options) + { + $this->ContractBundle = new ContractBundle($options->contractBundleId, $options->waiverCode); + $this->Version = $options->version; + } +} diff --git a/src/Amadeus/Client/Struct/Ticket/UpdateRefund/ContractBundle.php b/src/Amadeus/Client/Struct/Ticket/UpdateRefund/ContractBundle.php new file mode 100644 index 000000000..6d86f2e5b --- /dev/null +++ b/src/Amadeus/Client/Struct/Ticket/UpdateRefund/ContractBundle.php @@ -0,0 +1,52 @@ + + */ +class ContractBundle extends BaseWsMessage +{ + /** @var int */ + public $ID; + + /** @var WaiverCode */ + public $WaiverCode; + + /** + * ContractBundle constructor. + * + * @param int $id + * @param string $waiverCode + */ + public function __construct($id, $waiverCode) + { + $this->ID = $id; + $this->WaiverCode = new WaiverCode($waiverCode); + } +} diff --git a/src/Amadeus/Client/Struct/Ticket/UpdateRefund/WaiverCode.php b/src/Amadeus/Client/Struct/Ticket/UpdateRefund/WaiverCode.php new file mode 100644 index 000000000..74f086c2d --- /dev/null +++ b/src/Amadeus/Client/Struct/Ticket/UpdateRefund/WaiverCode.php @@ -0,0 +1,47 @@ + + */ +class WaiverCode extends BaseWsMessage +{ + /** @var string */ + public $Code; + + /** + * WaiverCode constructor. + * + * @param string $waiverCode + */ + public function __construct($waiverCode) + { + $this->Code = $waiverCode; + } +} diff --git a/tests/Amadeus/Client/ResponseHandler/BaseTest.php b/tests/Amadeus/Client/ResponseHandler/BaseTest.php index 9dc8ac550..41cfc8b74 100644 --- a/tests/Amadeus/Client/ResponseHandler/BaseTest.php +++ b/tests/Amadeus/Client/ResponseHandler/BaseTest.php @@ -1804,6 +1804,44 @@ public function testCanHandleUnknownTicketInitRefund() $this->assertEquals(Result::STATUS_UNKNOWN, $result->status); } + public function testCanHandleOkTicketUpdateRefund() + { + $respHandler = new ResponseHandler\Base(); + + $sendResult = new SendResult(); + $sendResult->responseXml = $this->getTestFile('dummyTicketUpdateRefundResponse.txt'); + + $result = $respHandler->analyzeResponse($sendResult, 'Ticket_UpdateRefund'); + + $this->assertEquals(Result::STATUS_OK, $result->status); + $this->assertCount(0, $result->messages); + } + + public function testCanHandleFailTicketUpdateRefund() + { + $respHandler = new ResponseHandler\Base(); + + $sendResult = new SendResult(); + $sendResult->responseXml = $this->getTestFile('dummyTicketUpdateRefundFailResponse.txt'); + + $result = $respHandler->analyzeResponse($sendResult, 'Ticket_InitRefund'); + + $this->assertEquals(Result::STATUS_ERROR, $result->status); + $this->assertCount(1, $result->messages); + } + + public function testCanHandleUnknownTicketUpdateRefund() + { + $respHandler = new ResponseHandler\Base(); + + $sendResult = new SendResult(); + $sendResult->responseXml = $this->getTestFile('dummyTicketUpdateRefundUnknownResponse.txt'); + + $result = $respHandler->analyzeResponse($sendResult, 'Ticket_InitRefund'); + + $this->assertEquals(Result::STATUS_UNKNOWN, $result->status); + } + public function testCanHandleOkTicketIgnoreRefund() { $respHandler = new ResponseHandler\Base(); diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/dummyTicketUpdateRefundFailResponse.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyTicketUpdateRefundFailResponse.txt new file mode 100644 index 000000000..45e66bae3 --- /dev/null +++ b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyTicketUpdateRefundFailResponse.txt @@ -0,0 +1,14 @@ + + + + + NEED REFUND RECORD + + + + diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/dummyTicketUpdateRefundResponse.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyTicketUpdateRefundResponse.txt new file mode 100644 index 000000000..34eb11ee4 --- /dev/null +++ b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyTicketUpdateRefundResponse.txt @@ -0,0 +1,146 @@ + + + + + + + + + + + RID + 36 + + + + + + + + + + + TOM + SEAVER + SEAVER/TOM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + I + + + + + + + 1 + RF + + + + + 2 + RF + + + + + DUB + LHR + DUB + + + + + + + + 2020 + 07 + 08 + + + + + + 2020 + 07 + 08 + + + + + CASH + + + + + 33630763 + NYC1S21R0 + 9998WSSU + + TKTT + + + TKT + Y + + + DIS + B + + + + + + diff --git a/tests/Amadeus/Client/ResponseHandler/testfiles/dummyTicketUpdateRefundUnknownResponse.txt b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyTicketUpdateRefundUnknownResponse.txt new file mode 100644 index 000000000..84ebc1952 --- /dev/null +++ b/tests/Amadeus/Client/ResponseHandler/testfiles/dummyTicketUpdateRefundUnknownResponse.txt @@ -0,0 +1,7 @@ + + diff --git a/tests/Amadeus/Client/Struct/Ticket/UpdateRefundTest.php b/tests/Amadeus/Client/Struct/Ticket/UpdateRefundTest.php new file mode 100644 index 000000000..17602468e --- /dev/null +++ b/tests/Amadeus/Client/Struct/Ticket/UpdateRefundTest.php @@ -0,0 +1,50 @@ + + */ +class UpdateRefundTest extends BaseTestCase +{ + public function testCanMakeMessageUpdateRefund() + { + $opt = new TicketUpdateRefundOptions([ + 'contractBundleId' => 1, + 'waiverCode' => 'TESTWAIVER11', + ]); + + $msg = new UpdateRefund($opt); + $this->assertEquals('3.000', $msg->Version); + + $this->assertEquals('TESTWAIVER11', $msg->ContractBundle->WaiverCode->Code); + $this->assertEquals(1, $msg->ContractBundle->ID); + } +} diff --git a/tests/Amadeus/ClientTest.php b/tests/Amadeus/ClientTest.php index 651ec3246..6fc88b541 100644 --- a/tests/Amadeus/ClientTest.php +++ b/tests/Amadeus/ClientTest.php @@ -5909,6 +5909,62 @@ public function testCanSendTicketInitRefund() $this->assertEquals($messageResult, $response); } + public function testCanSendTicketUpdateRefund() + { + $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock(); + + $mockedSendResult = new Client\Session\Handler\SendResult(); + $mockedSendResult->responseXml = 'dummyTicketUpdateRefundResponse'; + + $messageResult = new Client\Result($mockedSendResult); + + $expectedMessageResult = new Client\Struct\Ticket\UpdateRefund( + new Client\RequestOptions\TicketUpdateRefundOptions([ + + ]) + ); + + $mockSessionHandler + ->expects($this->once()) + ->method('sendMessage') + ->with('Ticket_UpdateRefund', $expectedMessageResult, ['endSession' => false, 'returnXml' => true]) + ->willReturn($mockedSendResult); + $mockSessionHandler + ->expects($this->never()) + ->method('getLastResponse'); + $mockSessionHandler + ->expects($this->once()) + ->method('getMessagesAndVersions') + ->willReturn(['Ticket_UpdateRefund' => ['version' => '3.0', 'wsdl' => 'dc22e4ee']]); + + $mockResponseHandler = $this->getMockBuilder('Amadeus\Client\ResponseHandler\ResponseHandlerInterface') + ->getMock(); + + $mockResponseHandler + ->expects($this->once()) + ->method('analyzeResponse') + ->with($mockedSendResult, 'Ticket_UpdateRefund') + ->willReturn($messageResult); + + $par = new Params(); + $par->sessionHandler = $mockSessionHandler; + $par->requestCreatorParams = new Params\RequestCreatorParams([ + 'receivedFrom' => 'some RF string', + 'originatorOfficeId' => 'NYCXXXXXX' + ]); + $par->responseHandler = $mockResponseHandler; + + $client = new Client($par); + + $response = $client->ticketUpdateRefund( + new Client\RequestOptions\TicketUpdateRefundOptions([ + + ]) + ); + + $this->assertEquals($messageResult, $response); + } + public function testCanSendTicketIgnoreRefund() { $mockSessionHandler = $this->getMockBuilder('Amadeus\Client\Session\Handler\HandlerInterface')->getMock();