From c1989a8c30e90dd11f52b97ca9baa5f0705adca6 Mon Sep 17 00:00:00 2001 From: Free Kashmir!!! Date: Sat, 9 May 2020 20:29:59 +0500 Subject: [PATCH 01/21] update composer.json change package name and code formatting. --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index d495a1a1..596dc227 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "alfallouji/dhl_api", + "name": "mutahhar/dhl-api", "description": "PHP library to communicate with the DHL XML Services.", @@ -9,11 +9,11 @@ "license": "LGPL-2.1", - "autoload": { + "autoload": { "classmap" : [ "DHL" ] - }, + }, - "authors": [ + "authors": [ { "name": "Bashar Al-Fallouji", "email": "bashar@alfallouji.com" From 6c0b6e0b7fe109bafb70809b0d37d01c5d25100d Mon Sep 17 00:00:00 2001 From: Free Kashmir!!! Date: Sun, 10 May 2020 20:00:38 +0500 Subject: [PATCH 02/21] revert name back incomposer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 596dc227..b23b46b8 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "mutahhar/dhl-api", + "name": "alfallouji/dhl_api", "description": "PHP library to communicate with the DHL XML Services.", From 29c444a180515ca9a7234bda8611c9ef80ed353b Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Wed, 13 May 2020 22:45:51 +0500 Subject: [PATCH 03/21] changed Email > subobject to falseContact datatype --- DHL/Datatype/AM/Contact.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DHL/Datatype/AM/Contact.php b/DHL/Datatype/AM/Contact.php index 9bfb0b54..8230f260 100644 --- a/DHL/Datatype/AM/Contact.php +++ b/DHL/Datatype/AM/Contact.php @@ -22,7 +22,7 @@ * @version 0.1 */ -namespace DHL\Datatype\AM; +namespace DHL\Datatype\AM; use DHL\Datatype\Base; /** @@ -47,37 +47,37 @@ class Contact extends Base 'subobject' => false, 'comment' => 'Name', 'maxLength' => '35', - ), + ), 'PhoneNumber' => array( 'type' => 'PhoneNumber', 'required' => false, 'subobject' => false, 'comment' => 'Phone Number', - ), + ), 'PhoneExtension' => array( 'type' => 'PhoneExtension', 'required' => false, 'subobject' => false, 'comment' => '', 'maxLength' => '5', - ), + ), 'FaxNumber' => array( 'type' => 'PhoneNumber', 'required' => false, 'subobject' => false, 'comment' => 'Phone Number', - ), + ), 'Telex' => array( 'type' => 'Telex', 'required' => false, 'subobject' => false, 'comment' => 'Telex number and answer back code', 'maxLength' => '25', - ), + ), 'Email' => array( 'type' => 'Email', 'required' => false, - 'subobject' => true, - ), + 'subobject' => false, + ), ); } From c881c998f5ee00fabbb2dd6cb1102c243f48d461 Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Wed, 13 May 2020 22:45:51 +0500 Subject: [PATCH 04/21] changed - Email > subobject to false in AM Contact datatype --- DHL/Datatype/AM/Contact.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DHL/Datatype/AM/Contact.php b/DHL/Datatype/AM/Contact.php index 9bfb0b54..8230f260 100644 --- a/DHL/Datatype/AM/Contact.php +++ b/DHL/Datatype/AM/Contact.php @@ -22,7 +22,7 @@ * @version 0.1 */ -namespace DHL\Datatype\AM; +namespace DHL\Datatype\AM; use DHL\Datatype\Base; /** @@ -47,37 +47,37 @@ class Contact extends Base 'subobject' => false, 'comment' => 'Name', 'maxLength' => '35', - ), + ), 'PhoneNumber' => array( 'type' => 'PhoneNumber', 'required' => false, 'subobject' => false, 'comment' => 'Phone Number', - ), + ), 'PhoneExtension' => array( 'type' => 'PhoneExtension', 'required' => false, 'subobject' => false, 'comment' => '', 'maxLength' => '5', - ), + ), 'FaxNumber' => array( 'type' => 'PhoneNumber', 'required' => false, 'subobject' => false, 'comment' => 'Phone Number', - ), + ), 'Telex' => array( 'type' => 'Telex', 'required' => false, 'subobject' => false, 'comment' => 'Telex number and answer back code', 'maxLength' => '25', - ), + ), 'Email' => array( 'type' => 'Email', 'required' => false, - 'subobject' => true, - ), + 'subobject' => false, + ), ); } From b658b74bf736168b617f319121feff1e70d20b42 Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Thu, 14 May 2020 18:50:16 +0500 Subject: [PATCH 05/21] added commercial invoice fields in shipment validation request for AM region. --- DHL/Datatype/AM/ExportDeclaration.php | 50 ++++++-- DHL/Datatype/AM/ExportLineItem.php | 45 ++++--- DHL/Datatype/AM/Shipper.php | 32 ++--- DHL/Datatype/Base.php | 148 +++++++++++----------- DHL/Entity/AM/ShipmentValidateRequest.php | 57 ++++++--- 5 files changed, 194 insertions(+), 138 deletions(-) diff --git a/DHL/Datatype/AM/ExportDeclaration.php b/DHL/Datatype/AM/ExportDeclaration.php index 22e481c3..b8aa4887 100644 --- a/DHL/Datatype/AM/ExportDeclaration.php +++ b/DHL/Datatype/AM/ExportDeclaration.php @@ -22,7 +22,7 @@ * @version 0.1 */ -namespace DHL\Datatype\AM; +namespace DHL\Datatype\AM; use DHL\Datatype\Base; /** @@ -45,7 +45,7 @@ class ExportDeclaration extends Base 'type' => '', 'required' => false, 'subobject' => false, - ), + ), 'IsPartiesRelation' => array( 'type' => 'YesNo', 'required' => false, @@ -53,33 +53,33 @@ class ExportDeclaration extends Base 'comment' => 'Boolean flag', 'length' => '1', 'enumeration' => 'Y,N', - ), + ), 'ECCN' => array( 'type' => '', 'required' => false, 'subobject' => false, - ), + ), 'SignatureName' => array( 'type' => 'SignatureName', 'required' => false, 'subobject' => false, 'comment' => 'Signature name', 'maxLength' => '35', - ), + ), 'SignatureTitle' => array( 'type' => 'SignatureTitle', 'required' => false, 'subobject' => false, 'comment' => 'Signature title', 'maxLength' => '35', - ), + ), 'ExportReason' => array( 'type' => 'ExportReason', 'required' => false, 'subobject' => false, 'comment' => 'Export reason', 'length' => '1', - ), + ), 'ExportReasonCode' => array( 'type' => 'ExportReasonCode', 'required' => false, @@ -87,14 +87,14 @@ class ExportDeclaration extends Base 'comment' => 'Export reason code (P:Permanent, T:Temporary, R:Re-Export)', 'length' => '1', 'enumeration' => 'P,T,R', - ), + ), 'SedNumber' => array( 'type' => 'SEDNumber', 'required' => false, 'subobject' => false, 'comment' => '', 'enumeration' => 'FTSR,XTN,SAS', - ), + ), 'SedNumberType' => array( 'type' => 'SEDNumberType', 'required' => false, @@ -102,16 +102,42 @@ class ExportDeclaration extends Base 'comment' => '', 'length' => '1', 'enumeration' => 'F,X,S', - ), + ), 'MxStateCode' => array( 'type' => '', 'required' => false, 'subobject' => false, - ), + ), 'ExportLineItem' => array( 'type' => 'ExportLineItem', 'required' => false, 'subobject' => true, - ), + 'multivalues' => true, + ), + 'InvoiceNumber' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + ), + 'InvoiceDate' => array( + 'type' => 'date', + 'required' => false, + 'subobject' => false, + ), + 'OtherCharges1' => array( + 'type' => 'number', + 'required' => false, + 'subobject' => false, + ), + 'OtherCharges2' => array( + 'type' => 'number', + 'required' => false, + 'subobject' => false, + ), + 'OtherCharges3' => array( + 'type' => 'number', + 'required' => false, + 'subobject' => false, + ), ); } diff --git a/DHL/Datatype/AM/ExportLineItem.php b/DHL/Datatype/AM/ExportLineItem.php index a0d496fe..a43d0bb5 100644 --- a/DHL/Datatype/AM/ExportLineItem.php +++ b/DHL/Datatype/AM/ExportLineItem.php @@ -22,7 +22,7 @@ * @version 0.1 */ -namespace DHL\Datatype\AM; +namespace DHL\Datatype\AM; use DHL\Datatype\Base; /** @@ -48,26 +48,26 @@ class ExportLineItem extends Base 'comment' => '', 'minInclusive' => '1', 'maxInclusive' => '200', - ), + ), 'Quantity' => array( 'type' => 'Quantity', 'required' => false, 'subobject' => false, 'comment' => 'Quantity', 'maxInclusive' => '32000', - ), + ), 'QuantityUnit' => array( 'type' => 'QuantityUnit', 'required' => false, 'subobject' => false, 'comment' => 'Quantity unit of measure (tens, hundreds, thousands, etc.)', 'maxLength' => '8', - ), + ), 'Description' => array( 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'Value' => array( 'type' => 'Money', 'required' => false, @@ -75,7 +75,7 @@ class ExportLineItem extends Base 'comment' => 'Monetary amount (with 2 decimal precision)', 'minInclusive' => '0.00', 'maxInclusive' => '9999999999.99', - ), + ), 'IsDomestic' => array( 'type' => 'YesNo', 'required' => false, @@ -83,7 +83,7 @@ class ExportLineItem extends Base 'comment' => 'Boolean flag', 'length' => '1', 'enumeration' => 'Y,N', - ), + ), 'CommodityCode' => array( 'type' => 'CommodityCode', 'required' => false, @@ -91,35 +91,50 @@ class ExportLineItem extends Base 'comment' => 'Commodity codes for shipment type', 'minLength' => '1', 'maxLength' => '20', - ), + ), 'ScheduleB' => array( 'type' => 'ScheduleB', 'required' => false, 'subobject' => false, 'comment' => 'Schedule B numner', 'maxLength' => '15', - ), + ), 'ECCN' => array( 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'Weight' => array( - 'type' => '', + 'type' => 'WeightSeg', 'required' => false, - 'subobject' => false, - ), + 'subobject' => true, + ), + 'GrossWeight' => array( + 'type' => 'WeightSeg', + 'required' => false, + 'subobject' => true, + ), 'License' => array( 'type' => '', 'required' => false, 'subobject' => false, - ), + ), 'LicenseSymbol' => array( 'type' => 'LicenseNumber', 'required' => false, 'subobject' => false, 'comment' => 'Export license number', 'maxLength' => '16', - ), + ), + 'ManufactureCountryCode' => array( + 'type' => 'CountryCode', + 'required' => false, + 'subobject' => false, + ), + 'ManufactureCountryName' => array( + 'type' => 'CountryName', + 'required' => false, + 'subobject' => false, + ), ); } diff --git a/DHL/Datatype/AM/Shipper.php b/DHL/Datatype/AM/Shipper.php index 0ad682f6..79156ed9 100644 --- a/DHL/Datatype/AM/Shipper.php +++ b/DHL/Datatype/AM/Shipper.php @@ -22,7 +22,7 @@ * @version 0.1 */ -namespace DHL\Datatype\AM; +namespace DHL\Datatype\AM; use DHL\Datatype\Base; /** @@ -47,14 +47,14 @@ class Shipper extends Base 'subobject' => false, 'comment' => 'Shipper\'s ID', 'maxLength' => '30', - ), + ), 'CompanyName' => array( 'type' => 'CompanyNameValidator', 'required' => false, 'subobject' => false, 'comment' => 'Name of company / business', 'maxLength' => '35', - ), + ), 'RegisteredAccount' => array( 'type' => 'AccountNumber', 'required' => false, @@ -62,81 +62,81 @@ class Shipper extends Base 'comment' => 'DHL Account Number', 'maxInclusive' => '9999999999', 'minInclusive' => '100000000', - ), + ), 'AddressLine' => array( 'type' => 'AddressLine', 'required' => false, 'subobject' => false, 'comment' => 'Address Line', 'maxLength' => '35', - ), + ), 'City' => array( 'type' => 'City', 'required' => false, 'subobject' => false, 'comment' => 'City name', 'maxLength' => '35', - ), + ), 'Division' => array( 'type' => 'Division', 'required' => false, 'subobject' => false, 'comment' => 'Division (e.g. state, prefecture, etc.) name', 'maxLength' => '35', - ), + ), 'DivisionCode' => array( 'type' => '', 'required' => false, 'subobject' => false, - ), + ), 'PostalCode' => array( 'type' => 'PostalCode', 'required' => false, 'subobject' => false, 'comment' => 'Full postal/zip code for address', - ), + ), 'OriginServiceAreaCode' => array( 'type' => 'OriginServiceAreaCode', 'required' => false, 'subobject' => false, 'comment' => 'OriginServiceAreaCode', 'maxLength' => '3', - ), + ), 'OriginFacilityCode' => array( 'type' => 'OriginFacilityCode', 'required' => false, 'subobject' => false, 'comment' => 'OriginFacilityCode', 'maxLength' => '3', - ), + ), 'CountryCode' => array( 'type' => 'CountryCode', 'required' => false, 'subobject' => false, 'comment' => 'ISO country codes', 'length' => '2', - ), + ), 'CountryName' => array( 'type' => 'CountryName', 'required' => false, 'subobject' => false, 'comment' => 'ISO country name', 'maxLength' => '35', - ), + ), 'FederalTaxId' => array( 'type' => '', 'required' => false, 'subobject' => false, - ), + ), 'StateTaxId' => array( 'type' => '', 'required' => false, 'subobject' => false, - ), + ), 'Contact' => array( 'type' => 'Contact', 'required' => false, 'subobject' => true, - ), + ), ); } diff --git a/DHL/Datatype/Base.php b/DHL/Datatype/Base.php index dd30b7a7..a3813f23 100644 --- a/DHL/Datatype/Base.php +++ b/DHL/Datatype/Base.php @@ -42,14 +42,14 @@ abstract class Base protected $_values = array(); /** - * Parent node name of the object + * Parent node name of the object * @var string */ protected $_xmlNodeName = null; /** * Class constructor - */ + */ public function __construct() { $this->initializeValues(); @@ -57,17 +57,17 @@ public function __construct() /** * Check if current object is empty or not - * + * * @return boolean True if it is, false otherwise */ public function isEmpty() { - foreach ($this->_values as $k => $v) + foreach ($this->_values as $k => $v) { if (is_object($v)) { - if (!$v->isEmpty()) - { + if (!$v->isEmpty()) + { return false; } } @@ -82,9 +82,9 @@ public function isEmpty() /** * Generates the XML to be sent to DHL - * + * * @param \XMLWriter $xmlWriter XMl Writer instance - * + * * @return void */ public function toXML(\XMLWriter $xmlWriter = null) @@ -97,7 +97,7 @@ public function toXML(\XMLWriter $xmlWriter = null) $displayedParentNode = false; $this->validateParameters(); - if (null !== $this->_xmlNodeName) + if (null !== $this->_xmlNodeName) { $parentNode = $this->_xmlNodeName; } @@ -109,15 +109,15 @@ public function toXML(\XMLWriter $xmlWriter = null) $xmlWriter->startElement($parentNode); - foreach ($this->_params as $name => $infos) + foreach ($this->_params as $name => $infos) { - if ($this->$name) + if ($this->$name) { - if (is_object($this->$name)) + if (is_object($this->$name)) { $this->$name->toXML($xmlWriter); } - elseif (is_array($this->$name)) + elseif (is_array($this->$name)) { if ('string' == $this->_params[$name]['type']) { @@ -128,18 +128,18 @@ public function toXML(\XMLWriter $xmlWriter = null) } else { - if (!isset($this->_params[$name]['disableParentNode']) || false == $this->_params[$name]['disableParentNode']) - { + if (!isset($this->_params[$name]['disableParentNode']) || false == $this->_params[$name]['disableParentNode']) + { $xmlWriter->startElement($name); } - foreach ($this->$name as $subelement) + foreach ($this->$name as $subelement) { $subelement->toXML($xmlWriter); } - if (!isset($this->_params[$name]['disableParentNode']) || false == $this->_params[$name]['disableParentNode']) - { + if (!isset($this->_params[$name]['disableParentNode']) || false == $this->_params[$name]['disableParentNode']) + { $xmlWriter->endElement(); } } @@ -156,18 +156,18 @@ public function toXML(\XMLWriter $xmlWriter = null) /** * Initialize object from an XML string - * + * * @param string $xml XML String - * + * * @return void */ - public function initFromXML($xml) + public function initFromXML($xml) { $xml = simplexml_load_string(str_replace('req:', '', $xml)); $parts = explode('\\', get_class($this)); $className = array_pop($parts); - foreach ($xml->children() as $child) - { + foreach ($xml->children() as $child) + { $childName = $child->getName(); if (isset($this->$childName) && is_object($this->$childName)) @@ -176,7 +176,7 @@ public function initFromXML($xml) } elseif (isset($this->_params[$childName]['multivalues']) && $this->_params[$childName]['multivalues']) { - foreach ($child->children() as $subchild) + foreach ($child->children() as $subchild) { $subchildName = $subchild->getName(); $childClassname = implode('\\', $parts) . '\\' . $this->_params[$subchildName]['type']; @@ -203,20 +203,20 @@ public function initFromXML($xml) /** * Setter for multivalues field - * + * * @param string $key Key to set * @param mixed $value Value to set - * + * * @return void * @throws \InvalidArgumentException Throws exception if key is not valid */ - public function __call($name, $arguments) + public function __call($name, $arguments) { $key = str_replace('add', '', $name); - if (isset($this->_params[$key . 's']) - && $this->_params[$key . 's']['type'] != 'string' - && isset($this->_params[$key. 's']['multivalues']) + if (isset($this->_params[$key . 's']) + && $this->_params[$key . 's']['type'] != 'string' + && isset($this->_params[$key. 's']['multivalues']) && true === $this->_params[$key . 's']['multivalues']) { $key .= 's'; @@ -227,14 +227,14 @@ public function __call($name, $arguments) throw new \InvalidArgumentException('Field : ' . $key . ' is not defined for ' . get_class($this)); } - if (empty($arguments) && count($arguments) > 1) + if (empty($arguments) && count($arguments) > 1) { throw new \InvalidArgumentException($name . ' method takes only 1 argument'); } $this->validateParameterType($key, $arguments[0]); $this->validateParameterValue($key, $arguments[0]); - + if (isset($this->_params[$key]['multivalues']) && $this->_params[$key]['multivalues']) { $this->_values[$key][] = $arguments[0]; @@ -244,28 +244,28 @@ public function __call($name, $arguments) throw new \InvalidArgumentException('This is not a multivalues field : ' . $key . ' called via method ' . $name); } } - + /** * Magic isset function - * + * * @param string $key Key to check - * - * @return bolean True if it exsits, false otherwise + * + * @return bolean True if it exsits, false otherwise */ - final public function __isset($key) + final public function __isset($key) { return array_key_exists($key, $this->_values); } /** * Magic getter function - * + * * @param string $key Key to get - * - * @return mixed Value of the property + * + * @return mixed Value of the property * @throws \InvalidArgumentException Throws exceptin if key is not valid */ - final public function __get($key) + final public function __get($key) { if (!array_key_exists($key, $this->_values)) { @@ -277,14 +277,14 @@ final public function __get($key) /** * Magic setter function - * + * * @param string $key Key to set * @param mixed $value Value to set - * + * * @return void * @throws \InvalidArgumentException Throws exception if key is not valid */ - final public function __set($key, $value) + final public function __set($key, $value) { if (!array_key_exists($key, $this->_values)) { @@ -295,7 +295,7 @@ final public function __set($key, $value) $this->validateParameterValue($key, $value); $this->_values[$key] = $value; } - + /** * Initialize property values bag * @@ -303,9 +303,9 @@ final public function __set($key, $value) */ protected function initializeValues() { - foreach ($this->_params as $name => $infos) + foreach ($this->_params as $name => $infos) { - if (isset($infos['multivalues']) && $infos['multivalues']) + if (isset($infos['multivalues']) && $infos['multivalues']) { $this->_values[$name] = array(); } @@ -326,24 +326,24 @@ protected function initializeValues() /** * Validate all parameters - * + * * @return boolean True upon success * @throws \InvalidArgumentException Throws exception if type not valid or if value are missing */ protected function validateParameters() { - foreach ($this->_params as $name => $infos) + foreach ($this->_params as $name => $infos) { - if ($this->_values[$name]) + if ($this->_values[$name]) { - if (is_array($this->_values[$name]) && isset($infos['subobject']) && true === $infos['subobject']) + if (is_array($this->_values[$name]) && isset($infos['subobject']) && true === $infos['subobject']) { foreach ($this->_values[$name] as $subelement) { $subelement->validateParameters(); } } - else + else { $this->validateParameterType($name, $this->_values[$name]); $this->validateParameterValue($name, $this->_values[$name]); @@ -356,37 +356,37 @@ protected function validateParameters() /** * Validate the type of a parameter - * + * * @param string $key Key to check * @param mixed $value Value to check - * + * * @return boolean True upon success * @throws \InvalidArgumentException Throws exception if type is not valid */ protected function validateParameterType($key, $value) { - if (null === $value) + if (null === $value) { return true; } - switch ($this->_params[$key]['type']) + switch ($this->_params[$key]['type']) { case 'string': - if (is_array($value) && isset($this->_params[$key]['multivalues']) && true === $this->_params[$key]['multivalues']) + if (is_array($value) && isset($this->_params[$key]['multivalues']) && true === $this->_params[$key]['multivalues']) { - foreach ($value as $subvalue) + foreach ($value as $subvalue) { - if (null !== $subvalue && $subvalue !== (string) $subvalue) + if (null !== $subvalue && $subvalue !== (string) $subvalue) { - throw new \InvalidArgumentException('Invalid type for ' . $key . '. It should be of type : ' + throw new \InvalidArgumentException('Invalid type for ' . $key . '. It should be of type : ' . $this->_params[$key]['type'] . ' but it has a value of : ' . $subvalue); } } } elseif ($value !== (string) $value) { - throw new \InvalidArgumentException('Invalid type for ' . $key . '. It should be of type : ' + throw new \InvalidArgumentException('Invalid type for ' . $key . '. It should be of type : ' . $this->_params[$key]['type'] . ' but it has a value of : ' . $value); } break; @@ -397,7 +397,7 @@ protected function validateParameterType($key, $value) $date = date(DATE_ISO8601, $timestamp); if (strtotime($date) !== strtotime($value)) { - throw new \InvalidArgumentException('Invalid type for ' . $key . '. It should be of type : ' + throw new \InvalidArgumentException('Invalid type for ' . $key . '. It should be of type : ' . $this->_params[$key]['type'] . ' but it has a value of : ' . $value); } break; @@ -405,9 +405,9 @@ protected function validateParameterType($key, $value) case 'positiveInteger': case 'negativeInteger': case 'integer': - if (false === filter_var((int) $value, FILTER_VALIDATE_INT) && ((int) $value != $value)) + if (false === filter_var((int) $value, FILTER_VALIDATE_INT) && ((int) $value != $value)) { - throw new \InvalidArgumentException('Invalid type for ' . $key . '. It should be of type : ' + throw new \InvalidArgumentException('Invalid type for ' . $key . '. It should be of type : ' . $this->_params[$key]['type'] . ' but it has a value of : ' . $value); } break; @@ -421,7 +421,7 @@ protected function validateParameterType($key, $value) $className = str_replace('Entity', 'DataType', implode('\\', $parts) . '\\' . $this->_params[$key]['type']); if (!$value instanceof $className) { - throw new \InvalidArgumentException('Invalid type for ' . $key . '. It should be of type : ' + throw new \InvalidArgumentException('Invalid type for ' . $key . '. It should be of type : ' . $this->_params[$key]['type'] . ' but it has a value of : "' . print_r($value, true) . '"'); } } @@ -433,27 +433,27 @@ protected function validateParameterType($key, $value) /** * Validate the value of a parameter - * + * * @param string $key Key to check * @param mixed $value Value to check - * + * * @return boolean True upon success * @throws \InvalidArgumentException Throws exception if value is not valid */ protected function validateParameterValue($key, $value) { - foreach ($this->_params[$key] as $type => $typeValue) + foreach ($this->_params[$key] as $type => $typeValue) { - switch ($type) + switch ($type) { case 'enumeration': $acceptedValues = explode(',', $typeValue); - if (!in_array($value, $acceptedValues)) + if (!in_array($value, $acceptedValues)) { throw new \InvalidArgumentException('Field ' . $key . ' cannot be set to value : ' . $value . '. Accepted values are : ' . $typeValue); } break; - + case 'length': if (strlen($value) != $typeValue) { @@ -474,14 +474,14 @@ protected function validateParameterValue($key, $value) throw new \InvalidArgumentException('Field ' . $key . ' has a size of ' . strlen($value) . ' and it cannot be less than this size : ' . $typeValue); } break; - + case 'minInclusive': if ($value < $typeValue) { throw new \InvalidArgumentException('Field ' . $key . ' cannot be smaller than ' . $typeValue); } break; - + case 'maxInclusive': if ($value > $typeValue) { @@ -492,7 +492,7 @@ protected function validateParameterValue($key, $value) case 'pattern': $matches = array(); $typeValue = "/" . $typeValue . "/"; - if (1 !== preg_match($typeValue, $value, $matches) || (strlen($value) > 0 && !$matches[0])) + if (1 !== preg_match($typeValue, $value, $matches) || (strlen($value) > 0 && !$matches[0])) { throw new \InvalidArgumentException('Field ' . $key . ' should match regex pattern : ' . $typeValue . ' and it has a value of ' . $value); } diff --git a/DHL/Entity/AM/ShipmentValidateRequest.php b/DHL/Entity/AM/ShipmentValidateRequest.php index be7cfcb8..f6a88dae 100644 --- a/DHL/Entity/AM/ShipmentValidateRequest.php +++ b/DHL/Entity/AM/ShipmentValidateRequest.php @@ -22,7 +22,7 @@ * @version 0.1 */ -namespace DHL\Entity\AM; +namespace DHL\Entity\AM; use DHL\Entity\Base; /** @@ -57,90 +57,90 @@ class ShipmentValidateRequest extends Base 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'NewShipper' => array( 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'LanguageCode' => array( 'type' => 'string', 'required' => false, 'subobject' => false, 'comment' => 'ISO Language Code', - ), + ), 'PiecesEnabled' => array( 'type' => 'string', 'required' => false, 'subobject' => false, 'comment' => 'Pieces Enabling Flag', 'enumeration' => 'Y,N', - ), + ), 'Billing' => array( 'type' => 'Billing', 'required' => false, 'subobject' => true, - ), + ), 'Consignee' => array( 'type' => 'Consignee', 'required' => false, 'subobject' => true, - ), + ), 'Commodity' => array( 'type' => 'Commodity', 'required' => false, 'subobject' => true, - ), + ), 'Dutiable' => array( 'type' => 'Dutiable', 'required' => false, 'subobject' => true, - ), + ), 'ExportDeclaration' => array( 'type' => 'ExportDeclaration', 'required' => false, 'subobject' => true, - ), + ), 'Reference' => array( 'type' => 'Reference', 'required' => false, 'subobject' => true, - ), + ), 'ShipmentDetails' => array( 'type' => 'ShipmentDetails', 'required' => false, 'subobject' => true, - ), + ), 'Shipper' => array( 'type' => 'Shipper', 'required' => false, 'subobject' => true, - ), + ), 'SpecialService' => array( 'type' => 'SpecialService', 'required' => false, 'subobject' => true, - ), + ), 'Place' => array( 'type' => 'Place', 'required' => false, 'subobject' => true, - ), + ), 'EProcShip' => array( 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'Airwaybill' => array( 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'DocImages' => array( 'type' => 'DocImages', 'required' => false, 'subobject' => true, - ), + ), 'LabelImageFormat' => array( 'type' => 'string', 'required' => false, @@ -149,16 +149,31 @@ class ShipmentValidateRequest extends Base 'minLength' => '3', 'maxLength' => '4', 'enumeration' => 'PDF,ZPL2,EPL2', - ), + ), 'RequestArchiveDoc' => array( 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'Label' => array( 'type' => 'Label', 'required' => false, 'subobject' => true, - ), + ), + 'UseDHLInvoice' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + ), + 'DHLInvoiceLanguageCode' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + ), + 'DHLInvoiceType' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + ), ); } From 784d57bf59294dea9e77868456532a40f6a2379d Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Mon, 18 May 2020 21:10:22 +0500 Subject: [PATCH 06/21] added schema version to DHL\Entity\AM\ShipmentValidateRequest --- DHL/Entity/AM/ShipmentValidateRequest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/DHL/Entity/AM/ShipmentValidateRequest.php b/DHL/Entity/AM/ShipmentValidateRequest.php index f6a88dae..5883126c 100644 --- a/DHL/Entity/AM/ShipmentValidateRequest.php +++ b/DHL/Entity/AM/ShipmentValidateRequest.php @@ -48,6 +48,18 @@ class ShipmentValidateRequest extends Base */ protected $_serviceXSD = 'ShipmentValidateRequest.xsd'; + /** + * @var string + * The schema version + */ + protected $_schemaVersion = '6.2'; + + /** + * Display the schema version + * @var boolean + */ + protected $_displaySchemaVersion = true; + /** * Parameters to be send in the body * @var array From 434fb857828d4447a26c8a35a956d114357cd0bf Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Mon, 18 May 2020 23:26:33 +0500 Subject: [PATCH 07/21] added metadata fields in request header for AM Shipment Validation Request --- DHL/Datatype/AM/MetaData.php | 55 +++++++++++++++++++++ DHL/Datatype/AM/Request.php | 9 +++- DHL/Entity/Base.php | 92 ++++++++++++++++++++++-------------- 3 files changed, 119 insertions(+), 37 deletions(-) create mode 100644 DHL/Datatype/AM/MetaData.php diff --git a/DHL/Datatype/AM/MetaData.php b/DHL/Datatype/AM/MetaData.php new file mode 100644 index 00000000..0bf12691 --- /dev/null +++ b/DHL/Datatype/AM/MetaData.php @@ -0,0 +1,55 @@ + array( + 'type' => 'string', + 'required' => true, + 'subobject' => false, + ), + 'SoftwareVersion' => array( + 'type' => 'string', + 'required' => true, + 'subobject' => false, + ), + ); +} diff --git a/DHL/Datatype/AM/Request.php b/DHL/Datatype/AM/Request.php index 6c4312ae..6340ac2a 100644 --- a/DHL/Datatype/AM/Request.php +++ b/DHL/Datatype/AM/Request.php @@ -22,7 +22,7 @@ * @version 0.1 */ -namespace DHL\Datatype\AM; +namespace DHL\Datatype\AM; use DHL\Datatype\Base; /** @@ -45,6 +45,11 @@ class Request extends Base 'type' => 'ServiceHeader', 'required' => false, 'subobject' => true, - ), + ), + 'MetaData' => array( + 'type' => 'MetaData', + 'required' => false, + 'subobject' => true, + ), ); } diff --git a/DHL/Entity/Base.php b/DHL/Entity/Base.php index 7a568b34..57d65df0 100644 --- a/DHL/Entity/Base.php +++ b/DHL/Entity/Base.php @@ -63,11 +63,26 @@ abstract class Base extends BaseDataType 'Password' => array( 'type' => 'string', 'required' => true, + ) + ); + + /** + * Parameters to be used in the MetaData Header + * @var array + */ + protected $_metaDataParams = array( + 'SoftwareName' => array( + 'type' => 'string', + 'required' => true, + ), + 'SoftwareVersion' => array( + 'type' => 'string', + 'required' => true, ), ); /** - * Parameters to be used in the body + * Parameters to be used in the body * @var array */ protected $_bodyParams = array(); @@ -103,7 +118,7 @@ abstract class Base extends BaseDataType protected $_displaySchemaVersion = false; /** - * Parent node name of the object + * Parent node name of the object * @var string */ protected $_xmlNodeName = null; @@ -116,10 +131,10 @@ abstract class Base extends BaseDataType /** * Class constructor - */ + */ public function __construct() { - $this->_params = array_merge($this->_headerParams, $this->_bodyParams); + $this->_params = array_merge($this->_headerParams, $this->_metaDataParams, $this->_bodyParams); $this->initializeValues(); } @@ -127,7 +142,7 @@ public function __construct() * Generates the XML to be sent to DHL * * @param \XMLWriter $xmlWriter XMl Writer instance - * + * * @return string */ public function toXML(\XMLWriter $xmlWriter = null) @@ -138,40 +153,47 @@ public function toXML(\XMLWriter $xmlWriter = null) $xmlWriter->openMemory(); $xmlWriter->setIndent(true); $xmlWriter->startDocument('1.0', 'UTF-8'); - + $xmlWriter->startElement('req:' . $this->_serviceName); $xmlWriter->writeAttribute('xmlns:req', self::DHL_REQ); $xmlWriter->writeAttribute('xmlns:xsi', self::DHL_XSI); $xmlWriter->writeAttribute('xsi:schemaLocation', self::DHL_REQ . ' ' .$this->_serviceXSD); - - if ($this->_displaySchemaVersion) + + if ($this->_displaySchemaVersion) { $xmlWriter->writeAttribute('schemaVersion', $this->_schemaVersion); } - if (null !== $this->_xmlNodeName) + if (null !== $this->_xmlNodeName) { $xmlWriter->startElement($this->_xmlNodeName); } $xmlWriter->startElement('Request'); $xmlWriter->startElement('ServiceHeader'); - foreach ($this->_headerParams as $name => $infos) + foreach ($this->_headerParams as $name => $infos) { $xmlWriter->writeElement($name, $this->$name); } - $xmlWriter->endElement(); // End of Request $xmlWriter->endElement(); // End of ServiceHeader - foreach ($this->_bodyParams as $name => $infos) + $xmlWriter->startElement('MetaData'); + foreach ($this->_metaDataParams as $name => $infos) + { + $xmlWriter->writeElement($name, $this->$name); + } + $xmlWriter->endElement(); // End of MetaData + $xmlWriter->endElement(); // End of Request + + foreach ($this->_bodyParams as $name => $infos) { if ($this->$name) { - if (is_object($this->$name)) + if (is_object($this->$name)) { $this->$name->toXML($xmlWriter); } - elseif (is_array($this->$name)) + elseif (is_array($this->$name)) { if ('string' == $this->_params[$name]['type']) { @@ -182,18 +204,18 @@ public function toXML(\XMLWriter $xmlWriter = null) } else { - if (!isset($this->_params[$name]['disableParentNode']) || false == $this->_params[$name]['disableParentNode']) - { + if (!isset($this->_params[$name]['disableParentNode']) || false == $this->_params[$name]['disableParentNode']) + { $xmlWriter->startElement($name); } - foreach ($this->$name as $subelement) + foreach ($this->$name as $subelement) { $subelement->toXML($xmlWriter); } - if (!isset($this->_params[$name]['disableParentNode']) || false == $this->_params[$name]['disableParentNode']) - { + if (!isset($this->_params[$name]['disableParentNode']) || false == $this->_params[$name]['disableParentNode']) + { $xmlWriter->endElement(); } } @@ -208,25 +230,25 @@ public function toXML(\XMLWriter $xmlWriter = null) $xmlWriter->endElement(); // End of parent node // End of class name tag - if (null !== $this->_xmlNodeName) + if (null !== $this->_xmlNodeName) { $xmlWriter->endElement(); } $xmlWriter->endDocument(); - + return $xmlWriter->outputMemory(true); } /** * Initialize object from an XML string - * + * * @param string $xml XML String - * + * * @return void * @throws \Exception Exception thrown if response returned has an error */ - public function initFromXML($xml) + public function initFromXML($xml) { $xml = simplexml_load_string(str_replace('req:', '', $xml)); @@ -238,8 +260,8 @@ public function initFromXML($xml) $parts = explode('\\', get_class($this)); $className = array_pop($parts); - foreach ($xml->children() as $child) - { + foreach ($xml->children() as $child) + { $childName = $child->getName(); switch ($childName) { @@ -257,7 +279,7 @@ public function initFromXML($xml) } elseif (isset($this->_params[$childName]['multivalues']) && $this->_params[$childName]['multivalues']) { - foreach ($child->children() as $subchild) + foreach ($child->children() as $subchild) { $subchildName = $subchild->getName(); if ($subchild->count() > 1) @@ -277,7 +299,7 @@ public function initFromXML($xml) $childObj = new $childClassname(); $childObj->initFromXml($subchild->asXML()); } - + $addMethodName = 'add' . ucfirst($subchildName); $this->$addMethodName($childObj); } @@ -297,11 +319,11 @@ public function initFromXML($xml) */ protected function initializeValues() { - foreach ($this->_params as $name => $infos) + foreach ($this->_params as $name => $infos) { if (!$this->_isSubobject && isset($infos['subobject']) && $infos['subobject']) { - if (isset($infos['multivalues']) && $infos['multivalues']) + if (isset($infos['multivalues']) && $infos['multivalues']) { $this->_values[$name] = array(); } @@ -324,29 +346,29 @@ protected function initializeValues() /** * Validate all parameters - * + * * @return boolean True upon success * @throws \InvalidArgumentException Throws exception if type not valid or if value are missing */ protected function validateParameters() { - foreach ($this->_params as $name => $infos) + foreach ($this->_params as $name => $infos) { if (isset($infos['required']) && true === $infos['required'] && $this->_values[$name] === null) { throw new \InvalidArgumentException('Field ' . $name . ' has no value'); } - if ($this->_values[$name]) + if ($this->_values[$name]) { - if (is_array($this->_values[$name])) + if (is_array($this->_values[$name])) { foreach ($this->_values[$name] as $subelement) { $subelement->validateParameters(); } } - else + else { $this->validateParameterType($name, $this->_values[$name]); $this->validateParameterValue($name, $this->_values[$name]); From 09ea39018d55368e599c52aacaea3260dc05b75e Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Tue, 19 May 2020 19:58:15 +0500 Subject: [PATCH 08/21] fix - added 'disableParentNode' parameter to ExportLineItem element. --- DHL/Datatype/AM/ExportDeclaration.php | 1 + 1 file changed, 1 insertion(+) diff --git a/DHL/Datatype/AM/ExportDeclaration.php b/DHL/Datatype/AM/ExportDeclaration.php index b8aa4887..3f19c7e3 100644 --- a/DHL/Datatype/AM/ExportDeclaration.php +++ b/DHL/Datatype/AM/ExportDeclaration.php @@ -113,6 +113,7 @@ class ExportDeclaration extends Base 'required' => false, 'subobject' => true, 'multivalues' => true, + 'disableParentNode' => true, ), 'InvoiceNumber' => array( 'type' => 'string', From 7001dbdbe40903a6af1993764934ff2276732f02 Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Tue, 19 May 2020 19:59:46 +0500 Subject: [PATCH 09/21] fix - formatting: removing spaces. --- DHL/Datatype/AM/ShipmentDetails.php | 46 +++++++++++++-------------- DHL/Datatype/AP/ExportDeclaration.php | 24 +++++++------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/DHL/Datatype/AM/ShipmentDetails.php b/DHL/Datatype/AM/ShipmentDetails.php index cefd5480..6a908218 100644 --- a/DHL/Datatype/AM/ShipmentDetails.php +++ b/DHL/Datatype/AM/ShipmentDetails.php @@ -22,7 +22,7 @@ * @version 0.1 */ -namespace DHL\Datatype\AM; +namespace DHL\Datatype\AM; use DHL\Datatype\Base; /** @@ -45,13 +45,13 @@ class ShipmentDetails extends Base 'type' => 'positiveInteger', 'required' => false, 'subobject' => false, - ), + ), 'Pieces' => array( 'type' => 'Piece', 'required' => false, 'subobject' => true, 'multivalues' => true, - ), + ), 'Weight' => array( 'type' => 'Weight', 'required' => false, @@ -60,7 +60,7 @@ class ShipmentDetails extends Base 'fractionDigits' => '1', 'maxInclusive' => '999999.9', 'totalDigits' => '7', - ), + ), 'WeightUnit' => array( 'type' => 'WeightUnit', 'required' => false, @@ -68,14 +68,14 @@ class ShipmentDetails extends Base 'comment' => 'Unit of weight measurement (L:Pounds)', 'length' => '1', 'enumeration' => 'K,L', - ), + ), 'ProductCode' => array( 'type' => 'ProductCode', 'required' => false, 'subobject' => false, - 'comment' => 'DHL product code - D : US Overnight (>0.5 lb) and Worldwide Express Non-dutiable (>0.5 lb) - X : USA Express Envelope (less than or = 0.5 lb) and Worldwide Express-International Express Envelope (less than or = 0.5 lb) + 'comment' => 'DHL product code + D : US Overnight (>0.5 lb) and Worldwide Express Non-dutiable (>0.5 lb) + X : USA Express Envelope (less than or = 0.5 lb) and Worldwide Express-International Express Envelope (less than or = 0.5 lb) W : Worldwide Express-Dutiable Y : DHL Second Day Express . Must be Express Envelop with weight lessthan or = 0.5 lb G : DHL Second Day . Weight > 0.5 lb or not an express envelop @@ -83,14 +83,14 @@ class ShipmentDetails extends Base 'pattern' => '([A-Z0-9])*', 'minLength' => '1', 'maxLength' => '4', - ), + ), 'GlobalProductCode' => array( 'type' => 'ProductCode', 'required' => false, 'subobject' => false, - 'comment' => 'DHL product code - D : US Overnight (>0.5 lb) and Worldwide Express Non-dutiable (>0.5 lb) - X : USA Express Envelope (less than or = 0.5 lb) and Worldwide Express-International Express Envelope (less than or = 0.5 lb) + 'comment' => 'DHL product code + D : US Overnight (>0.5 lb) and Worldwide Express Non-dutiable (>0.5 lb) + X : USA Express Envelope (less than or = 0.5 lb) and Worldwide Express-International Express Envelope (less than or = 0.5 lb) W : Worldwide Express-Dutiable Y : DHL Second Day Express . Must be Express Envelop with weight lessthan or = 0.5 lb G : DHL Second Day . Weight > 0.5 lb or not an express envelop @@ -98,7 +98,7 @@ class ShipmentDetails extends Base 'pattern' => '([A-Z0-9])*', 'minLength' => '1', 'maxLength' => '4', - ), + ), 'LocalProductCode' => array( 'type' => 'LocalProductCode', 'required' => false, @@ -106,20 +106,20 @@ class ShipmentDetails extends Base 'comment' => '', 'minLength' => '1', 'maxLength' => '4', - ), + ), 'Date' => array( 'type' => 'Date', 'required' => false, 'subobject' => false, 'comment' => 'Date only', - ), + ), 'Contents' => array( 'type' => 'ShipmentContents', 'required' => false, 'subobject' => false, 'comment' => 'Shipment contents description', 'maxLength' => '90', - ), + ), 'DoorTo' => array( 'type' => 'DoorTo', 'required' => false, @@ -127,7 +127,7 @@ class ShipmentDetails extends Base 'comment' => 'Defines the type of delivery service that applies to the shipment', 'length' => '2', 'enumeration' => 'DD,DA,AA,DC', - ), + ), 'DimensionUnit' => array( 'type' => 'DimensionUnit', 'required' => false, @@ -135,7 +135,7 @@ class ShipmentDetails extends Base 'comment' => 'Dimension Unit I (inches)', 'length' => '1', 'enumeration' => 'C,I', - ), + ), 'InsuredAmount' => array( 'type' => 'Money', 'required' => false, @@ -143,7 +143,7 @@ class ShipmentDetails extends Base 'comment' => 'Monetary amount (with 2 decimal precision)', 'minInclusive' => '0.00', 'maxInclusive' => '9999999999.99', - ), + ), 'PackageType' => array( 'type' => 'PackageType', 'required' => false, @@ -151,7 +151,7 @@ class ShipmentDetails extends Base 'comment' => 'Package Type (EE: DHL Express Envelope, OD:Other DHL Packaging, CP:Customer-provided.Ground shipments must choose CP)', 'length' => '2', 'enumeration' => 'EE,OD,CP', - ), + ), 'IsDutiable' => array( 'type' => 'YesNo', 'required' => false, @@ -159,14 +159,14 @@ class ShipmentDetails extends Base 'comment' => 'Boolean flag', 'length' => '1', 'enumeration' => 'Y,N', - ), + ), 'CurrencyCode' => array( 'type' => 'CurrencyCode', 'required' => false, 'subobject' => false, 'comment' => 'ISO currency code', 'length' => '3', - ), + ), 'CustData' => array( 'type' => 'CustData', 'required' => false, @@ -174,6 +174,6 @@ class ShipmentDetails extends Base 'comment' => 'CustData', 'minLength' => '1', 'maxLength' => '100', - ), + ), ); } diff --git a/DHL/Datatype/AP/ExportDeclaration.php b/DHL/Datatype/AP/ExportDeclaration.php index 1d8fbe9f..51c150f9 100644 --- a/DHL/Datatype/AP/ExportDeclaration.php +++ b/DHL/Datatype/AP/ExportDeclaration.php @@ -22,7 +22,7 @@ * @version 0.1 */ -namespace DHL\Datatype\AP; +namespace DHL\Datatype\AP; use DHL\Datatype\Base; /** @@ -45,7 +45,7 @@ class ExportDeclaration extends Base 'type' => '', 'required' => false, 'subobject' => false, - ), + ), 'IsPartiesRelation' => array( 'type' => 'YesNo', 'required' => false, @@ -53,33 +53,33 @@ class ExportDeclaration extends Base 'comment' => 'Boolean flag', 'length' => '1', 'enumeration' => 'Y,N', - ), + ), 'ECCN' => array( 'type' => '', 'required' => false, 'subobject' => false, - ), + ), 'SignatureName' => array( 'type' => 'SignatureName', 'required' => false, 'subobject' => false, 'comment' => 'Signature name', 'maxLength' => '35', - ), + ), 'SignatureTitle' => array( 'type' => 'SignatureTitle', 'required' => false, 'subobject' => false, 'comment' => 'Signature title', 'maxLength' => '35', - ), + ), 'ExportReason' => array( 'type' => 'ExportReason', 'required' => false, 'subobject' => false, 'comment' => 'Export reason', 'length' => '1', - ), + ), 'ExportReasonCode' => array( 'type' => 'ExportReasonCode', 'required' => false, @@ -87,14 +87,14 @@ class ExportDeclaration extends Base 'comment' => 'Export reason code (P:Permanent, T:Temporary, R:Re-Export)', 'length' => '1', 'enumeration' => 'P,T,R', - ), + ), 'SedNumber' => array( 'type' => 'SEDNumber', 'required' => false, 'subobject' => false, 'comment' => '', 'enumeration' => 'FTSR,XTN,SAS', - ), + ), 'SedNumberType' => array( 'type' => 'SEDNumberType', 'required' => false, @@ -102,16 +102,16 @@ class ExportDeclaration extends Base 'comment' => '', 'length' => '1', 'enumeration' => 'F,X,S', - ), + ), 'MxStateCode' => array( 'type' => '', 'required' => false, 'subobject' => false, - ), + ), 'ExportLineItem' => array( 'type' => 'ExportLineItem', 'required' => false, 'subobject' => true, - ), + ), ); } From b7f7ebaaa41836a1df0e48878be63189570a558d Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Tue, 19 May 2020 20:02:27 +0500 Subject: [PATCH 10/21] add - RegionCode parameter to AM\ShipmentValidateRequest. fix - rearranged commercial invoice parameters in AM\ShipmentValidateRequest. --- DHL/Entity/AM/ShipmentValidateRequest.php | 39 ++++++++++++++--------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/DHL/Entity/AM/ShipmentValidateRequest.php b/DHL/Entity/AM/ShipmentValidateRequest.php index 5883126c..c84bd13d 100644 --- a/DHL/Entity/AM/ShipmentValidateRequest.php +++ b/DHL/Entity/AM/ShipmentValidateRequest.php @@ -65,6 +65,15 @@ class ShipmentValidateRequest extends Base * @var array */ protected $_bodyParams = array( + 'RegionCode' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + 'comment' => 'RegionCode', + 'minLength' => '2', + 'maxLength' => '2', + 'enumeration' => 'AP,EU,AM', + ), 'RequestedPickupTime' => array( 'type' => 'string', 'required' => false, @@ -108,6 +117,21 @@ class ShipmentValidateRequest extends Base 'required' => false, 'subobject' => true, ), + 'UseDHLInvoice' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + ), + 'DHLInvoiceLanguageCode' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + ), + 'DHLInvoiceType' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + ), 'ExportDeclaration' => array( 'type' => 'ExportDeclaration', 'required' => false, @@ -172,20 +196,5 @@ class ShipmentValidateRequest extends Base 'required' => false, 'subobject' => true, ), - 'UseDHLInvoice' => array( - 'type' => 'string', - 'required' => false, - 'subobject' => false, - ), - 'DHLInvoiceLanguageCode' => array( - 'type' => 'string', - 'required' => false, - 'subobject' => false, - ), - 'DHLInvoiceType' => array( - 'type' => 'string', - 'required' => false, - 'subobject' => false, - ), ); } From 80209daacdb6a945a7ebd789811bb61e41dd08c4 Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Tue, 19 May 2020 20:05:43 +0500 Subject: [PATCH 11/21] add - added schema version related properties to AM\GetQuote --- DHL/Entity/AM/GetQuote.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/DHL/Entity/AM/GetQuote.php b/DHL/Entity/AM/GetQuote.php index 6e00f010..e602e08b 100644 --- a/DHL/Entity/AM/GetQuote.php +++ b/DHL/Entity/AM/GetQuote.php @@ -22,7 +22,7 @@ * @version 0.1 */ -namespace DHL\Entity\AM; +namespace DHL\Entity\AM; use DHL\Entity\Base; /** @@ -43,11 +43,24 @@ class GetQuote extends Base protected $_serviceXSD = 'DCT-req.xsd'; /** - * Parent node name of the object + * Parent node name of the object * @var string */ protected $_xmlNodeName = 'GetQuote'; + /** + * @var string + * The schema version + */ + protected $_schemaVersion = '6.2'; + + /** + * Display the schema version + * @var boolean + */ + protected $_displaySchemaVersion = true; + + /** * Parameters to be send in the body * @var array @@ -59,27 +72,27 @@ class GetQuote extends Base 'subobject' => true, 'multivalues' => false, 'minOccurs' => 1, - ), + ), 'BkgDetails' => array( 'type' => 'BkgDetailsType', 'required' => false, 'subobject' => true, 'multivalues' => false, 'minOccurs' => 1, - ), + ), 'To' => array( 'type' => 'DCTTo', 'required' => false, 'subobject' => true, 'multivalues' => false, 'minOccurs' => 1, - ), + ), 'Dutiable' => array( 'type' => 'DCTDutiable', 'required' => false, 'subobject' => true, 'multivalues' => false, 'minOccurs' => 0, - ), + ), ); } From 9d2d4c28552113d7eac93dbdbf342abe576f7e36 Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Tue, 19 May 2020 20:59:18 +0500 Subject: [PATCH 12/21] add - added Weight and GrossWeight elements to AM\ExportLineItem --- DHL/Datatype/AM/ExportLineItem.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DHL/Datatype/AM/ExportLineItem.php b/DHL/Datatype/AM/ExportLineItem.php index a43d0bb5..1945a480 100644 --- a/DHL/Datatype/AM/ExportLineItem.php +++ b/DHL/Datatype/AM/ExportLineItem.php @@ -105,12 +105,12 @@ class ExportLineItem extends Base 'subobject' => false, ), 'Weight' => array( - 'type' => 'WeightSeg', + 'type' => 'Weight', 'required' => false, 'subobject' => true, ), 'GrossWeight' => array( - 'type' => 'WeightSeg', + 'type' => 'GrossWeight', 'required' => false, 'subobject' => true, ), From 494748ec5b5812dab7d78f4907c5cdcc63ff7d75 Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Tue, 19 May 2020 21:00:41 +0500 Subject: [PATCH 13/21] fix - rearranged attributes. --- DHL/Datatype/AM/ExportDeclaration.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/DHL/Datatype/AM/ExportDeclaration.php b/DHL/Datatype/AM/ExportDeclaration.php index 3f19c7e3..ff4fd0eb 100644 --- a/DHL/Datatype/AM/ExportDeclaration.php +++ b/DHL/Datatype/AM/ExportDeclaration.php @@ -108,13 +108,6 @@ class ExportDeclaration extends Base 'required' => false, 'subobject' => false, ), - 'ExportLineItem' => array( - 'type' => 'ExportLineItem', - 'required' => false, - 'subobject' => true, - 'multivalues' => true, - 'disableParentNode' => true, - ), 'InvoiceNumber' => array( 'type' => 'string', 'required' => false, @@ -140,5 +133,12 @@ class ExportDeclaration extends Base 'required' => false, 'subobject' => false, ), + 'ExportLineItem' => array( + 'type' => 'ExportLineItem', + 'required' => false, + 'subobject' => true, + 'multivalues' => true, + 'disableParentNode' => true, + ), ); } From cd494de7eea226fa700dee9bb251fd8c46003a24 Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Tue, 19 May 2020 21:19:22 +0500 Subject: [PATCH 14/21] fix - renamed ShipmentValidateRequest to ShipmentRequest cause DHL api is giving error when sending request with "req:ShipmentRequest" root element. --- ...alidateRequest.php => ShipmentRequest.php} | 10 ++--- DHL/Entity/AP/ShipmentValidateRequest.php | 40 ++++++++--------- DHL/Entity/EA/ShipmentValidateRequest.php | 44 +++++++++---------- 3 files changed, 47 insertions(+), 47 deletions(-) rename DHL/Entity/AM/{ShipmentValidateRequest.php => ShipmentRequest.php} (95%) diff --git a/DHL/Entity/AM/ShipmentValidateRequest.php b/DHL/Entity/AM/ShipmentRequest.php similarity index 95% rename from DHL/Entity/AM/ShipmentValidateRequest.php rename to DHL/Entity/AM/ShipmentRequest.php index c84bd13d..04f40e93 100644 --- a/DHL/Entity/AM/ShipmentValidateRequest.php +++ b/DHL/Entity/AM/ShipmentRequest.php @@ -15,7 +15,7 @@ */ /** - * File: ShipmentValidateRequest.php + * File: ShipmentRequest.php * Project: DHL API * * @author Al-Fallouji Bashar @@ -26,9 +26,9 @@ use DHL\Entity\Base; /** - * ShipmentValidateRequest Request model for DHL API + * ShipmentRequest Request model for DHL API */ -class ShipmentValidateRequest extends Base +class ShipmentRequest extends Base { /** * Is this object a subobject @@ -40,13 +40,13 @@ class ShipmentValidateRequest extends Base * Name of the service * @var string */ - protected $_serviceName = 'ShipmentValidateRequest'; + protected $_serviceName = 'ShipmentRequest'; /** * @var string * Service XSD */ - protected $_serviceXSD = 'ShipmentValidateRequest.xsd'; + protected $_serviceXSD = 'ShipmentRequest.xsd'; /** * @var string diff --git a/DHL/Entity/AP/ShipmentValidateRequest.php b/DHL/Entity/AP/ShipmentValidateRequest.php index 9926da5b..6c41fe85 100644 --- a/DHL/Entity/AP/ShipmentValidateRequest.php +++ b/DHL/Entity/AP/ShipmentValidateRequest.php @@ -15,18 +15,18 @@ */ /** - * File: ShipmentValidateRequest.php + * File: ShipmentRequest.php * Project: DHL API * * @author Al-Fallouji Bashar * @version 0.1 */ -namespace DHL\Entity\AP; +namespace DHL\Entity\AP; use DHL\Entity\Base; /** - * ShipmentValidateRequest Request model for DHL API + * ShipmentRequest Request model for DHL API */ class ShipmentValidateRequest extends Base { @@ -58,74 +58,74 @@ class ShipmentValidateRequest extends Base 'required' => false, 'subobject' => false, 'comment' => 'ISO Language Code', - ), + ), 'PiecesEnabled' => array( 'type' => 'string', 'required' => false, 'subobject' => false, 'comment' => 'Pieces Enabling Flag', 'enumeration' => 'Y,N', - ), + ), 'Billing' => array( 'type' => 'Billing', 'required' => false, 'subobject' => true, - ), + ), 'Consignee' => array( 'type' => 'Consignee', 'required' => false, 'subobject' => true, - ), + ), 'Commodity' => array( 'type' => 'Commodity', 'required' => false, 'subobject' => true, - ), + ), 'Dutiable' => array( 'type' => 'Dutiable', 'required' => false, 'subobject' => true, - ), + ), 'ExportDeclaration' => array( 'type' => 'ExportDeclaration', 'required' => false, 'subobject' => true, - ), + ), 'Reference' => array( 'type' => 'Reference', 'required' => false, 'subobject' => true, - ), + ), 'ShipmentDetails' => array( 'type' => 'ShipmentDetails', 'required' => false, 'subobject' => true, - ), + ), 'Shipper' => array( 'type' => 'Shipper', 'required' => false, 'subobject' => true, - ), + ), 'SpecialService' => array( 'type' => 'SpecialService', 'required' => false, 'subobject' => true, - ), + ), 'EProcShip' => array( 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'Airwaybill' => array( 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'DocImages' => array( 'type' => 'DocImages', 'required' => false, 'subobject' => true, - ), + ), 'LabelImageFormat' => array( 'type' => 'string', 'required' => false, @@ -134,16 +134,16 @@ class ShipmentValidateRequest extends Base 'minLength' => '3', 'maxLength' => '4', 'enumeration' => 'PDF,ZPL2,EPL2', - ), + ), 'RequestArchiveDoc' => array( 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'Label' => array( 'type' => 'Label', 'required' => false, 'subobject' => true, - ), + ), ); } diff --git a/DHL/Entity/EA/ShipmentValidateRequest.php b/DHL/Entity/EA/ShipmentValidateRequest.php index 496aaea6..54a88216 100644 --- a/DHL/Entity/EA/ShipmentValidateRequest.php +++ b/DHL/Entity/EA/ShipmentValidateRequest.php @@ -15,18 +15,18 @@ */ /** - * File: ShipmentValidateRequest.php + * File: ShipmentRequest.php * Project: DHL API * * @author Al-Fallouji Bashar * @version 0.1 */ -namespace DHL\Entity\EA; +namespace DHL\Entity\EA; use DHL\Entity\Base; /** - * ShipmentValidateRequest Request model for DHL API + * ShipmentRequest Request model for DHL API */ class ShipmentValidateRequest extends Base { @@ -57,85 +57,85 @@ class ShipmentValidateRequest extends Base 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'LanguageCode' => array( 'type' => 'string', 'required' => false, 'subobject' => false, 'comment' => 'ISO Language Code', - ), + ), 'PiecesEnabled' => array( 'type' => 'string', 'required' => false, 'subobject' => false, 'comment' => 'Pieces Enabling Flag', 'enumeration' => 'Y,N', - ), + ), 'Billing' => array( 'type' => 'Billing', 'required' => false, 'subobject' => true, - ), + ), 'Consignee' => array( 'type' => 'Consignee', 'required' => false, 'subobject' => true, - ), + ), 'Commodity' => array( 'type' => 'Commodity', 'required' => false, 'subobject' => true, - ), + ), 'Dutiable' => array( 'type' => 'Dutiable', 'required' => false, 'subobject' => true, - ), + ), 'ExportDeclaration' => array( 'type' => 'ExportDeclaration', 'required' => false, 'subobject' => true, - ), + ), 'Reference' => array( 'type' => 'Reference', 'required' => false, 'subobject' => true, - ), + ), 'ShipmentDetails' => array( 'type' => 'ShipmentDetails', 'required' => false, 'subobject' => true, - ), + ), 'Shipper' => array( 'type' => 'Shipper', 'required' => false, 'subobject' => true, - ), + ), 'SpecialService' => array( 'type' => 'SpecialService', 'required' => false, 'subobject' => true, - ), + ), 'Place' => array( 'type' => 'Place', 'required' => false, 'subobject' => true, - ), + ), 'EProcShip' => array( 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'Airwaybill' => array( 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'DocImages' => array( 'type' => 'DocImages', 'required' => false, 'subobject' => true, - ), + ), 'LabelImageFormat' => array( 'type' => 'string', 'required' => false, @@ -144,16 +144,16 @@ class ShipmentValidateRequest extends Base 'minLength' => '3', 'maxLength' => '4', 'enumeration' => 'PDF,ZPL2,EPL2', - ), + ), 'RequestArchiveDoc' => array( 'type' => 'string', 'required' => false, 'subobject' => false, - ), + ), 'Label' => array( 'type' => 'Label', 'required' => false, 'subobject' => true, - ), + ), ); } From 42c0746f6db3ec6cce58a593e7fbd24be1dfe4cd Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Tue, 19 May 2020 22:27:46 +0500 Subject: [PATCH 15/21] fix - added GrossWeight and Weight classes for shipment request. --- DHL/Datatype/AM/GrossWeight.php | 62 +++++++++++++++++++++++++++++++++ DHL/Datatype/AM/Weight.php | 62 +++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 DHL/Datatype/AM/GrossWeight.php create mode 100644 DHL/Datatype/AM/Weight.php diff --git a/DHL/Datatype/AM/GrossWeight.php b/DHL/Datatype/AM/GrossWeight.php new file mode 100644 index 00000000..9c618789 --- /dev/null +++ b/DHL/Datatype/AM/GrossWeight.php @@ -0,0 +1,62 @@ + array( + 'type' => 'Weight', + 'required' => false, + 'subobject' => false, + 'comment' => 'Weight of piece or shipment', + 'fractionDigits' => '1', + 'maxInclusive' => '999999.9', + 'totalDigits' => '7', + ), + 'WeightUnit' => array( + 'type' => 'WeightUnit', + 'required' => false, + 'subobject' => false, + 'comment' => 'Unit of weight measurement (L:Pounds)', + 'length' => '1', + 'enumeration' => 'K,L', + ), + ); +} diff --git a/DHL/Datatype/AM/Weight.php b/DHL/Datatype/AM/Weight.php new file mode 100644 index 00000000..ff0bbd5f --- /dev/null +++ b/DHL/Datatype/AM/Weight.php @@ -0,0 +1,62 @@ + array( + 'type' => 'Weight', + 'required' => false, + 'subobject' => false, + 'comment' => 'Weight of piece or shipment', + 'fractionDigits' => '1', + 'maxInclusive' => '999999.9', + 'totalDigits' => '7', + ), + 'WeightUnit' => array( + 'type' => 'WeightUnit', + 'required' => false, + 'subobject' => false, + 'comment' => 'Unit of weight measurement (L:Pounds)', + 'length' => '1', + 'enumeration' => 'K,L', + ), + ); +} From 60fef72fd38dcc559313fee09c4a01109cfb8c49 Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Wed, 20 May 2020 02:04:46 +0500 Subject: [PATCH 16/21] fix - change schema version of get quote request to 1.0, because making it 6.2 (latest from DHL side) is giving error. --- DHL/Entity/AM/GetQuote.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DHL/Entity/AM/GetQuote.php b/DHL/Entity/AM/GetQuote.php index e602e08b..57e6d6c8 100644 --- a/DHL/Entity/AM/GetQuote.php +++ b/DHL/Entity/AM/GetQuote.php @@ -52,7 +52,7 @@ class GetQuote extends Base * @var string * The schema version */ - protected $_schemaVersion = '6.2'; + protected $_schemaVersion = '1.0'; /** * Display the schema version From 11244eeb04a3787519b4dd072aec8a3e778be440 Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Tue, 7 Jul 2020 01:40:25 +0500 Subject: [PATCH 17/21] set AddressLine for Consignee and Shipper to 45. and enable multivalues for AddressLine. --- DHL/Datatype/AM/Consignee.php | 27 ++++++++++++++------------- DHL/Datatype/AM/Shipper.php | 3 ++- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/DHL/Datatype/AM/Consignee.php b/DHL/Datatype/AM/Consignee.php index 02aeca7f..f91e1358 100644 --- a/DHL/Datatype/AM/Consignee.php +++ b/DHL/Datatype/AM/Consignee.php @@ -22,7 +22,7 @@ * @version 0.1 */ -namespace DHL\Datatype\AM; +namespace DHL\Datatype\AM; use DHL\Datatype\Base; /** @@ -47,67 +47,68 @@ class Consignee extends Base 'subobject' => false, 'comment' => 'Name of company / business', 'maxLength' => '35', - ), + ), 'AddressLine' => array( 'type' => 'AddressLine', 'required' => false, 'subobject' => false, 'comment' => 'Address Line', - 'maxLength' => '35', - ), + 'maxLength' => '45', + 'multivalues' => true, + ), 'City' => array( 'type' => 'City', 'required' => false, 'subobject' => false, 'comment' => 'City name', 'maxLength' => '35', - ), + ), 'Division' => array( 'type' => 'Division', 'required' => false, 'subobject' => false, 'comment' => 'Division (e.g. state, prefecture, etc.) name', 'maxLength' => '35', - ), + ), 'DivisionCode' => array( 'type' => '', 'required' => false, 'subobject' => false, - ), + ), 'PostalCode' => array( 'type' => 'PostalCode', 'required' => false, 'subobject' => false, 'comment' => 'Full postal/zip code for address', - ), + ), 'CountryCode' => array( 'type' => 'CountryCode', 'required' => false, 'subobject' => false, 'comment' => 'ISO country codes', 'length' => '2', - ), + ), 'CountryName' => array( 'type' => 'CountryName', 'required' => false, 'subobject' => false, 'comment' => 'ISO country name', 'maxLength' => '35', - ), + ), 'FederalTaxId' => array( 'type' => '', 'required' => false, 'subobject' => false, - ), + ), 'StateTaxId' => array( 'type' => '', 'required' => false, 'subobject' => false, - ), + ), 'Contact' => array( 'type' => 'Contact', 'required' => false, 'subobject' => true, - ), + ), ); } diff --git a/DHL/Datatype/AM/Shipper.php b/DHL/Datatype/AM/Shipper.php index 79156ed9..fbd4aef1 100644 --- a/DHL/Datatype/AM/Shipper.php +++ b/DHL/Datatype/AM/Shipper.php @@ -68,7 +68,8 @@ class Shipper extends Base 'required' => false, 'subobject' => false, 'comment' => 'Address Line', - 'maxLength' => '35', + 'maxLength' => '45', + 'multivalues' => true, ), 'City' => array( 'type' => 'City', From 7c8b4293667448b31589b814c6591206b379301f Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Wed, 8 Jul 2020 19:10:40 +0500 Subject: [PATCH 18/21] change AddressLine type to "string" from "AddressLine" in AM/Shipper and AM/Consignee DataType. --- DHL/Datatype/AM/Consignee.php | 2 +- DHL/Datatype/AM/Shipper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DHL/Datatype/AM/Consignee.php b/DHL/Datatype/AM/Consignee.php index f91e1358..9037592a 100644 --- a/DHL/Datatype/AM/Consignee.php +++ b/DHL/Datatype/AM/Consignee.php @@ -49,7 +49,7 @@ class Consignee extends Base 'maxLength' => '35', ), 'AddressLine' => array( - 'type' => 'AddressLine', + 'type' => 'string', 'required' => false, 'subobject' => false, 'comment' => 'Address Line', diff --git a/DHL/Datatype/AM/Shipper.php b/DHL/Datatype/AM/Shipper.php index fbd4aef1..677e110a 100644 --- a/DHL/Datatype/AM/Shipper.php +++ b/DHL/Datatype/AM/Shipper.php @@ -64,7 +64,7 @@ class Shipper extends Base 'minInclusive' => '100000000', ), 'AddressLine' => array( - 'type' => 'AddressLine', + 'type' => 'string', 'required' => false, 'subobject' => false, 'comment' => 'Address Line', From a9660c8a753556da05bd1d87816617abb49e4ec6 Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Wed, 8 Jul 2020 19:11:40 +0500 Subject: [PATCH 19/21] check if "maxLength" attribute is set on an array loop over array elements and validate "maxLength" for each item of array. --- DHL/Datatype/Base.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/DHL/Datatype/Base.php b/DHL/Datatype/Base.php index a3813f23..ae659ad3 100644 --- a/DHL/Datatype/Base.php +++ b/DHL/Datatype/Base.php @@ -462,9 +462,18 @@ protected function validateParameterValue($key, $value) break; case 'maxLength': - if (strlen($value) > $typeValue) - { - throw new \InvalidArgumentException('Field ' . $key . ' has a size of ' . strlen($value) . ' and it cannot exceed this size : ' . $typeValue); + if ( is_array( $value ) ) { + foreach( $value as $item ) { + if ( strlen( $item ) > $typeValue ) { + throw new \InvalidArgumentException( 'Field ' . $key . ' has a size of ' . strlen( $item ) . ' and it cannot exceed this size : ' . $typeValue ); + } + } + } + else { + if (strlen($value) > $typeValue) + { + throw new \InvalidArgumentException('Field ' . $key . ' has a size of ' . strlen($value) . ' and it cannot exceed this size : ' . $typeValue); + } } break; From a104d4f656a1725ca2cf5d6fc2ed0d457cd8e1c1 Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Thu, 13 Aug 2020 03:59:04 +0500 Subject: [PATCH 20/21] added pickup requet related classes in AM --- DHL/Datatype/AM/Pickup.php | 90 +++++++++++++++++ DHL/Datatype/AM/PickupContact.php | 57 +++++++++++ DHL/Datatype/AM/PickupPlace.php | 140 +++++++++++++++++++++++++++ DHL/Datatype/AM/Place.php | 18 ++-- DHL/Datatype/AM/Requestor.php | 108 +++++++++++++++++++++ DHL/Datatype/AM/RequestorContact.php | 57 +++++++++++ DHL/Entity/AM/BookPickupRequest.php | 63 ++++++------ 7 files changed, 496 insertions(+), 37 deletions(-) create mode 100644 DHL/Datatype/AM/Pickup.php create mode 100644 DHL/Datatype/AM/PickupContact.php create mode 100644 DHL/Datatype/AM/PickupPlace.php create mode 100644 DHL/Datatype/AM/Requestor.php create mode 100644 DHL/Datatype/AM/RequestorContact.php diff --git a/DHL/Datatype/AM/Pickup.php b/DHL/Datatype/AM/Pickup.php new file mode 100644 index 00000000..90d2780f --- /dev/null +++ b/DHL/Datatype/AM/Pickup.php @@ -0,0 +1,90 @@ + array( + 'type' => 'date', + 'required' => true, + 'subobject' => false, + ), + 'PickupTypeCode' => array( + 'type' => 'string', + 'required' => true, + 'subobject' => false, + 'length' => '1', + 'enumeration' => 'S,A' + ), + 'ReadyByTime' => array( + 'type' => 'string', //'TimeHM', + 'required' => true, + 'subobject' => false, + 'length' => '5', + ), + 'CloseTime' => array( + 'type' => 'string', //'TimeHM', + 'required' => true, + 'subobject' => false, + 'length' => '5', + ), + 'AfterHoursClosingTime' => array( + 'type' => 'string', //'TimeHM', + 'required' => false, + 'subobject' => false, + 'length' => '5', + ), + 'AfterHoursLocation' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + 'maxLength' => 35, + ), + 'Pieces' => array( + 'type' => 'number', + 'required' => false, + 'subobject' => false, + 'minInclusive' => 1, + 'maxInclusive' => 999, + ), + 'RemotePickupFlag' => array( + 'type' => 'YesNo', + 'required' => false, + 'subobject' => false, + 'comment' => 'Boolean flag', + 'length' => '1', + 'enumeration' => 'Y,N', + ), + 'weight' => array( + 'type' => 'Weight', + 'required' => false, + 'subobject' => true, + ), + 'SpecialInstructions' => array( + 'type' => 'SpecialInstructions', + 'required' => false, + 'subobject' => false, + 'maxLength' =>80 + ), + 'Remarks' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + 'maxLength' => 2048, + ), + ); + } diff --git a/DHL/Datatype/AM/PickupContact.php b/DHL/Datatype/AM/PickupContact.php new file mode 100644 index 00000000..55992fcc --- /dev/null +++ b/DHL/Datatype/AM/PickupContact.php @@ -0,0 +1,57 @@ + array( + 'type' => 'string', + 'required' => true, + 'subobject' => false, + 'comment' => 'Name', + 'maxLength' => '35', + ), + 'Phone' => array( + 'type' => 'string', + 'required' => true , + 'subobject' => false, + 'comment' => 'Phone Number', + 'maxLength' => '25', + ), + 'PhoneExtension' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + 'comment' => '', + 'maxLength' => '5', + ), + ); + } diff --git a/DHL/Datatype/AM/PickupPlace.php b/DHL/Datatype/AM/PickupPlace.php new file mode 100644 index 00000000..ec2e954f --- /dev/null +++ b/DHL/Datatype/AM/PickupPlace.php @@ -0,0 +1,140 @@ + array( + 'type' => 'string', + 'required' => true, + 'subobject' => false, + 'comment' => 'Identifies if a location is a business, residence, or both (B:Business, R:Residence, C:Business Residence)', + 'length' => '1', + 'enumeration' => 'B,R,C', + ), + 'CompanyName' => array( + 'type' => 'CompanyNameValidator', + 'required' => true, + 'subobject' => false, + 'comment' => 'Name of company / business', + 'maxLength' => '45', + ), + 'Address1' => array( + 'type' => 'string', + 'required' => true, + 'subobject' => false, + 'comment' => 'Address Line', + 'maxLength' => '45', + ), + 'Address2' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + 'comment' => 'Address Line', + 'maxLength' => '45', + ), + 'Address3' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + 'comment' => 'Address Line', + 'maxLength' => '45', + ), + 'PackageLocation' => array( + 'type' => 'string', + 'required' => true, + 'subobject' => false, + 'comment' => 'Address Line', + 'maxLength' => '45', + ), + 'City' => array( + 'type' => 'City', + 'required' => true, + 'subobject' => false, + 'comment' => 'City name', + 'maxLength' => '45', + ), + 'StateCode' => array( + 'type' => 'StateCode', + 'required' => false, + 'subobject' => false, + 'comment' => 'State', + 'maxLength' => '45', + ), + 'DivisionName' => array( + 'type' => 'Division', + 'required' => false, + 'subobject' => false, + 'comment' => 'State', + 'maxLength' => '45', + ), + 'CountryCode' => array( + 'type' => 'CountryCode', + 'required' => true, + 'subobject' => false, + 'comment' => 'ISO country codes', + 'length' => '2', + ), + 'PostalCode' => array( + 'type' => 'PostalCode', + 'required' => false, + 'subobject' => false, + 'comment' => 'Full postal/zip code for address', + ), + 'RouteCode' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + 'comment' => 'Full postal/zip code for address', + ), + 'Suburb' => array( + 'type' => 'Suburb', + 'required' => false, + 'subobject' => false, + 'comment' => 'Full postal/zip code for address', + ), + ); +} diff --git a/DHL/Datatype/AM/Place.php b/DHL/Datatype/AM/Place.php index 25df20fe..31c07426 100644 --- a/DHL/Datatype/AM/Place.php +++ b/DHL/Datatype/AM/Place.php @@ -22,7 +22,7 @@ * @version 0.1 */ -namespace DHL\Datatype\AM; +namespace DHL\Datatype\AM; use DHL\Datatype\Base; /** @@ -48,35 +48,35 @@ class Place extends Base 'comment' => 'Identifies if a location is a business, residence, or both (B:Business, R:Residence, C:Business Residence)', 'length' => '1', 'enumeration' => 'B,R,C', - ), + ), 'CompanyName' => array( 'type' => 'CompanyNameValidator', 'required' => false, 'subobject' => false, 'comment' => 'Name of company / business', 'maxLength' => '35', - ), + ), 'AddressLine' => array( 'type' => 'AddressLine', 'required' => false, 'subobject' => false, 'comment' => 'Address Line', 'maxLength' => '35', - ), + ), 'City' => array( 'type' => 'City', 'required' => false, 'subobject' => false, 'comment' => 'City name', 'maxLength' => '35', - ), + ), 'CountryCode' => array( 'type' => 'CountryCode', 'required' => false, 'subobject' => false, 'comment' => 'ISO country codes', 'length' => '2', - ), + ), 'DivisionCode' => array( 'type' => 'StateCode', 'required' => false, @@ -84,19 +84,19 @@ class Place extends Base 'comment' => 'Division (state) code.', 'maxLength' => '2', 'minLength' => '2', - ), + ), 'Division' => array( 'type' => 'State', 'required' => false, 'subobject' => false, 'comment' => 'State', 'maxLength' => '35', - ), + ), 'PostalCode' => array( 'type' => 'PostalCode', 'required' => false, 'subobject' => false, 'comment' => 'Full postal/zip code for address', - ), + ), ); } diff --git a/DHL/Datatype/AM/Requestor.php b/DHL/Datatype/AM/Requestor.php new file mode 100644 index 00000000..4be971e4 --- /dev/null +++ b/DHL/Datatype/AM/Requestor.php @@ -0,0 +1,108 @@ + array( + 'type' => 'AccountType', + 'required' => true, + 'subobject' => false, + ), + 'AccountNumber' => array( + 'type' => 'AccountNumber', + 'required' => true, + 'subobject' => false, + 'maxLength' => '12', + ), + 'RequestorContact' => array( + 'type' => 'RequestorContact', + 'required' => false, + 'subobject' => true, + ), + 'CompanyName' => array( + 'type' => 'CompanyNameValidator', + 'required' => false, + 'subobject' => false, + 'comment' => 'Name of company / business', + 'maxLength' => '60', + 'minLength' => '2', + ), + 'Address1' => array( + 'type' => 'string', + 'required' => true, + 'subobject' => false, + 'comment' => 'Address Line', + 'maxLength' => '45', + ), + 'Address2' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + 'comment' => 'Address Line', + 'maxLength' => '45', + ), + 'Address3' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + 'comment' => 'Address Line', + 'maxLength' => '45', + ), + 'City' => array( + 'type' => 'City', + 'required' => true, + 'subobject' => false, + 'comment' => 'City name', + 'maxLength' => '35', + ), + 'CountryCode' => array( + 'type' => 'CountryCode', + 'required' => true, + 'subobject' => false, + 'comment' => 'ISO country codes', + 'length' => '2', + ), + 'DivisionName' => array( + 'type' => 'Division', + 'required' => false, + 'subobject' => false, + 'comment' => 'State', + 'maxLength' => '35', + ), + 'PostalCode' => array( + 'type' => 'PostalCode', + 'required' => false, + 'subobject' => false, + 'comment' => 'Full postal/zip code for address', + ), + ); + } diff --git a/DHL/Datatype/AM/RequestorContact.php b/DHL/Datatype/AM/RequestorContact.php new file mode 100644 index 00000000..e3ee9c51 --- /dev/null +++ b/DHL/Datatype/AM/RequestorContact.php @@ -0,0 +1,57 @@ + array( + 'type' => 'string', + 'required' => true, + 'subobject' => false, + 'comment' => 'Name', + 'maxLength' => '35', + ), + 'Phone' => array( + 'type' => 'string', + 'required' => true , + 'subobject' => false, + 'comment' => 'Phone Number', + 'maxLength' => '25', + ), + 'PhoneExtension' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + 'comment' => '', + 'maxLength' => '5', + ), + ); + } diff --git a/DHL/Entity/AM/BookPickupRequest.php b/DHL/Entity/AM/BookPickupRequest.php index 0a13a118..0a8254d4 100644 --- a/DHL/Entity/AM/BookPickupRequest.php +++ b/DHL/Entity/AM/BookPickupRequest.php @@ -22,7 +22,7 @@ * @version 0.1 */ -namespace DHL\Entity\AM; +namespace DHL\Entity\AM; use DHL\Entity\Base; /** @@ -40,13 +40,25 @@ class BookPickupRequest extends Base * Name of the service * @var string */ - protected $_serviceName = 'BookPickupRequest'; + protected $_serviceName = 'BookPURequest'; /** * @var string * Service XSD */ - protected $_serviceXSD = 'BookPickupRequest.xsd'; + protected $_serviceXSD = 'pickup-global-req.xsd'; + + /** + * @var string + * The schema version + */ + protected $_schemaVersion = '3.0'; + + /** + * Display the schema version + * @var boolean + */ + protected $_displaySchemaVersion = true; /** * Parameters to be send in the body @@ -54,39 +66,34 @@ class BookPickupRequest extends Base */ protected $_bodyParams = array( 'Requestor' => array( - 'type' => 'string', - 'required' => false, - 'subobject' => false, - ), + 'type' => 'Requestor', + 'required' => true, + 'subobject' => true, + ), 'Place' => array( - 'type' => 'Place', - 'required' => false, + 'type' => 'PickupPlace', + 'required' => true, 'subobject' => true, - ), + ), 'Pickup' => array( - 'type' => 'string', - 'required' => false, - 'subobject' => false, - ), + 'type' => 'Pickup', + 'required' => true, + 'subobject' => true, + ), 'PickupContact' => array( - 'type' => 'string', - 'required' => false, - 'subobject' => false, - ), - 'ShipmentDetails' => array( + 'type' => 'PickupContact', + 'required' => true, + 'subobject' => true, + ), + 'ShipmentDetails' => array( // TODO: check datatype class parameters 'type' => 'ShipmentDetails', 'required' => false, 'subobject' => true, - ), - 'PickupType' => array( - 'type' => 'string', - 'required' => false, - 'subobject' => false, - ), - 'LargestPiece' => array( - 'type' => 'string', + ), + 'ConsigneeDetails' => array( // TODO: make datatype class + 'type' => 'ConsigneeDetails', 'required' => false, 'subobject' => false, - ), + ), ); } From f07b07e8af5784c77af04bf32e0d27ac97a5ccc2 Mon Sep 17 00:00:00 2001 From: Mutahhar Date: Thu, 8 Oct 2020 17:49:20 +0500 Subject: [PATCH 21/21] new - added AccountType, AccountNumber, and BillToAccountNumber fields in Datatype\AM\ShipmentDetails/ --- DHL/Datatype/AM/ShipmentDetails.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/DHL/Datatype/AM/ShipmentDetails.php b/DHL/Datatype/AM/ShipmentDetails.php index 6a908218..0fb76299 100644 --- a/DHL/Datatype/AM/ShipmentDetails.php +++ b/DHL/Datatype/AM/ShipmentDetails.php @@ -41,6 +41,21 @@ class ShipmentDetails extends Base * @var array */ protected $_params = array( + 'AccountType' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + ), + 'AccountNumber' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + ), + 'BillToAccountNumber' => array( + 'type' => 'string', + 'required' => false, + 'subobject' => false, + ), 'NumberOfPieces' => array( 'type' => 'positiveInteger', 'required' => false,