-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapiary.apib
240 lines (174 loc) · 5.33 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
FORMAT: 1A
HOST: http://contactbooster-rails.herokuapp.com/
# contactbooster/rails
API using rails-api for contactbooster app.
# status code
```200``` successfull request with body returned
```201``` successfull creation request with body returned
```204``` successfull request with nothing returned
```400``` bad request (input, validations, parameters...)
```404``` resource(s) not found
# endpoints documentation
# Group List
## List [/lists/{id}]
A single List object with all its contacts
+ Model (application/json; charset=utf-8)
{
"id": 1,
"name": "Friends",
"position": 0
}
+ Parameters
+ id (required, number, `1`) ... Numeric `id` of the List to perform action with
### Retrieve a List [GET]
+ Response 200 (application/json; charset=utf-8)
{
"id": 1,
"name": "Friends",
"position": 0,
"contacts": [
{ "id": 1, "firstname": "Michael", "lastname": "Jordan", "phone": "555533331", "list_id", 1 },
{ "id": 2, "firstname": "Scottie", "lastname": "Pippen", "phone": "222244444, "list_id", 1" }
]
}
### Remove a List [DELETE]
+ Response 204
+ Response 404 (application/json; charset=utf-8)
{
"error": "resource not found."
}
### Update a List [PATCH]
+ Request (application/json; charset=utf-8)
{
"list": { "name": "Work", "position": 1 }
}
+ Response 200 (application/json; charset=utf-8)
{
"id": 2,
"name": "Work",
"position": 1
}
+ Response 404 (application/json; charset=utf-8)
{
"error": "resource not found."
}
## Lists Collection [/lists]
+ Model (application/json; charset=utf-8)
{
"total": 2,
"lists":
[
{
"id": 1,
"name": "friends",
"position": 0,
"contacts": [
{ "id": 1, "firstname": "Joey", "lastname": "Tribianni", "phone": "555533331" }
]
},
{
"id": 2,
"name": "family",
"position": 1,
"contacts": [
{ "id": 2, "firstname": "Michel", "lastname": "Platini", "phone": "555533331" },
{ "id": 3, "firstname": "Jean pierre", "lastname": "Papin", "phone": "555533331" }
]
}
]
}
### List all Lists [GET]
+ Response 200 (application/json; charset=utf-8)
[Lists Collection][]
### Create a List [POST]
+ Request (application/json; charset=utf-8)
{
"list": {
"name": "Friends",
"position": 0
}
}
+ Response 201 (application/json; charset=utf-8)
[List][]
# Group Contact
## Contact [/lists/{list_id}/contacts/{contact_id}]
+ Model (application/json; charset=utf-8)
{
"id": 1,
"list_id": 1,
"lastname": "Hawk",
"firstname": "Tony",
"phone": "55544433322"
}
+ Parameters
+ list_id (required, number, `1`) ... Numeric `id` of the List to perform action with.
+ contact_id (required, number, `1`) ... Numeric `id` of the contact to perform action with. Has example value.
### Retrieve a contact [GET]
+ Response 200 (application/json; charset=utf-8)
[Contact][]
+ Response 404 (application/json; charset=utf-8)
{
"error": "resource not found."
}
### Delete a contact [DELETE]
+ Response 204
+ Response 404 (application/json; charset=utf-8)
{
"error": "resource not found."
}
### Update a contact [PATCH]
+ Request (application/json; charset=utf-8)
{
"contact": { "lastname": "Guez" }
}
+ Response 200 (application/json; charset=utf-8)
{
"id": 1,
"list_id": 1,
"lastname": "Guez",
"firstname": "Tony",
"phone": "55544433322"
}
+ Response 400 (application/json; charset=utf-8)
{
"phone": "Invalid phone format.",
"lastname": "Lastname should have a length between 2 and 20 characters.",
"firstname": "Firstname should have a length between 2 and 20 characters."
}
+ Response 404 (application/json; charset=utf-8)
{
"error": "resource not found."
}
## Contacts Collection [/lists/{list_id}/contacts]
+ Parameters
+ list_id (required, number, `1`) ... Numeric `id` of the List to perform action with.
+ Model (application/json; charset=utf-8)
[{
"id": 1,
"list_id": 1,
"lastname": "Jordan",
"firstname": "Michael",
"phone": "5555544444"
},
{
"id": 1,
"list_id": 1,
"lastname": "Pippen",
"firstname": "Scottie",
"phone": "66666666"
}]
### List all Contacts [GET]
+ Response 200 (application/json; charset=utf-8)
[Contacts Collection][]
### Create a contact [POST]
+ Request (application/json; charset=utf-8)
{
"contact" : {
"lastname": "Hawk",
"list_id": 1,
"firstname": "Tony",
"phone": "55544433322"
}
}
+ Response 201 (application/json; charset=utf-8)
[Contact][]