-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapiary.apib
308 lines (187 loc) · 7.93 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
FORMAT: 1A
HOST: https://web-automart.herokuapp.com/api/v1
# AutoMart
AutoMart is an online marketplace for automobiles of diverse makes,
model or body type.
With AutoMart, users can sell their cars or
buy from trusted dealerships or private sellers.
## User Collection [/auth]
### Log In An Existing User [POST/auth/signin]
+ Request (application/json)
+ Attributes
+ email: `anuakin@gmail.com` (string) - user email address
+ password: `secret` (string) - user password
+ Response 200 (application/json)
+ Attributes (User response)
### Register a new user [POST/auth/signup]
+ Request (application/json)
+ Attributes
+ firstName: `anu` (string) - user firstname
+ lastName: `akin` (string) - user lastname
+ email: `anuakin@gmail.com` (string) - user email address
+ password: `secret` (string) - user password
+ address: `25, olasebikan street, Agbado, Lagos` (string) - user address
+ Response 201 (application/json)
+ Attributes (User response)
## Car Collection [/car]
### Post a car advert [POST/car]
+ Request (multipart/form-data; boundary=BOUNDARY)
--BOUNDARY
Content-Disposition: form-data; name="image[file]"; filename="image.jpg"
Content-Type: image/jpeg
showcase.jpg
--BOUNDARY
Content-Disposition: form-data; name="email"
Content-Type: text/plain
anuoluwapoakinseye@gmail.com
--BOUNDARY
Content-Disposition: form-data; name="created_on"
Content-Type: text/plain
2019-06-06T00:41:44.496Z
--BOUNDARY
Content-Disposition: form-data; name="manufacturer"
Content-Type: text/plain
bmw
--BOUNDARY
Content-Disposition: form-data; name="model"
Content-Type: text/plain
s3
--BOUNDARY
Content-Disposition: form-data; name="price"
Content-Type: text/plain
1755999.99
--BOUNDARY
Content-Disposition: form-data; name="bodyType"
Content-Type: text/plain
coupe
--BOUNDARY--
+ Response 201 (application/json)
+ Attributes (Post car response)
### Update a car Advert status [PATCH/car/{carId}/status]
+ Parameter
+ carId: `1` (number) - car ID to be updated
+ Request (application/json)
+ Attributes
+ status: `sold` (string) - new status
+ Response 202 (application/json)
+ Attributes (Update car status response)
### Update a car Advert price [PATCH/car/{carId}/price]
+ Parameter
+ carId: `1` (number) - car ID to be updated
+ Request (application/json)
+ Attributes
+ price: `1749999.99` (number) - new price
+ Response 202 (application/json)
+ Attributes (Update car price response)
### Fetch a specific car advert [GET/car/{carId}]
+ Parameter
+ carId: `1` (number) - car ID to be fetch
+ Response 200 (application/json)
+ Attributes (Fetch car response)
### Fetch all unsold car advert [GET/car?status=available]
+ Response 200 (application/json)
+ Attributes (array [Fetch car response])
### Fetch all unsold car within price range [GET/car?status=available&min_price=1700000&max_price=2500000]
+ Response 200 (application/json)
+ Attributes (array [Fetch car response])
### Delete a car advert [DELETE/car/{carId}]
- Parameter
- carId: `1` (number) - car Id of advert to be deletedd
+ Response 200 (application/json)
+ Attributes (Delete car response)
### Fetch all car advert whether sold or unsold [GET/car]
+ Response 200 (application/json)
+ Attributes (array [Fetch car response])
### Fetch all unsold car which state reads new [GET/car?status=available&state=new]
+ Response 200 (application/json)
+ Attributes (array [Fetch car response])
### Fetch all unsold car which state reads used [GET/car?status=available&state=used]
+ Response 200 (application/json)
+ Attributes (array [Fetch car response])
## Order Collection [/order]
### Make a purchase order on car advert [POST/order]
+ Request (application/json)
+ Attributes
+ email: `taiwoakin@gmail.com` (string) - buyer email address
+ carId: 2 (number) - car ID number
+ amount: 1750000.00 (number) - Amount to be offered for the purchase
+ Response 201 (application/json)
+ Attributes (Purchase order response)
### Update price of purchase order if order status is pending [PATCH/order/{orderId}/price]
+ Parameter
+ orderId: `1` (number) - purchase order ID to be updated
+ Request (application/json)
+ Attributes
+ price: `1755000` (number) - new price
+ Response 202 (application/json)
+ Attributes (Update purchase order price response)
## Flag Collection [/flag]
### Flag/Report a car advert as fraudulent [POST/flag]
+ Request (application/json)
+ Attributes
+ carId: 2 (number) - car ID number
+ reason: `pricing` (string)
+ description: `the price of the car is too expensive` (string)
+ Response 201 (application/json)
+ Attributes (flag advert response)
# Data Structures
## User response (object)
+ id: `1` (number) - user ID number
+ first_name: `anu` (string) user first name
+ last_name: `akin` (string) user last name
+ email: `anuakin@gmail.com` (string) user email address
+ token: `544yiu4y090939849rl;kfliuwruy` (string) user generated token
## Post car response (object)
+ id: `1` (number) - car ID
+ email: `anuoluwapoakinseye@gmail.com` (string) car owner email address
+ created_on: `2019-06-06T00:41:44.496Z` (string) car posted date
+ manufacturer: `bmw` (string) car manufacturer
+ model: `s3` (string) car model
+ price: `1755999.99` (number) car price
+ status: `available` (string) car status
## Update car status response
+ id: `1` (number) - car ID
+ email: `anuoluwapoakinseye@gmail.com` (string) - car owner email address
+ created_on: `2019/05/25/ 13:30:30` (string) - car advert posted date
+ manufacturer: `bwm` (string) - car manufacturer
+ model: `BMW 3 Series 320d 2014` (string) - car model
+ price: `1759999.99` (string) - car price
+ state: `used` (string) - car state
+ status: `sold` (string) - car status
## Update car price response (object)
+ id: `1` (number) - car ID
+ email: `anuoluwapoakinseye@gmail.com` (string) - car owner email address
+ created_on: `2019/05/25/ 13:30:30` (string) - car advert posted date
+ manufacturer: `bwm` (string) - car manufacturer
+ model: `BMW 3 Series 320d 2014` (string) - car model
+ price: `1749999.99` (string) - car price
+ state: `used` (string) - car state
+ status: `available` (string) - car status
## Fetch car response (object)
+ id: `1` (number) - car ID
+ owner: `1` (number) - car owner ID
+ created_on: `2019/05/25/ 13:30:30` (string) - car advert posted date
+ state: `used` (string) - car state
+ status: `sold` (string) - car status
+ price: `1759999.99` (string) - car price
+ manufacturer: `bwm` (string) - car manufacturer
+ model: `BMW 3 Series 320d 2014` (string) - car model
+ body_type: `car` (string) - car body type
## Delete car response (object)
+ data: `Car Ad successfully deleted` (string) - message after advert is deleted
## Purchase order response (object)
+ id: `1` (number) - order ID number
+ car_id: `1` (number) - purchase car ID number
+ price: `1759999.99` (number) - price of the car
+ price_offered: 1750000.00 (number) - Amount to be offered for the purchase
## Update purchase order price response (object)
+ id: 1 (number) - order ID number
+ car_id: 2 (number) - purchase car ID number
+ status: `pending` (string) - status of the order
+ old_price_offered: 1750000.00 (number) - old purchase order price
+ new_price_offered: `1755000` (number) - new price to be updated
## flag advert response (object)
+ id: `1` (number) - flag ID number
+ car_id: `1` (number) - flagged car ID number
+ reason: `pricing` (string)
+ description: `the price of the car is too expensive` (string)