sergeevpasha/laravel-dpd 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sergeevpasha/laravel-dpd

最新稳定版本:v2.0.3

Composer 安装命令:

composer require sergeevpasha/laravel-dpd

包简介

Tiny DPD API wrapper for Laravel

关键字:

README 文档

README

Maintainability Test Coverage CodeFactor Generic badge Generic badge

IMPORTANT UPDATE

DPD made lots of changes, so the best way I see it is having DPD API as a service, so starting from now on this package will have only a few basic functionality required for it, consider using it (will be available later) instead.

Laravel DPD API Wrapper

Allows you to:

  • Get all DPD cities
  • Get all DPD Terminals
  • Calculate a delivery

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'),
'user'       => env('DPD_USER'),
'login'      => env('DPD_LOGIN'),
'password'   => env('DPD_PASSWORD'),
'prefix'     => 'dpd',
'middleware' => ['web']
php artisan vendor:publish --provider="SergeevPasha\DPD\Providers\DPDServiceProvider" --tag="config"

After installing, you may just import the client

use SergeevPasha\DPD\Libraries\DPDClient;
/* 
    You may find your User ID by entering DPD Cabinet.
    Here we are initializing the client.
*/
$client = new DPDClient('user', 'key');

Now we can use these methods:

$client->getCountryCities(string $country)
$client->getTerminals()
$client->findByTrackNumber(string $trackNumber)  
/* 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

统计信息

  • 总下载量: 1.89k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固