-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_doc.txt
161 lines (133 loc) · 4.25 KB
/
api_doc.txt
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
API Descriptions:
This application provides a RESTful API for Drugstoc Inventory Management BE Assessment.
Auth Endpoints:
1. POST /api/users/register/
- Description: Create a new user
- Request Body: name, email, password, password2, address
- Auth: Not required
- Response: name, email, password, password2, address
Note: The register endpoint above creates a normal user account. However, an admin account can be gotten from a normal
user account when a superuser logins to Django admin page and update `is_admin` metadata to `true`
and add `Admin` group for the user.
2. POST /api/users/login/
- Description: login user
- Request Body: email, password
- Auth: Not required
- Response: id, metadata, refresh_token, access_token
3. GET /api/users/profile
- Description: Retrieve user profile by access token provided
- Auth: Bearer token
- Response: all user fields
4. POST /api/users/logout/
- Description: Logout auth user
- Request Body: refresh_token
- Auth: Bearer token
- Response: nil
Inventory Products Endpoints:
1. POST /api/inventory/products/add//
- Description: Create a new product by admin user
- Request Body: name, description, price, quantity, address
- Auth: Bearer token
- Response: id, owner, name, description, price, quantity, created_at, updated_at
2. GET /api/inventory/products/
- Description: List products for an admin user
- Request Body: nil
- Auth: Bearer token
- Response: list of products
3. PUT /api/inventory/products/:id/
- Description: Update product by an admin user
- Request Body: any field(s)
- Auth: Bearer token
- Response: id, owner, name, description, price, quantity, created_at, updated_at
4. DELETE /api/inventory/products/:id/
- Description: Delete product published by an admin user
- Request Body: nil
- Auth: Bearer token
- Response: nil
Note: This search functionality works when postgres database is used
5. GET /api/inventory/products/search?q=
- Description: Search for products by the specified field
- Request Body: nil
- Auth: Bearer token
- Response: list of products
- Search From: title, description
Inventory Orders Endpoints:
1. POST /api/inventory/orders/
- Description: Create a new order
- Request Body:
{
"items": [
{
"product": "0aa9ea8dce",
"quantity": 1
}
]
}
- Auth: Bearer token
- Response: order fields data
2. GET /api/inventory/orders/
- Description: List orders
- Request Body: nil
- Auth: Bearer token
- Response: list of orders
- Filters: status, date_from, date_to
3. PUT /api/inventory/orders/:id/status/
- Description: Update order status by an admin user
- Request Body:
{
"status": "completed"
}
- Auth: Bearer token
- Response: order fields data
4. DELETE /api/inventory/orders/:id/
- Description: Delete order
- Request Body: nil
- Auth: Bearer token
- Response: nil
5. GET /api/inventory/orders/:id/
- Description: Get order detail
- Request Body: nil
- Auth: Bearer token
- Response: order data
Inventory Report Endpoints:
1. GET /api/inventory/report/stock/
- Description: Get product out of stock
- Request Body: nil
- Auth: Bearer token
- Response:
[
{
"id": "0aa9ea8dce",
"name": "Product Name",
"quantity": 0,
"description": "Product Description",
"created_at": "2024-07-02T14:15:28.043625+01:00",
"updated_at": "2024-07-02T15:37:00.599740+01:00"
}
]
2. GET /api/inventory/report/sales/
- Description: Get product order sales by certain period
- Request Body: nil
- Auth: Bearer token
- Response:
{
"id": "21c7f528da",
"name": "Product beast",
"description": "Product beast Description",
"quantity": 4,
"price": 100,
"created_at": "2024-07-26T13:22:49.098161+01:00",
"updated_at": "2024-07-26T13:24:23.399251+01:00",
"owner": "Admin"
}
3. GET /api/inventory/report/order/frequent
- Description: Get product ordered frequent with most quantity
- Request Body: nil
- Auth: Bearer token
- Response:
[
{
"date": "2024-07-02",
"total_sales": 400
}
]