Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: prevent api errors for long person and company names #486

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading