2017 © Pedro Peláez
 

library gls-tracking

Web-IT GLS Tracking API

image

webit/gls-tracking

Web-IT GLS Tracking API

  • Friday, October 6, 2017
  • by dbojdo
  • Repository
  • 4 Watchers
  • 4 Stars
  • 373 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 3 % Grown

The README.md

GLS Tracking SDK

Installation

Add the webit/gls-tracking into composer.json, (*1)

{
    "require": {
        "php":              ">=5.3.2",
        "webit/gls-tracking": "^2.0"
    }
}

Configuration / Usage

API Factory preparation

use Doctrine\Common\Annotations\AnnotationRegistry;
use Webit\GlsTracking\Api\Factory\TrackingApiFactory;
use Webit\GlsTracking\Model\UserCredentials;

$loader = include __DIR__.'/../vendor/autoload.php';
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));

if (is_file(__DIR__ .'/config.php') == false) {
    throw new \LogicException(
        'Missing required file "examples/config.php". Create it base on "examples/config.php.dist".'
    );
}

$config = require __DIR__ .'/config.php';

$apiFactory = new TrackingApiFactory();

Tracking API

$credentials = new UserCredentials('user', 'pass');

$api = $apiFactory->createTrackingApi($credentials);
$details = $api->getParcelDetails($parcelNo);

/** @var \Webit\GlsTracking\Model\Event $event */
printf("Details of parcel \"%s\"\n", $parcelNo);
foreach ($details->getHistory() as $event) {
    printf(
        "%s - Status: %s (%s), Location: %s, %s (%s)\n",
        $event->getDate(),
        $event->getCode(),
        $event->getDescription(),
        $event->getLocationName(),
        $event->getCountryName(),
        $event->getLocationCode()
    );
}
printf("Received by: %s\n", $details->getSignature());

$pod = $api->getProofOfDelivery($parcelNo);

printf("Proof of delivery filename: %s\n", $pod->getFileName());
file_put_contents('/your/docs/dir/' . $pod->getFileName(), $pod->getFile());

Tracking Url Provider

use Webit\GlsTracking\UrlProvider\TrackingUrlProviderFactory;
$factory = new TrackingUrlProviderFactory();

/** @var array $config */

$username = 'username';

$urlProvider = $factory->createTrackingUrlProvider();

$reference = 'parcel-no';

$url = $urlProvider->getStandardTrackingUrl($reference, 'EN', 'EN');

printf("Url for tracking \"%s\" (encrypted): %s\n", $reference, $url);

$url = $urlProvider->getEncryptedTrackingUrl($credentials, $reference, $config['language']);

printf("Url for tracking \"%s\" (encrypted): %s\n", $reference, $url);

$customerReference = 'customer-ref';
$customerNo = 'customer-no';
$url = $urlProvider->getEncryptedCustomerReferenceTrackingUrl($credentials, $customerReference, $customerNo, $config['language']);

printf("Url for tracking \"%s\" with customer \"%s\": %s\n", $customerReference, $customerNo, $url);

Examples

To configure the examples: * Copy examples/config.php.dist to examples/config.php * Change the values accordingly, (*2)

Run: bash php examples/details.php php examples/url-provider.php, (*3)

Tests

Unit / Integration tests

./vendor/bin/phpunit --testsuite unit

API tests

Requires valid GLS Tracking API credentials and valid parcel numbers, (*4)

Copy phpunit.xml.dist to phpunit.xml then edit env variables accordingly, (*5)

./vendor/bin/phpunit --testsuite api

The Versions

06/10 2017

dev-master

9999999-dev

Web-IT GLS Tracking API

  Sources   Download

MIT

The Requires

 

The Development Requires

tracking track trace parcel gls

06/10 2017

2.0.0

2.0.0.0

Web-IT GLS Tracking API

  Sources   Download

MIT

The Requires

 

The Development Requires

tracking track trace parcel gls

21/09 2017

1.x-dev

1.9999999.9999999.9999999-dev

Web-IT GLS Tracking API

  Sources   Download

The Requires

 

The Development Requires

tracking track trace parcel gls

06/12 2016

1.0.1

1.0.1.0

Web-IT GLS Tracking API

  Sources   Download

The Requires

 

The Development Requires

tracking track trace parcel gls

06/12 2016

1.0.2

1.0.2.0

Web-IT GLS Tracking API

  Sources   Download

The Requires

 

The Development Requires

tracking track trace parcel gls

05/12 2016

1.0.0

1.0.0.0

Web-IT GLS Tracking API

  Sources   Download

The Requires

 

The Development Requires

tracking track trace parcel gls