-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapiary.apib
305 lines (205 loc) · 7.02 KB
/
apiary.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
FORMAT: 1A
HOST: http://schools-hacks.cloudapp.net/api
# PragueHacks Školník API
App providing fast search and comparison of schools. Based on
open data provided by municipalities and using crowdsourcing
of users and school officials who fill the remaining interesting
data about the school.
# Školník API Root [/]
Empty request. Use for test of the API and for availability check.
## Hello world [GET]
+ Response 200 (application/json)
{
"success": true,
"msg": "Hello, world!"
}
## Group Anonymous user {level 0}
Actions requested by an anonymous user.
## Subscribe to a school [/subscribe]
Anonymous user subscribes to a selected school. Email notifications
will be sent to him on important updates.
Returns *cancel token*, token required for verification of cancelling
this action.
### Subscribe to a school [POST]
+ Request (application/json)
{
"school_id": "11234",
"email": "[email protected]
}
+ Response 200 (application/json)
{
"success": true,
"cancel_token": "c0fbb4ce07ae7d29658071e265ac9650"
}
+ Response 400 (application/json)
{
"success": false,
"msg": "Already subscribed."
}
## Unsubscribe from a school [/unsubscribe]
Unsubscribe from a school. Use the cancel token obtained from
the previous subscription action (or otherwise from backend).
### Unsubscribe from a school [POST]
+ Request (application/json)
{
"school_id": "11234",
"email": "[email protected]"
"cancel_token": "c0fbb4ce07ae7d29658071e265ac9650"
}
+ Response 200 (application/json)
{
"success": true
}
+ Response 400 (application/json)
{
"success": false,
"msg": "Not subscribed.|Invalid cancel token."
}
## Request edit [/request-edit]
User requests edit providing an email - system should send him a link
directed to the edit page.
Server will also generate an *edit token*, that is used for validation
when applying changes. __The *edit token* is valid only for 1 hour__.
The edit token will give user the privilege of level 1, but if this
email is approved as an owner, it will give the privileges of level 2.
If the edit token was already generated, refresh the generation
datetime and send the email again with the same token.
### Request edit [POST]
+ Request (application/json)
{
"school_id": "11234",
"email": "[email protected]"
}
+ Response 200 (application/json)
{
"success": true
}
## Claim ownership [/claim-ownership]
User claims he wants to be an owner of the school. He has to provide
proof he is an official. The app administrator has to approve him
first.
### Claim ownership [POST]
+ Request (application/json)
{
"school_id": "11234",
"email": "[email protected]",
"message": "Dobrý den, pracuji na ZŠ ABC Praha 99 jako
správce sítě a rád bych získal přístupová práva. Důkazem budiž můj
oficiální školní mail, ze kterého chci získat přístup. Najdete mne
na stránkách školy: www.abcpraha99.com/ajtak-lojza"
}
+ Response 200 (application/json)
{
"success": true
}
## Group One-time Editor {level 1}
## Edit school data [/school/{school_id}/edit/{edit_token}]
Edit the school data. User edits data in a form and confirms his edit.
After edit is completed, the *edit token* must be destroyed.
It is crucial not to simply do a document rewrite, but log the change
including all old and new values, so the change is reversible.
### Edit school data [POST]
+ Request (application/json)
{
"some_category": {
"some_key": "some_value",
"key2": "another_value"
}
"another_edited_category": {
"key3": 123,
"key4": [ 1, 3, 4 ]
}
}
+ Response 200 (application/json)
{
"success": true
}
+ Response 400 (application/json)
{
"success": false,
"msg": "Cannot edit data of higher level."
}
+ Response 401 (application/json)
{
"success": false,
"msg": "Invalid edit token."
}
+ Parameters
+ school_id (string) - School ID
+ edit_token (string) - Token matching some existing token for
given school
## Group School Owner {level 2}
All owners of given school are the same level admins and can add,
edit and delete other owner's emails.
## List all owners [/owners/list/{school_id}/{owner_token}]
Lists all approved owners of this school.
### List all owners [GET]
+ Response 200 (application/json)
{
"success": true
}
+ Response 400 (application/json)
{
"success": false,
"msg": "Invalid owner token.|Email already present."
}
+ Parameters
+ school_id (string) - School ID
+ owner_token (string) - Owner token
## Add owner email [/owners/add/{school_id}/{owner_token}]
Owner adds another owner email, which is automatically approved.
### Add owner email [POST]
+ Request (application/json)
{
"email": "[email protected]"
}
+ Response 200 (application/json)
{
"success": true
}
+ Response 400 (application/json)
{
"success": false,
"msg": "Invalid owner token.|Email already present."
}
+ Parameters
+ school_id (string) - School ID
+ owner_token (string) - Owner token
## Add owner email [/owners/edit/{school_id}/{owner_token}]
Owner edits another owner's email (or his own).
### Edit owner email [POST]
+ Request (application/json)
{
"old_email": "[email protected]",
"email": "[email protected]"
}
+ Response 200 (application/json)
{
"success": true
}
+ Response 400 (application/json)
{
"success": false,
"msg": "Invalid owner token.|Email does not exist.|Email already present."
}
+ Parameters
+ school_id (string) - School ID
+ owner_token (string) - Owner token
## Delete owner email [/owners/delete/{school_id}/{owner_token}]
Owner deletes another owner's email (or his own).
__Note the 204 response must be empty (no *success: true* this time).__
### Delete owner email [DELETE]
+ Request (application/json)
{
"school_id": "11234",
"email": "[email protected]"
}
+ Response 204 (application/json)
+ Response 400 (application/json)
{
"success": false,
"msg": "Invalid owner token.|Email does not exist."
}
+ Parameters
+ school_id (string) - School ID
+ owner_token (string) - Owner token