lsv / glsdk-parcelshop-api
Webservice for GLS ParcelShop
Installs: 1 877
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- doctrine/collections: ~1.0
- guzzlehttp/guzzle: ^6.0
Requires (Dev)
- fabpot/php-cs-fixer: ~1.4
- pdepend/pdepend: ~2.0
- phing/phing: ~2.0
- phpdocumentor/phpdocumentor: ~2.0
- phploc/phploc: ~2.0
- phpmd/phpmd: ~2.0
- phpunit/phpunit: ~4.0
- satooshi/php-coveralls: ~0.6
- sebastian/phpcpd: ~2.0
- squizlabs/php_codesniffer: ~1.4
This package is auto-updated.
Last update: 2024-12-10 11:13:39 UTC
README
Get parcelshops from either
- A parcelshop number
- A danish zipcode
- Nearby an address
- Or get all parcelshops in Denmark
Get single parcelshop by Id
<?php require 'vendor/autoload.php'; use Lsv\GlsDk\ParcelShop; $p = new ParcelShop(); $shop = $p->getParcelshop( ID );
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\GlsDk\ParcelShop; $p = new ParcelShop(); $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\GlsDk\ParcelShop; $p = new ParcelShop(); $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
Get all parcelshops in Denmark
<?php require 'vendor/autoload.php'; use Lsv\GlsDk\ParcelShop; $p = new ParcelShop(); $shops = $p->getAllParcelshops();
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\GlsDk\ParcelShop; use GuzzleHttp\Subscriber\Retry\RetrySubscriber; $retry = new RetrySubscriber([ 'filter' => RetrySubscriber::createStatusFilter() ]); $client = new GuzzleHttp\Client(); $client->getEmitter()->attach($retry); $p = new ParcelShop($client); $shops = $p->getAllParcelshops();
Change to another GLS country
<?php require 'vendor/autoload.php'; use Lsv\GlsDk\ParcelShop; $p = new ParcelShop(null, 'url-to-webservice'); $shops = $p->getAllParcelshops();