Community
Obtaining Vehicle / Trailer info for a Route
Hi all,
Trying to figure out how to link these pieces together. If you create a route and assign a driver to it, the route API does not display the vehicle/trailer that are picked by the driver. You need to use the vehicle-assignment API call to get that info.
As an example, the route API For a given route returns (non-relevant info stripped out):
{
"id": ####,
"dispatch_jobs": [
{
"id": ####
}
]
}
The vehicle assignment history for that same time period displays:
"vehicleAssignments": [
{
"isPassenger": false,
"vehicle": {
"id": "####"
},
"startTime": "2021-03-24T19:56:01.302Z",
"endTime": "2021-03-24T19:56:44.000Z",
"assignmentType": "driverApp"
},
{
"isPassenger": false,
"vehicle": {
"id": "####"
},
"startTime": "2021-03-24T20:41:35.352Z",
"endTime": "2021-03-24T21:00:23.717Z",
"assignmentType": "driverApp"
},
{
"isPassenger": false,
"vehicle": {
"id": "####"
},
"startTime": "2021-03-24T21:00:23.717Z",
"endTime": "2021-03-24T21:30:09.000Z",
"assignmentType": "driverApp"
},
{
"isPassenger": false,
"vehicle": {
"id": "####"
},
"startTime": "2021-03-24T21:40:40.191Z",
"endTime": "2021-03-24T23:23:28.000Z",
"assignmentType": "driverApp"
},
{
"isPassenger": false,
"vehicle": {
"id": "####"
},
"startTime": "2021-03-24T23:23:33.743Z",
"endTime": "2021-03-24T23:59:41.000Z",
"assignmentType": "driverApp"
}
]
As it stands, the only way I can think of to get the vehicle assignment, is to basically take the millisecond start/end time from the route, convert it to a UTC timestamp (side note - please be consistent on this. for example, start/end times in vehicle assignment are in UTC timestamps, whereas start/end times for routes are in milliseconds), and then query the vehicle assignment for the driver on the route and for that time range.
But that approach seems very prone to error. Seems like the vehicle assignment should just be part of the route instead?