trackmage / trackmage-sdk-php
TrackMage PHP SDK
Installs: 8 401
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=5.6
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^6.2
- psr/log: ^1.1
Requires (Dev)
- phpstan/phpstan: ^0.12.83
- phpstan/phpstan-phpunit: ^0.12.18
- phpunit/phpunit: ^5|^7
- symfony/console: *
This package is not auto-updated.
Last update: 2024-11-03 03:03:24 UTC
README
Trackmage - A tracking page for your store. Beautiful, branded, customizable.
TrackMage SDK for php
TrackMage is your most automated shipment tracking tool ever. Discover the simple way to show your customers where their parcels are, provide support and get more great reviews
Getting Started
- Create a TrackMage account – First of all, you need to sign up for a TrackMage account and retrieve your clientId and clientSecret.
- Minimum requirements – To run the SDK you need to have installed PHP >= 5.6. We highly recommend using v7.2 or higher.
- Install the SDK – Using [Composer] is the recommended way to install the
TrackMage SDK for PHP. The SDK is available on Packagist as the
trackmage/trackmage-sdk-php
packagecomposer require trackmage/trackmage-sdk-php
- See the docs There are API documentation and the Swagger reference
Quick examples
Create a client
use TrackMage\Client\TrackMageClient;
$clientId = '<client-it>';
$clientSecret = '<client-secret>';
$client = new TrackMageClient($clientId, $clientSecret);
Posting a tracking number
$workspaceId = 100;
$response = $client->post('/shipments', ['json' => [
'workspace' => '/workspaces/'.$workspaceId,
'trackingNumber' => 'TN-1',
]]);
$shipment = TrackMageClient::item($response);
$response = $client->get('/workspaces/'.self::$workspaceId.'/shipments');
$shipments = TrackMageClient::collection($response);
Get workspaces list
$response = $client->get('/workspaces/'.$workspaceId.'/shipments');
$workspaces = TrackMageClient::collection($response);
Get carriers list
$response = $client->get('/public/carriers');
$carriers = TrackMageClient::collection($response);
Create webhook
Here is the webhook handler example that you need to make accessible on your side.
$workflow = [
'type' => 'webhook',
'period' => 'immediately',
'title' => 'Webhook for testing',
'workspace' => '/workspaces/<id>',
'enabled' => true,
'concurrency' => '1',
'url' => 'http://acme.example',
'authType' => 'basic',
'username' => 'webhook_user',
'password' => 'password',
'notificationEmails' => [
'test@email.com', 'test-2@email.com',
],
];
$response = $client->post('/workflows', ['json' => $workflow]);
$workflow = TrackMageClient::item($response);
$workflowId = $workflow['id'];
Tests
To run the unit tests:
composer update ./vendor/bin/phpunit
phpstan
vendor/bin/phpstan analyse -c phpstan.neon
vendor/bin/phpstan analyse -c phpstan-tests.neon