-
Notifications
You must be signed in to change notification settings - Fork 7
API: Pages
A Page represents a screen within the Sana mobile app. It encapsulates a series of Element objects and has a ShowIf that represents the conditions that it will be shown.
/api/pages
Only the user that owns the procedure that this page is a part of may access or modify it.
Field Name | Type | Required? | Default Value | Read Only? | Description |
---|---|---|---|---|---|
procedure | Procedure |
Yes | No | The procedure that this page belongs to. | |
display_index | int |
Yes | No | Represents where the page is located from 1..n within the procedure. | |
show_if | list<ShowIf> |
No | No | The condition for displaying this page. You can have a maximum of one of these per page. | |
elements | list<Element> |
No | No | The elements that make up this page. These are automatically added when creating an element. | |
created |
datetime |
Yes | Yes | The time that this object was created. This value is auto-generated | |
last_modified |
datetime |
Yes | Yes | The last time that this object was updated. This value is auto-generated. |
To create a page POST
to /api/pages
.
201: Object Created Successfully
400: Bad value in the request body. Check the response for errors
401: Invalid Request Token
POST /api/pages
Host: sanaprotocolbuilder.me
Authorization: Token <token>
{
"procedure":8,
"display_index":0
}
{
"id":7,
"display_index":0,
"procedure":8,
"elements":[],
"last_modified":"2016-03-06T23:33:32.595421Z",
"created":"2016-03-06T23:33:32.595488Z",
"show_if":[]
}
To update a procedure PUT
to /api/pages/{id}
, where id
is the id
of the page. You only need to send the fields that are to be updated in the body of the request. Sending up other fields that are not modified, will not do anything.
200: Object Updated Successfully
400: Bad value in the request body. Check the response for errors
401: Invalid Request Token
404: Page does not exist
PUT /api/pages/7
Host: sanaprotocolbuilder.me
Authorization: Token <token>
{
"display_index":1
}
{
"id":7,
"display_index":1,
"procedure":8,
"elements":[],
"last_modified":"2016-03-06T23:33:32.595421Z",
"created":"2016-03-06T23:33:32.595488Z",
"show_if":[]
}
To update multiple pages, even with partial data, send a PATCH
request to /api/pages/partial_bulk_update
.
200: Object successfully updated 400: Invalid or missing data in request body
PATCH /api/pages/partial_bulk_update
Host: sanaprotocolbuilder.me
Authorization: Token <token>
[
{
"id": 2,
"display_index": 1
},
{
"id": 3,
"display_index": 2
}
]
[
{
"id":2,
"display_index":1,
"procedure":8,
"elements":[],
"last_modified":"2016-03-06T23:33:32.595421Z",
"created":"2016-03-06T23:33:32.595488Z",
"show_if":[]
},
{
"id":3,
"display_index":2,
"procedure":12,
"elements":[],
"last_modified":"2016-03-06T23:35:32.595421Z",
"created":"2016-03-06T23:34:32.595488Z",
"show_if":[]
}
]
To delete a procedure send a DELETE
request to /api/pages/{id}
where the id
is the id
of the page to be deleted.
203: Object successfully deleted
401: Invalid Request Token
404: Page does not exist
DELETE /api/pages/7
Host: sanaprotocolbuilder.me
Authorization: Token <token>
No response body
To get all procedures that you own GET
to /api/pages
.
200: Success
401: Invalid Request Token
GET /api/pages
Host: sanaprotocolbuilder.me
Authorization: Token <token>
[
{
"id":8,
"display_index":0,
"procedure":2,
"elements":[
],
"last_modified":"2016-03-06T23:47:29.543346Z",
"created":"2016-03-06T23:47:29.543405Z",
"show_if":[
]
},
{
"id":9,
"display_index":1,
"procedure":2,
"elements":[
],
"last_modified":"2016-03-06T23:47:30.438138Z",
"created":"2016-03-06T23:47:30.438169Z",
"show_if":[
]
},
{
"id":10,
"display_index":2,
"procedure":2,
"elements":[
],
"last_modified":"2016-03-06T23:47:31.023659Z",
"created":"2016-03-06T23:47:31.023690Z",
"show_if":[
]
},
{
"id":11,
"display_index":3,
"procedure":2,
"elements":[
],
"last_modified":"2016-03-06T23:47:31.592751Z",
"created":"2016-03-06T23:47:31.592780Z",
"show_if":[
]
},
{
"id":12,
"display_index":4,
"procedure":2,
"elements":[
],
"last_modified":"2016-03-06T23:47:32.153689Z",
"created":"2016-03-06T23:47:32.153721Z",
"show_if":[
]
},
{
"id":13,
"display_index":5,
"procedure":2,
"elements":[
],
"last_modified":"2016-03-06T23:47:32.875413Z",
"created":"2016-03-06T23:47:32.875441Z",
"show_if":[
]
}
]
To get all procedures that you own GET
to /api/pages/{id}
, Where id
is the procedure's id
.
200: Success
401: Invalid Request Token
404: Procedure does not exist
GET /api/procedures/7
Host: sanaprotocolbuilder.me
Authorization: Token <token>
{
"id":7,
"display_index":1,
"procedure":8,
"elements":[],
"last_modified":"2016-03-06T23:33:32.595421Z",
"created":"2016-03-06T23:33:32.595488Z",
"show_if":[]
}