dhl / sdk-api-ecom-us
DHL eCommerce US API SDK
1.0.0
2021-03-17 15:51 UTC
Requires
- php: ^7.1.0
- ext-json: *
- netresearch/jsonmapper: ^1.4.0
- php-http/discovery: ^1.0.0
- php-http/httplug: ^2.0.0
- php-http/logger-plugin: ^1.0.0
- psr/http-client: ^1.0.0
- 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
- psr/http-message-implementation: ^1.0.0
- psr/log: ^1.1.0
Requires (Dev)
- nyholm/psr7: ^1.0.0
- php-http/mock-client: dev-upgrade-version-2
- phpstan/phpstan: ^0.12.2
- phpunit/phpunit: ^7.0.0
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-09-20 16:04:29 UTC
README
DHL eCommerce US API SDK 包提供了以下网络服务的接口
- DHL eCommerce Solutions Americas API,版本 4
需求
系统需求
- PHP 7.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 消息的任何包
开发包需求
nyholm/psr7
:PSR-7 HTTP 消息工厂和消息实现phpunit/phpunit
:测试框架php-http/mock-client
:HTTPlug 模拟客户端实现phpstan/phpstan
:静态分析工具squizlabs/php_codesniffer
:静态分析工具
安装
$ composer require dhl/sdk-api-ecom-us
卸载
$ composer remove dhl/sdk-api-ecom-us
测试
$ ./vendor/bin/phpunit -c test/phpunit.xml
特性
DHL eCommerce US API SDK 支持以下特性
- 创建标签
- 创建清单
标签创建
为 DHL eCommerce 创建标签以及相关的运输文件。
公共 API
适合消费的库组件包括
- 服务
- 服务工厂
- 标签服务
- 数据传输对象构建器
- 数据传输对象
- 身份验证存储
- 带有包装标识符和标签数据的标签
使用
$logger = new \Psr\Log\NullLogger(); $authStorage = new \Dhl\Sdk\EcomUs\Model\Auth\AuthenticationStorage( $username = 'u5er', $password = 'p4ss' ); $serviceFactory = new \Dhl\Sdk\EcomUs\Service\ServiceFactory(); $service = $serviceFactory->createLabelService($authStorage, $logger, $sandbox = true); $requestBuilder = new \Dhl\Sdk\EcomUs\Model\Label\LabelRequestBuilder(); $requestBuilder->setShipperAccount( $pickupAccountNumber = '5323000', $distributionCenter = 'USMCO1' ); $requestBuilder->setShipperAddress( $country = 'US', $postalCode = '33324', $city = 'Plantation', $streetLines = ['1210 South Pine Island Road'], $company = 'DHL eCommerce' ); $requestBuilder->setReturnAddress( $country = 'US', $postalCode = '33324', $city = 'Plantation', $streetLines = ['1210 South Pine Island Road'], $company = 'DHL eCommerce' ); $requestBuilder->setRecipientAddress( $country = 'US', $postalCode = '90232', $city = 'Culver City', $streetLines = ['10441 Jefferson Blvd.', 'Suite 200'], $name = 'Jane Doe', $company = 'Foo Factory', $email = 'foo@example.org', $phone = '800 123456', $state = 'CA' ); $requestBuilder->setPackageId($uniquePackageId = 'TEST-9876543210'); $requestBuilder->setPackageDetails( $shippingProduct = 'PLT', $currency = 'USD', $packageWeight = 1.2, $weightUnit = 'LB' ); $labelRequest = $requestBuilder->create(); $label = $service->createLabel($labelRequest);
清单
创建包装清单并检索文件。
公共 API
适合消费的库组件包括
- 服务
- 服务工厂
- 清单服务
- 数据传输对象
- 身份验证存储
- 包含文档和包装错误的清单
使用
$logger = new \Psr\Log\NullLogger(); $authStorage = new \Dhl\Sdk\EcomUs\Model\Auth\AuthenticationStorage( $username = 'u5er', $password = 'p4ss' ); $serviceFactory = new \Dhl\Sdk\EcomUs\Service\ServiceFactory(); $service = $serviceFactory->createManifestationService($authStorage, $logger, $sandbox = true); // create manifest for all available packages $manifest = $service->createManifest($pickupAccountNumber = '5323000'); // OR create manifest for certain packages, identified by number $manifest = $service->createPackageManifest( $pickupAccountNumber = '5323000', $packageIds = [ "TEST-0123456789", "TEST-9876543210" ] ); // documentation may not be instantly available, try again later if ($manifest->getStatus() !== \Dhl\Sdk\EcomUs\Api\Data\ManifestInterface::STATUS_COMPLETED) { $manifest = $service->getManifest( $pickupAccountNumber = '5323000', $requestId = $manifest->getRequestId() ); }