daurensky/winfreight-php-sdk

PHP SDK for Winfreight API

1.0.4 2022-11-07 09:53 UTC

This package is auto-updated.

Last update: 2024-12-07 14:32:28 UTC


README

The Winfreight SDK for PHP makes it easy for developers to access Winfreight API in their PHP code. You can get started in minutes by installing the SDK through Composer or by downloading a single zip or phar file from our latest release.

Jump to:

Getting started

  1. Get your username and password of Winfreight API.
  2. Minimum requirements - To run the SDK, your system will need to have PHP >= 7.1.
  3. composer require daurensky/winfreight-php-sdk
  4. Check the Quiz Examples

Quick Examples

Authorize client

<?php

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

use Daurensky\WinfreightPhpSdk\Winfreight;

$username = {username};
$password = {password};

// Prev token data
$accessToken = {prev access token};
$expiresIn = {prev expires in};

$winfreight = new Winfreight($username, $password);
$winfreight->setToken($accessToken, $expiresIn);

if ($winfreight->rottenToken()) {
    $authorization = $winfreight->renewToken();

    /*
     * Your token refresh. Ex:
     * DB::insert('credentials', [
     *   'access_token' => $authorization->getAccessToken();
     *   'expires_in'   => $authorization->getExpiresIn();
     * ]);
    */
}

Get data from API

<?php

$hubCodes = $winfreight->getHubCodes([
    'GroupName' => 'Wintest',
    'Province'  => 'Western Cape',
    'Suburb'    => 'Constantiavale',
]);

$servCodee = $winfreight->getServCode([
    'GroupName' => 'Wintest',
]);

$portalWaybill = $winfreight->createPortalWaybill([
    'Waybill'          => 'TEST005',
    'Date'             => '2021/01/13',
    'SenderCustomerID' => 13,
    ...
]);

To do