2017 © Pedro Peláez
 

library glsdk-parcelshop-api

Webservice for GLS ParcelShop

image

lsv/glsdk-parcelshop-api

Webservice for GLS ParcelShop

  • Tuesday, June 27, 2017
  • by lsv
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,758 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

GLS parcelshop (for Denmark)

Build Status Coverage Status, (*1)

Get parcelshops from either, (*2)

  • 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, (*3)

Returns $shop is a Entity\Parcelshop object, (*4)

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, (*5)

Returns $shops is a array of Entity\Parcelshop, (*6)

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, (*7)

Throws Exceptions\MalformedAddressException if address is unknown, (*8)

Returns $shops is a array of Entity\Parcelshop, (*9)

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, (*10)

Add retry guzzle client

First install it with composer, (*11)

composer require guzzlehttp/retry-subscriber

Now create our client, (*12)

<?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();

The Versions