Introduction
Inside of a Client Site (section Security and Patrol, Site Locations & Sections) is a means of defining locations & sections in a particular order with an up-down sorting and parent-child structuring. The TrackTik API allows you to define this structure/ordering.
The basic approach and template is the following.
Obtain a list of Site Location IDs
[GET] /site-locations?account={id}
{
"name": "floor 1",
"details": "it's flat",
"type": "",
"account": 687,
"parent": 0,
"order": 1,
==> "id": 466
},
{
"name": "Back Door",
"details": "",
"type": "SECTION",
"account": 687,
"parent": 466,
"order": 2,
==> "id": 470
},
{
"name": "E1",
"details": "",
"type": "ELEVATOR",
"account": 687,
"parent": 466,
"order": 3,
==> "id": 471
}
Scenario: top-down order
To keep a flast list of items in an order that you define, you can use this template:
[POST] /clients/687/actions/sort-site-locations
{
"siteLocations":[
{"id": 466},
{"id": 470},
{"id": 471}
]
}
The comma separated list is an array where the top-down order that you place them in the payload will associate them as a top-down order in the TrackTik web portal. The above action/payload produces the following result:
Scenario: top-down order and with children under a parent
Imagine a scenario that you want to place locations E1 and Back Door as children locations to the top location Floor 1.
[POST] /clients/687/actions/sort-site-locations
{
"siteLocations":[
{
"id":466,
"children":[
{"id":470},
{"id":471}
]
}
]
}
Notice how for any “id” : value item JSON object, you can add a child array of “id”:value items.
Maximum Tree Depth = 10
You can nest children under children where the top child is a parent of them. You may nest this depth up to 10 degrees of depth in total for any single tree of items.