Shift

A Shift is a period where the current location of the Driver is made available for queries. Shifts are commonly used to get the Driver's current location to assign Tasks.

When a Shift is active, the mobile SDK sends locations for the Driver. The current location of the Driver can be obtained by retrieving the Driver object.

The Shift object

Property Type Description
id uuid string Unique identifier for the object
driver JSON The driver object who is on the shift
is_active boolean A boolean indicating whether the shift is active or not
start_location GeoJSON point The location where the shift started
end_location GeoJSON point The location where the shift ended
started_at ISO datetime string The time at which the shift started
ended_at ISO datetime string The time at which the shift ended

Create a Shift

Creates a new shift object.

HTTP Request

POST https://app.hypertrack.io/api/v1/shifts/

[warning] Starting shifts in SDK

For the shift to be started in the SDK using the server-side API, the SDK must be connected with the same driver id. Read the shifts guide for Android and iOS.

Returns

Returns a shift object if the call succeeded.

Parameters

Parameter Required Description
driver_id Yes The id of the driver on shift
start_location No Start location of the shift
started_at No Start time of the shift, default is current time
curl -H "Authorization: token YOUR_PK_TOKEN" \
     -H "Content-Type: application/json" \
     -X POST \
     -d "{\"driver_id\": \"f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a\"}" \
     https://app.hypertrack.io/api/v1/shifts/

Example response

{
  "id": "1273dcf6-2cf6-40ff-81ca-b9e297a156e1",
  "driver_id": "f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a",
  "is_active": true,
  "start_location": null,
  "started_at": "2016-07-15T07:36:39.100912Z",
  "end_location": null,
  "ended_at": null,
  "created_at": "2016-07-15T07:36:39.100626Z",
  "modified_at": "2016-07-15T07:36:39.100654Z"
}

Retrieve a Shift

Retrieves a shift object with the id.

HTTP Request

GET https://app.hypertrack.io/api/v1/shifts/<id>/

Returns

Returns a shift object if a valid identifier was provided.

curl -H "Authorization: token YOUR_PK_TOKEN" \
     -X GET \
     https://app.hypertrack.io/api/v1/shifts/1273dcf6-2cf6-40ff-81ca-b9e297a156e1/

Example response

{
  "id": "1273dcf6-2cf6-40ff-81ca-b9e297a156e1",
  "driver_id": "f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a",
  "is_active": true,
  "start_location": null,
  "started_at": "2016-07-15T07:36:39.100912Z",
  "end_location": null,
  "ended_at": null,
  "created_at": "2016-07-15T07:36:39.100626Z",
  "modified_at": "2016-07-15T07:36:39.100654Z"
}

End a Shift

Ends a shift object with the id.

HTTP Request

POST https://app.hypertrack.io/api/v1/shifts/<id>/end/

Returns

Returns a shift object if the call succeeded.

curl -H "Authorization: token YOUR_PK_TOKEN" \
     -X GET \
     https://app.hypertrack.io/api/v1/shifts/1273dcf6-2cf6-40ff-81ca-b9e297a156e1/end/

Example response

{
  "id": "1273dcf6-2cf6-40ff-81ca-b9e297a156e1",
  "driver_id": "f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a",
  "is_active": false,
  "start_location": null,
  "started_at": "2016-07-15T07:36:39.100912Z",
  "end_location": null,
  "ended_at": "2016-07-15T07:45:30.200921Z",
  "created_at": "2016-07-15T07:36:39.100626Z",
  "modified_at": "2016-07-15T07:36:39.100654Z"
}

Delete a Shift

Delete an existing shift object.

HTTP Request

DELETE https://app.hypertrack.io/api/v1/shift/<id>/

Returns

Empty response if the object is deleted.

curl -H "Authorization: token YOUR_SK_TOKEN" \
     -X DELETE \
     https://app.hypertrack.io/api/v1/shifts/f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a/

Example response

{}

List all Shifts

List all shift objects. The list can be filtered using the following parameters.

HTTP Request

GET https://app.hypertrack.io/api/v1/shifts/

Returns

Returns a list of shifts.

Parameters

Parameter Required Description
page_size No Maximum number of objects to return, default is 50
id No Filter shifts with a comma separated list of ids
driver_id No Filter shift objects for a particular driver
is_active No Filter only active or inactive shifts
min_date No Filter objects by minimum created at date
max_date No Filter objects by maximum created at date
curl -H "Authorization: token YOUR_SK_TOKEN" \
     -X GET \
     https://app.hypertrack.io/api/v1/shifts/?is_active=False

Example response

{
  "count":1,
  "next":null,
  "previous":null,
  "results":[
    {
      "id": "1273dcf6-2cf6-40ff-81ca-b9e297a156e1",
      "driver_id": "f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a",
      "is_active": false,
      "start_location": null,
      "started_at": "2016-07-15T07:36:39.100912Z",
      "end_location": null,
      "ended_at": "2016-07-15T07:45:30.200921Z",
      "created_at": "2016-07-15T07:36:39.100626Z",
      "modified_at": "2016-07-15T07:36:39.100654Z"
    }
  ]
}

Was this helpful? Yes, thanks! Not really

results matching ""

    No results matching ""