Skip to content

Commit

Permalink
Add VendorInfo to support the new IOSS , HMRC and VOEC number created… (
Browse files Browse the repository at this point in the history
  • Loading branch information
jay1963 authored Mar 30, 2022
1 parent b0c73fd commit 2ef3ac8
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Entity/ShipFrom.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
28 changes: 28 additions & 0 deletions src/Entity/Shipper.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class Shipper implements NodeInterface
*/
protected $address;

/**
* @var VendorInfo
*/
protected $vendorInfo;

/**
* @param null|object $attributes
*/
Expand Down Expand Up @@ -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));
}
}
}

Expand Down Expand Up @@ -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
*/
Expand Down
129 changes: 129 additions & 0 deletions src/Entity/VendorInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php

namespace Ups\Entity;

use DOMDocument;
use DOMElement;
use Ups\NodeInterface;

class VendorInfo implements NodeInterface
{
/**
* @var string
*/
private $vendorCollectIDTypeCode;

/**
* @var string
*/
private $vendorCollectIDNumber;

/**
* @var string
*/
private $consigneeType;

/**
* @param null|object $attributes
*/
public function __construct($attributes = null)
{
if (null !== $attributes) {
if (isset($attributes->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;
}
}
4 changes: 4 additions & 0 deletions src/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit 2ef3ac8

Please sign in to comment.