-
Notifications
You must be signed in to change notification settings - Fork 1
POST child sleep
Register a new sleep and associate it to a Child.
child_id: string (A 24-byte hex ID)
{
"start_time": "2019-08-18T01:40:30Z",
"end_time": "2019-08-18T09:52:30Z",
"duration": 29520000,
"type": "classic",
"pattern": {
"data_set": [
{
"start_time": "2019-08-18T01:40:30.00Z",
"name": "restless",
"duration": 60000
},
{
"start_time": "2019-08-18T01:41:30.00Z",
"name": "asleep",
"duration": 360000
},
{
"start_time": "2019-08-18T01:47:30.00Z",
"name": "restless",
"duration": 240000
},
{
"start_time": "2019-08-18T01:51:30.00Z",
"name": "asleep",
"duration": 60000
},
{
"start_time": "2019-08-18T02:32:30.00Z",
"name": "awake",
"duration": 180000
},
{
"start_time": "2019-08-18T06:47:30.00Z",
"name": "restless",
"duration": 60000
},
{
"start_time": "2019-08-18T06:48:30.00Z",
"name": "asleep",
"duration": 2580000
},
{
"start_time": "2019-08-18T07:31:30.00Z",
"name": "restless",
"duration": 120000
},
{
"start_time": "2019-08-18T09:36:30.00Z",
"name": "asleep",
"duration": 960000
}
]
}
}
curl -X POST "https://localhost:4001/v1/children/5a62be07d6f33400146c9b61/sleep" -H "accept: application/json" -H "Content-Type: application/json" -d "{"start_time":"2018-08-18T01:40:30Z","end_time":"2018-08-18T09:52:30Z","duration":29520000,"type":"classic","pattern":{"data_set":[{"start_time":"2018-08-18T01:40:30.00Z","name":"restless","duration":60000},{"start_time":"2018-08-18T01:41:30.00Z","name":"asleep","duration":360000},{"start_time":"2018-08-18T01:47:30.00Z","name":"restless","duration":240000},{"start_time":"2018-08-18T01:51:30.00Z","name":"asleep","duration":60000},{"start_time":"2018-08-18T01:52:30.00Z","name":"restless","duration":60000},{"start_time":"2018-08-18T01:53:30.00Z","name":"asleep","duration":2100000},{"start_time":"2018-08-18T02:28:30.00Z","name":"restless","duration":240000},{"start_time":"2018-08-18T02:32:30.00Z","name":"awake","duration":180000},{"start_time":"2018-08-18T02:35:30.00Z","name":"asleep","duration":15120000},{"start_time":"2018-08-18T06:47:30.00Z","name":"restless","duration":60000},{"start_time":"2018-08-18T06:48:30.00Z","name":"asleep","duration":2580000},{"start_time":"2018-08-18T07:31:30.00Z","name":"restless","duration":120000},{"start_time":"2018-08-18T07:33:30.00Z","name":"asleep","duration":120000},{"start_time":"2018-08-18T07:35:30.00Z","name":"restless","duration":60000},{"start_time":"2018-08-18T07:36:30.00Z","name":"asleep","duration":1200000},{"start_time":"2018-08-18T07:56:30.00Z","name":"restless","duration":60000},{"start_time":"2018-08-18T07:57:30.00Z","name":"asleep","duration":2580000},{"start_time":"2018-08-18T08:40:30.00Z","name":"restless","duration":180000},{"start_time":"2018-08-18T08:43:30.00Z","name":"asleep","duration":1200000},{"start_time":"2018-08-18T09:03:30.00Z","name":"restless","duration":60000},{"start_time":"2018-08-18T09:04:30.00Z","name":"asleep","duration":1740000},{"start_time":"2018-08-18T09:03:30.00Z","name":"restless","duration":180000},{"start_time":"2018-08-18T09:36:30.00Z","name":"asleep","duration":960000}]}}"
-
201
Sleep saved sucessfully.{ "id": "3bc1274329fb282470e45004", "start_time": "2019-08-18T01:40:30Z", "end_time": "2019-08-18T09:52:30Z", "duration": 29520000, "type": "classic", "pattern": { "data_set": [ { "start_time": "2019-08-18T01:40:30.00Z", "name": "restless", "duration": 60000 }, { "start_time": "2019-08-18T01:41:30.00Z", "name": "asleep", "duration": 360000 }, { "start_time": "2019-08-18T01:47:30.00Z", "name": "restless", "duration": 240000 }, { "start_time": "2019-08-18T01:51:30.00Z", "name": "asleep", "duration": 60000 }, { "start_time": "2019-08-18T02:32:30.00Z", "name": "awake", "duration": 180000 }, { "start_time": "2019-08-18T06:47:30.00Z", "name": "restless", "duration": 60000 }, { "start_time": "2019-08-18T06:48:30.00Z", "name": "asleep", "duration": 2580000 }, { "start_time": "2019-08-18T07:31:30.00Z", "name": "restless", "duration": 120000 }, { "start_time": "2019-08-18T09:36:30.00Z", "name": "asleep", "duration": 960000 } ], "summary": { "asleep": { "count": 4, "duration": 3960000 }, "awake": { "count": 1, "duration": 180000 }, "restless": { "count": 4, "duration": 480000 } } }, "child_id": "5a62be07de34500146d9c544" }
-
207
Successful request, however, can have several status codes for the case of a list of submitted sleep records.{ "success": [ { "code": 201, "item": { "id": "5db6fa35fce8d130bf48a9d2", "start_time": "2019-08-18T01:40:30Z", "end_time": "2019-08-18T09:52:30Z", "duration": 29520000, "type": "classic", "pattern": { "data_set": [ { "start_time": "2019-08-18T01:40:30.00Z", "name": "restless", "duration": 60000 }, { "start_time": "2019-08-18T01:41:30.00Z", "name": "asleep", "duration": 360000 }, { "start_time": "2019-08-18T01:47:30.00Z", "name": "restless", "duration": 240000 }, { "start_time": "2019-08-18T01:51:30.00Z", "name": "asleep", "duration": 60000 }, { "start_time": "2019-08-18T02:32:30.00Z", "name": "awake", "duration": 180000 }, { "start_time": "2019-08-18T06:47:30.00Z", "name": "restless", "duration": 60000 }, { "start_time": "2019-08-18T06:48:30.00Z", "name": "asleep", "duration": 2580000 }, { "start_time": "2019-08-18T07:31:30.00Z", "name": "restless", "duration": 120000 }, { "start_time": "2019-08-18T09:36:30.00Z", "name": "asleep", "duration": 960000 } ], "summary": { "asleep": { "count": 4, "duration": 3960000 }, "awake": { "count": 1, "duration": 180000 }, "restless": { "count": 4, "duration": 480000 } } }, "child_id": "5a62be07de34500146d9c544" } } ], "error": [ { "code": 409, "message": "Sleep is already registered...", "item": { "start_time": "2019-08-21T01:40:30Z", "end_time": "2019-08-21T09:52:30Z", "duration": 29520000, "type": "classic", "pattern": { "data_set": [ { "start_time": "2019-08-18T01:40:30.00Z", "name": "restless", "duration": 60000 }, { "start_time": "2019-08-18T01:41:30.00Z", "name": "asleep", "duration": 360000 }, { "start_time": "2019-08-18T01:47:30.00Z", "name": "restless", "duration": 240000 }, { "start_time": "2019-08-18T01:51:30.00Z", "name": "asleep", "duration": 60000 }, { "start_time": "2019-08-18T02:32:30.00Z", "name": "awake", "duration": 180000 }, { "start_time": "2019-08-18T06:47:30.00Z", "name": "restless", "duration": 60000 }, { "start_time": "2019-08-18T06:48:30.00Z", "name": "asleep", "duration": 2580000 }, { "start_time": "2019-08-18T07:31:30.00Z", "name": "restless", "duration": 120000 }, { "start_time": "2019-08-18T09:36:30.00Z", "name": "asleep", "duration": 960000 } ], "summary": { "asleep": { "count": 4, "duration": 3960000 }, "awake": { "count": 1, "duration": 180000 }, "restless": { "count": 4, "duration": 480000 } } }, "child_id": "5a62be07de34500146d9c544" } } ] }
-
400
Validation errors-
- Example
{ "code": 400, "message": "Required fields were not provided...", "description": "start_time, end_time, duration, type, pattern are required!" }
- Example
-
Missing data_set
- Example
{ "code": 400, "message": "Required fields were not provided...", "description": "pattern.data_set is required!" }
- Example
-
Empty data_set
- Example
{ "code": 400, "message": "One or more request fields are invalid...", "description": "pattern.data_set must not be empty!" }
- Example
-
Invalid date
- Pattern
{ "code": 400, "message": "Datetime: {datetime}, is not in valid ISO 8601 format." }
- Pattern
-
end_time older than start_time
- Pattern
{ "code": 400, "message": "One or more request fields are invalid...", "description": "The end_time parameter can not contain an older date than that the start_time parameter!" }
- Pattern
-
Invalid duration parameter
- Pattern
{ "code": 400, "message": "One or more request fields are invalid...", "description": "duration value does not match values passed in start_time and end_time parameters!" }
- Pattern
-
- Example
{ "code": 400, "message": "One or more request fields are invalid...", "description": "duration must be an integer equal to or greater than zero." }
- Naming pattern of attributes that have other objects as its type
pattern.data_set.duration
- Example
-
Invalid sleep type
- Pattern
{ "code": 400, "message": "One or more request fields are invalid...", "description": "The names of the allowed Sleep Pattern types are: classic, stages." }
- Pattern
-
Some invalid type in data_set items
- Pattern
{ "code": 400, "message": "One or more request fields are invalid...", "description": "The names of the allowed data_set patterns are: asleep, restless, awake." || "The names of the allowed data_set patterns are: deep, light, rem, awake." }
- Pattern
-
409
Conflict Error
OCARIoT IoT Tracking Microservice API (Full documentation)
- POST children.physicalactivities
- GET children.physicalactivities
- GET children.physicalactivities.activity_id
- DELETE children.physicalactivities.activity_id
- POST children.weights
- GET children.weights
- GET children.weights.weight_id
- DELETE children.weights.weight_id
- POST children.bodyfats
- GET children.bodyfats
- GET children.bodyfats.bodyfat_id
- DELETE children.bodyfats.bodyfat_id