Download the PHP package stuartapp/stuart-client-php without Composer
On this page you can find all versions of the php package stuartapp/stuart-client-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stuartapp/stuart-client-php
More information about stuartapp/stuart-client-php
Files in stuartapp/stuart-client-php
Package stuart-client-php
Short Description Stuart PHP client library
License MIT
Homepage https://github.com/StuartApp/stuart-client-php/
Informations about the package stuart-client-php
Stuart PHP Client
For a complete documentation of all endpoints offered by the Stuart API, you can visit Stuart API documentation.
Changelog
Visit Changelog
Running the demo
Install
Via Composer:
Usage
- Initialize Client
- Create a Job
- Minimalist
- Complete
- With scheduling at pickup
- With scheduling at drop off
- With stacking (multi-drop)
- Get a Job
- Cancel a Job
- Validate a Job
- Cancel a delivery
- Get a pricing
- Get a job eta to pickup
- Custom requests
Import the library
If composer is not installed, install it:
Add the library to your project:
Autoloading
In order to load all the classes from this library, just execute the autoload at the beginning of the Stuart code
Get credentials
For Sandbox (testing environment, couriers are bots) https://dashboard.sandbox.stuart.com/settings/api
For Production (real world, real couriers) https://dashboard.stuart.com/settings/api
Initialize client
You can also pass your own Guzzle client instance to the \Stuart\HttpClient
constructor:
This can be useful if you need to attach middlewares to the Guzzle client.
Caching
It's highly recommended adding a caching mechanism for the authentication process.
To do so, simply extend the Psr\SimpleCache\CacheInterface
class and implement your own version.
There's a cache based on disk available out of the box for you to use. To use it, simply modify the Authentication class initialization and pass the cache implementation in the constructor:
Debugging token cache issues
You can initialize the DiskCache, Authenticator and HttpClient classes by passing a true
value to the last constructor parameter of these classes.
Create a Job
Important: Even if you can create a Job with a minimal set of parameters, we highly recommend that you fill as many information as you can in order to ensure the delivery process goes well.
Minimalist
Package size based
Complete
Package size based
With scheduling at pickup
For more information about job scheduling you should check our API documentation.
With scheduling at dropoff
For more information about job scheduling you should check our API documentation.
Please note that this feature can only be used with only one dropoff.
With fleet targeting
With end customer time window information (used for metrics purposes only)
With stacking (multi-drop)
Package size based
Get a Job
Once you successfully created a Job you can retrieve it this way:
Or when you create a new Job:
The Stuart API determine the optimal route on your behalf,
that's why the getDeliveries()
method will return an empty
array when the Job has not been created yet. The getDeliveries()
method will return an array of Delivery
as soon as the Job is created.
Cancel a job
Once you successfully created a Job you can cancel it in this way:
The result will hold the boolean value true
if the job was cancelled. If
there was an error, it will contain an error object.
For more details about how cancellation works, please refer to our dedicated documentation section.
Validate a Job
Before creating a Job you can validate it (control delivery area & address format). Validating a Job is optional and does not prevent you from creating a Job.
The result will hold the boolean value true
if the job is valid. If
there was an error, it will contain an error object.
Validate an address
We encourage to validate an address to find out if we can pickup / deliver there. Phone number is optional only for those places that the address is specific enough.
Cancel a delivery
Once you successfully created a Delivery you can cancel it in this way:
Get a pricing
Before creating a Job you can ask for a pricing. Asking for a pricing is optional and does not prevent you from creating a Job.
Get a job ETA to pickup
Before creating a Job you can ask for an estimated time of arrival at the pickup location (expressed in seconds). Asking for ETA is optional and does not prevent you from creating a job.
Custom requests
You can also send requests on your own without relying on the \Stuart\Client
.
It allows you to use endpoints that are not yet available on the \Stuart\Client
and enjoy the \Stuart\Authenticator
.
All versions of stuart-client-php with dependencies
guzzlehttp/guzzle Version ^6.2|^7.0
league/oauth2-client Version ^2.1
psr/simple-cache Version ^1.0