lsv / pd-parcelshop-api
Webservice for PostNord ParcelShop
Installs: 2 050
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: ^5.6|^7.0
- ext-json: *
- doctrine/collections: ~1.0
- guzzlehttp/guzzle: ^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0|^2.5
- pdepend/pdepend: ^2.0
- phing/phing: ^2.0
- phploc/phploc: ^4.0
- phpmd/phpmd: ^2.0
- phpunit/phpunit: ^5.0
- sebastian/phpcpd: ^3.0
- squizlabs/php_codesniffer: ^3.0
README
Get parcelshops from either
- A parcelshop number
- A danish zipcode
- Nearby an address
Connecting
You will need an ApiKey to get access to the API
Get single parcelshop by Id
<?php require 'vendor/autoload.php'; use Lsv\PdDk\Client; $p = new Client( API_KEY ); $shop = $p->getParcelshop( ZIPCODE , ID ); // Yes zipcode is unfortunately mandatory
Throws Exceptions\ParcelNotFoundException
if not found
Returns $shop
is a Entity\Parcelshop
object
Get parcelshops from a zipcode
<?php require 'vendor/autoload.php'; use Lsv\PdDk\Client; $p = new Client( API_KEY ); $shops = $p->getParcelshopsFromZipcode( ZIPCODE );
Throws Exceptions\NoParcelsFoundInZipcodeException
if none found
Returns $shops
is a array of Entity\Parcelshop
Get parcelshops near address
<?php require 'vendor/autoload.php'; use Lsv\PdDk\Client; $p = new Client( API_KEY ); $shops = $p->getParcelshopsNearAddress( STREET , ZIPCODE, 20 );
Third argument is how many you want
Throws Exceptions\MalformedAddressException
if address is unknown
Returns $shops
is a array of Entity\Parcelshop
Add retry guzzle client
First install it with composer
composer require guzzlehttp/retry-subscriber
Now create our client
<?php require 'vendor/autoload.php'; use Lsv\PdDk\Client; use GuzzleHttp\Subscriber\Retry\RetrySubscriber; $retry = new RetrySubscriber([ 'filter' => RetrySubscriber::createStatusFilter() ]); $httpClient = new GuzzleHttp\Client(); $httpClient->getEmitter()->attach($retry); $p = new Client($httpClient); $shops = $p->getParcelshopsNearAddress( STREET , ZIPCODE, 20 );