From 81dbffecf1c332ac5ca296e86d7799ac877c9e97 Mon Sep 17 00:00:00 2001 From: Villermen Date: Wed, 5 Jul 2023 10:33:05 +0200 Subject: [PATCH] Assert house number is passed separately for undocumented sender address logic Closes #25. --- src/Client.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Client.php b/src/Client.php index 85d887f..bdefc64 100644 --- a/src/Client.php +++ b/src/Client.php @@ -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() ?? '',