signifly / gls-parcel-shop
A simple wrapper for GLS Parcel Shop Webservice
Requires
- php: ^7.2.5|^8.0
- illuminate/support: ^6.0|^7.0|^8.0
- laminas/laminas-soap: ^2.8
Requires (Dev)
- orchestra/testbench: ^4.0|^5.0|^6.0
- phpunit/phpunit: ^7.5|^8.0|^9.0
This package is auto-updated.
Last update: 2024-04-21 14:48:38 UTC
README
The signifly/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 signifly/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 Signifly\ParcelShop\Contracts\ParcelShop; $client = app(ParcelShop::class);
Get all parcel shops
$client->all('DK'); // returns Illuminate\Support\Collection
This request returns a collection of Signifly\ParcelShop\Resources\ParcelShop
resources.
Find a specific parcel shop
$parcelShop = $client->find(12345); // returns Signifly\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('Vesterbrogade 44', '1620', 'DK', 10); // returns Illuminate\Support\Collection
Find parcel shops within a zip code
$client->within('1620', 'DK'); // returns Illuminate\Support\Collection
Testing
composer test
Security
If you discover any security issues, please email dev@signifly.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.