From a1dc7c46d532fc9c06cc5a8feed1b869c2f632a1 Mon Sep 17 00:00:00 2001 From: Dona Stephen Date: Mon, 26 Apr 2021 09:37:23 -0700 Subject: [PATCH 1/2] Support for Mail Innovation label creation --- src/Entity/Service.php | 2 ++ src/Entity/Shipment.php | 60 +++++++++++++++++++++++++++++++++++++++++ src/Shipping.php | 8 ++++++ 3 files changed, 70 insertions(+) diff --git a/src/Entity/Service.php b/src/Entity/Service.php index 137753d7..0f8c190a 100644 --- a/src/Entity/Service.php +++ b/src/Entity/Service.php @@ -17,6 +17,7 @@ class Service implements NodeInterface const S_3DAYSELECT = '12'; const S_GROUND = '03'; const S_SURE_POST = '93'; + const S_MAIL_INNOVATIONS = 'M4'; // Valid international values const S_STANDARD = '11'; @@ -106,6 +107,7 @@ class Service implements NodeInterface '74' => 'UPS Express 12:00', '93' => 'UPS Sure Post', '96' => 'UPS Worldwide Express Freight', + 'M4' => 'UPS Mail Innovations', ]; /** @deprecated */ diff --git a/src/Entity/Shipment.php b/src/Entity/Shipment.php index 89854827..3f14c2c1 100644 --- a/src/Entity/Shipment.php +++ b/src/Entity/Shipment.php @@ -4,6 +4,12 @@ class Shipment { + + const USPS_ENDORSEMENT_RETURN_SERVICE = 1; + const USPS_ENDORSEMENT_FORWARDING_SERVICE = 2; + const USPS_ENDORSEMENT_ADDRESS_SERVICE = 3; + const USPS_ENDORSEMENT_CHANGE_SERVICE = 4; + const USPS_ENDORSEMENT_NO_SERVICE = 5; /** * @var PaymentInformation */ @@ -122,6 +128,20 @@ class Shipment * @var bool */ private $taxInformationIndicator; + + /** + * Required for Mail Innovations. + * + * @var integer + */ + private $uspsEndorsement; + + /** + * Required for Mail Innovations. + * + * @var string + */ + private $packageId; public function __construct() { @@ -610,4 +630,44 @@ public function setTaxInformationIndicator(bool $taxInformationIndicator): self return $this; } + + /** + * @return int $uspsEndorsement + */ + public function getUSPSEndorsement() + { + return $this->uspsEndorsement; + } + + /** + * @param integer $uspsEndorsement + * + * @return Shipment + */ + public function setUSPSEndorsement($uspsEndorsement) + { + $this->uspsEndorsement = $uspsEndorsement; + + return $this; + } + + /** + * @return int $packageId + */ + public function getPackageId() + { + return $this->packageId; + } + + /** + * @param integer $packageId + * + * @return Shipment + */ + public function setPackageId($packageId) + { + $this->packageId = $packageId; + + return $this; + } } diff --git a/src/Shipping.php b/src/Shipping.php index 04ee8315..3fcc6ce0 100644 --- a/src/Shipping.php +++ b/src/Shipping.php @@ -132,6 +132,14 @@ private function createConfirmRequest( if ($shipment->getDescription()) { $shipmentNode->appendChild($xml->createElement('Description', $shipment->getDescription())); } + + if ($shipment->getUspsEndorsement()) { + $shipmentNode->appendChild($xml->createElement('USPSEndorsement', $shipment->getUSPSEndorsement())); + } + + if ($shipment->getPackageId()) { + $shipmentNode->appendChild($xml->createElement('PackageID', $shipment->getPackageId())); + } $returnService = $shipment->getReturnService(); if (isset($returnService)) { From bbcc3fda847c9d8965940dcc042d28da8a6a5869 Mon Sep 17 00:00:00 2001 From: Dona Stephen Date: Mon, 26 Apr 2021 11:38:26 -0700 Subject: [PATCH 2/2] Fix style issue --- src/Entity/Shipment.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Entity/Shipment.php b/src/Entity/Shipment.php index 3f14c2c1..670f6927 100644 --- a/src/Entity/Shipment.php +++ b/src/Entity/Shipment.php @@ -4,7 +4,6 @@ class Shipment { - const USPS_ENDORSEMENT_RETURN_SERVICE = 1; const USPS_ENDORSEMENT_FORWARDING_SERVICE = 2; const USPS_ENDORSEMENT_ADDRESS_SERVICE = 3; @@ -131,14 +130,12 @@ class Shipment /** * Required for Mail Innovations. - * * @var integer */ private $uspsEndorsement; /** * Required for Mail Innovations. - * * @var string */ private $packageId;