Skip to content

Commit

Permalink
fix(shipment): include address2 in street (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Ernst authored Oct 13, 2023
1 parent 931485e commit 0e434de
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Shipment/Request/PostShipmentsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ private function getPickupLocation(Shipment $shipment): ?array
private function getRecipient(Shipment $shipment): array
{
$recipient = $shipment->recipient;
$street = trim(implode(' ', [$recipient->address1, $recipient->address2])) ?: null;

return Utils::filterNull([
'area' => $recipient->area,
Expand All @@ -272,7 +273,7 @@ private function getRecipient(Shipment $shipment): array
'postal_code' => $recipient->postalCode,
'region' => $recipient->region,
'state' => $recipient->state,
'street' => $recipient->address1,
'street' => $street,
'street_additional_info' => $recipient->address2,
'eori_number' => $recipient->eoriNumber,
'vat_number' => $recipient->vatNumber,
Expand Down
12 changes: 12 additions & 0 deletions tests/Unit/Shipment/Repository/CreateConceptsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@
],
],
],
'address with address1 and address2 combined' => [
'input' => [
[
'carrier' => ['id' => Carrier::CARRIER_POSTNL_ID],
'recipient' => array_merge(DEFAULT_INPUT_RECIPIENT, [
'address1' => 'Tuinstraat',
'address2' => '35',
]),
],
],
],

'simple domestic shipment' => [
'input' => [
[
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"carrier": 1,
"general_settings": {
"save_recipient_address": 0
},
"options": {
"package_type": 1,
"delivery_type": 2
},
"physical_properties": {
"weight": 0
},
"recipient": {
"cc": "NL",
"city": "Hoofddorp",
"person": "Jaap Krekel",
"postal_code": "2132JE",
"street": "Tuinstraat 35",
"street_additional_info": "35"
}
}
]

0 comments on commit 0e434de

Please sign in to comment.