Skip to content

Commit

Permalink
PNR: support individual security element ES (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
suiram2010 committed Dec 12, 2020
1 parent 2c64678 commit 75674fb
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/samples/pnr-create-modify.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1000,4 +1000,25 @@ Central System reporting database.
'freeText' => 'MISC TICKETING INFORMATION'
]);
]
]);
Security Element (ES)
===============================

Adding an Individual Security Element (ES) to a PNR

.. code-block:: php
use Amadeus\Client\RequestOptions\PnrAddMultiElementsOptions;
use Amadeus\Client\RequestOptions\Pnr\Element\PnrSecurity;
$createPnrOptions = new PnrAddMultiElementsOptions([
'actionCode' => PnrAddMultiElementsOptions::ACTION_END_TRANSACT_RETRIEVE,
'elements' => [
new PnrSecurity([
'identification' => 'WGFD00321',
'accessMode' => PnrSecurity::ACCESS_MODE_BOTH,
'indicator' => PnrSecurity::INDICATOR_GLOBAL
]);
]
]);
128 changes: 128 additions & 0 deletions src/Amadeus/Client/RequestOptions/Pnr/Element/PnrSecurity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?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\Element;

use Amadeus\Client\RequestOptions\Pnr\Element;

/**
* PnrSecurity
*
* @package Amadeus\Client\RequestOptions\Pnr\Element
* @author Dieter Devlieghere <dermikagh@gmail.com>
*/
class PnrSecurity extends Element
{
/**
* Access Mode "Both read and write"
*
* See documentation Amadeus Core webservices
* Functional documentation PNR_AddMultiElements
* [PNR segment or element name, coded codeset: 001C_1A_98.1.2]
*
* @var string
*/
const ACCESS_MODE_BOTH = "B";
/**
* Access Mode "No Access"
*
* See documentation Amadeus Core webservices
* Functional documentation PNR_AddMultiElements
* [PNR segment or element name, coded codeset: 001C_1A_98.1.2]
*
* @var string
*/
const ACCESS_MODE_NO_ACCESS = "N";
/**
* Access Mode "Read only"
*
* See documentation Amadeus Core webservices
* Functional documentation PNR_AddMultiElements
* [PNR segment or element name, coded codeset: 001C_1A_98.1.2]
*
* @var string
*/
const ACCESS_MODE_READ_ONLY = "R";
/**
* Access Mode "Write only"
*
* See documentation Amadeus Core webservices
* Functional documentation PNR_AddMultiElements
* [PNR segment or element name, coded codeset: 001C_1A_98.1.2]
*
* @var string
*/
const ACCESS_MODE_WRITE_ONLY = "W";
/**
* Access Mode "No access mode defined"
*
* See documentation Amadeus Core webservices
* Functional documentation PNR_AddMultiElements
* [PNR segment or element name, coded codeset: 001C_1A_98.1.2]
*
* @var string
*/
const ACCESS_MODE_UNDEFINED = "X";
/**
* Amadeus global core office identification
*
* See documentation Amadeus Core webservices
* Functional documentation PNR_AddMultiElements
* [Codeset for General indicator, coded (Ref: 107P 1A 98.1.13)]
*
* @var string
*/
const INDICATOR_GLOBAL = 'G';
/**
* IATA number
*
* See documentation Amadeus Core webservices
* Functional documentation PNR_AddMultiElements
* [Codeset for General indicator, coded (Ref: 107P 1A 98.1.13)]
*
* @var string
*/
const INDICATOR_IATA_NUMBER = 'I';
/**
* Pseudo-office identification
*
* See documentation Amadeus Core webservices
* Functional documentation PNR_AddMultiElements
* [Codeset for General indicator, coded (Ref: 107P 1A 98.1.13)]
*
* @var string
*/
const INDICATOR_PSEUDO_OFFICE = 'P';

/**
* @var string
*/
public $identification;
/**
* @var string
*/
public $accessMode;
/**
* @var string
*/
public $indicator;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class DataElementsIndiv extends WsMessageUtility
* @var ElementManagementData
*/
public $elementManagementData;
/**
* @var PnrSecurity
*/
public $pnrSecurity;
/**
* @var Accounting
Expand Down Expand Up @@ -292,6 +295,10 @@ protected function loadElement($element, $elementType)
/** @var Element\FareMiscellaneousInformation $element */
$this->fareElement = new FareElement($element->indicator, $element->passengerType, $element->freeText, $element->officeId);
break;
case 'PnrSecurity':
/** @var Element\PnrSecurity $element */
$this->pnrSecurity = new PnrSecurity($element);
break;
default:
throw new InvalidArgumentException('Element type '.$elementType.' is not supported');
}
Expand Down Expand Up @@ -325,6 +332,7 @@ protected function makeSegmentNameForRequestElement($elementType, $element)
'ManualIssuedTicket' => ElementManagementData::SEGNAME_MANUAL_DOCUMENT_REGISTRATION_WITH_ET_NUMBER,
'ScheduleChange' => ElementManagementData::SEGNAME_RECEIVE_FROM,
'FareMiscellaneousInformation' => null, // Special case - the type is a parameter.
'PnrSecurity' => ElementManagementData::SEGNAME_INDIVIDUAL_SECURITY,
];

if (array_key_exists($elementType, $sourceArray)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ class ElementManagementData
* FK - shadow AIR office ID element
*/
const SEGNAME_AIR_OFFICE_ID = 'FK';

/**
* Segment name "Individual Security"
*
* @var string
*/
const SEGNAME_INDIVIDUAL_SECURITY = "ES";

/**
* @var Reference
Expand Down
52 changes: 52 additions & 0 deletions src/Amadeus/Client/Struct/Pnr/AddMultiElements/PnrSecurity.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\Pnr\AddMultiElements;

use Amadeus\Client\RequestOptions\Pnr\Element\PnrSecurity as SecurityReOpts;

/**
* PnrSecurity
*
* @package Amadeus\Client\Struct\Pnr\AddMultiElements
* @author Dieter Devlieghere <dermikagh@gmail.com>
*/
class PnrSecurity
{
/**
* @var Security[]
*/
public $security;

public $securityInfo;

/**
* @var string
*/
public $indicator;

public function __construct(SecurityReOpts $securityReq)
{
$this->indicator = $securityReq->indicator;
$this->security[] = new Security($securityReq->identification, $securityReq->accessMode);
}
}
48 changes: 48 additions & 0 deletions src/Amadeus/Client/Struct/Pnr/AddMultiElements/Security.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\Pnr\AddMultiElements;

/**
* Security
*
* @package Amadeus\Client\Struct\Pnr\AddMultiElements
* @author Dieter Devlieghere <dermikagh@gmail.com>
*/
class Security
{
/**
* @var string
*/
public $identification;

/**
* @var string
*/
public $accessMode;

public function __construct($identification, $accessMode)
{
$this->identification = $identification;
$this->accessMode = $accessMode;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php


namespace Amadeus\Client\Struct\Pnr\AddMultiElements;

class SecurityInfo
{
}
21 changes: 21 additions & 0 deletions tests/Amadeus/Client/Struct/Pnr/AddMultiElementsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2088,5 +2088,26 @@ public function testMakePnrWithFormOfPaymentCreditCardWithFreeText()
$this->assertEquals('BERNDMUELLER', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->fopExtension[0]->newFopsDetails->chdData);
$this->assertEquals('CREDIT CARD FREE TEXT', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->formOfPayment->fop->freetext);
}

public function testPnrSecurityES(){
$createPnrOptions = new PnrCreatePnrOptions();
$createPnrOptions->receivedFrom = "unittest";
$createPnrOptions->actionCode = PnrCreatePnrOptions::ACTION_END_TRANSACT_RETRIEVE;
$createPnrOptions->elements[] = new Element\PnrSecurity(
[
'identification' => 'WGFD00321',
'accessMode' => Element\PnrSecurity::ACCESS_MODE_BOTH,
'indicator' => Element\PnrSecurity::INDICATOR_GLOBAL
]
);

$requestStruct = new AddMultiElements($createPnrOptions);

$this->assertEquals(2, count($requestStruct->dataElementsMaster->dataElementsIndiv));
$this->assertEquals('ES', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->elementManagementData->segmentName);
$this->assertEquals('WGFD00321', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->pnrSecurity->security[0]->identification);
$this->assertEquals('B', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->pnrSecurity->security[0]->accessMode);
$this->assertEquals('G', $requestStruct->dataElementsMaster->dataElementsIndiv[0]->pnrSecurity->indicator);
}
}

0 comments on commit 75674fb

Please sign in to comment.