Skip to content

Commit

Permalink
Implemented Ticket_DeleteTSMP message
Browse files Browse the repository at this point in the history
  • Loading branch information
DerMika committed Oct 27, 2016
1 parent 1d09751 commit 18f0a36
Show file tree
Hide file tree
Showing 14 changed files with 539 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Release 1.2.0 (Unreleased)
* Request Creator split up in 1 dedicated class per message.
* Implemented ``Ticket_DeleteTSMP``

# Release 1.1.0 (19 October 2016)

Expand Down
39 changes: 39 additions & 0 deletions docs/samples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,45 @@ Delete the TST with number 2:
])
);
-----------------
Ticket_DeleteTSMP
-----------------

Delete TSMs attached to passengers with tattoos 2 and 3:

.. code-block:: php
use Amadeus\Client\RequestOptions\TicketDeleteTsmpOptions;
$deleteTstResult = $client->ticketDeleteTSMP(
new TicketDeleteTsmpOptions([
'paxTattoos' => [2, 3]
])
);
Delete TSMs attached to the infant of passenger with tattoo 1:

.. code-block:: php
use Amadeus\Client\RequestOptions\TicketDeleteTsmpOptions;
$deleteTstResult = $client->ticketDeleteTSMP(
new TicketDeleteTsmpOptions([
'infantTattoos' => [1]
])
);
Delete TSMs for TSMs tattoo 2 and 4:

.. code-block:: php
use Amadeus\Client\RequestOptions\TicketDeleteTsmpOptions;
$deleteTstResult = $client->ticketDeleteTSMP(
new TicketDeleteTsmpOptions([
'tsmTattoos' => [2, 4]
])
);
-----------------
Ticket_DisplayTST
Expand Down
14 changes: 14 additions & 0 deletions src/Amadeus/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,20 @@ public function ticketDeleteTST(RequestOptions\TicketDeleteTstOptions $options,
return $this->callMessage($msgName, $options, $messageOptions);
}

/**
* Ticket_DeleteTSMP
*
* @param RequestOptions\TicketDeleteTsmpOptions $options
* @param array $messageOptions (OPTIONAL)
* @return Result
*/
public function ticketDeleteTSMP(RequestOptions\TicketDeleteTsmpOptions $options, $messageOptions = [])
{
$msgName = 'Ticket_DeleteTSMP';

return $this->callMessage($msgName, $options, $messageOptions);
}

/**
* Ticket_DisplayTST
*
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\TicketDeleteTsmpOptions;
use Amadeus\Client\Struct;

/**
* Ticket_DeleteTSMP Request converter
*
* @package Amadeus\Client\RequestCreator\Converter\Ticket
* @author Dieter Devlieghere <dieter.devlieghere@benelux.amadeus.com>
*/
class DeleteTSMPConv extends BaseConverter
{
/**
* @param TicketDeleteTsmpOptions $requestOptions
* @param int|string $version
* @return Struct\Ticket\DeleteTSMP
*/
public function convert($requestOptions, $version)
{
return new Struct\Ticket\DeleteTSMP($requestOptions);
}
}
55 changes: 55 additions & 0 deletions src/Amadeus/Client/RequestOptions/TicketDeleteTsmpOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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;

/**
* TicketDeleteTsmpOptions
*
* @package Amadeus\Client\RequestOptions
* @author Dieter Devlieghere <dieter.devlieghere@benelux.amadeus.com>
*/
class TicketDeleteTsmpOptions extends Base
{
/**
* List of TSM-P tattoos to delete
*
* @var int[]
*/
public $tsmTattoos = [];

/**
* List of passenger tattoos for who to delete all TSMP's
*
* @var int[]
*/
public $paxTattoos = [];

/**
* List of infant tattoos for who to delete all TSMP's
*
* (The tattoos you need to provide here are the parent passenger tattoos)
*
* @var int[]
*/
public $infantTattoos = [];
}
9 changes: 9 additions & 0 deletions src/Amadeus/Client/ResponseHandler/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,15 @@ protected function analyzeTicketDeleteTSTResponse($response)
return $this->analyzeTicketCreateTSTFromPricingResponse($response);
}

/**
* @param SendResult $response Ticket_DeleteTSMP result
* @return Result
*/
protected function analyzeTicketDeleteTSMPResponse($response)
{
return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
}

/**
* @param SendResult $response Ticket_CreateTSTFromPricing result
* @return Result
Expand Down
48 changes: 48 additions & 0 deletions src/Amadeus/Client/Struct/Ticket/CriteriaTattoo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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;

/**
* CriteriaTattoo
*
* @package Amadeus\Client\Struct\Ticket
* @author Dieter Devlieghere <dieter.devlieghere@benelux.amadeus.com>
*/
class CriteriaTattoo
{
/**
* @var ReferenceDetails
*/
public $referenceDetails;

/**
* CriteriaTattoo constructor.
*
* @param string $type ReferenceDetails::TYPE_*
* @param string|int $value the tattoo
*/
public function __construct($type, $value)
{
$this->referenceDetails = new ReferenceDetails($type, $value);
}
}
71 changes: 71 additions & 0 deletions src/Amadeus/Client/Struct/Ticket/DeleteTSMP.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?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\TicketDeleteTsmpOptions;
use Amadeus\Client\Struct\BaseWsMessage;

/**
* DeleteTSMP
*
* @package Amadeus\Client\Struct\Ticket
* @author Dieter Devlieghere <dieter.devlieghere@benelux.amadeus.com>
*/
class DeleteTSMP extends BaseWsMessage
{
/**
* @var CriteriaTattoo[]
*/
public $criteriaTattoo = [];

/**
* DeleteTSMP constructor.
*
* @param TicketDeleteTsmpOptions $params
*/
public function __construct(TicketDeleteTsmpOptions $params)
{
foreach ($params->infantTattoos as $infantTattoo) {
$this->addCriteriaTattoo($infantTattoo, ReferenceDetails::TYPE_INFANT_PARENT_TATTOO);
}

foreach ($params->paxTattoos as $paxTattoo) {
$this->addCriteriaTattoo($paxTattoo, ReferenceDetails::TYPE_PASSENGER_TATTOO);
}

foreach ($params->tsmTattoos as $tsmTattoo) {
$this->addCriteriaTattoo($tsmTattoo, ReferenceDetails::TYPE_TSM_TATTOO);
}
}

/**
* Add a tattoo ref to the message
*
* @param string|int $tattoo
* @param string $type
*/
protected function addCriteriaTattoo($tattoo, $type)
{
$this->criteriaTattoo[] = new CriteriaTattoo($type, $tattoo);
}
}
60 changes: 60 additions & 0 deletions src/Amadeus/Client/Struct/Ticket/ReferenceDetails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?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;

/**
* ReferenceDetails
*
* @package Amadeus\Client\Struct\Ticket
* @author Dieter Devlieghere <dieter.devlieghere@benelux.amadeus.com>
*/
class ReferenceDetails
{
const TYPE_INFANT_PARENT_TATTOO = "INF";
const TYPE_PASSENGER_TATTOO = "PAX";
const TYPE_TSM_TATTOO = "TSM";

/**
* self::TYPE_*
*
* @var string
*/
public $type;

/**
* @var string|int
*/
public $value;

/**
* ReferenceDetails constructor.
*
* @param string $type
* @param int|string $value
*/
public function __construct($type, $value)
{
$this->type = $type;
$this->value = $value;
}
}
15 changes: 15 additions & 0 deletions tests/Amadeus/Client/ResponseHandler/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,21 @@ public function testCanHandleTicketDeleteTSTErrResponse()
$this->assertEquals("NEED PNR", $result->messages[0]->text);
}

public function testCanHandleTicketDeleteTSMPErrorResponse()
{
$respHandler = new ResponseHandler\Base();

$sendResult = new SendResult();
$sendResult->responseXml = $this->getTestFile('dummyTicketDeleteTsmpErrorResponse.txt');

$result = $respHandler->analyzeResponse($sendResult, 'Ticket_DeleteTSMP');

$this->assertEquals(Result::STATUS_ERROR, $result->status);
$this->assertEquals(1, count($result->messages));
$this->assertEquals('911', $result->messages[0]->code);
$this->assertEmpty($result->messages[0]->text);
}

public function testCanHandleTicketDisplayTSTErrResponse()
{
$respHandler = new ResponseHandler\Base();
Expand Down
Loading

0 comments on commit 18f0a36

Please sign in to comment.