Skip to content

Commit b2fa9a7

Browse files
committed
Add the EEIFilingOption node to the InternationalForms container. Associated nodes include UPSFiling, ShipperFiling, and POA. Also added a new directory for entity test classes so we can check the constructor, getters, setters, and toNode methods on the entities.
Remove one StyleCI PHP Issue be more stringent. don't just assert not empty. make sure it equals what we want
1 parent 9e7ba94 commit b2fa9a7

File tree

6 files changed

+703
-0
lines changed

6 files changed

+703
-0
lines changed

src/Entity/EEIFilingOption.php

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
<?php
2+
3+
namespace Ups\Entity;
4+
5+
use DOMDocument;
6+
use DOMElement;
7+
use Ups\NodeInterface;
8+
9+
class EEIFilingOption implements NodeInterface
10+
{
11+
const FO_SHIPPER = '1'; // Shipper Filed
12+
const FO_UPS = '3'; // UPS Filed
13+
14+
/**
15+
* @var string
16+
*/
17+
private $code;
18+
19+
/**
20+
* @var string
21+
*/
22+
private $emailAddress;
23+
24+
/**
25+
* @var string
26+
*/
27+
private $description;
28+
29+
/**
30+
* @var UPSFiled
31+
*/
32+
private $upsFiled;
33+
34+
/**
35+
* @var ShipperFiled
36+
*/
37+
private $shipperFiled;
38+
39+
/**
40+
* @param null|object $attributes
41+
*/
42+
public function __construct($attributes = null)
43+
{
44+
if (null !== $attributes) {
45+
if (isset($attributes->Code)) {
46+
$this->setCode($attributes->Code);
47+
}
48+
if (isset($attributes->EmailAddress)) {
49+
$this->setEmailAddress($attributes->EmailAddress);
50+
}
51+
if (isset($attributes->Description)) {
52+
$this->setDescription($attributes->Description);
53+
}
54+
if (isset($attributes->UPSFiled)) {
55+
$this->setUPSFiled(new UPSFiled($attributes->UPSFiled));
56+
}
57+
if (isset($attributes->ShipperFiled)) {
58+
$this->setShipperFiled(new ShipperFiled($attributes->ShipperFiled));
59+
}
60+
}
61+
}
62+
63+
/**
64+
* @param null|DOMDocument $document
65+
*
66+
* @return DOMElement
67+
*/
68+
public function toNode(DOMDocument $document = null)
69+
{
70+
if (null === $document) {
71+
$document = new DOMDocument();
72+
}
73+
74+
$node = $document->createElement('EEIFilingOption');
75+
76+
$code = $this->getCode();
77+
if (isset($code)) {
78+
$node->appendChild($document->createElement('Code', $code));
79+
}
80+
81+
$emailAddress = $this->getEmailAddress();
82+
if (isset($emailAddress)) {
83+
$node->appendChild($document->createElement('EMailAdress', $emailAddress));
84+
}
85+
86+
$description = $this->getDescription();
87+
if (isset($description)) {
88+
$node->appendChild($document->createElement('Description', $description));
89+
}
90+
91+
$upsFiled = $this->getUPSFiled();
92+
if (isset($upsFiled)) {
93+
$node->appendChild($upsFiled->toNode($document));
94+
}
95+
96+
$shipperFiled = $this->getShipperFiled();
97+
if (isset($shipperFiled)) {
98+
$node->appendChild($shipperFiled->toNode($document));
99+
}
100+
101+
return $node;
102+
}
103+
104+
/**
105+
* @return string
106+
*/
107+
public function getCode()
108+
{
109+
return $this->code;
110+
}
111+
112+
/**
113+
* @param string $code
114+
*
115+
* @return $this
116+
*/
117+
public function setCode($code)
118+
{
119+
$this->code = $code;
120+
121+
return $this;
122+
}
123+
124+
/**
125+
* @return string
126+
*/
127+
public function getEmailAddress()
128+
{
129+
return $this->emailAddress;
130+
}
131+
132+
/**
133+
* @param string $emailAddress
134+
*
135+
* @return $this
136+
*/
137+
public function setEmailAddress($emailAddress)
138+
{
139+
$this->emailAddress = $emailAddress;
140+
141+
return $this;
142+
}
143+
144+
/**
145+
* @return string
146+
*/
147+
public function getDescription()
148+
{
149+
return $this->description;
150+
}
151+
152+
/**
153+
* @param string $description
154+
*
155+
* @return $this
156+
*/
157+
public function setDescription($description)
158+
{
159+
$this->description = $description;
160+
161+
return $this;
162+
}
163+
164+
/**
165+
* @return UPSFiled
166+
*/
167+
public function getUPSFiled()
168+
{
169+
return $this->upsFiled;
170+
}
171+
172+
/**
173+
* @param UPSFiled $upsFiled
174+
*
175+
* @return $this
176+
*/
177+
public function setUPSFiled(UPSFiled $upsFiled)
178+
{
179+
$this->upsFiled = $upsFiled;
180+
181+
return $this;
182+
}
183+
184+
/**
185+
* @return ShipperFiled
186+
*/
187+
public function getShipperFiled()
188+
{
189+
return $this->shipperFiled;
190+
}
191+
192+
/**
193+
* @param ShipperFiled $shipperFiled
194+
*
195+
* @return $this
196+
*/
197+
public function setShipperFiled(ShipperFiled $shipperFiled)
198+
{
199+
$this->shipperFiled = $shipperFiled;
200+
201+
return $this;
202+
}
203+
}

src/Entity/InternationalForms.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ class InternationalForms implements NodeInterface
139139
*/
140140
private $additionalDocumentIndicator;
141141

142+
/**
143+
* @var EEIFilingOption
144+
*/
145+
private $eeiFilingOption;
146+
142147
/**
143148
* @return array
144149
*/
@@ -182,6 +187,9 @@ public function __construct($attributes = null)
182187
if (isset($attributes->CurrencyCode)) {
183188
$this->setCurrencyCode($attributes->CurrencyCode);
184189
}
190+
if (isset($attributes->EEIFilingOption)) {
191+
$this->setEEIFilingOption(new EEIFilingOption($attributes->EEIFilingOption));
192+
}
185193
}
186194
}
187195

@@ -311,6 +319,9 @@ public function toNode(DOMDocument $document = null)
311319
if ($this->getAdditionalDocumentIndicator() !== null) {
312320
$node->appendChild($document->createElement('AdditionalDocumentIndicator'));
313321
}
322+
if ($this->getEEIFilingOption() !== null) {
323+
$node->appendChild($this->getEEIFilingOption()->toNode($document));
324+
}
314325
foreach ($this->products as $product) {
315326
$node->appendChild($product->toNode($document));
316327
}
@@ -483,4 +494,24 @@ public function getAdditionalDocumentIndicator()
483494
{
484495
return $this->additionalDocumentIndicator;
485496
}
497+
498+
/**
499+
* @param EEIFilingOption $eeiFilingOption
500+
*
501+
* @return $this
502+
*/
503+
public function setEEIFilingOption(EEIFilingOption $eeiFilingOption)
504+
{
505+
$this->eeiFilingOption = $eeiFilingOption;
506+
507+
return $this;
508+
}
509+
510+
/**
511+
* @return EEIFilingOption
512+
*/
513+
public function getEEIFilingOption()
514+
{
515+
return $this->eeiFilingOption;
516+
}
486517
}

src/Entity/POA.php

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
3+
namespace Ups\Entity;
4+
5+
use DOMDocument;
6+
use DOMElement;
7+
use Ups\NodeInterface;
8+
9+
class POA implements NodeInterface
10+
{
11+
const POA_ONE_TIME = '1'; // One Time POA
12+
const POA_BLANKET = '2'; // Blanket POA
13+
14+
/**
15+
* @var string
16+
*/
17+
private $code;
18+
19+
/**
20+
* @var string
21+
*/
22+
private $description;
23+
24+
/**
25+
* @param null|object $attributes
26+
*/
27+
public function __construct($attributes = null)
28+
{
29+
if (null !== $attributes) {
30+
if (isset($attributes->Code)) {
31+
$this->setCode($attributes->Code);
32+
}
33+
if (isset($attributes->Description)) {
34+
$this->setDescription($attributes->Description);
35+
}
36+
}
37+
}
38+
39+
/**
40+
* @param null|DOMDocument $document
41+
*
42+
* @return DOMElement
43+
*/
44+
public function toNode(DOMDocument $document = null)
45+
{
46+
if (null === $document) {
47+
$document = new DOMDocument();
48+
}
49+
50+
$node = $document->createElement('POA');
51+
52+
$code = $this->getCode();
53+
if (isset($code)) {
54+
$node->appendChild($document->createElement('Code', $code));
55+
}
56+
57+
$description = $this->getDescription();
58+
if (isset($description)) {
59+
$node->appendChild($document->createElement('Description', $description));
60+
}
61+
62+
return $node;
63+
}
64+
65+
/**
66+
* @return string
67+
*/
68+
public function getCode()
69+
{
70+
return $this->code;
71+
}
72+
73+
/**
74+
* @param string $code
75+
*
76+
* @return $this
77+
*/
78+
public function setCode($code)
79+
{
80+
$this->code = $code;
81+
82+
return $this;
83+
}
84+
85+
/**
86+
* @return string
87+
*/
88+
public function getDescription()
89+
{
90+
return $this->description;
91+
}
92+
93+
/**
94+
* @param string $description
95+
*
96+
* @return $this
97+
*/
98+
public function setDescription($description)
99+
{
100+
$this->description = $description;
101+
102+
return $this;
103+
}
104+
}

0 commit comments

Comments
 (0)