Skip to content

Commit 9506695

Browse files
authored
Merge pull request #4 from proclame/add-email-entity
Add EmailAddress field to Shipper and ShipTo entities.
2 parents 112784b + 8141f86 commit 9506695

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

demo/create-label.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
$shipper->setAttentionName(""); // optional
4949
$shipper->setTaxIdentificationNumber(""); // optional
5050
$shipper->setPhone($phone);
51+
$shipper->setEmail(""); // optional
5152
$shipper->setShippingNumber("123456");
5253
$shipper->setFaxNumber(""); // optional
5354
$shipper->setAddress($address);
@@ -68,6 +69,7 @@
6869
$shipTo->setName("Shipper Test");
6970
$shipTo->setAttentionName(""); // optional
7071
$shipTo->setPhone($phone);
72+
$shipTo->setEmail(""); // optional
7173
$shipTo->setAddress($address);
7274
$shipTo->setResidential(""); // optional
7375
/************ End ShipTo **********/
@@ -114,7 +116,7 @@
114116
$packaging->setDescription("Ups Letter"); // optional
115117

116118
// Dimensions can be optional
117-
$unitOfMeasurement = new UnitOfMeasurement();
119+
$unitOfMeasurement = new UnitOfMeasurement();
118120
$unitOfMeasurement->setCode(UnitOfMeasurement::INCHES);
119121
$unitOfMeasurement->setDescription("Inches"); // optional
120122

src/Entity/ShipTo.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class ShipTo
66
{
77
private ?string $name;
88
private string $attentionName = "";
9+
private string $email = "";
910
private Phone $phone;
1011
private Address $address;
1112
private string $residential = "";
@@ -14,7 +15,7 @@ public function __construct()
1415
{
1516
$this->phone = new Phone();
1617
}
17-
18+
1819
public function setName(string $name): self
1920
{
2021
$this->name = $name;
@@ -48,6 +49,17 @@ public function getPhone(): Phone
4849
return $this->phone;
4950
}
5051

52+
public function setEmail(string $email): self
53+
{
54+
$this->email = $email;
55+
return $this;
56+
}
57+
58+
public function getEmail(): string
59+
{
60+
return $this->email;
61+
}
62+
5163
public function setAddress(Address $address): self
5264
{
5365
$this->address = $address;
@@ -85,6 +97,10 @@ public function toArray(): array
8597
$shipTo["Phone"] = $this->phone->toArray();
8698
}
8799

100+
if ($this->email) {
101+
$shipTo["EmailAddress"] = $this->email;
102+
}
103+
88104
if ($this->residential) {
89105
$shipTo["Residential"] = $this->residential;
90106
}

src/Entity/Shipper.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Shipper
77
private ?string $name;
88
private string $attentionName = "";
99
private string $taxIdentificationNumber = "";
10+
private string $email = "";
1011
private Phone $phone;
1112
private ?string $shipperNumber;
1213
private string $faxNumber = "";
@@ -61,6 +62,17 @@ public function getPhone(): Phone
6162
return $this->phone;
6263
}
6364

65+
public function setEmail(string $email): self
66+
{
67+
$this->email = $email;
68+
return $this;
69+
}
70+
71+
public function getEmail(): string
72+
{
73+
return $this->email;
74+
}
75+
6476
public function setShippingNumber(string $shipper_number): self
6577
{
6678
$this->shipperNumber = $shipper_number;
@@ -114,6 +126,10 @@ public function toArray(): array
114126
$shipper["Phone"] = $this->phone->toArray();
115127
}
116128

129+
if ($this->email) {
130+
$shipTo["EmailAddress"] = $this->email;
131+
}
132+
117133
if ($this->faxNumber) {
118134
$shipper["FaxNumber"] = $this->faxNumber;
119135
}

0 commit comments

Comments
 (0)