Skip to content

Commit

Permalink
[finishes #187584937] buyer track order status
Browse files Browse the repository at this point in the history
  • Loading branch information
solangeihirwe03 committed Jun 19, 2024
1 parent 6d83b26 commit 3fee88b
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 5 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ Our e-commerce web application server, developed by Team Ninjas, facilitates smo
- Buyer create-update cart Endpoint
- buyer add product to wish list Endpoint
- buyer delete products from wishlist
- buyer delete product from wishlist
- buyer delete product from wishlist
- Buyer track order status Endpoint
- Admin update order status Endpoint

## TABLE OF API ENDPOINTS SPECIFICATION AND DESCRIPTION

Expand Down Expand Up @@ -96,8 +98,10 @@ Our e-commerce web application server, developed by Team Ninjas, facilitates smo
| 31 | GET | /api/cart/buyer-get-cart/:cartId | 200 OK | private | Buyer get cart details |
| 32 | POST | /api/cart/create-update-cart | 201 CREATED | private | Buyer create-update cart |
| 33 | POST | /api/shop/buyer-add-product-wishList/:id | 200 OK | private | buyer add product to wish list |
| 34 | delete | /api/shop/delete-whishlist-products | 200 OK | private | buyer delete products from wishlist |
| 35 | delete | /api/shop/delete-whishlist-product:id | 200 OK | private | buyer delete product from wishlist |
| 34 | delete | /api/shop/delete-wishlist-products | 200 OK | private | buyer delete products from wishlist |
| 35 | delete | /api/shop/delete-wishlist-product:id | 200 OK | private | buyer delete product from wishlist |
| 36 | GET | /api/cart/user-get-order-status/:id | 200 OK | private | user get order status |
| 35 | PUT | /api/cart/admin-update-order-status/:id | 200 OK | private | admin update order status |


## INSTALLATION
Expand Down
2 changes: 1 addition & 1 deletion src/modules/cart/test/cart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ describe("adminUpdateOrderStatus", () => {
});

it("should update order status", async () => {
const mockUpdateStatus = [1]; // Assuming Sequelize returns an array with the number of affected rows
const mockUpdateStatus = [1];
sandbox.stub(cartRepositories, "updateOrderStatus").resolves(mockUpdateStatus);
await cartController.adminUpdateOrderStatus(req, res);
expect(res.status).to.have.been.calledWith(httpStatus.OK);
Expand Down
2 changes: 2 additions & 0 deletions src/routes/cartRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ router.get(
isCartIdExist,
cartControllers.buyerGetCart
);
router.get("/user-get-order-status/:id",userAuthorization(["buyer"]), cartControllers.buyerGetOrderStatus )
router.put("/admin-update-order-status/:id", userAuthorization(["admin"]), cartControllers.adminUpdateOrderStatus)

export default router;
164 changes: 163 additions & 1 deletion swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3072,6 +3072,168 @@
}
}
}
},
"/api/cart/user-get-order-status/{id}": {
"get": {
"tags": [
"Buyer Routes"
],
"summary": "Get order status for a buyer",
"description": "Retrieve the status of an order by order ID for a buyer.",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"description": "The ID of the order to retrieve the status for",
"schema": {
"type": "string"
}
}
],
"security": [
{
"bearerAuth": []
}
],
"responses": {
"200": {
"description": "Order status retrieved successfully.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Order Status found successfully"
},
"data": {
"type": "string",
"example": "pending"
}
}
}
}
}
},
"500": {
"description": "Internal server error",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "integer",
"example": 500
},
"error": {
"type": "string",
"example": "Internal server error"
}
}
}
}
}
}
}
}
},
"/api/cart/admin-update-order-status/{id}": {
"put": {
"tags": [
"Buyer Routes"
],
"summary": "Admin update order status",
"description": "Update the status of an order by order ID.",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"description": "The ID of the order to update the status for",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"description": "Updated status of the order",
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "shipped"
}
},
"required": [
"status"
]
}
}
}
},
"security": [
{
"bearerAuth": []
}
],
"responses": {
"200": {
"description": "Status updated successfully!",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string",
"example": "Status updated successfully!"
},
"data": {
"type": "object",
"example": {
"affectedRows": 1
}
}
}
}
}
}
},
"500": {
"description": "Internal server error",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "integer",
"example": 500
},
"error": {
"type": "string",
"example": "Internal server error"
}
}
}
}
}
}
}
}
}
}
}
}






0 comments on commit 3fee88b

Please sign in to comment.