定制 solunsky/dpd-interconnector 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

solunsky/dpd-interconnector

Composer 安装命令:

composer require solunsky/dpd-interconnector

包简介

Interconnector is a REST-based Web-Service to integrate information systems of DPD customers, which through POST requests allows using DPD services provided. Interconnector allows to use DPD services by transmitting shipment information, requesting package pickups, printing parcel labels, etc.

README 文档

README

Interconnector is a REST-based Web-Service to integrate information systems of DPD customers, which through POST requests allows using DPD services provided. Interconnector allows to use DPD services by transmitting shipment information, requesting package pickups, printing parcel labels, etc.

Documentation

Interconnector (EN) V2.6 | From DPD LV (DPD shipment creation and tracking web services)

Interconnector (EN) V2.4 | From DPD EE

Installiation

Require

  • PHP >=5.5

Work at PHP ^7.*

composer require solunsky/dpd-interconnector

Full example

use Solunsky\Interconnector\Authentication;
use Solunsky\Interconnector\Request\CreateShipment;
use Solunsky\Interconnector\Request\PrintLabel;
use Solunsky\Interconnector\Client;

$auth = new Authentication('username', 'password', 'lv');
$shipmentRequest = new CreateShipment($auth, $params);
$client = new Client(array('verify' => false));

// Response
$shipmentResponse = $client->get($shipmentRequest);
// Output json

// Response Label
$printRequest = new PrintLabel($auth, $shipmentResponse['pl_number']);
$printResponse = $client->get($printRequest, false);
// Output string

header("Content-type:application/pdf");
echo $print;

Authentication (Step 1)

Params:
string|array $countryCode: 'lv' or 'ee' or 'lt' or array("uk" => "https://integration.dpd.uk/ws-mapper-rest/")
boolean $debug: default false
Example:
use Solunsky\Interconnector\Authentication;

$auth = new Authentication('username', 'password', $countryCode);

Methods (Step 2)

Shipment creation

This method creates shipment that can contain one or multiple parcels. The data that is needed for creating shipments will depend on DPD service that is requested.

Params:

Read the documentation

array $params
Example:
use Solunsky\Interconnector\Request\CreateShipment;

$response = new CreateShipment($auth, $params);

Parcel label creation

This method generates a parcel label. There’s a possibility to configure automatic data submission by DPD triggered by parcel printing.

Params:

Read the documentation

string $numbers: parcel number (pl_number)
string $printType: default PDF, other epl, zpl
string $printFormat: default A6, other A4, A5
integer $printSequence: default 1
string $printPosition: default LeftTop
Example:
use Solunsky\Interconnector\Request\PrintLabel;

$print = new PrintLabel($auth, $response['pl_number']);

header("Content-type:application/pdf");
echo $print;

Parcel pickup request

This method provides information for DPD that you need a courier that should pick up your parcels. It has to be used in cases if there is no pre-agreed regular parcel’ pick-up time.

Params:

Read the documentation

array $params
Example:
use Solunsky\Interconnector\Request\ParcelPickup;

$response = new ParcelPickup($auth, $params);

Pickup point search

This method provides a list of DPD Pickup points (parcel shops and pickup lockers).

Params:

Read the documentation

array $params

Parcel pickup request

This method provides information for DPD that you need a courier that should pick up your parcels. It has to be used in cases if there is no pre-agreed regular parcel’ pick-up time.

Params:

Read the documentation

array $params
Example:
use Solunsky\Interconnector\Request\ParcelPickup;

$response = new ParcelPickup($auth, $params);

Deleting a parcel

This method deletes a specific parcel. If shipment consists of more than one parcel, whole shipment will be deleted in case if any parcel from this shipment is deleted.

Note: this function cannot be done in case if data has been transferred to DPD by closing manifest, by using parcelDataSend_ (SendParcelData) or by automatic data transfer that is configured by DPD.

Params:

Read the documentation

string $numbers
Example:
use Solunsky\Interconnector\Request\DeleteShipment;

$response = new DeleteShipment($auth, $numbers);

Parcel data submission

This method submits shipment data to DPD. Regularity for this function can be adapted to client processes, but it should be requested at least 30 minutes before courier arrival. If needed, can be used after each parcel. It should not be used in case if manifest closure is used or if automatic data transfer is configured by DPD.

Params:

Read the documentation

mixed $auth
Example:
use Solunsky\Interconnector\Request\SendParcelData;

$response = new SendParcelData($auth);

Manifest closure

This method submits shipment data for shipments that are created on specific date and returns document that contains information about all the parcels that has been created by the API user on this date and that were not included in any other manifest. Regularity for this function can be adapted to client processes, but it should be requested at least 30 minutes before courier arrival. If needed, can be used after each parcel. It should not be used in case if parcel data submission method is used or if automatic data transfer is configured by DPD.

Params:

Read the documentation

mixed $date: (YYYYMM-DD)
mixed $format: default PDF, other json, zpl, epl
Example:
use Solunsky\Interconnector\Request\PrintManifest;

$response = new PrintManifest($auth, $date, $format);

Collection request

This method allows to order a courier to address of a third party. For example - for DPD client to organize his customer a free return of goods (paid by DPD client not his customer).

Params:

Read the documentation

array $params
Example:
use Solunsky\Interconnector\Request\RequestCollection;

$response = new RequestCollection($auth, $params);

Client (Step 3)

Params:

Read GuzzleHttp documentation

Class Client

array $params

Method Get

mixed $request,
boolean $jsonDecode: default true
Example:
use Solunsky\Interconnector\Client;

$client = new Client(array('verify' => false));

$response = $client->get($request);

Create custom request

If you want to create your custom request use this example.

namespace Solunsky\Interconnector\Request;

class CustomRequest extends Request
{
    private $params;

    public function __construct($authentication, $params)
    {
        parent::__construct($authentication);

        $this->params = $params;
    }

    public function get()
    {
        $body = array_merge(
            $this->authentication->credentials(),
            $this->params
        );

        $headers = array(
            'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8',
        );

        return $this->build('POST', 'method_uri', $headers, $body);
    }
}

Use:
$customRequest = new CustomRequest($auth, $params);

$response = $client->get($customRequest);

solunsky/dpd-interconnector 适用场景与选型建议

solunsky/dpd-interconnector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.07k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 10 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「shipping」 「delivery」 「label」 「parcel」 「courier」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 solunsky/dpd-interconnector 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 solunsky/dpd-interconnector 我们能提供哪些服务?
定制开发 / 二次开发

基于 solunsky/dpd-interconnector 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 36
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-11