-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiary.apib
358 lines (254 loc) · 8.54 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
FORMAT: 1A
HOST: https://justdoit-api.herokuapp.com
# JustDoIt
*justdoit* is an API that lets you manage bucketlists.
## Signup [/signup]
### Create a new user [POST]
Unregistered users must sign up to use the service. They sign up with first_name, last_name, email and password. Additionally, the password must be confirmed.
+ Request (application/json)
+ Body
{
"first_name": "Jack",
"last_name": "Bauer",
"email": "jackbauer@gmail.com",
"password": "1234567890",
"password_confirmation": "1234567890"
}
+ Response 201 (application/json)
+ Body
{
"message": "User created and logged in"
}
### Login [/auth/login]
Registered users must be logged in to use the service. All endpoints except for **signup** and **login** require that the user is logged in.
### Authenticate a user and generate an authorization token [POST]
Before a user can make requests to the API, one must be logged in. The login action responds with an authorization token that will be used to authenticate subsequent requests. For a successful login the following parameters must be provided: `email` and `password`.
+ Request (application/json)
+ Body
{
"email": "<email>"
"password": "<password>"
}
+ Response 200 (application/json)
+ Body
{
"message": "Successfully logged in",
"authorization_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo2LCJleHAiOjE0ODA3NjgxMTR9.T2bpTIbMLLqBNT1k_j098H3fu4PhD4fp71ukx9EGCi0"
}
## Logout [/auth/logout]
A logged in user can log out. Logging out deletes the users token.
### Log out a user [GET]
+ Response 200 (application/json)
+ Body
{
"message": "Successfully logged out"
}
+ Headers
Authorization: <authorization token>
## Bucketlist Collection [/bucketlists/]
### Create a new bucketlist [POST]
Users can create new bucketlists by supplying a 'name' parameter. The server responds then with the created bucketlist.
+ Request (application/json)
+ Body
{
"name": "Watch IMDB top 250"
}
+ Headers
Authorization: <authorization token>
+ Response 201 (application/json)
+ Body
{
"id": 1,
"name": "Watch IMDB top 250",
"items": [],
"date_created": "2016-12-02 12:52:52",
"date_modified": "2016-12-02 12:52:52",
"created_by": 1
}
### List all bucketlists [GET]
Lists all the bucketlists, with or without the following options:
- page - the page to the results.
- limit - the number of results to be returned. Maximum is 100. Default is 20
- q - the query.
+ Request (application/json)
+ Headers
Authorization: <authorization token>
+ Parameters
+ page(optional, int)
+ Default: 1
+ limit(optional, int) the number of results to be displayed
+ Default: 20
+ q(optional, string) the query string
+ Default: ""
+ Response 200 (application/json)
+ Body
[
{
"id": 1,
"name": "Watch IMDB top 250",
"items": [
{
"id": 1,
"name": "The Matrix",
"date_created": "2016-12-02 12:52:52",
"date_modified": "2016-12-02 12:52:52",
"done": false
}
],
"date_created": "2016-12-02 12:52:52",
"date_modified": "2016-12-02 12:52:52",
"created_by": 1
},
{
"id": 2,
"name": "Travel the world",
"items": [],
"date_created": "2016-12-02 12:52:52",
"date_modified": "2016-12-02 12:52:52",
"created_by": 1
}
]
## Bucketlist Record [/bucketlists/<id>]
### Retrieve a specific bucketlist [GET]
Retrieve a bucketlist based on the given `id`.
+ Request 200 (application/json)
+ Headers
Authorization: <authorization token>
+ Response 201 (application/json)
+ Body
{
"id": 1,
"name": "IMDB Top 250",
"items": [
{
"id": 3,
"name": "The Matrix",
"date_created": "2016-12-02 12:52:52",
"date_modified": "2016-12-02 12:52:52",
"done": false
}
],
"date_created": "2016-12-02 12:52:52",
"date_modified": "2016-12-02 12:52:52",
}
### Update a bucketlist [PUT]
Update the attributes of a given bucket list
+ Request 200 (application/json)
+ Headers
Authorization: <authorization token>
+ Body
{
"name": "New Name"
}
+ Response 200 (application/json)
+ Body
{
"id": 1,
"name": "New Name",
"items": [
{
"id": 3,
"name": "The Matrix",
"date_created": "2016-12-02 12:52:52",
"date_modified": "2016-12-02 12:52:52",
"done": false
}
],
"date_created": "2016-12-02 12:52:52",
"date_modified": "2016-12-02 12:52:52",
}
### Delete a bucketlist [DELETE]
This deletes a given bucketlist
+ Request 200 (application/json)
+ Headers
Authorization: <authorization token>
+ Response 200 (application/json)
+ Body
{
"message": "Bucketlist successfully deleted"
}
## Item Collection [/bucketlists/<id>/items/]
### Create a new Item [POST]
A user can create a new item in any of the bucketlists.
+ Request (application/json)
+ Headers
Authorization: <authorization token>
+ Body
{
"name": "The Matrix"
}
+ Response 201 (application/json)
+ Body
{
"id": 5,
"name": "The Matrix",
"date_created": "2016-12-02 12:52:52",
"date_modified": "2016-12-02 12:52:52",
"done": false
}
### List all Items in a bucketlist [GET]
+ Request (application/json)
+ Headers
Authorization: <authorization token>
+ Response 200 (application/json)
+ Body
{
[
{
"id": 4,
"name": "The Matrix 1",
"date_created": "2016-12-02 12:52:52",
"date_modified": "2016-12-02 12:52:52",
"done": false
},
{
"id": 5,
"name": "The Matrix 2",
"date_created": "2016-12-02 12:52:52",
"date_modified": "2016-12-02 12:52:52",
"done": false
}
]
}
## Item Record [/bucketlists/<id>/items/<id>]
### Retrieve a single item from a bucketlist [GET]
+ Request (application/json)
+ Headers
Authorization: <authorization token>
+ Response 200 (application/json)
+ Body
{
"id": 5,
"name": "The Matrix",
"date_created": "2016-12-02 12:52:52",
"date_modified": "2016-12-02 12:52:52",
"done": false
}
### Update an item [PUT]
To update an item, supply a 'name' or 'done' attribute that will update the resource
+ Request (application/json)
+ Headers
Authorization: <authorization token>
+ Body
{
"done": true
}
+ Response 200 (application/json)
+ Body
{
"id": 5,
"name": "The Matrix",
"date_created": "2016-12-02 12:52:52",
"date_modified": "2016-12-02 12:52:52",
"done": true
}
### Delete an item [DELETE]
You can delete an item from the bucketlist by specifying an id
+ Request (application/json)
+ Headers
Authorization: <authorization token>
+ Response 200 (application/json)
+ Body
{
"message": "List successfully deleted"
}