PHP code example of webapix / mygls-sdk
1. Go to this page and download the library: Download webapix/mygls-sdk library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
webapix / mygls-sdk example snippets
php
use GuzzleHttp\Client as HttpClient;
use Webapix\GLS\Client;
use Webapix\GLS\Models\Parcel;
use Webapix\GLS\Services\SMS;
use Webapix\GLS\Requests\PrintLabels;
$parcel = (new Parcel)
->setClientNumber(123456789)
->setPickupAddress(<class that extends \Webapix\GLS\Contracts\Address>)
->setDeliveryInfo(<class that extends \Webapix\GLS\Contracts\Contact>)
->when($order->cutomerWantsSmsAlert(), function (Parcel $parcel) use ($order) {
return $parcel->addService(
new SMS($order->phone_number, 'Your package (#ParcelNr#) is on its way to GLS facility!')
);
});
$client = new Client(new HttpClient);
$request = PrintLabels;
$request->addParcel($parcel);
/** @var \Webapix\GLS\Responses\PrintLabels $response */
$response = $client->on($account)->request($request);
if ($response->successfull()) {
// get the pdf
$response->getPdf();
}