Giter Club home page Giter Club logo

dhl-api-wrapper's Introduction

Dhl-api-wrapper (Deprecated, please read our warning)

WARNING

Provided as-is, but deprecated and no longer supported.

Installing via Composer

The recommended way to install the wrapper is through Composer.

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version of the wrapper:

php composer.phar require dhl-plugins/dhl-api-wrapper

After installing, you need to require Composer's autoloader:

require __DIR__ . '/vendor/autoload.php';

Frequently asked questions

See FAQ.md.

Getting Started

First you will need to initialise the client like this:

$client = new \Dhl\ApiClient([
    'apiUser' => $apiUser,
    'apiKey' => $apiKey,
    'accountId' => $accountId,
    'organisationId' => $organisationId,
]);

Then you can begin making requests like shown below. Please note that the list of requests below is not complete.

More complete examples are located in the examples directory

Create Shipping Label

check the create label example for the $parameters variable.

// Create a DHL shipping label
$label = $client->createLabel($parameters);
$rawPdf = $labelResult->offsetGet('pdf');
if (!file_put_contents('DHLshippingLabel.pdf', base64_decode($rawPdf))) {
    printf('could not write label.%s', PHP_EOL);
} else {
    printf('Shipping label writen.%s', PHP_EOL);
}

Retrieve Capabilities

// Retrieve the capabilities for your account and shipment information.
// The result can be used as `options` in the createLabel call.
$result = $client->capabilities([
    'fromCountry' => 'NL',
    'fromPostalCode' => '3542 AD',
    'toCountry' => 'NL',
    'toPostalCode' => '3542 AB',
]);
printf('<pre>%s</pre>', print_r($result, true));

Destination Countries

// Get a list of all destination Countries.
$result = $client->destinationCountries(['senderType' => 'business', 'fromCountry' => 'NL']);
printf('<pre>%s</pre>', print_r($result, true));

Endpoints which are available, take a look in the ./src/Dhl/resources directory for reference.

Bugs & Issues

We no longer maintain this wrapper.

dhl-api-wrapper's People

Contributors

dunduro avatar roerlemans avatar rud5g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dhl-api-wrapper's Issues

Access token and Refresh token not being cached

The authentication token does not get cached therefore each new session requires a new authentication. I'm not sure whether the API Gateway of DHL parcel has a limit of authentications per hour, but I suppose sending a lot of new authentication requests is not a feasible solution.

AuthMiddleware.php uses undefined variables called $accessTokenCache and $refreshTokenCache. I suppose we can just cache both the access and refresh tokens and recreate them when they're expired.

Any reason why these prototypes exist yet the caching implementation is not there? Is there more to it? Is it unstable?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.