定制 jackbayliss/laravel-dhl-api 二次开发

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

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

jackbayliss/laravel-dhl-api

最新稳定版本:v1

Composer 安装命令:

composer require jackbayliss/laravel-dhl-api

包简介

DHL XML Wrapper for Laravel

README 文档

README

I needed a DHL wrapper so I could efficiently provide courier quotes to customers- I did find one. But, it needed to be adjusted to work for my needs- this is effectively the edited version to provide Quotes, Routing and Tracking.

Getting Started

Prerequisites

This should work fine on Laravel>=5.7.28, if your version of Laravel does not support auto linking you will need to add \jackbayliss\DHLApi\DHLAPIProvider::class into your providers array located in config/app.php

Installing

composer require jackbayliss/laravel-dhl-api

Usage Examples

Config setup

In order to use the wrapper you'll need to setup a few things in your Config.php file- or alternatively you .env file if you don't want to use the config.

You'll need to set from_country_code,from_post_code,account_number,siteid,password in your config

or alternatively set DHL_SITEID,DHL_PASSWORD,DHL_ACCOUNT_NUMBER, DHL_FROM_COUNTRYCODE,DHL_FROM_POSTCODE in your .env don't forget to edit the config to be null for all the entries.

Quotation

This is typically used to get shipping quotes, as well as the time for transit etc.

$quote = new \jackbayliss\DHLApi\Calls\GetQuote();
$quote->declaredValue(10)->reference("0999999999990393939333333333")
->currency("GBP")->toCountryCode("DE")->toPostalCode("91056")->setPieces([
 array("height" => 10,"width" => 10 ,"depth" => 2,"weight" => 0.5)
]);

$quote->getResponse();

Tracking

Self explanitory- it'll track a parcel for you.

 $tracking = new \jackbayliss\DHLApi\Calls\GetTracking();
 $tracking = $tracking->reference("0999999999990393939333333333")->trackingNumber("8564385550");
 $tracking->getResponse();

Routing

Used to provide routing information about a parcel to a particular address.

$routing = new  \jackbayliss\DHLApi\Calls\GetRouting();

$routing = $routing->reference("0999999999990393939333333333")->address([
'RegionCode' => 'EU', 
'RequestType' => 'O', 
'Address1'  => 'Oracle Parkway,',
'Address2' => 'Thames Valley Park (TVP)', 
'Address3' => 'Berkshire', 
'PostalCode' => 'RG6 1RA',
'City' => 'Reading',
'Division' => 'RE',
'CountryCode' => 'GB',
'CountryName' => 'United Kingdom', 
'OriginCountryCode' => 'GB'
]);

$routing->getResponse();

Methods

These methods can be linked to any of the above core API classes.

getResponse() - This will execute the cURL request and return the XML data as an Object.

getRawResponse() - This will return the XML response from the DHL API as A String.

toXML() - This will return the XML you sent to the DHL API as A String.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

统计信息

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

GitHub 信息

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

其他信息

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