Skip to content

Commit 2ef3ac8

Browse files
authored
Add VendorInfo to support the new IOSS , HMRC and VOEC number created… (#334)
1 parent b0c73fd commit 2ef3ac8

File tree

4 files changed

+166
-0
lines changed

4 files changed

+166
-0
lines changed

src/Entity/ShipFrom.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public function toNode(DOMDocument $document = null)
3434
$node->appendChild($address->toNode($document));
3535
}
3636

37+
$vendorInfo = $this->getVendorInfo();
38+
if (isset($vendorInfo)) {
39+
$node->appendChild($vendorInfo->toNode($document));
40+
}
41+
3742
return $node;
3843
}
3944
}

src/Entity/Shipper.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ class Shipper implements NodeInterface
5353
*/
5454
protected $address;
5555

56+
/**
57+
* @var VendorInfo
58+
*/
59+
protected $vendorInfo;
60+
5661
/**
5762
* @param null|object $attributes
5863
*/
@@ -88,6 +93,9 @@ public function __construct($attributes = null)
8893
if (isset($attributes->Address)) {
8994
$this->setAddress(new Address($attributes->Address));
9095
}
96+
if (isset($attributes->VendorInfo)) {
97+
$this->setVendorInfo(new VendorInfo($attributes->VendorInfo));
98+
}
9199
}
92100
}
93101

@@ -142,6 +150,26 @@ public function setAddress(Address $address)
142150
return $this;
143151
}
144152

153+
/**
154+
* @return VendorInfo
155+
*/
156+
public function getVendorInfo()
157+
{
158+
return $this->vendorInfo;
159+
}
160+
161+
/**
162+
* @param VendorInfo $vendorInfo
163+
*
164+
* @return Shipper
165+
*/
166+
public function setVendorInfo(VendorInfo $vendorInfo)
167+
{
168+
$this->vendorInfo = $vendorInfo;
169+
170+
return $this;
171+
}
172+
145173
/**
146174
* @return string
147175
*/

src/Entity/VendorInfo.php

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<?php
2+
3+
namespace Ups\Entity;
4+
5+
use DOMDocument;
6+
use DOMElement;
7+
use Ups\NodeInterface;
8+
9+
class VendorInfo implements NodeInterface
10+
{
11+
/**
12+
* @var string
13+
*/
14+
private $vendorCollectIDTypeCode;
15+
16+
/**
17+
* @var string
18+
*/
19+
private $vendorCollectIDNumber;
20+
21+
/**
22+
* @var string
23+
*/
24+
private $consigneeType;
25+
26+
/**
27+
* @param null|object $attributes
28+
*/
29+
public function __construct($attributes = null)
30+
{
31+
if (null !== $attributes) {
32+
if (isset($attributes->VendorCollectIDTypeCode)) {
33+
$this->setVendorCollectIDTypeCode($attributes->VendorCollectIDTypeCode);
34+
}
35+
if (isset($attributes->VendorCollectIDNumber)) {
36+
$this->setVendorCollectIDNumber($attributes->VendorCollectIDNumber);
37+
}
38+
if (isset($attributes->ConsigneeType)) {
39+
$this->setConsigneeType($attributes->ConsigneeType);
40+
}
41+
}
42+
}
43+
44+
/**
45+
* @param null|DOMDocument $document
46+
*
47+
* @return DOMElement
48+
*/
49+
public function toNode(DOMDocument $document = null)
50+
{
51+
if (null === $document) {
52+
$document = new DOMDocument();
53+
}
54+
55+
$node = $document->createElement('VendorInfo');
56+
if ($this->getVendorCollectIDTypeCode()) {
57+
$node->appendChild($document->createElement('VendorCollectIDTypeCode', $this->getVendorCollectIDTypeCode()));
58+
}
59+
60+
if ($this->getVendorCollectIDNumber()) {
61+
$node->appendChild($document->createElement('VendorCollectIDNumber', $this->getVendorCollectIDNumber()));
62+
}
63+
if ($this->getConsigneeType()) {
64+
$node->appendChild($document->createElement('ConsigneeType', $this->getConsigneeType()));
65+
}
66+
67+
return $node;
68+
}
69+
70+
/**
71+
* @return string
72+
*/
73+
public function getVendorCollectIDTypeCode()
74+
{
75+
return $this->vendorCollectIDTypeCode;
76+
}
77+
78+
/**
79+
* @param string $vendorCollectIDTypeCode
80+
*
81+
* @return $this
82+
*/
83+
public function setVendorCollectIDTypeCode($vendorCollectIDTypeCode)
84+
{
85+
$this->vendorCollectIDTypeCode = $vendorCollectIDTypeCode;
86+
87+
return $this;
88+
}
89+
90+
/**
91+
* @return string
92+
*/
93+
public function getVendorCollectIDNumber()
94+
{
95+
return $this->vendorCollectIDNumber;
96+
}
97+
98+
/**
99+
* @param string vendorCollectIDNumber
100+
*
101+
* @return $this
102+
*/
103+
public function setVendorCollectIDNumber($vendorCollectIDNumber)
104+
{
105+
$this->vendorCollectIDNumber = $vendorCollectIDNumber;
106+
107+
return $this;
108+
}
109+
110+
/**
111+
* @return string
112+
*/
113+
public function getConsigneeType()
114+
{
115+
return $this->consigneeType;
116+
}
117+
118+
/**
119+
* @param string $consigneeType
120+
*
121+
* @return $this
122+
*/
123+
public function setConsigneeType($consigneeType)
124+
{
125+
$this->consigneeType = $consigneeType;
126+
127+
return $this;
128+
}
129+
}

src/Shipping.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ private function createConfirmRequest(
221221
$shipFromNode->appendChild($xml->createElement('FaxNumber', $shipment->getShipFrom()->getFaxNumber()));
222222
}
223223

224+
if (!empty($shipment->getShipFrom()->getVendorInfo())) {
225+
$shipFromNode->appendChild($shipment->getShipFrom()->getVendorInfo()->toNode($xml));
226+
}
227+
224228
$shipFromNode->appendChild($shipment->getShipFrom()->getAddress()->toNode($xml));
225229
}
226230

0 commit comments

Comments
 (0)