-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathapi.http
264 lines (192 loc) Β· 5.91 KB
/
api.http
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
### πππ JWT login πππ
# @name jwt_login
POST http://localhost:3000/jwt/login
Content-Type: application/json
Origin: http://localhost:3000
{
"email": "[email protected]",
"password": "admin"
}
###
@token = {{ jwt_login.response.body.token }}
### πππ Ge me πππ
GET http://localhost:3000/jwt/me
Authorization: Bearer {{ token }}
### πππ Session login πππ
POST http://localhost:3000/session/login
Content-Type: application/json
{
"email": "[email protected]",
"password": "admin"
}
###
POST http://localhost:3000/session/logout
### πππ Customer Endpoints πππ
###
POST http://localhost:3000/customers
Content-Type: application/json
<xml></xml>
### With form-urlencoded
POST http://localhost:3000/customers
Content-Type: application/x-www-form-urlencoded
name=john_doe&[email protected]&password=securepassword&phone=1234567890&address=123 Main St
###
# @name createCustomer
POST http://localhost:3000/customers
Content-Type: application/json
{
"name": "john_doe",
"email": "[email protected]",
"password": "securepassword",
"phone": "1234567890",
"address": "123 Main St"
}
###
@customer_id = {{ createCustomer.response.body.id }}
### Get a customer by ID
GET http://localhost:3000/admin/customers/{{ customer_id }}
Authorization: Bearer {{ token }}
### List customers in admin with pagination and optional filtering
GET http://localhost:3000/admin/customers?page=1&limit=10
Authorization: Bearer {{ token }}
### Update a customer
PATCH http://localhost:3000/admin/customers/{{ customer_id }}
Content-Type: application/json
Authorization: Bearer {{ token }}
{
"password": "newpassword",
"phone": "0987654321",
"address": "456 Elm St"
}
### Delete a customer
DELETE http://localhost:3000/admin/customers/{{ customer_id }}
Content-Type: application/json
Authorization: Bearer {{ token }}
{
"id": 1
}
### πππ Category Endpoints πππ
# @name createCategory
POST http://localhost:3000/admin/categories
Content-Type: application/json
Authorization: Bearer {{ token }}
{
"name": "Category Name",
"slug": "category-slug"
}
###
@category_id = {{ createCategory.response.body.id }}
@category_slug = {{ createCategory.response.body.slug }}
### Get a category by slug
GET http://localhost:3000/categories/{{ category_slug }}
### List categories with pagination and optional filtering
GET http://localhost:3000/categories?page=1&limit=10&name=Category
### List categories in admin with pagination and optional filtering
GET http://localhost:3000/admin/categories?page=1&limit=10&name=Category
Authorization: Bearer {{ token }}
### Update a category
PATCH http://localhost:3000/admin/categories/{{ category_id }}
Content-Type: application/json
Authorization: Bearer {{ token }}
{
"name": "Updated Category Name",
"slug": "updated-category-slug"
}
### Delete a category
DELETE http://localhost:3000/admin/categories/{{ category_id }}
Content-Type: application/json
Authorization: Bearer {{ token }}
{
"id": "{{ category_id }}"
}
### πππ Product Endpoints πππ
# @name createProduct
POST http://localhost:3000/admin/products
Content-Type: application/json
Authorization: Bearer {{ token }}
{
"name": "Product Name",
"slug": "product-slug",
"description": "Product Description",
"price": 100,
"categoryIds": [ "{{ category_id }}" ]
}
###
@product_id = {{ createProduct.response.body.data.id }}
@product_slug = {{ createProduct.response.body.data.slug }}
### Get a product by ID
GET http://localhost:3000/admin/products/{{ product_id }}
Authorization: Bearer {{ token }}
### Get a product by slug
GET http://localhost:3000/products/{{ product_slug }}
### Update a product
PATCH http://localhost:3000/admin/products/{{ product_id }}
Content-Type: application/json
Authorization: Bearer {{ token }}
{
"id": "{{ product_id }}",
"name": "Updated Product Name",
"slug": "{{ product_slug }}",
"description": "Updated Product Description",
"price": 150,
"categoryIds": [ "{{ category_id }}" ]
}
### Delete a product
DELETE http://localhost:3000/admin/products/{{ product_id }}
Content-Type: application/json
Authorization: Bearer {{ token }}
{
"id": "{{ product_id }}"
}
### OPTIONS /products
OPTIONS http://localhost:3000/admin/products
###
OPTIONS http://localhost:3000/admin/products/1
### List products with pagination and optional filtering&name=Product&categories_slug=category-slug,xpto1,xpto2
GET http://localhost:3000/products?page=1&limit=10
### List products in admin with pagination and optional filtering &name=Product&categories_slug=category-slug&user_id=1
GET http://localhost:3000/admin/products?page=2&limit=1
Authorization: Bearer {{ token }}
# Content-Type: application/x-www-form-urlencoded
# Accept: text/css
### Get csv of products
GET http://localhost:3000/admin/products/listProducts.csv
Authorization: Bearer {{ token }}
### πππ Cart Endpoints πππ
### Create a cart
# @name createCart
POST http://localhost:3000/carts
###
@cart_uuid = {{ createCart.response.body.uuid }}
### Add an item to the cart "customerId": "{{ customer_id }}",
# @name addItemToCart
POST http://localhost:3000/carts/{{cart_uuid}}/items
Content-Type: application/json
{
"productId": "{{ product_id }}",
"quantity": 1
}
###
@cart_id = {{ addItemToCart.response.body.id }}
### Get a cart by ID
GET http://localhost:3000/carts/{{ cart_uuid }}
### Remove an item from the cart
DELETE http://localhost:3000/carts/{{cart_uuid}}/items/1
Content-Type: application/json
{
"cartItemId": 1
}
### Clear the cart
POST http://localhost:3000/carts/{{cart_uuid}}/clear
### πππ Order Endpoints πππ
### Create an order
POST http://localhost:3000/orders
Content-Type: application/json
Authorization: Bearer {{ token }}
{
"payment_method": "CREDIT_CARD",
"cart_uuid": "{{ cart_uuid }}"
}
### List orders with pagination and optional filtering
GET http://localhost:3000/orders?page=1&limit=10
Authorization: Bearer {{ token }}