Creating Drivers
To get started creating a driver, first clone the driver-skeleton repository.
Once this has been cloned, update any relevant details such as the package name, description, and namespace.
You can then rename the Skeleton and SkeletonServiceProvider classes to the name of your driver.
Inside the Skeleton class, there are multiple methods, here is an overview of what each does:
- The public
__constructmethod - this is where the class should be instantiated, and anything class properties derived from the configuration should be initialised. - The public
find()method - this should return an instance of theTrackingDetailsDTO, and is where the tracking details should be received from an API. - The private
mapStatus()andgetHeaders()methods - these two methods are utility helper methods for mapping delivery values from the API to aStatusenum instance, and for retrieving any relevant headers for the requests such as APIAuthorizationheaders.
Once the driver has been created, it's important to add tests, these can be mocked via a MockHandler, but should reflect the result of the actual API.
Note: All custom exceptions should implement the
ParcelTrap\Contracts\ParcelTrapExceptioninterface.
The driver can then be published to Packagist, make sure to use the parceltrap-driver keyword so that your driver can be discovered more easily.