dhl / sdk-api-unified-tracking
DPDHL 集团统一货运跟踪 API SDK
2.3.0
2024-05-24 10:40 UTC
Requires
- php: ^8.1.0
- ext-json: *
- netresearch/jsonmapper: ^4.0.0
- php-http/discovery: ^1.17.0
- php-http/httplug: ^2.2.0
- php-http/logger-plugin: ^1.2.1
- psr/http-client: ^1.0.1
- psr/http-client-implementation: ^1.0.0
- psr/http-factory: ^1.0.0
- psr/http-factory-implementation: ^1.0.0
- psr/http-message: ^1.0.0 || ^2.0.0
- psr/http-message-implementation: ^1.0.0 || ^2.0.0
- psr/log: ^1.1.0 || ^2.0.0 || ^3.0.0
Requires (Dev)
- fig/log-test: ^1.1.0
- nyholm/psr7: ^1.0.0
- php-http/mock-client: ^1.5.0
- phpstan/phpstan: ^1.5.0
- phpunit/phpunit: ^10.1.0
- rector/rector: *
- squizlabs/php_codesniffer: ^3.4
- symfony/finder: ^3.4.0
README
货运跟踪 API 提供最新的货运状态报告。此 API 的用户可以
- 检索货运的跟踪信息。
- 识别与货运相关的 Deutsche Post DHL (DPDHL) 服务提供商。
- 验证 DPDHL 是否使用了正确的送货地址。这可以减少误送货物的数量。
要求
系统要求
- PHP 8.1+,需要 JSON 扩展
包要求
netresearch/jsonmapper
:将 JSON 响应消息反序列化为 PHP 对象的映射器php-http/discovery
:HTTP 客户端和消息工厂实现的发现服务php-http/httplug
:可插拔的 HTTP 客户端抽象php-http/logger-plugin
:HTTPlug 的 HTTP 客户端日志插件psr/http-client
:PSR-18 HTTP 客户端接口psr/http-factory
:PSR-7 HTTP 消息工厂接口psr/http-message
:PSR-7 HTTP 消息接口psr/log
:PSR-3 日志接口
虚拟包要求
psr/http-client-implementation
:任何提供 PSR-18 兼容 HTTP 客户端的包psr/http-factory-implementation
:任何提供 PSR-7 兼容 HTTP 消息工厂的包psr/http-message-implementation
:任何提供 PSR-7 HTTP 消息的包
开发包要求
fig/log-test
:用于测试的 PSR-3 日志实现nyholm/psr7
:PSR-7 HTTP 消息工厂和消息实现phpunit/phpunit
:测试框架php-http/mock-client
:HTTPlug 模拟客户端实现phpstan/phpstan
:静态分析工具rector/rector
:自动重构工具,帮助进行 PHP 升级squizlabs/php_codesniffer
:静态分析工具symfony/finder
:用于加载预记录的 Web 服务响应的文件工具
安装
$ composer require dhl/sdk-api-unified-tracking
卸载
$ composer remove dhl/sdk-api-unified-tracking
测试
$ ./vendor/bin/phpunit -c test/phpunit.xml
静态代码分析
$ ./vendor/bin/phpstan --level=7 analyze ./src/
$ ./vendor/bin/phpcs --standard=PSR12 src/ test/
功能
DPDHL 集团统一货运跟踪 API SDK 支持以下功能
- 获取可跟踪货运的高级信息
跟踪服务
无论 DHL 的哪个业务单元正在处理货运,都可以获取可跟踪货运的状态信息。可以通过提供额外的搜索参数来缩小搜索结果的范围。
公共 API
适用于消费的库组件包括
- 服务
- 服务工厂
- 跟踪服务
- 数据传输对象
- 带有详细货运事件的跟踪信息
用法
<?php $consumerKey = 'Your application consumer key'; $logger = new \Psr\Log\NullLogger(); $defaultTimeZone = new \DateTimeZone('Europe/Berlin'); // or date_default_timezone_get() $trackingNumber = '9876543210'; $serviceFactory = new \Dhl\Sdk\UnifiedTracking\Service\ServiceFactory(); $service = $serviceFactory->createTrackingService($consumerKey, $logger, $defaultTimeZone); $response = $service->retrieveTrackingInformation($trackingNumber);