handler)(new GetShipmentByExternalOrderRef($externalOrderId)); if ($shipment === null) { return new JsonResponse(['error' => 'Shipment not found.'], Response::HTTP_NOT_FOUND); } return new JsonResponse([ 'orderRef' => $shipment->orderRef->toString(), 'status' => $shipment->status()->value, 'address' => [ 'recipientName' => $shipment->address->recipientName, 'street' => $shipment->address->street, 'city' => $shipment->address->city, 'postalCode' => $shipment->address->postalCode, 'country' => $shipment->address->country, ], 'parcel' => [ 'weightInGrams' => $shipment->parcel->weightInGrams, 'description' => $shipment->parcel->description, ], ]); } }