Skip to content

Commit

Permalink
Implemented Ticket_UpdateRefund. For now only waiver codes are suppor…
Browse files Browse the repository at this point in the history
…ted.
  • Loading branch information
shoxy committed Jul 8, 2020
1 parent 3609afd commit 7a07977
Show file tree
Hide file tree
Showing 16 changed files with 615 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/398) - 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
Expand Down
1 change: 1 addition & 0 deletions docs/list-of-supported-messages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions docs/samples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions src/Amadeus/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
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 Amadeus\Client\RequestCreator\Converter\Ticket;

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

/**
* Ticket_UpdateRefund request converter
*
* @package Amadeus\Client\RequestCreator\Converter\Ticket
* @author Vladimir Kikot <shoxyoyo@gmail.com>
*/
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);
}
}
38 changes: 38 additions & 0 deletions src/Amadeus/Client/RequestOptions/TicketUpdateRefundOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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;

/**
* TicketUpdateRefundOptions Request Options
*
* @package Amadeus\Client\RequestOptions
* @author Vladimir Kikot <shoxyoyo@gmail.com>
*/
class TicketUpdateRefundOptions extends Base
{
/** @var int */
public $contractBundleId;

/** @var string */
public $waiverCode;
}
33 changes: 33 additions & 0 deletions src/Amadeus/Client/ResponseHandler/Ticket/HandlerUpdateRefund.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\Ticket;

/**
* HandlerUpdateRefund
*
* @package Amadeus\Client\ResponseHandler\Ticket
* @author Vladimir Kikot <shoxyoyo@gmail.com>
*/
class HandlerUpdateRefund extends HandlerInitRefund
{
}
51 changes: 51 additions & 0 deletions src/Amadeus/Client/Struct/Ticket/UpdateRefund.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\Ticket;

use Amadeus\Client\RequestOptions\TicketUpdateRefundOptions;
use Amadeus\Client\Struct\BaseWsMessage;
use Amadeus\Client\Struct\Ticket\UpdateRefund\ContractBundle;

/**
* UpdateRefund request structure
*
* @package Amadeus\Client\Struct\Ticket
* @author Vladimir Kikot <shoxyoyo@gmail.com>
*/
class UpdateRefund extends BaseWsMessage
{
/** @var ContractBundle $ContractBundle */
public $ContractBundle;

public $Version = "3.000";

/**
* UpdateRefund constructor.
*
* @param TicketUpdateRefundOptions $options
*/
public function __construct($options)
{
$this->ContractBundle = new ContractBundle($options->contractBundleId, $options->waiverCode);
}
}
52 changes: 52 additions & 0 deletions src/Amadeus/Client/Struct/Ticket/UpdateRefund/ContractBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?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\Ticket\UpdateRefund;

use Amadeus\Client\Struct\BaseWsMessage;

/**
* ContractBundle request structure
*
* @package Amadeus\Client\Struct\Ticket\UpdateRefund
* @author Vladimir Kikot <shoxyoyo@gmail.com>
*/
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);
}
}
47 changes: 47 additions & 0 deletions src/Amadeus/Client/Struct/Ticket/UpdateRefund/WaiverCode.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\Struct\Ticket\UpdateRefund;

use Amadeus\Client\Struct\BaseWsMessage;

/**
* WaiverCode request structure
*
* @package Amadeus\Client\Struct\Ticket\UpdateRefund
* @author Vladimir Kikot <shoxyoyo@gmail.com>
*/
class WaiverCode extends BaseWsMessage
{
/** @var string */
public $Code;

/**
* WaiverCode constructor.
*
* @param string $waiverCode
*/
public function __construct($waiverCode)
{
$this->Code = $waiverCode;
}
}
38 changes: 38 additions & 0 deletions tests/Amadeus/Client/ResponseHandler/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<AMA_TicketUpdateRefundRS xmlns="http://xml.amadeus.com/2010/06/TicketGTP_v3"
xmlns:ama="http://xml.amadeus.com/2010/06/Types_v2"
xmlns:att="http://xml.amadeus.com/2010/06/TicketTypes_v2"
xmlns:iata="http://www.iata.org/IATA/2007/00/IATA2010.1"
xmlns:ota="http://www.opentravel.org/OTA/2003/05/OTA2010B"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="3.000">
<GeneralReply>
<Errors>
<ama:Errors>
<ama:Error Type="000" Code="11004">NEED REFUND RECORD</ama:Error>
</ama:Errors>
</Errors>
</GeneralReply>
</AMA_TicketUpdateRefundRS>

0 comments on commit 7a07977

Please sign in to comment.