Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
senghe committed Feb 6, 2025
1 parent dda1c73 commit e764554
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 10 additions & 1 deletion spec/EventListener/ShippingExportEventListenerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ function let (
ObjectManager $objectManager
) {
$shippingLabelsPath = 'labels';
$this->beConstructedWith($webClient, $requestStack, $filesystem, $objectManager, $shippingLabelsPath);
$this->beConstructedWith(
$webClient,
$requestStack,
$filesystem,
$objectManager,
$shippingLabelsPath,
'PDF',
'PDF',
'Test',
);
}

function it_export_shipment
Expand Down
7 changes: 6 additions & 1 deletion src/EventListener/ShippingExportEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public function exportShipment(ResourceControllerEvent $exportShipmentEvent): vo

$dpd->setSender($this->webClient->getSender());

/** @var object{"parcels": array} $result */
$result = $dpd->sendPackage($this->webClient->getParcels(), $this->webClient->getReceiver(), 'SENDER', $this->webClient->getServices());

$speedLabel = $dpd->generateSpeedLabelsByPackageIds([$result->packageId], $this->webClient->getPickupAddress(), 'DOMESTIC', $this->labelFileFormat, $this->labelPageFormat, $this->labelType); /** @phpstan-ignore-line */
Expand All @@ -110,7 +111,10 @@ public function exportShipment(ResourceControllerEvent $exportShipmentEvent): vo

$session->getFlashBag()->add('success', 'bitbag.ui.shipment_data_has_been_exported');
$this->saveShippingLabel($shippingExport, $speedLabel->filedata, strtolower($this->labelFileFormat)); /** @phpstan-ignore-line */
$this->markShipmentAsExported($shippingExport, $result->parcels[0]);

/** @var object{"Waybill": ?string} $parcel */
$parcel = $result->parcels[0];
$this->markShipmentAsExported($shippingExport, $parcel);
}

public function saveShippingLabel(
Expand Down Expand Up @@ -150,6 +154,7 @@ private function getFilename(ShippingExportInterface $shippingExport): string
);
}

/** @param object{"Waybill": ?string} $parcel */
private function markShipmentAsExported(ShippingExportInterface $shippingExport, $parcel): void
{
$shippingExport->setState(ShippingExportInterface::STATE_EXPORTED);
Expand Down

0 comments on commit e764554

Please sign in to comment.