diff --git a/src/Shipment/Request/PostShipmentsRequest.php b/src/Shipment/Request/PostShipmentsRequest.php index 251a811fc..a5a417209 100644 --- a/src/Shipment/Request/PostShipmentsRequest.php +++ b/src/Shipment/Request/PostShipmentsRequest.php @@ -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, @@ -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, diff --git a/tests/Unit/Shipment/Repository/CreateConceptsTest.php b/tests/Unit/Shipment/Repository/CreateConceptsTest.php index 12b6b6053..27f85c0db 100644 --- a/tests/Unit/Shipment/Repository/CreateConceptsTest.php +++ b/tests/Unit/Shipment/Repository/CreateConceptsTest.php @@ -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' => [ [ diff --git a/tests/__snapshots__/CreateConceptsTest__it_creates_a_valid_request_from_a_shipment_collection_with_data_set_address_with_address1_and_address2_combined__1.json b/tests/__snapshots__/CreateConceptsTest__it_creates_a_valid_request_from_a_shipment_collection_with_data_set_address_with_address1_and_address2_combined__1.json new file mode 100644 index 000000000..2d71610ea --- /dev/null +++ b/tests/__snapshots__/CreateConceptsTest__it_creates_a_valid_request_from_a_shipment_collection_with_data_set_address_with_address1_and_address2_combined__1.json @@ -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" + } + } +]