neriba/dpd-api-lib
Composer 安装命令:
composer require neriba/dpd-api-lib
包简介
DPD API library, to help to integrate with other systems
README 文档
README
DPD API library, to help to integrate with other systems
Official DPD docs
Instalation
To install via composer:
composer require neriba/dpd-api-lib
Authentication
Environments
- LT - Lithuania production (default).
- LT_TEST - Lithuania sandbox.
- LV - Latvia production.
- LV_TEST - Latvia sandbox.
- EE - Estonia production.
- EE_TEST - Estonia sandbox.
Get new token
If you don't have an API key from DPD, but you have an old API credencials name and password you can generate your own API key.
// By default, third parameter is Lithuanian production environment $getToken = new \NeriBa\DpdApiLib\ApiTokenGenerator('USERNAME','PASSWORD','LT_TEST'); $getToken->createAuthToken('Token name');
Create instance
$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9....'; // By default, third parameter is Lithuanian production environment $dpd = new \NeriBa\DpdApiLib\Request($token, 'LT_TEST');
Get user information
$dpd->authMe();
Get list of tokens
$dpd->getAuthTokenSecrets();
Delete existing token
$dpd->deleteAuthTokenSecrets('99bb2035-5ed8-4547-95ca-7ffb5e79e694');
Services
Get services and price for user
// additional parameters are possible as an array e.g ['countryFrom' => 'LT', 'countryTo' => 'LT'] // Parameters list: https://esiunta.dpd.lt/api#/Services/042db4934d823e1cc21745c549f2a810 $dpd->getServices(['countryFrom' => 'LT', 'countryTo' => 'LT']);
Shipment
Get list of shipments
// additional parameters are possible as an array e.g ['limit'=> 10] // Parameters list: https://esiunta.dpd.lt/api/#/Shipment/1aed3b00cafe6d7bd576b2b84b41826f $dpd->getShipments();
Create simple shipment
$senderAddress = new \NeriBa\DpdApiLib\Shipment\Package\Address(); $senderAddress ->setName('Test Sender') ->setPhone('62166025') ->setStreet('Uosių g') ->setStreetNo(24) ->setCity('Kaunas') ->setPostalCode('51446') ->setCountry('LT'); $receiverAddress = new \NeriBa\DpdApiLib\Shipment\Package\Address(); $receiverAddress ->setName('Test Receiver') ->setPhone('65123456') ->setStreet('Uriekstes') ->setStreetNo(24) ->setCity('Kaunas') ->setPostalCode('51446') ->setCountry('LT'); $shipment = new \NeriBa\DpdApiLib\Shipment\Shipment(); $shipment ->setSenderAddress($senderAddress) ->setReceiverAddress($receiverAddress) ->setService((new \NeriBa\DpdApiLib\Shipment\Package\Service())->setServiceName('DPD CLASSIC')) ->setParcel((new \NeriBa\DpdApiLib\Shipment\Package\Parcel())->setWeight(31)->setSize('XS')); $shipment2 = new \NeriBa\DpdApiLib\Shipment\Shipment(); $shipment2 ->setSenderAddress($senderAddress) ->setReceiverAddress($receiverAddress) ->setService((new \NeriBa\DpdApiLib\Shipment\Package\Service())->setServiceName('DPD CLASSIC')) ->setParcel((new \NeriBa\DpdApiLib\Shipment\Package\Parcel())->setWeight(10)->setSize('m')); // Max 50 shipments per request $dpd->createShipments([$shipment,$shipment2]);
Delete shipments
$dpd->deleteShipments(['0fa01f06-7c56-4c5c-a33f-0eca869663f3','0fa01f06-7c56-4c5c-a33f-0eca869663f4']);
Labels
Create label
$dpd->createShipmentsLabels((new \NeriBa\DpdApiLib\Shipment\Package\LabelOption())->setShipmentIds(['0fa01f06-7c56-4c5c-a33f-0eca869663f3']));
Invoice
Gets invoice by uuid
$dpd->getInvoices('0fa01f06-7c56-4c5c-a33f-0eca869663f3');
Lockers
Find lockers based on given criteria
$dpd->getLockers(['countryCode' => 'LT']);
Manifest
Create shipment manifest
$dpd->createShipmentManifest((new \NeriBa\DpdApiLib\Shipment\Package\Manifest())->setShipmentIds(['0fa01f06-7c56-4c5c-a33f-0eca869663f3']));
Get shipment manifest by uuid
$dpd->getShipmentsManifestByManifest('0fa01f06-7c56-4c5c-a33f-0eca869663f3');
Get shipment manifest by shipment uuid
$dpd->getShipmentsManifestByShipment('0fa01f06-7c56-4c5c-a33f-0eca869663f3');
Pickup
Create pickup
$pickupAddress = new \NeriBa\DpdApiLib\Shipment\Package\Address(); $pickupAddress ->setName('Test Sender') ->setContactName('Test Sender cc') ->setEmail('john.doe@email.com') ->setPhone('+37062166025') ->setStreet('Uosių g') ->setStreetNo(24) ->setCity('Kaunas') ->setPostalCode('51446') ->setCountry('LT'); $pickup = new \NeriBa\DpdApiLib\Pickup\Pickup(); $pickup ->setPallets([(new \NeriBa\DpdApiLib\Pickup\Package\Pallet())->setWeight(150)->setCount(1)]) ->setAddress($pickupAddress) ->setPickupDate('2022-10-12') ->setPickupTime('11:00', '15:00'); $dpd->createPickup($pickup);
Get pickups
// additional parameters are possible as an array e.g ['limit'=> 10] // Parameters list: https://esiunta.dpd.lt/api/#/Pickup/50e315fc1327d9f9a55db05ef66b4b48 $dpd->getPickups();
Get list of pickup timeframes
// additional parameters are possible as an array e.g ['country' => 'LT','zip' => 51336] // Parameters list: https://esiunta.dpd.lt/api/#/Pickup%20timeframes/e092e35374638c464b1e0b3eaa7513d9 $dpd->getPickupTimeFrames(['country' => 'LT','zip' => 51336]);
Problem
Get a description for a problem from the knowledge base
$dpd->getProblems(123456);
Status
Gets parcel statuses
// additional parameters are possible as an array e.g ['pknr' => '05808021421108','show_all' => 1] // Parameters list: https://esiunta.dpd.lt/api#/Status/ede44d1ca4e3e15955d44ecc42970e3c $dpd->getTrackingStatus(['pknr' => '05808021421108']);
Subscribe to parcel
// additional parameters are possible as an array e.g ['parcelnumber' => '05808021421108', 'callbackurl' => 'https://www.hereisyoursiteurl.com'] // Parameters list: https://esiunta.dpd.lt/api#/Status/8d78b691726ba36b76c5960067c1370c $dpd->subscribeToParcel(['parcelnumber' => '05808021421108', 'callbackurl' => 'https://www.hereisyoursiteurl.com']);
Unsubscribe to parcel
// additional parameters are possible as an array e.g ['parcelnumber' => '05808021421108', 'callbackurl' => 'https://www.hereisyoursiteurl.com'] // Parameters list: https://esiunta.dpd.lt/api#/Status/915e1bfce8f27458cfb3f27f78326866 $dpd->unsubscribeToParcel(['parcelnumber' => '05808021421108', 'callbackurl' => 'https://www.hereisyoursiteurl.com']);
Tracking
Environments
- LT - Lithuania production (default).
- LV - Latvia production.
- EE - Estonia production.
Get tracking info by parcel numbers
NOTE: Now tracking working without authorization,although the documentation says that it is used Bearer.
$apiKey = ''; // By default, second parameter is Lithuanian production environment $tracking = new \NeriBa\DpdApiLib\Tracking($apiKey,'LT'); $tracking->getTracking(['05808021421108','05808021421105']);
License
The MIT License (MIT). Please see License File for more information.
neriba/dpd-api-lib 适用场景与选型建议
neriba/dpd-api-lib 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 841 次下载、GitHub Stars 达 4, 最近一次更新时间为 2022 年 10 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 neriba/dpd-api-lib 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 neriba/dpd-api-lib 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 841
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-11