pamekar / laravel-postnl-api
Laravel PostNL API包
dev-master
2024-06-19 21:49 UTC
Requires
- guzzlehttp/guzzle: ^6.3|^7.0|^7.7
- illuminate/support: 5.8.*|6.*.*|7.*.*|8.*.*|9.*.*|10.*.*|11.*
- nesbot/carbon: ^2.16|^3.0
This package is not auto-updated.
Last update: 2024-09-25 23:03:57 UTC
README
通过ServiceProvider和Facade将PostNL API与Laravel 5 & 6集成。
安装
composer require deniztezcan/laravel-postnl-api
在config/app.php
中将ServiceProvider添加到providers数组中
'providers' => [ //other things here DenizTezcan\LaravelPostNLAPI\PostNLAPIServiceProvider::class, ];
将facade添加到facades数组中
'aliases' => [ //other things here 'PostNLAPI' => DenizTezcan\LaravelPostNLAPI\Facades\PostNLAPI::class, ];
最后,发布配置文件
php artisan vendor:publish --provider="DenizTezcan\LaravelPostNLAPI\PostNLAPIServiceProvider"
配置
请设置API:url
、key
以及客户code
、number
、location
、email
和address
,在config/postnlapi.php
中
用法
要生成barcode
,可以使用以下调用。要查找要使用的type
和serie
,请参阅PostNL文档
$barcode = PostNLAPI::generateBarcode('3S', '00000000000-99999999999');
要生成label
,可以使用以下调用。要查找要使用的PrinterType
、AddressType
和ProductCodeDelivery
,请参阅PostNL文档
use DenizTezcan\LaravelPostNLAPI\Entities\{Address, Contact}; $label = PostNLAPI::generateLabel( $barcode, 'GraphicFile|PDF', [Address::create([ 'AddressType' => '01', 'City' => "Testdorp", 'CompanyName' => "Crusty Crab BV", 'Countrycode' => "NL", 'HouseNr' => "1", 'Street' => "Teststraat", 'Zipcode' => "1111AA", 'FirstName' => "Meneer", 'Name' => "Krabs" ]), Address::create([ 'AddressType' => '09', 'City' => "Testdorp", 'CompanyName' => "Crusty Crab BV", 'Countrycode' => "NL", 'HouseNr' => "1", 'Street' => "Teststraat", 'Zipcode' => "1111AA", 'FirstName' => "Meneer", 'Name' => "Krabs" ])], [Contact::create([ 'ContactType' => "01", 'Email' => 'test@meneer.nl', 'SMSNr' => '061111111', 'TelNr' => '061111111' ])], '01', '3085', 'This is a reference', 'This is a remark' );
注意:注意需要传递给第二个和第三个参数的数组!没有它将无法正常工作!
要获取最近的PostNL位置的数组,可以使用以下调用。您必须将CountryCode
和PostalCode
作为参数传递。
$locations = PostNLAPI::nearestLocations('NL', '1111AA');