2017 © Pedro Peláez
 

library laravel-dhl-api

DHL API wrapper for LARAVEL

image

misterbrownrsa/laravel-dhl-api

DHL API wrapper for LARAVEL

  • Sunday, December 3, 2017
  • by MisterBrownRSA
  • Repository
  • 0 Watchers
  • 0 Stars
  • 42 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 45 % Grown

The README.md

Laravel DHL API

I needed a laravel-esque wrapper to make calls to the DHL XML service, but couldn't find any. So I created one. It was specifically designed for my own personal use, but you are welcome to submit issues, and I'll look into refactoring it so that it can be used in a more general purpose fashion., (*1)

Getting Started

Prerequisites

This was built and tested ONLY on Laravel 5.5, although I'm sure it'll work on previous versions as well., (*2)

Installing

composer require misterbrownrsa/laravel-dhl-api

Since Laravel 5.5 automatically includes the service provider, it won't be necessary to register it. However, if you really want to, run the following command, (*3)


Usage Examples

Capability

This is typically used to test the validity of addresses and DHL's capability to deliver. Validate must return true., (*4)

$user = User::first();

$GetCapability = new \MisterBrownRSA\DHL\API\GetCapability();
$GetCapability->user($user);
dd($GetCapability->validate());

Dump the request, (*5)

dump($GetCapability->toXML());

Dump the response, (*6)

dump($GetCapability->doCurlPost());
dump($GetCapability->requestRAW());

Quotation

This is used to get product information such as the price and total transit days., (*7)

$product = [];
foreach ($cart->items as $key => $cartItem) {
    for ($i = 1; $i <= $cartItem->quantity; $i++) {
        $product[ $key ]['height'] = $box['height'];
        $product[ $key ]['depth'] = $box['length'];
        $product[ $key ]['width'] = $box['width'];
        $product[ $key ]['weight'] = $cartItem->warehouse->product->weight + $box1['weight'];
    }
}
$GetQuote = new \MisterBrownRSA\DHL\API\GetQuote();
$GetQuote->user($user)
    ->reference($cart->order->reference)
    ->addProduct($product)
    ->declaredValue($cart->subtotal);

$result = $GetQuote
    ->doCurlPost();

dd($result);

Dump the request, (*8)

dd($GetQuote->toXML());

Dump the response, (*9)

dump($GetQuote->results());
dump($GetQuote->resultsRAW());

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details, (*10)

Acknowledgments

  • Thanks David for your help during the implementation process

The Versions

03/12 2017

dev-master

9999999-dev

DHL API wrapper for LARAVEL

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

by Duwayne Brown

03/12 2017

1.0.0

1.0.0.0

DHL API wrapper for LARAVEL

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

by Duwayne Brown