-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiary.apib
516 lines (420 loc) · 15.4 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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
FORMAT: 1A
HOST: http://app.esn-cz.cz/api/
# ESN API Documentation
ESN API documentation for ESN project. This project is divided
to many phases. This version of the API is for version 01.
# Allowed HTTPs requests:
<pre>
POST : To create resource
PUT : Update resource
GET : Get a resource or list of resources
DELETE : To delete resource
</pre>
# Description Of Usual Server Responses:
- 200 `OK` - the request was successful (some API calls may return 201 instead).
- 201 `Created` - the request was successful and a resource was created.
- 204 `No Content` - the request was successful but there is no representation to return (i.e. the response is empty).
- 400 `Bad Request` - the request could not be understood or was missing required parameters.
- 401 `Unauthorized` - authentication failed or user doesn't have permissions for requested operation.
- 403 `Forbidden` - access denied.
- 404 `Not Found` - resource was not found.
- 405 `Method Not Allowed` - requested method is not supported for resource.
- 500 `Internal Server Error` - server error
# Authentication
<table>
<tr>
<td> Token </td>
<td> Token/API key </td>
</tr>
</table>
# Section
Represents city and university details. With one city, user
can choose more universities.
---
**City attributes:**
- id `(Number)` : Unique Identifier.
- name `(String)` : City Name.
- city_image `(URL)` : City Image.
- state `(String)` : City State.
- best_tip_title `(String)` : City Best Offer.
- best_tip_image `(URL)` : City Best Offer Image.
- latitude `(String)` : Latitude Coordinates of the City.
- longtitude `(String)` : Longtitude Coordinates of the City.
- city_desc `(String)` : Description of city. Short one.
---
**University attributes:**
- id `(Number)` : Unique Identifier.
- name `(String)` : University Name.
- section_name `(String)` : ESN section name. For future reference.
- section_desc `(String)` : Description of section.
---
## Section Collection [/sections]
### List all cities and related universities [GET]
This is called when user starts the app for the first time
and when user change settings in the app settings section.
User can choose one city and more universtities.
Based on the GPS is automatically choosen city where is the user.
He can change this city in the app manually.
Cities and universities are ordered alphabetically
from the server side.
+ Request
+ Headers
Authorization: JWT ABC123
+ Response 200 (application/json)
[
{
"id" : 1,
"name": "Prague",
"city_image" : "https://trello-attachments.s3.amazonaws.com/52589bca65b0b14e1d004d94/581efa2dafc1d1f2ca807a35/edcdf68eb2adb0005c80a6326ff3b354/prague_bg.png",
"state" : "Czech Republic",
"best_tip_image" : "",
"best_tip_title" : "Tip: Try Proti Proudu in Prague",
"longitude": "14.4378005",
"latitude" : "50.0755381",
"city_desc" : "",
"universities": [
{
"id": 1,
"name": "Charles University",
"section_name": "IC CUNI",
"section_desc": ""
}, {
"id": 2,
"name": "Czech Technical University",
"section_name": "ISC CTU in Prague",
"section_desc": ""
}, {
"id": 3,
"name": "Czech University of Life Sciences",
"section_name": "ESN CULS Prague",
"section_desc": ""
}, {
"id": 4,
"name": "University of Chemistry and Technology",
"section_name": "ESN UCT Prague",
"section_desc": ""
}, {
"id": 5,
"name": "Universiy of Economics",
"section_name": "ESN VSE Prague",
"section_desc": ""
}
]
},
{
"id" : 2,
"name": "Olomouc",
"city_image" : "https://trello-attachments.s3.amazonaws.com/52589bca65b0b14e1d004d94/581efa2dafc1d1f2ca807a35/7f70545d47a9353a56f72fe4d5a858f4/olomouc_bg.png",
"state" : "Czech Republic",
"best_tip_image" : "",
"best_tip_title" : "Best coffee shop in Olomouc",
"longitude": "17.2508787",
"latitude" : "49.593778",
"city_desc" : "",
"universities": [
{
"id": 6,
"name": "Palacký University",
"section_name": "ESN UP Olomouc",
"section_desc": ""
}
]
}
]
## Homepage Collection [/homepage]
Represents home screen in the application.
---
**Home attributes:**
- full_name `(String)` : Name of the person.
- user_photo `(URL String)` : Photo of the user.
- esn_section `(String)` : ESN section related with person.
- welcome_description `(String)` : Description of the welcome text.
- news `(String)` : Formatted html text of the news.
- news_images `(Array(URL String))` : Images for the news.
---
### Homepage List [GET]
+ Request
+ Headers
Authorization: JWT ABC123
+ Response 200 (application/json)
{
"full_name" : Svetlana Margetova
"user_photo" : "",
"esn_section" : "esn_brno",
"welcome_description" : "bla bla bla",
"news" : "<p>Ahoj <strong>Svet</strong></p>"
"news_images" : [
"left" : "",
"right" : ""
]
}
## Subcategory Collection [/subcategories?category=1]
---
Represents subcategory details. One main category contains
more subcategories, where one subcategory can be in more
main categories.
---
**Subcategory attributes:**
- id `(Number)` : Unique Identifier.
- parent_category `(Number)` : parent super category. server side
- name `(String)` : Subcategory Name.
- color `(String)` : Subcategory Color.
- icon `(URL)` : Subcategory Icon.
- order `(Number)` : listing priority. lower = more important. server side
### List all subcategories [GET]
Subcategories and categories are ordered based on the order
from the server side.
We use subcategory color and icon. When there is no icon and
color for the subcategory, you can use category color and icon.
Also you can use category color and icon when data are
grouped on the map.
+ Request
+ Headers
Authorization: JWT ABC123
+ Response 200 (application/json)
[
{
"id":1,
"parent_category":1,
"name":"University",
"color":"#2e3192",
"icon":"https://www.esn-cz.cz/esnczapp/icons/students-cap.svg",
"order":1,
"pois" : [9, 10, 11, 12, 13]
},
{
"id":2,
"parent_category":1,
"name":"Erasmus Student Network",
"color":"#00aeef",
"icon":"https://www.esn-cz.cz/esnczapp/icons/esnstar.svg",
"order":2,
"pois" : [25]
},
{
"id":5,
"parent_category":1,
"name":"Canteens",
"color":"#f47b20",
"icon":"https://www.esn-cz.cz/esnczapp/icons/013-plate-fork-and-knife.svg",
"order":"3",
"pois" : [14, 15, 16, 17, 18]
},
{
"id":4,
"parent_category":1,
"name":"Faculties",
"color":"#ec008c",
"icon":"https://www.esn-cz.cz/esnczapp/icons/012-university-building.svg",
"order":4,
"pois" : [1, 2, 3, 4, 5, 6, 7, 8]
},
{
"id":3,
"parent_category":1,
"name":"Dormitories",
"color":"#7ac143",
"icon":"https://www.esn-cz.cz/esnczapp/icons/011-sleeping-bed-silhouette.svg",
"order":5,
"pois" : [19, 20, 21, 22, 23, 24]
}
]
## Update Collection [/update_from={datetime}]
---
Sent all updated data as a difference between datetime and the current date.
# States
<table>
<tr>
<td> New </td>
<td> New data created </td>
</tr>
<tr>
<td> Update </td>
<td> Updated existing data </td>
</tr>
<tr>
<td> Delete </td>
<td> Deleted existing data </td>
</tr>
</table>
### Update all data [GET]
+ Request
+ Headers
Authorization: JWT ABC123
+ Parameters
+ datetime (String) ... Timestamp in unix format: `YYYY-MM-DDTHH:MM:SS`.
+ Response 200 (application/json)
[
{ "subcategories" : [
{
"id" : 1,
"name" : "Vodafone",
"color" : "#333333",
"icon" : "",
"state" : "New"
},
{
"id" : 2,
"name" : "Discounts",
"color" : "#33323",
"icon" : "",
"state" : "Delete"
}
]
},
{ "categories" : [
{
"id" : 1,
"name" : "Vodafone",
"color" : "#333333",
"icon" : "",
"state" : "Update"
}
]
}
]
## Environment Collection [/environments]
### Get environment state [GET]
This is called when user starts the app for the first time
and when user change settings in the app settings section.
When is_production is True, in the app you should use
production url links for the other calls. When it is false, you
should use development url links for the other calls.
Represents environment for the api calls. It could be
development or production.
---
**Environment attributes:**
- id `(Number)` : Unique Identifier.
- is_production `(Boolean)` : Production Identifier.
---
+ Request
+ Headers
Authorization: JWT ABC123
+ Response 200 (application/json)
[
{
"id" : 1,
"is_production", True
}
]
## Category Collection [/categories{?universities}]
---
Represents category a details.
---
**Category attributes:**
- id `(Number)` : Unique Identifier.
- name `(String)` : Category Name.
- color `(String)` : Category Color.
- icon `(URL)` : Category Icon.
- order `(Number)` : listing priority. lower = more important. server side
### List all categories [GET]
Categories are ordered based on the order
from the server side.
We use category color and icon.
Also you can use category color and icon when data are
grouped on the map.
Komentár (martin wpa): toto sú "super"kategórie, globálne pre všetkých,
bez ohľadu na výber mesta a univerzity. Parameter je asi teda zbytočný.
Subkateórie sa potom radia do týchto kategórií (napr. Doctors and health patrí pod Services.)
+ Request
+ Headers
Authorization: JWT ABC123
+ Parameters
+ universities (array[int])... array of the selected universities ids.
+ Response 200 (application/json)
[
{
"id": 1,
"name": "University",
"icon": "https://www.esn-cz.cz/esnczapp/icons/students-cap.svg",
"color": "#2e3192",
"order": 1
},
{
"id": 2,
"name": "Services",
"icon": "https://www.esn-cz.cz/esnczapp/icons/016-building.svg",
"color": "#7ac143",
"order": 2
},
{
"id": 3,
"name": "Discounts",
"icon": "https://www.esn-cz.cz/esnczapp/icons/015-wallet.svg",
"color": "#ec008c",
"order": 3
},
{
"id": 4,
"name": "Vodafone",
"icon": "https://www.esn-cz.cz/esnczapp/icons/014-smartphone-with-a-smile.svg",
"color": "#E60000",
"order": 4
}
]
## POI Detail [/poi/1]
---
Represents Point of Interest details. One POI can be in more subcategories and categories.
This is called when user click on the main category tab or during the first
call of the app, when is dowloaded default category.
**POI attributes:**
- id `(Number)` : Unique Identifier.
- category_path `(String)` : Full Path for the Category.
- full_address `(String)` : POI City.
- name `(String)` : POI Name.
- latitude `(String)` : POI Latitude coordinates.
- longitude `(String)` : POI Longitude coordinates.
- preview_image `(URL)` : POI Preview Image in the List View.
- image_list `(Array[URL])` : POI List of Images for the Slider in the POI Detail.
- content_title `(String)` : POI Title of the Content Section.
- content_body `(String)` : POI Body of the Content Section.
- website_link `(URL)` : POI URL of the partner website.
- subcategory_id `(Array(Number))` : POI Subcategory Identifier.
- discount `(Integer)` : POI discount.
---
### POI Detail [GET]
POIs are ordered based on the order from the server side.
This call also contains information for the POI detail section.
+ Request
+ Headers
Authorization: JWT ABC123
+ Response 200 (application/json)
{
"id": 1,
"name": "Sts Cyril and Methodius Faculty of Theology",
"full_address": "Univerzitní 244/22, Olomouc",
"latitude": "49.59466",
"longitude": "17.254988",
"discount" : 12,
"website_link": "https://www.cmtf.upol.cz/en/",
"preview_image": "http://new.uss.upol.cz/wp-content/uploads/2014/10/UpolLOgo.png",
"subcategory_id": [
4
],
"image_list": [
{
"id": 1,
"image_url": "http://vizual.upol.cz/soubory_v2/logotypy/logo_cmtf_barva.png",
"order": 1
},
{
"id": 2,
"image_url": "http://vizual.upol.cz/soubory_v2/logotypy/logo_cmtf_barva.png",
"order": 2
}
],
"content": [
{
"content_title": "Content block title",
"content_body": "Opening hours 24/7"
},
{
"content_title": "",
"content_body": ""
},
{
"content_title": "",
"content_body": ""
}
]
}