PHP code example of rafalli / dpd-info-services-bundle
1. Go to this page and download the library: Download rafalli/dpd-info-services-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rafalli / dpd-info-services-bundle example snippets
use Rafalli\DpdInfoServicesBundle\Dto\Request\RetrievalContextDto;
use Rafalli\DpdInfoServicesBundle\Dto\Response\DpdEventDto;
use Rafalli\DpdInfoServicesBundle\Exception\DpdApiException;
use Rafalli\DpdInfoServicesBundle\Service\DpdInfoServiceClientInterface;
// Inject the interface via constructor
public function __construct(
private readonly DpdInfoServiceClientInterface $dpdClient
) {}
// Fetch and process events
try {
$response = $this->dpdClient->fetchNewEvents(new RetrievalContextDto(limit: 100));
foreach ($response->events as $event) {
// $event is an instance of DpdEventDto
// Access data: $event->waybill, $event->eventCode, $event->newWaybill
}
// Confirm processing (Required by DPD API to clear the queue)
if ($response->
use Rafalli\DpdInfoServicesBundle\Service\WaybillDeliveryTrackerInterface;
public function __construct(
private readonly WaybillDeliveryTrackerInterface $deliveryTracker
) {}
public function checkStatus(string $waybill): void
{
// Returns true if the parcel is marked as delivered (including COD deliveries)
if ($this->deliveryTracker->isDelivered($waybill)) {
}
}
public function checkDeliveryDate(string $waybill): void
{
// Returns the DateTimeImmutable object of the exact delivery moment
$date = $this->deliveryTracker->getDeliveryDate($waybill);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.