Skip to content

Commit 5bb9271

Browse files
authored
feat: prevent api errors for long person and company names (#486)
* feat: prevent api errors for long person and company names * fix: implement feedback
1 parent a9b29e5 commit 5bb9271

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/Model/Consignment/AbstractConsignment.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@ abstract class AbstractConsignment
229229
*/
230230
public const LABEL_DESCRIPTION_MAX_LENGTH = 45;
231231

232+
/**
233+
* @var int
234+
*/
235+
public const PERSON_NAME_MAX_LENGTH = 50;
236+
237+
/**
238+
* @var int
239+
*/
240+
public const COMPANY_NAME_MAX_LENGTH = 50;
241+
232242
/**
233243
* @internal
234244
* @var null|string
@@ -1245,7 +1255,7 @@ public function getPerson(): string
12451255
*/
12461256
public function setPerson(string $person): self
12471257
{
1248-
$this->person = $person;
1258+
$this->person = Str::limit($person, self::PERSON_NAME_MAX_LENGTH);
12491259

12501260
return $this;
12511261
}
@@ -1268,6 +1278,10 @@ public function getCompany(): ?string
12681278
*/
12691279
public function setCompany(?string $company): self
12701280
{
1281+
if (isset($company)) {
1282+
$company = Str::limit($company, self::COMPANY_NAME_MAX_LENGTH);
1283+
}
1284+
12711285
$this->company = $company;
12721286

12731287
return $this;

src/Model/Consignment/UPSConsignment.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ class UPSConsignment extends AbstractConsignment
1111
{
1212
public const DEFAULT_WEIGHT = 3000;
1313

14+
/**
15+
* @var int
16+
*/
17+
public const PERSON_NAME_MAX_LENGTH = 35;
18+
1419
/**
1520
* @internal
1621
* @var int

0 commit comments

Comments
 (0)