From e14d5bbfa37d3c67d8ae082fda795abbbcc2c083 Mon Sep 17 00:00:00 2001 From: dieter Date: Fri, 26 Feb 2016 17:06:52 +0100 Subject: [PATCH] PNR_AddMultiElements support for Address & Accounting Information elements --- .../Pnr/Element/AccountingInfo.php | 61 +++++++++ .../RequestOptions/Pnr/Element/Address.php | 100 ++++++++++++++ .../Client/Struct/Pnr/AddMultiElements.php | 18 ++- .../Struct/Pnr/AddMultiElements/Account.php | 66 +++++++++ .../Pnr/AddMultiElements/Accounting.php | 56 ++++++++ .../Struct/Pnr/AddMultiElements/Address.php | 65 +++++++++ .../AddMultiElements/DataElementsIndiv.php | 6 + .../ElementManagementData.php | 39 +++++- .../Pnr/AddMultiElements/FreetextDetail.php | 2 + .../Pnr/AddMultiElements/OptionalData.php | 84 ++++++++++++ .../AddMultiElements/StructuredAddress.php | 129 ++++++++++++++++++ src/Amadeus/Client/Struct/Pnr/Cancel.php | 1 + .../Client/Struct/Pnr/Cancel/Element.php | 1 + .../Client/Struct/Pnr/Cancel/Elements.php | 1 + 14 files changed, 621 insertions(+), 8 deletions(-) create mode 100644 src/Amadeus/Client/RequestOptions/Pnr/Element/AccountingInfo.php create mode 100644 src/Amadeus/Client/RequestOptions/Pnr/Element/Address.php create mode 100644 src/Amadeus/Client/Struct/Pnr/AddMultiElements/Account.php create mode 100644 src/Amadeus/Client/Struct/Pnr/AddMultiElements/Accounting.php create mode 100644 src/Amadeus/Client/Struct/Pnr/AddMultiElements/Address.php create mode 100644 src/Amadeus/Client/Struct/Pnr/AddMultiElements/OptionalData.php create mode 100644 src/Amadeus/Client/Struct/Pnr/AddMultiElements/StructuredAddress.php diff --git a/src/Amadeus/Client/RequestOptions/Pnr/Element/AccountingInfo.php b/src/Amadeus/Client/RequestOptions/Pnr/Element/AccountingInfo.php new file mode 100644 index 000000000..d3833b406 --- /dev/null +++ b/src/Amadeus/Client/RequestOptions/Pnr/Element/AccountingInfo.php @@ -0,0 +1,61 @@ +freetextData = new FreetextData( $element->receivedFrom, FreetextDetail::TYPE_RECEIVE_FROM @@ -359,6 +361,20 @@ protected function createElement($element, &$tatooCounter) $createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_TICKETING_ELEMENT, $tatooCounter); $createdElement->ticketElement = new TicketElement($element); break; + case 'AccountingInfo': + /** @var Element\AccountingInfo $element */ + $createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_ACCOUNTING_INFORMATION, $tatooCounter); + $createdElement->accounting = new Accounting($element); + break; + case 'Address': + /** @var Element\Address $element */ + $createdElement = new DataElementsIndiv($element->type, $tatooCounter); + if ($element->type === ElementManagementData::SEGNAME_ADDRESS_BILLING_UNSTRUCTURED || ElementManagementData::SEGNAME_ADDRESS_MAILING_UNSTRUCTURED) { + $createdElement->freetextData = new FreetextData($element->freeText, FreetextDetail::TYPE_MAILING_ADDRESS); + } else { + $createdElement->structuredAddress = new StructuredAddress($element); + } + break; default: throw new InvalidArgumentException('Element type ' . $elementType . 'is not supported'); } diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Account.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Account.php new file mode 100644 index 000000000..e5bce6608 --- /dev/null +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Account.php @@ -0,0 +1,66 @@ +number = $number; + } +} diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Accounting.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Accounting.php new file mode 100644 index 000000000..371b65a37 --- /dev/null +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Accounting.php @@ -0,0 +1,56 @@ +account = new Account($params->accountNumber); + $this->account->costNumber = $params->costCenter; + $this->account->clientReference = $params->clientRefNumber; + $this->account->companyNumber = $params->companyIdNumber; + } +} diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Address.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Address.php new file mode 100644 index 000000000..b822428d0 --- /dev/null +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/Address.php @@ -0,0 +1,65 @@ + + */ +class Address +{ + const OPT_ADDRESS_LINE_1 = "A1"; + + + /** + * A1 Address line1 + * A2 Address line 2 + * CI City + * CO Country + * CY Company + * NA Name + * PO P.O. BOX + * ST State + * ZP Postal code + * + * @var string + */ + public $optionA1 = self::OPT_ADDRESS_LINE_1; + + /** + * @var string + */ + public $optionTextA1; + + /** + * Address constructor. + * + * @param string $addressLineOne + */ + public function __construct($addressLineOne) + { + $this->optionTextA1 = $addressLineOne; + } +} diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/DataElementsIndiv.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/DataElementsIndiv.php index 439b6fdfe..6150f2d0d 100644 --- a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/DataElementsIndiv.php +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/DataElementsIndiv.php @@ -39,6 +39,9 @@ class DataElementsIndiv */ public $elementManagementData; public $pnrSecurity; + /** + * @var Accounting + */ public $accounting; /** * To specify different kinds of remarks @@ -64,6 +67,9 @@ class DataElementsIndiv * @var FreetextData */ public $freetextData; + /** + * @var StructuredAddress + */ public $structuredAddress; public $optionElement; public $printer; diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/ElementManagementData.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/ElementManagementData.php index 7109c4d33..568f359f7 100644 --- a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/ElementManagementData.php +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/ElementManagementData.php @@ -36,6 +36,7 @@ class ElementManagementData * See documentation Amadeus Core webservices * Functional documentation PNR_AddMultiElements * [PNR segment or element name, coded codesets (Ref: 110P 1A 98.98.2)] + * * @var string */ const SEGNAME_RECEIVE_FROM = "RF"; @@ -45,52 +46,76 @@ class ElementManagementData * See documentation Amadeus Core webservices * Functional documentation PNR_AddMultiElements * [PNR segment or element name, coded codesets (Ref: 110P 1A 98.98.2)] + * * @var string */ const SEGNAME_GENERAL_REMARK = "RM"; /** * Segment name "Form Of Payment" + * * @var string */ const SEGNAME_FORM_OF_PAYMENT = "FP"; /** - * * Segment name "Ticketing Element" + * * @var string */ const SEGNAME_TICKETING_ELEMENT = "TK"; - /** * AP and related elements + * * @var string */ const SEGNAME_CONTACT_ELEMENT = "AP"; - /** * OSI - Other Service Information * * @var string */ const SEGNAME_OTHER_SERVICE_INFORMATION = "OS"; - /** * AI - Accounting Information * * @var string */ const SEGNAME_ACCOUNTING_INFORMATION = "AI"; - /** * SSR - Special Service Request * * @var string */ const SEGNAME_SPECIAL_SERVICE_REQUEST = "SSR"; + /** + * AB - Billing Address element + * + * @var string + */ + const SEGNAME_ADDRESS_BILLING_STRUCTURED = "AB"; + /** + * ABU - Unstructured Billing Address element + * + * @var string + */ + const SEGNAME_ADDRESS_BILLING_UNSTRUCTURED = "ABU"; + /** + * AM - Mailing address element + * + * @var string + */ + const SEGNAME_ADDRESS_MAILING_STRUCTURED = "AM"; + /** + * AMU - Unstructured Mailing Address Element + * + * @var string + */ + const SEGNAME_ADDRESS_MAILING_UNSTRUCTURED = "AMU"; /** * @var Reference */ public $reference; + /** * [PNR segment or element name, coded codesets (Ref: 110P 1A 98.98.2)] * @@ -101,8 +126,8 @@ class ElementManagementData /** * Create new ElementManagementData * - * @param string $segmentName one of the constants SEGNAME_* defined in this class - * @param int $tatoo optional tatoo nr to reference this element + * @param string|null $segmentName one of the constants SEGNAME_* defined in this class + * @param int|null $tatoo Optional tatoo nr to reference this element */ public function __construct($segmentName = null, $tatoo = null) { diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/FreetextDetail.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/FreetextDetail.php index 4f2c45678..4a5b5d2f5 100644 --- a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/FreetextDetail.php +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/FreetextDetail.php @@ -65,6 +65,8 @@ class FreetextDetail const TYPE_OTHER_SERVICE_INFO_OSI = "28"; + const TYPE_MAILING_ADDRESS = "P08"; + /** * @var string */ diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/OptionalData.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/OptionalData.php new file mode 100644 index 000000000..9c6224748 --- /dev/null +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/OptionalData.php @@ -0,0 +1,84 @@ + + */ +class OptionalData +{ + const OPT_ADDRESS_LINE_1 = "A1"; + + const OPT_ADDRESS_LINE_2 = "A2"; + + const OPT_CITY = "CI"; + + const OPT_COUNTRY = "CO"; + + const OPT_COMPANY = "CY"; + + const OPT_NAME = "NA"; + + const OPT_PO_BOX = "PO"; + + const OPT_STATE = "ST"; + + const OPT_ZIP_CODE = "ZP"; + + /** + * self::OPT_* + * + * A1 Address line1 + * A2 Address line 2 + * CI City + * CO Country + * CY Company + * NA Name + * PO P.O. BOX + * ST State + * ZP Postal code + * + * @var string + */ + public $option; + + /** + * @var string + */ + public $optionText; + + /** + * OptionalData constructor. + * + * @param string $text + * @param string $option self::OPT_* + */ + public function __construct($text, $option) + { + $this->optionText = $text; + $this->option = $option; + } +} diff --git a/src/Amadeus/Client/Struct/Pnr/AddMultiElements/StructuredAddress.php b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/StructuredAddress.php new file mode 100644 index 000000000..27013800b --- /dev/null +++ b/src/Amadeus/Client/Struct/Pnr/AddMultiElements/StructuredAddress.php @@ -0,0 +1,129 @@ + + */ +class StructuredAddress +{ + const TYPE_BILLING_ADDRESS = "2"; + + const TYPE_MAILING_ADDRESS = "P08"; + + const TYPE_MISC_ADDRESS = "P18"; + + const TYPE_HOME_MAILING_ADDRESS = "P24"; + + const TYPE_DELIVERY_MAILING_ADDRESS = "P25"; + + /** + * @var string + */ + public $informationType; + /** + * @var Address + */ + public $address; + + /** + * @var OptionalData + */ + public $optionalData = []; + + /** + * StructuredAddress constructor. + * + * @param AddressOptions $params + */ + public function __construct(AddressOptions $params) + { + $this->informationType = $this->makeType($params->type); + + $this->address = new Address($params->addressLine1); + + if (!empty($params->addressLine2)) { + $this->optionalData[] = new OptionalData( + $params->addressLine2, + OptionalData::OPT_ADDRESS_LINE_2 + ); + }; + + if (!empty($params->city)) { + $this->optionalData[] = new OptionalData( + $params->city, + OptionalData::OPT_CITY + ); + }; + + if (!empty($params->country)) { + $this->optionalData[] = new OptionalData( + $params->country, + OptionalData::OPT_COUNTRY + ); + }; + + if (!empty($params->name)) { + $this->optionalData[] = new OptionalData( + $params->name, + OptionalData::OPT_NAME + ); + }; + + if (!empty($params->state)) { + $this->optionalData[] = new OptionalData( + $params->state, + OptionalData::OPT_STATE + ); + }; + + if (!empty($params->zipCode)) { + $this->optionalData[] = new OptionalData( + $params->zipCode, + OptionalData::OPT_ZIP_CODE + ); + }; + } + + /** + * @param string $segmentType + * @return string|null + */ + protected function makeType($segmentType) + { + $infType = null; + + if ($segmentType === ElementManagementData::SEGNAME_ADDRESS_BILLING_STRUCTURED) { + $infType = self::TYPE_BILLING_ADDRESS; + } elseif ($segmentType === ElementManagementData::SEGNAME_ADDRESS_MAILING_STRUCTURED) { + $infType = self::TYPE_MAILING_ADDRESS; + } + + return $infType; + } +} diff --git a/src/Amadeus/Client/Struct/Pnr/Cancel.php b/src/Amadeus/Client/Struct/Pnr/Cancel.php index 0b106a5b0..8c101a3f5 100644 --- a/src/Amadeus/Client/Struct/Pnr/Cancel.php +++ b/src/Amadeus/Client/Struct/Pnr/Cancel.php @@ -32,6 +32,7 @@ * PNR_Cancel message structure * * @package Amadeus\Client\Struct\Pnr + * @author Dieter Devlieghere */ class Cancel extends BaseWsMessage { diff --git a/src/Amadeus/Client/Struct/Pnr/Cancel/Element.php b/src/Amadeus/Client/Struct/Pnr/Cancel/Element.php index f4c33eba7..2609526d8 100644 --- a/src/Amadeus/Client/Struct/Pnr/Cancel/Element.php +++ b/src/Amadeus/Client/Struct/Pnr/Cancel/Element.php @@ -26,6 +26,7 @@ * Element * * @package Amadeus\Client\Struct\Pnr\Cancel + * @author Dieter Devlieghere */ class Element { diff --git a/src/Amadeus/Client/Struct/Pnr/Cancel/Elements.php b/src/Amadeus/Client/Struct/Pnr/Cancel/Elements.php index 1aa97272c..68f4eb16d 100644 --- a/src/Amadeus/Client/Struct/Pnr/Cancel/Elements.php +++ b/src/Amadeus/Client/Struct/Pnr/Cancel/Elements.php @@ -26,6 +26,7 @@ * Elements * * @package Amadeus\Client\Struct\Pnr\Cancel + * @author Dieter Devlieghere */ class Elements {