diff --git a/src/Entity/ShipFrom.php b/src/Entity/ShipFrom.php index 25aba75..a192b51 100644 --- a/src/Entity/ShipFrom.php +++ b/src/Entity/ShipFrom.php @@ -34,6 +34,11 @@ public function toNode(DOMDocument $document = null) $node->appendChild($address->toNode($document)); } + $vendorInfo = $this->getVendorInfo(); + if (isset($vendorInfo)) { + $node->appendChild($vendorInfo->toNode($document)); + } + return $node; } } diff --git a/src/Entity/Shipper.php b/src/Entity/Shipper.php index f0d3a2b..19e7ad0 100644 --- a/src/Entity/Shipper.php +++ b/src/Entity/Shipper.php @@ -53,6 +53,11 @@ class Shipper implements NodeInterface */ protected $address; + /** + * @var VendorInfo + */ + protected $vendorInfo; + /** * @param null|object $attributes */ @@ -88,6 +93,9 @@ public function __construct($attributes = null) if (isset($attributes->Address)) { $this->setAddress(new Address($attributes->Address)); } + if (isset($attributes->VendorInfo)) { + $this->setVendorInfo(new VendorInfo($attributes->VendorInfo)); + } } } @@ -142,6 +150,26 @@ public function setAddress(Address $address) return $this; } + /** + * @return VendorInfo + */ + public function getVendorInfo() + { + return $this->vendorInfo; + } + + /** + * @param VendorInfo $vendorInfo + * + * @return Shipper + */ + public function setVendorInfo(VendorInfo $vendorInfo) + { + $this->vendorInfo = $vendorInfo; + + return $this; + } + /** * @return string */ diff --git a/src/Entity/VendorInfo.php b/src/Entity/VendorInfo.php new file mode 100644 index 0000000..37eda3d --- /dev/null +++ b/src/Entity/VendorInfo.php @@ -0,0 +1,129 @@ +VendorCollectIDTypeCode)) { + $this->setVendorCollectIDTypeCode($attributes->VendorCollectIDTypeCode); + } + if (isset($attributes->VendorCollectIDNumber)) { + $this->setVendorCollectIDNumber($attributes->VendorCollectIDNumber); + } + if (isset($attributes->ConsigneeType)) { + $this->setConsigneeType($attributes->ConsigneeType); + } + } + } + + /** + * @param null|DOMDocument $document + * + * @return DOMElement + */ + public function toNode(DOMDocument $document = null) + { + if (null === $document) { + $document = new DOMDocument(); + } + + $node = $document->createElement('VendorInfo'); + if ($this->getVendorCollectIDTypeCode()) { + $node->appendChild($document->createElement('VendorCollectIDTypeCode', $this->getVendorCollectIDTypeCode())); + } + + if ($this->getVendorCollectIDNumber()) { + $node->appendChild($document->createElement('VendorCollectIDNumber', $this->getVendorCollectIDNumber())); + } + if ($this->getConsigneeType()) { + $node->appendChild($document->createElement('ConsigneeType', $this->getConsigneeType())); + } + + return $node; + } + + /** + * @return string + */ + public function getVendorCollectIDTypeCode() + { + return $this->vendorCollectIDTypeCode; + } + + /** + * @param string $vendorCollectIDTypeCode + * + * @return $this + */ + public function setVendorCollectIDTypeCode($vendorCollectIDTypeCode) + { + $this->vendorCollectIDTypeCode = $vendorCollectIDTypeCode; + + return $this; + } + + /** + * @return string + */ + public function getVendorCollectIDNumber() + { + return $this->vendorCollectIDNumber; + } + + /** + * @param string vendorCollectIDNumber + * + * @return $this + */ + public function setVendorCollectIDNumber($vendorCollectIDNumber) + { + $this->vendorCollectIDNumber = $vendorCollectIDNumber; + + return $this; + } + + /** + * @return string + */ + public function getConsigneeType() + { + return $this->consigneeType; + } + + /** + * @param string $consigneeType + * + * @return $this + */ + public function setConsigneeType($consigneeType) + { + $this->consigneeType = $consigneeType; + + return $this; + } +} diff --git a/src/Shipping.php b/src/Shipping.php index 0165e06..92e3c49 100644 --- a/src/Shipping.php +++ b/src/Shipping.php @@ -221,6 +221,10 @@ private function createConfirmRequest( $shipFromNode->appendChild($xml->createElement('FaxNumber', $shipment->getShipFrom()->getFaxNumber())); } + if (!empty($shipment->getShipFrom()->getVendorInfo())) { + $shipFromNode->appendChild($shipment->getShipFrom()->getVendorInfo()->toNode($xml)); + } + $shipFromNode->appendChild($shipment->getShipFrom()->getAddress()->toNode($xml)); }