PHP code example of sudiptpa / transdirect

1. Go to this page and download the library: Download sudiptpa/transdirect 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/ */

    

sudiptpa / transdirect example snippets


  $client = new Sujip\Transdirect\Transdirect($apiKey);  

    $parameters = [
        'declared_value' => '1000.00',
        'referrer' => 'API',
        'requesting_site' => 'http://www.test.com.au',
        'tailgate_pickup' => true,
        'tailgate_delivery' => true,
        'items' => [
            ['weight' => '38.63',
                'height' => '0.25',
                'width' => '1.65',
                'length' => '3.32',
                'quantity' => 1,
                'description' => 'carton',
            ],
            [
                'weight' => '39.63',
                'height' => '1.25',
                'width' => '2.65',
                'length' => '4.32',
                'quantity' => 2,
                'description' => 'carton',
            ],
        ],
        'sender' => [
            'address' => '21 Kirksway Place',
            'company_name' => 'Test Company',
            'email' => '[email protected]',
            'name' => 'Sujip Thapa',
            'postcode' => '2000',
            'phone' => 123456789,
            'state' => '',
            'suburb' => 'SYDNEY',
            'type' => 'business',
            'country' => 'AU',
        ],
        'receiver' => [
            'address' => '216 Moggill Rd',
            'company_name' => 'Test Receiver',
            'email' => '[email protected]',
            'name' => 'John Smith',
            'postcode' => '3000',
            'phone' => 123456789,
            'state' => '',
            'suburb' => 'MELBOURNE',
            'type' => 'business',
            'country' => 'AU',
        ],
    ];
    
  $response = $client->createBooking($parameters);
  $quotes = $response->getQuotes();
  $josn = $response->toJson();
  $bookingId = $response->getId();
  $statusCode = $response->getCode();