-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add API for fetching most frequent ordered product and its tests
- Loading branch information
1 parent
8e7630e
commit f5606d5
Showing
5 changed files
with
227 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
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 would create normal user account. To make a account an admin, a superuser would have to login to | ||
Django admin page and update the user account `is_admin` metadata to `true` and add `Admin` group for the user too. | ||
Then the normal user account turn to an admin that can add, update and delete products. | ||
|
||
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: | ||
[ | ||
{ | ||
"date": "2024-07-02", | ||
"total_sales": 400 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters