Repository navigation
Expand file tree
/
Copy pathhttp-requests.http
More file actions
438 lines (348 loc) · 9.82 KB
/
Copy pathhttp-requests.http
File metadata and controls
438 lines (348 loc) · 9.82 KB
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
@baseUrl = http://localhost:{{localhost}}/api/v1
@authBase = {{baseUrl}}/auth
@passwordResetBase = {{baseUrl}}/password-reset
@authHeader = Bearer {{authToken}}
### Health check (public)
GET http://localhost:{{localhost}}/actuator/health
Accept: application/json
### Application runtime information (requires authentication)
GET http://localhost:{{localhost}}/actuator/appinfo
Authorization: {{authHeader}}
Accept: application/json
### Register a user
# Use a unique username/email. Account activation requires the OTP sent by email.
POST {{authBase}}/register
Content-Type: application/json
{
"first_name": "Ada",
"last_name": "Lovelace",
"username": "ada.lovelace",
"email": "ada@example.com",
"password": "DemoPassword123!",
"confirm_password": "DemoPassword123!"
}
### Activate a user account
# Replace the OTP with the six-digit code received by email.
POST {{authBase}}/activate-account
Content-Type: application/json
{
"email": "ada@example.com",
"activation_code": "123456"
}
### Login
# The response handler stores access_token and refresh_token for subsequent requests.
POST {{authBase}}/login
Content-Type: application/json
{
"email": "admin@example.com",
"password": "Admin1234#"
}
> {%
client.global.set("authToken", response.body.data.access_token);
client.global.set("refreshToken", response.body.data.refresh_token);
%}
### Refresh access and refresh tokens
POST {{authBase}}/refresh-token
Authorization: Bearer {{refreshToken}}
Content-Type: application/json
> {%
client.global.set("authToken", response.body.data.access_token);
client.global.set("refreshToken", response.body.data.refresh_token);
%}
### Get current user profile
GET {{authBase}}/me
Authorization: {{authHeader}}
Accept: application/json
### Get current token claims
GET {{authBase}}/token-info
Authorization: {{authHeader}}
Accept: application/json
### Logout
POST {{authBase}}/logout
Authorization: {{authHeader}}
> {%
client.global.set("authToken", "");
client.global.set("refreshToken", "");
%}
### Request a web password-reset link (legacy auth endpoint)
POST {{authBase}}/forgot-password
Content-Type: application/json
{
"email": "ada@example.com"
}
### Reset password with the link token (legacy auth endpoint)
# Replace token with the value from the reset link.
POST {{authBase}}/reset-password?token=PASTE_RESET_TOKEN_HERE
Content-Type: application/json
{
"new_password": "NewDemoPassword123!",
"confirm_password": "NewDemoPassword123!"
}
### Request a web password-reset link
POST {{passwordResetBase}}/web
Content-Type: application/json
{
"email": "ada@example.com"
}
### Request a mobile password-reset OTP
POST {{passwordResetBase}}/mobile
Content-Type: application/json
{
"email": "ada@example.com"
}
### Verify a mobile password-reset OTP
POST {{passwordResetBase}}/verify-otp
Content-Type: application/json
{
"email": "ada@example.com",
"otp": "123456"
}
### Confirm password reset with a link token or mobile OTP
# The token query parameter accepts either the web reset token or the mobile OTP.
POST {{passwordResetBase}}/confirm?token=PASTE_RESET_TOKEN_OR_OTP_HERE
Content-Type: application/json
{
"new_password": "NewDemoPassword123!",
"confirm_password": "NewDemoPassword123!"
}
### List categories (public, paginated)
GET {{baseUrl}}/categories?page=0&size=20&sort=id,asc
Accept: application/json
### Get category details (public)
GET {{baseUrl}}/categories/1
Accept: application/json
### Create category (ADMIN)
POST {{baseUrl}}/categories
Authorization: {{authHeader}}
Content-Type: application/json
{
"category_name": "Accessories"
}
### Update category (ADMIN)
PUT {{baseUrl}}/categories/1
Authorization: {{authHeader}}
Content-Type: application/json
{
"category_name": "Computer Accessories"
}
### Delete category (ADMIN)
DELETE {{baseUrl}}/categories/1
Authorization: {{authHeader}}
### List products (public, paginated)
GET {{baseUrl}}/products?page=0&size=20&sort=id,asc
Accept: application/json
### Filter products by category and name
GET {{baseUrl}}/products?categoryId=1&productName=keyboard&minPrice=10&maxPrice=200&page=0&size=20&sort=unitPrice,asc
Accept: application/json
### Get product details (public)
GET {{baseUrl}}/products/1
Accept: application/json
### Create product (ADMIN)
POST {{baseUrl}}/products
Authorization: {{authHeader}}
Content-Type: application/json
{
"category_id": 1,
"product_name": "Mechanical Keyboard",
"description": "Compact mechanical keyboard",
"unit_price": 79.99
}
### Update product (ADMIN)
PUT {{baseUrl}}/products/1
Authorization: {{authHeader}}
Content-Type: application/json
{
"category_id": 1,
"product_name": "Mechanical Keyboard",
"description": "Compact mechanical keyboard",
"unit_price": 84.99
}
### Delete product (ADMIN)
DELETE {{baseUrl}}/products/1
Authorization: {{authHeader}}
### Upload a product image (ADMIN)
# Replace the local file path before sending.
POST {{baseUrl}}/products/1/images?altText=Keyboard%20front&isPrimary=true
Authorization: {{authHeader}}
Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="product.jpg"
Content-Type: image/jpeg
< ./product.jpg
--WebAppBoundary--
### Delete a product image (ADMIN)
DELETE {{baseUrl}}/products/1/images/1
Authorization: {{authHeader}}
### List customers (paginated)
GET {{baseUrl}}/customers?page=0&size=20&sort=id,asc
Authorization: {{authHeader}}
Accept: application/json
### Search customers (paginated)
GET {{baseUrl}}/customers?search=Ada&page=0&size=20&sort=lastName,asc
Authorization: {{authHeader}}
Accept: application/json
### Get customer details
GET {{baseUrl}}/customers/1
Authorization: {{authHeader}}
Accept: application/json
### Create customer (ADMIN)
POST {{baseUrl}}/customers
Authorization: {{authHeader}}
Content-Type: application/json
{
"first_name": "Ada",
"last_name": "Lovelace",
"telephone": "+441234567890",
"email": "ada.customer@example.com",
"address": "12 St James's Square, London"
}
### Update customer (ADMIN)
PUT {{baseUrl}}/customers/1
Authorization: {{authHeader}}
Content-Type: application/json
{
"first_name": "Ada",
"last_name": "Lovelace",
"telephone": "+441234567890",
"email": "ada.customer@example.com",
"address": "12 St James's Square, London"
}
### Delete customer (ADMIN)
DELETE {{baseUrl}}/customers/1
Authorization: {{authHeader}}
### List orders for a customer
GET {{baseUrl}}/customers/1/orders?page=0&size=20&sort=id,desc
Authorization: {{authHeader}}
Accept: application/json
### Get authenticated user's cart (USER)
GET {{baseUrl}}/cart
Authorization: {{authHeader}}
Accept: application/json
### Add product to authenticated user's cart (USER)
POST {{baseUrl}}/cart/items
Authorization: {{authHeader}}
Content-Type: application/json
{
"product_id": 1,
"quantity": 2
}
### Update cart item quantity (USER)
PATCH {{baseUrl}}/cart/items/1
Authorization: {{authHeader}}
Content-Type: application/json
{
"quantity": 3
}
### Remove a cart item (USER)
DELETE {{baseUrl}}/cart/items/1
Authorization: {{authHeader}}
### Clear authenticated user's cart (USER)
DELETE {{baseUrl}}/cart
Authorization: {{authHeader}}
### Checkout authenticated user's cart (USER)
POST {{baseUrl}}/orders
Authorization: {{authHeader}}
### List orders visible to the authenticated user (USER/ADMIN)
GET {{baseUrl}}/orders?page=0&size=20&sort=id,desc
Authorization: {{authHeader}}
Accept: application/json
### Get order details (USER: own order; ADMIN: any order)
GET {{baseUrl}}/orders/1
Authorization: {{authHeader}}
Accept: application/json
### Update order status (ADMIN)
PATCH {{baseUrl}}/orders/1/status
Authorization: {{authHeader}}
Content-Type: application/json
{
"status": "CONFIRMED"
}
### Update a legacy customer/product order (ADMIN)
PUT {{baseUrl}}/orders/1
Authorization: {{authHeader}}
Content-Type: application/json
{
"customer_id": 1,
"product_id": 1,
"quantity": 2
}
### Delete order (ADMIN)
DELETE {{baseUrl}}/orders/1
Authorization: {{authHeader}}
### List users (ADMIN, paginated)
GET {{baseUrl}}/users?page=0&size=20&sort=id,asc
Authorization: {{authHeader}}
Accept: application/json
### Get user details (ADMIN)
GET {{baseUrl}}/users/1
Authorization: {{authHeader}}
Accept: application/json
### Update user profile (ADMIN)
PUT {{baseUrl}}/users/1
Authorization: {{authHeader}}
Content-Type: application/json
{
"username": "ada.updated",
"email": "ada.updated@example.com"
}
### Update user roles (ADMIN)
PATCH {{baseUrl}}/users/1/roles
Authorization: {{authHeader}}
Content-Type: application/json
{
"add": [2],
"remove": []
}
### Lock user account (ADMIN; cannot lock yourself)
PATCH {{baseUrl}}/users/1/lock
Authorization: {{authHeader}}
### Unlock user account (ADMIN)
PATCH {{baseUrl}}/users/1/unlock
Authorization: {{authHeader}}
### Delete user (ADMIN)
DELETE {{baseUrl}}/users/1
Authorization: {{authHeader}}
### List roles (ADMIN, paginated)
GET {{baseUrl}}/roles?page=0&size=20&sort=id,asc
Authorization: {{authHeader}}
Accept: application/json
### Create role (ADMIN)
POST {{baseUrl}}/roles
Authorization: {{authHeader}}
Content-Type: application/json
{
"role_name": "SUPPORT"
}
### Update role (ADMIN)
PUT {{baseUrl}}/roles/1
Authorization: {{authHeader}}
Content-Type: application/json
{
"role_name": "CUSTOMER_SUPPORT"
}
### Update role permissions (ADMIN)
PATCH {{baseUrl}}/roles/1/permissions
Authorization: {{authHeader}}
Content-Type: application/json
{
"add": [1],
"remove": []
}
### Delete role (ADMIN)
DELETE {{baseUrl}}/roles/1
Authorization: {{authHeader}}
### List permissions (ADMIN, paginated)
GET {{baseUrl}}/permissions?page=0&size=20&sort=id,asc
Authorization: {{authHeader}}
Accept: application/json
### Create permission (ADMIN)
POST {{baseUrl}}/permissions
Authorization: {{authHeader}}
Content-Type: application/json
{
"resource": "products",
"action": "read"
}
### Delete permission (ADMIN)
DELETE {{baseUrl}}/permissions/1
Authorization: {{authHeader}}