ginkida/laravel-dpd
Composer 安装命令:
composer require ginkida/laravel-dpd
包简介
DPD API wrapper for Laravel
README 文档
README
Laravel DPD API Wrapper
Allows you to:
- Find a City by query string
- Find a Street by City ID and query string
- Find a City that has Receive Points / Terminals
- Find Receive Points / Terminals
- Find Terminals
- Calculate a delivery
No Database required
If you did research of DPD API you must know, that they suppose you to fetch data files with cities, terminals and streets and manage all of it by your own. However, with this package, there is no need for that.
Pre-requirements
You need to get DPD API key, user, login and password. Key can be obtained in your cabinet at https://www.dpd.ru/ols/order/personal/integrationKey.do2
Installation
composer require sergeevpasha/laravel-dpd
Configuration
This package has a few configuration values:
'key' => env('DPD_KEY', null),
'user' => env('DPD_USER', null),
'login' => env('DPD_LOGIN', null),
'password' => env('DPD_PASSWORD', null),
'prefix' => 'dpd',
'middleware' => ['web']
If you only need to use DPDClient, you may completely skip this configuration. Otherwise, you can use default options and specify some data in .env file:
- DPD_KEY
- DPD_USER
- DPD_LOGIN
- DPD_PASSWORD
To make full use of predefined routes, you will need to publish the config:
php artisan vendor:publish --provider="SergeevPasha\DPD\Providers\DPDServiceProvider" --tag="config"
Now you can change routes prefix and middleware to whatever you need
Use Case #1
After installing, you may just import the client
use SergeevPasha\DPD\Libraries\DPDClient;
Firstly let's initialize and get a session. Session is required for a few methods.
/*
You may find your User ID by entering DPD Cabinet.
Here we are initializing the client.
*/
$client = new DPDClient('user', 'key');
/*
Please make sure you understand the diff between login and User.
We need to get a session, so we are authorizing with login and password
*/
$session = client->authorize('login', 'password);
Now we can use these methods:
$client->findCity(string $query, string $country) $client->findCityStreet(int $city, string $query, string $session) $client->findReceivePointCity(string $query) $client->getReceivePoints(string $bounds, string $city) $client->getTerminals(string $bounds, string $city) /* This one requires a Delivery Object, see next to see how to build it */ $client->getPrice(Delivery $delivery)
Delivery Object
To build a Delivery object you will need to pass an array to fromArray() method just like that:
Delivery::fromArray([
arrival_city_id => 123456, // Arrival City ID from findCity() method
derival_city_id => 123456, // Derival City ID from findCity() method
arrival_terminal => 1, // Set 1 if you are delivering to terminal
derival_terminal => 0, // Set 1 if you send from terminal
parcel_total_weight => 20, // Total parcel weight, KG
parcel_total_volume => 0.5, // Total parcel volume, M3
parcel_total_value => 1000500.50, // Total parcel volume, RUB
pickup_date => 2020-10-10, // YYYY-MM-DD Format, when your parcel should be picked up for delivery
max_delivery_days => 15, // Show only options that can be delivered for that or less amount of days
max_delivery_price => 1000.10, // Show only options that costs that or less price
services => [
'ECU',
'CUR'
], // List of available services
])
Available countries
If you need to specify a country you need to use one of these codes:
RU - Russia KZ - Kazakhstan AM - Armenia BY - Belarus KG - Kyrgyzstan
Available services
If you need to specify a service you need to use one of these codes:
BZP = '18:00';
ECN - ECONOMY
ECU - ECONOMY CU
CUR - CLASSIC
NDY - EXPRESS
CSM - Online Express
PCL - OPTIMUM
PUP - SHOP
DPI - CLASSIC international IMPORT
DPE - CLASSIC international EXPORT
MAX - MAX domestic
MXO - Online Max
Use Case #2
There are some predefined routes, that will be merged with your routes as well. You may check it by using
php artisan routes:list
It actually exposes the same methods to the routes, so it should be pretty clear on how to use it.
For more information on how to use it, please check out src/ folder.
ginkida/laravel-dpd 适用场景与选型建议
ginkida/laravel-dpd 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 05 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「dpd」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ginkida/laravel-dpd 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ginkida/laravel-dpd 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ginkida/laravel-dpd 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DPD Magento2 Shipping extension
DPD Connect - Magento2 Shipping GraphQL
OroCommerce DPD Integration
DPD Connect - Magento2 Shipping Hyva Compatibility module
DPD carrier api library
PHP wrapper for DPD Germany SOAP API
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-17