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
use Sujip\Transdirect\Transdirect;
$client = Transdirect::connect($apiKey);
$response = $client->quotes()->create([
'declared_value' => '1000.00',
'referrer' => 'API',
'requesting_site' => 'https://example.com.au',
'items' => [
[
'weight' => '38.63',
'height' => '0.25',
'width' => '1.65',
'length' => '3.32',
'quantity' => 1,
'description' => 'carton',
],
],
'sender' => [
'address' => '21 Kirksway Place',
'company_name' => 'Sender Company',
'email' => '[email protected] ',
'name' => 'Sender Name',
'postcode' => '2000',
'phone' => '0212345678',
'state' => 'NSW',
'suburb' => 'SYDNEY',
'type' => 'business',
'country' => 'AU',
],
'receiver' => [
'address' => '216 Moggill Rd',
'company_name' => 'Receiver Company',
'email' => '[email protected] ',
'name' => 'Receiver Name',
'postcode' => '3000',
'phone' => '0312345678',
'state' => 'VIC',
'suburb' => 'MELBOURNE',
'type' => 'business',
'country' => 'AU',
],
]);
$quotes = $response->getQuotes();
$client->quotes()->create($payload);
$client->bookings()->create($payload);
$client->bookings()->find($bookingId);
$client->bookings()->update($bookingId, $payload);
$client->bookings()->delete($bookingId);
$client->bookings()->action($bookingId, 'confirm', $payload);
$client->bookings()->nested($bookingId, 'label');
$client->orders()->create($payload);
$client->locations()->get(['q' => 'Sydney']);
$client->couriers()->get();
$client->member()->get();
$client->frequentRates()->get();
$client->tracking($bookingId);
$client->postcode('3000');
$client->pagedLocations(2);
$client = Transdirect::connect($apiKey)
->setSandboxEndpoint('https://sandbox.example.test/api')
->useSandbox();
$client = new Transdirect($apiKey, function ($method, $url, $headers, $body) {
return [
'status' => 200,
'headers' => ['Content-Type' => 'application/json'],
'body' => '{"ok":true}',
];
});