Skip to content

Commit

Permalink
Assert house number is passed separately for undocumented sender addr…
Browse files Browse the repository at this point in the history
…ess logic

Closes #25.
  • Loading branch information
villermen committed Jul 5, 2023
1 parent 31052b1 commit 81dbffe
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,14 @@ protected function getParcelData(
if ($senderAddress instanceof SenderAddress) {
$parcelData['sender_address'] = $senderAddress->getId();
} elseif ($senderAddress instanceof Address) {
// API will assert that house number is passed separately. See
// https://github.com/Webador/sendcloud/issues/25.
if (!$senderAddress->getHouseNumber()) {
throw new \InvalidArgumentException(
'House number must be passed separately on Address instance passed as sender address.'
);
}

$parcelData = array_merge($parcelData, [
'from_name' => $senderAddress->getName(),
'from_company_name' => $senderAddress->getCompanyName() ?? '',
Expand Down

0 comments on commit 81dbffe

Please sign in to comment.