Skip to content

Commit

Permalink
feat: prevent api errors for long person and company names (#486)
Browse files Browse the repository at this point in the history
* feat: prevent api errors for long person and company names

* fix: implement feedback
  • Loading branch information
joerivanveen authored Sep 10, 2024
1 parent a9b29e5 commit 5bb9271
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Model/Consignment/AbstractConsignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ abstract class AbstractConsignment
*/
public const LABEL_DESCRIPTION_MAX_LENGTH = 45;

/**
* @var int
*/
public const PERSON_NAME_MAX_LENGTH = 50;

/**
* @var int
*/
public const COMPANY_NAME_MAX_LENGTH = 50;

/**
* @internal
* @var null|string
Expand Down Expand Up @@ -1245,7 +1255,7 @@ public function getPerson(): string
*/
public function setPerson(string $person): self
{
$this->person = $person;
$this->person = Str::limit($person, self::PERSON_NAME_MAX_LENGTH);

return $this;
}
Expand All @@ -1268,6 +1278,10 @@ public function getCompany(): ?string
*/
public function setCompany(?string $company): self
{
if (isset($company)) {
$company = Str::limit($company, self::COMPANY_NAME_MAX_LENGTH);
}

$this->company = $company;

return $this;
Expand Down
5 changes: 5 additions & 0 deletions src/Model/Consignment/UPSConsignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ class UPSConsignment extends AbstractConsignment
{
public const DEFAULT_WEIGHT = 3000;

/**
* @var int
*/
public const PERSON_NAME_MAX_LENGTH = 35;

/**
* @internal
* @var int
Expand Down

0 comments on commit 5bb9271

Please sign in to comment.