Insert tasks at index (or append)
You may insert one or more tasks at a given index by providing the index as the first element in the array, followed by the task IDs. To append to the end, use -1
as your index. To prepend, use 0
. This insertion method is supported on all 3 types of containers: worker
, team
, and organization
.
For example, if you want to insert two tasks at position 3 for a given worker, such that all currently assigned tasks at index >= 3
are shifted forward, you would make the following request:
curl -X PUT "https://onfleet.com/api/v2/containers/workers/2Fwp6wS5wLNjDn36r1LJPscA" \
-u "cd3b3de84cc1ee040bf06512d233719c:" \
-d '{"tasks":[3,"l33lg5WLrja3Tft*MO383Gub","tsc4jFSETlXBIvi8XotH28Wt"]}'
onfleet.workers.insertTask(id="2Fwp6wS5wLNjDn36r1LJPscA", body={"tasks":[3,"l33lg5WLrja3Tft*MO383Gub","tsc4jFSETlXBIvi8XotH28Wt"]})
onfleet.workers.insertTask("2Fwp6wS5wLNjDn36r1LJPscA", {"tasks":[3,"l33lg5WLrja3Tft*MO383Gub","tsc4jFSETlXBIvi8XotH28Wt"]});
$onfleet->workers->insertTask("2Fwp6wS5wLNjDn36r1LJPscA", ["tasks"=>[3,"l33lg5WLrja3Tft*MO383Gub","tsc4jFSETlXBIvi8XotH28Wt"]])
{
"id": "NngUFbKT95Hly0PkFwPui*kg",
"timeCreated": 1518563775000,
"timeLastModified": 1518563775468,
"organization": "yAM*fDkztrT3gUcz9mNDgNOL",
"type": "WORKER",
"activeTask": null,
"tasks": [
"b3F~z2sU7H*auNKkM6LoiXzP",
"1ry863mrjoQaqMNxnrD5YvxH",
"VVLx5OdKvw0dRSjT2rGOc6Y*",
"l33lg5WLrja3Tft*MO383Gub",
"tsc4jFSETlXBIvi8XotH28Wt"
],
"worker": "2Fwp6wS5wLNjDn36r1LJPscA"
}
Note that, had one of the provided IDs been found at an index less than 3
, this ID would have been removed from its original index and inserted as per the request's insertion order.