sudiptpa / transdirect
A clean, dependency-free PHP client for the Transdirect REST API.
Fund package maintenance!
v2.0.0
2026-04-13 02:57 UTC
Requires
- php: >=7.0
Requires (Dev)
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^6.5 || ^9.6
Suggests
- ext-curl: Recommended for more reliable HTTP transport.
This package is auto-updated.
Last update: 2026-04-13 03:13:52 UTC
README
A clean, dependency-free PHP client for the Transdirect REST API.
- PHP 7.0+
- no runtime HTTP dependency
- fluent resource API
- configurable live and sandbox endpoints
- transport injection for tests
Install
composer require sudiptpa/transdirect
Quick start
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' => 'sender@example.com', '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' => 'receiver@example.com', 'name' => 'Receiver Name', 'postcode' => '3000', 'phone' => '0312345678', 'state' => 'VIC', 'suburb' => 'MELBOURNE', 'type' => 'business', 'country' => 'AU', ], ]); $quotes = $response->getQuotes();
Resources
$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();
Helpers
$client->tracking($bookingId); $client->postcode('3000'); $client->pagedLocations(2);
Sandbox
$client = Transdirect::connect($apiKey) ->setSandboxEndpoint('https://sandbox.example.test/api') ->useSandbox();
Sandbox mode now requires an explicit sandbox endpoint.
Custom transport
$client = new Transdirect($apiKey, function ($method, $url, $headers, $body) { return [ 'status' => 200, 'headers' => ['Content-Type' => 'application/json'], 'body' => '{"ok":true}', ]; });
Testing
composer test composer stan find src tests -name '*.php' -print0 | xargs -0 -n1 php -l