2017 © Pedro Peláez
 

symfony-bundle gls-bundle

GLS ADE and GLS Track & Trace API Symfony 2 integration

image

webit/gls-bundle

GLS ADE and GLS Track & Trace API Symfony 2 integration

  • Thursday, September 21, 2017
  • by dbojdo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 32 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

WebitGlsBundle

GLS ADE and GLS Track & Trace API Symfony 2 integration, (*2)

Installation

via Composer

Add the webit/gls-bundle into composer.json, (*3)

{
    "require": {
        "php":              ">=5.3.2",
        "webit/gls-bundle": "dev-master"
    },
    "autoload": {
        "psr-0": {
            "Acme": "src/"
        }
    }
}

Register bundle in Kernel

Add following lines:, (*4)

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Webit\Bundle\SoapApiBundle\WebitSoapApiBundle(),
    new Webit\Bundle\GlsBundle\WebitGlsBundle(),
    // ...
);

Configuration

You can define as much accounts as you need (ADE Accounts and Track & Trace as well), (*5)

webit_gls:
   ade_accounts:
       my-production-account:
           username: my-ade-username
           password: my-ade-password
           test_mode: false
       my-test-account:
           username: my-ade-test-username
           password: my-ade-test-password
           test_mode: true
      track_accounts:
          my-account:
              username: my-track-and-trace-username
              password: my-track-and-trace-password
              test_mode: false

Usage

To use GLS APIs you need AccountManager ('webit_gls.account_manager'), ApiProvider ('webit_gls.api_provider'), and TrackingUrlProvider ('webit_gls.tracking.url_provider'). You can get them directly from Service Container or inject them to your class., (*6)

<?php
namespace Acme\Bundle\AcmeBundle\Controller;

use Webit\Bundle\GlsBundle\Api\ApiProviderInterface;
use Webit\Bundle\GlsBundle\Account\AccountManagerInterface;
use Webit\GlsTracking\UrlProvider\TrackingUrlProvider;

class MyController
{

    /**
     * @var AccountManagerInterface
     */
    private $accountManager;

    /**
     * @var ApiProviderInterface
     */
    private $apiProvider;

    /**
     * @var TrackingUrlProvider
     */
    private $trackingUrlProvider;

    public function __construct(
        AccountManagerInterface $accountManager,
        ApiProviderInterface $apiProvider,
        TrackingUrlProvider $trackingUrlProvider
    ) {
        $this->accountManager = $accountManager;
        $this->apiProvider = $apiProvider;
        $this->trackingUrlProvider = $trackingUrlProvider;
    }

    public function consignmentPrepareAction()
    {
        /** @var \Webit\Bundle\GlsBundle\Account\AdeAccount */
        $account = $this->accountManager->getAdeAccount('my-test-account');

        /** @var \Webit\GlsAde\Api\ConsignmentPrepareApi */
        $consignmentPrepareApi = $this->apiProvider->getConsignmentPrepareApi($account);

        // do your stuff with API
    }

    public function checkParcelStatusAction()
    {
        /** @var \Webit\Bundle\GlsBundle\Account\TrackAccount */
        $account = $this->accountManager->getTrackAccount('my-account');

        /** @var \Webit\GlsTracking\Api\TrackingApi */
        $trackingApi = $this->apiProvider->getTrackingApi($account);

        // do your stuff with API
    }

    public function getTrackingUrlAction($reference, $country = 'EN')
    {
        $url = $trackingUrlProvider->getStandardTrackingUrl($reference, $country);

        // do your stuff with URL
    }
}

To learn how to use GLS APIs see: * GLS-ADE: https://github.com/dbojdo/gls-ade * GLS Track & Trace: https://github.com/dbojdo/gls-tracking, (*7)

The Versions

21/09 2017

dev-master

9999999-dev http://www.web-it.eu

GLS ADE and GLS Track & Trace API Symfony 2 integration

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle track shipment delivery dispatch parcel gls web-it gls-ade gls-track

21/09 2017

1.x-dev

1.9999999.9999999.9999999-dev http://www.web-it.eu

GLS ADE and GLS Track & Trace API Symfony 2 integration

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle track shipment delivery dispatch parcel gls web-it gls-ade gls-track