pactode / gls-parcel-shop
A simple wrapper for GLS Parcel Shop Webservice
Requires
- php: ^8.0
- illuminate/support: ^10.0
- laminas/laminas-soap: ^2.13
Requires (Dev)
- laravel/pint: ^1.10
- orchestra/testbench: ^8.0
- pestphp/pest: ^1.23
README
The pactode/gls-parcel-shop
package is a simple wrapper for the GLS Parcel Shop Webservice written in PHP with a service provider for Laravel.
Table of Contents
Installation
You can install the package via composer:
composer require pactode/gls-parcel-shop
The package will automatically register itself.
You can optionally publish the config file with:
php artisan vendor:publish --tag="parcel-shop-config"
Usage
The GLS Parcel Shop webservice allows you to retrieve the following information:
- All parcel shops for a given country
- Find a specific parcel shop by its unique number
- Find parcel shops near an address
- Find parcel shops within a specific zip code, country
Setting up the client
This can be skipped in Laravel as the client is bound to the service container.
$client = GLSParcelShop::make('http://www.gls.dk/webservices_v4/wsShopFinder.asmx?WSDL');
Resolving it from the Laravel Service Container
use Pactode\ParcelShop\Contracts\ParcelShop; $client = app(ParcelShop::class);
Get all parcel shops
$client->all('DK'); // returns Illuminate\Support\Collection
This request returns a collection of Pactode\ParcelShop\Resources\ParcelShop
resources.
Find a specific parcel shop
$parcelShop = $client->find(12345); // returns Pactode\ParcelShop\Resources\ParcelShop // The following getters are available for ParcelShop: $parcelShop->number(); $parcelShop->company(); $parcelShop->streetName(); $parcelShop->streetName2(); $parcelShop->zipCode(); $parcelShop->city(); $parcelShop->countryCode(); $parcelShop->latitude(); $parcelShop->longitude(); $parcelShop->openingHours(); // returns a collection of OpeningHour resources // Only available if you find parcel shops near an address $parcelShop->distance(); // 875 $parcelShop->distanceInKm(); // 0.875 // Available getters for the OpeningHour resource $openingHour->day(); // Monday $openingHour->from(); // 08:00 $openingHour->to(); // 20:00
Find parcel shops near an address
// Params: Street, Zip Code, Country Code, Amount (optional, default to 5) $client->nearest('Amaliegade 16', '1256', 'DK', 10); // returns Illuminate\Support\Collection
Find parcel shops within a zip code
$client->within('1256', 'DK'); // returns Illuminate\Support\Collection
Testing
composer test
Security
If you discover any security issues, please email dev@pactode.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.