-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuckyy.apbi
430 lines (335 loc) · 11.6 KB
/
buckyy.apbi
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
FORMAT: 1A
HOST: https://buckyy.herokuapp.com
# Buckyy
Buckyy is a simple API for a bucketlist application allowing consumers to perform CRUD operations
on bucketlists. A bucketlist has many items and belongs to a user.
API V1 https://github.com/andela-akabiru/buckyy
# Documentation guidelines
This is a RESTful API. Thus, all operations on resources will be described by their corresponding
Http verb.
In order to access the API resources, authentication is required. All requests except ``` /auth/signin ``` require
an authentication token passed in the ``` Authorization ``` header.
# Group User
Resources related to users in the API
### Create A New User [POST /signup]
This endpoint serves to signup new users. A user creates an account by making
a post request to ``` /signup ```. No authentication is required.
+ firstname (string) - First name of the user
+ lastname (string) - Last name of the user
+ email (string) - Unique email of the user
+ password (string)
+ password_confirmation (string) - Must be the same as password
+ Request (application/json)
{
"firstname": "Foo",
"lastname": "Bar",
"email": "foo@bar.com",
"password": "foobar",
"password_confirmation": "foobar"
}
+ Response 201 (application/json)
+ Body
{
"message": "Account created successfully"
}
### Login A User [POST /auth/login]
This endpoint serves to login existing users. It expects ```email``` and ``` password ```
for authentication and returns a token that expires 24 hours from the time it's created.
+ Request (application/json)
{
"email": "me@andela.com",
"password": "foobar"
}
+ Response 200 (application/json)
{
"auth_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJleHAiOjE0NjI5ODIyOTh9.pFyQmqKmca9GeU9hxzbvl0LCzpp13N9Ei2nzdGFrlUs"
}
### User Logout [GET /auth/logout]
This endpoint logs out a user
+ Response 200 (application/json)
{
"message": "Sorry, your token has expired. Please login to continue."
}
# Group Bucketlists
Resources related to buckelists in the API
## Bucketlist Collection [/bucketlists]
This endpoint serves all bucketlists belonging to a particular user.
The endpoint supports pagination, by default the pagination has a minimum default value of ```20``` and a maximum of ```100``` bucketlists.
### List All Bucketlists [GET]
+ Response 200 (application/json)
[
{
"created_by": "1",
"id": 3,
"items": [
{
"bucketlist_id": 3,
"done": false,
"id": 3,
"name": "Obi-Wan Kenobi",
"date_created": "2016-07-04 8:12:05",
"date_modified": "2016-07-04 8:12:05"
}
],
"name": "eaque"
},
{
"created_by": "1",
"id": 4,
"items": [
{
"bucketlist_id": 4,
"done": false,
"id": 4,
"name": "Chewbacca",
"date_created": "2016-07-04 8:12:05",
"date_modified": "2016-07-04 8:12:05"
}
],
"name": "non"
}
]
### List Paginated Bucketlists [GET /bucketlists?page=2&limit=3]
+ Response 200 (application/json)
[
{
"created_by": "1",
"id": 3,
"items": [
{
"bucketlist_id": 3,
"done": false,
"id": 3,
"name": "Obi-Wan Kenobi",
"date_created": "2016-07-04 8:12:05",
"date_modified": "2016-07-04 8:12:05"
}
],
"name": "eaque"
},
{
"created_by": "1",
"id": 4,
"items": [
{
"bucketlist_id": 4,
"done": false,
"id": 4,
"name": "Chewbacca",
"date_created": "2016-07-04 8:12:05",
"date_modified": "2016-07-04 8:12:05"
}
],
"name": "non"
},
{
"created_by": "1",
"id": 5,
"items": [
{
"bucketlist_id": 5,
"done": false,
"id": 4,
"name": "Chew",
"date_created": "2016-07-04 8:12:05",
"date_modified": "2016-07-04 8:12:05"
}
],
"name": "non"
}
]
### Search Bucketlist [GET /bucketlists?q=chewbacca]
+ Response 200
[
{
"created_by": "1",
"id": 3,
"items": [
{
"bucketlist_id": 3,
"done": false,
"id": 3,
"name": "Obi-Wan Kenobi",
"date_created": "2016-07-04 8:12:05",
"date_modified": "2016-07-04 8:12:05"
}
],
"name": "chewbacca"
},
{
"created_by": "1",
"id": 5,
"items": [
{
"bucketlist_id": 5,
"done": false,
"id": 4,
"name": "Chew",
"date_created": "2016-07-04 8:12:05",
"date_modified": "2016-07-04 8:12:05"
}
],
"name": "Chewbacca"
}
]
### Search bucketlist with pagination [GET /bucketlists?q=chew&page=1&limit=1]
+ Request
+ q (string) - Bucketlist we are searching for
+ page (number) - The page of the records to return
+ limit (number) - The limit of the records to return
+ Response 200
[
{
"created_by": "1",
"id": 3,
"items": [
{
"bucketlist_id": 3,
"done": false,
"id": 3,
"name": "Obi-Wan Kenobi",
"date_created": "2016-07-04 8:12:05",
"date_modified": "2016-07-04 8:12:05"
}
],
"name": "chewbacca"
}
]
## Bucketlist [/bucketlists/{id}]
An authenticated user may create, view, update or delete a single bucketlist using this endpoint. It takes a bucketlist id.
+ Parameters
+ id (number) - ID of the bucketlist in the form of an integer
### Create A New Bucketlist [POST /bucketlists]
+ Request (application/json)
{
"name": "Holiday in Vienna"
}
+ Response 201 (application/json)
{
"created_by": "1",
"id": 15,
"items": [],
"name": "Visit Vienna"
}
### Show a Bucketlist [GET /bucketlists/4]
+ Response 200 (application/json)
{
"created_by": "1",
"id": 4,
"items": [
{
"bucketlist_id": 4,
"created_at": "2016-06-30T12:57:51.613Z",
"done": false,
"id": 4,
"name": "Chewbacca",
"updated_at": "2016-06-30T12:57:51.613Z"
}
],
"name": "non"
}
### Update a Bucketlist [PUT /bucketlists/13]
+ Request (application/json)
{
"name": "Jabba the hut"
}
+ Response 201
{
"created_by": "4",
"date_created": "2016-07-08 10:52:16",
"date_modified": "2016-07-08 12:59:06",
"id": 13,
"items": [
{
"date_created": "2016-07-08 12:59:43",
"date_modified": "2016-07-08 12:59:43",
"done": false,
"id": 11,
"name": "item1"
},
{
"date_created": "2016-07-08 1:03:48",
"date_modified": "2016-07-08 1:03:48",
"done": false,
"id": 13,
"name": "item2"
},
{
"date_created": "2016-07-08 1:08:21",
"date_modified": "2016-07-08 1:09:32",
"done": false,
"id": 14,
"name": "foo"
}
],
"name": "Jabba the hut"
}
### Delete [DELETE /bucketlist/4]
+ Response 204
# Group Item
## Items Collection [/bucketlists/1/items/]
This endpoint serves all bucketlist items belonging to a particular bucketlist.
User can perform CRUD operations on this bucketlist items resource.
### Get All Bucketlist Items [GET /bucketlist/3/items]
+ Response 200 (application/json)
[
{
"bucketlist_id": 3,
"done": false,
"id": 3,
"name": "Obi-Wan Kenobi"
"date_created": "2016-07-04 8:12:05",
"date_modified": "2016-07-04 8:12:05"
},
{
"bucketlist_id": 3,
"done": false,
"id": 4,
"name": "Chewbacca",
"date_created": "2016-07-04 8:12:05",
"date_modified": "2016-07-04 8:12:05"
}
]
### Create A New Bucketlist Item [POST /bucketlists/3/items]
+ Request (application/json)
{
"name": "Visit Albert Hall",
"done": false
}
+ Response 201 (application/json)
+ Body
{
"created_by": "1",
"id": 3,
"items": [
{
"bucketlist_id": 13,
"done": false,
"id": 13,
"name": "Visit Albert Hall",
"date_created": "2016-07-04 8:12:05",
"date_modified": "2016-07-04 8:12:05",
}
],
"name": "Foo"
}
## Bucketlist Item [/bucketlists/13/items/{id}]
An authenticated user may view a single bucketlist item using this action. It takes a bucketlist and item id.
### View a Bucketlist Item [GET /bucketlists/13/items/13]
+ Response 200 (application/json)
{
"bucketlist_id": 13,
"done": false,
"id": 13,
"name": "Museam",
"date_created": "2016-07-04 8:12:05",
"date_modified": "2016-07-04 8:12:05"
}
### Update a Bucketlist [PUT /bucketlists/13/items/3]
+ Request (application/json)
{
"name": "hutt"
}
+ Response 204
### Delete [DELETE]
+ Response 204