Example
In this scenario, a manager called A uses the platform to create an activity and two time frames prior to a tennis match, where athletes B and C play against each other.
First, A should activate the devices used during this match.
A send a POST
request to /api/v1/devices/1/take-ownership/
to own the device 1.
A send a POST
request to /api/v1/devices/2/take-ownership/
to own the device 2.
Both B and C should give write permission to manager A to let him create a time frame related to them.
B send POST
request to /api/v1/athletes/2/managers/2/permissions/
(the first 2
is athlete B's ID, the second 2
is manager A's ID) with the following JSON body to give write permission to A for the entire year 2020. C do the same with his ID in the URL.
{
"start_time": "2020-01-01T00:00:00.000Z",
"expiration_time": "2020-12-31T23:59:59.000Z",
"permission": "WRITE"
}
B and C can also give read permission to manager A to let A retrieve or stream their (computed) data. To do that, they should use the same request as for write permission, but with value READ
instead of WRITE
at key permission
in the JSON body.
A send a POST
request to /api/v1/activities/
with the following JSON body to create the activity.
{
"name": "Tennis match of 30 may 2020 at Wimbledon",
"json": { "sport": "tennis", "type": "match" },
"json_schema": 2, // JsonSchema ID correspondig to tennis
"owner": 1 // ID of manager A
}
A send a POST
request to /api/v1/timeframes/
with the following JSON body to create the time frame for athlete B wearing device 1, starting at 20:00 and ending at 22:00.
{
"start_time": "2020-05-30T20:00:00.000Z",
"end_time": "2020-05-30T22:00:00.000Z",
"params": {}, // Seed doc for examples
"device": 1, // ID of device worn by athlete B
"activity": 1, // ID of previously created activity
"athlete": 2, // ID of athelte B
"owner": 1, // ID of manager A
"json_schema": 4 // ID of json schema
}
A send a POST
request to /api/timeframes/
with the following JSON body to create the time frame for athlete C wearing device 2, starting at 20:00 and ending at 22:00.
{
"start_time": "2020-05-30T20:00:00.000Z",
"end_time": "2020-05-30T22:00:00.000Z",
"params": {}, // Seed doc for examples
"device": 2, // ID of device worn by athlete C
"activity": 1, // ID of previously created activity
"athlete": 3, // ID of athelte C
"owner": 1, // ID of manager A
"json_schema": 4 // ID of json schema
}
As A has read permission on athletes B and C, he can live stream the compted data of both athletes, through WebSocket. For computed data of athlete B, A can open a WebSocket on /ws/v1/computed-data/1/2/
; 1
is the activity ID, and 2
is athlete B's time frame ID.