-
Notifications
You must be signed in to change notification settings - Fork 4
REST API Documentation
Login
"localhost:3000" + "/#"
Method: POST
Example
{
"username" : "myUserName",
"password" : "myPASSW1234!"
}
Fields
Elements | Descriptions | Type | Required |
---|---|---|---|
username | The username cannot be empty | String | true |
password | The password cannot be empty | String | true |
{ "result": "login success" } Possible status: 200, 400, 401
Message format: json
Example
Code: 200 OK
Register
"localhost:3000" + "/register"
Method: POST
Example
{
"username" : "myUserName",
"password" : "myPASSW1234!"
}
Fields
Elements | Descriptions | Type | Required |
---|---|---|---|
username | The username cannot be empty | String | true |
password | The password cannot be empty | String | true |
{ "result": "registration success" } Possible status: 200, 400, 401
Message format: json
Example
Code: 200 OK
Create Post
"localhost:3000" + "/create"
Method: POST
Example
{
"name":"Laptop Stand",
"description": "Useful to put laptop in a height and at a distance.",
"location": "4000 SW 34th St Block #733C",
"dimensions": "5 x 2 x 6 m",
"weight":10,
"age": 1,
"count": 2
}
Fields
Elements | Descriptions | Type | Required |
---|---|---|---|
name | Name of the product | String | true |
description | Description of the item | String | true |
location | Location to pickup the item | String | true |
dimensions | Dimensions of the item | String | true |
weight | Weight of the item | int | true |
age | Age of the item | int | true |
count | No pof items | int | true |
{ "result": "post creation success" } Possible status: 200, 400, 401
Message format: json
Example
Code: 200 OK
Edit post
"localhost:3000" + "/update/<post_id>"
Method: PATCH
Example
{
"name":"Steel Laptop Stand",
"weight": 11,
"count": 1
}
Fields
Same as create post fields. Eg: { "name":"Steel Laptop Stand", "weight": 11, "count": 1 }
{ "ID": 5, "CreatedAt": "2022-02-04T20:42:18.1731823-05:00", "UpdatedAt": "2022-02-04T20:47:02.5941861-05:00", "DeletedAt": null, "name": "Steel Laptop Stand", "description": "Useful to put laptop in a height and at a distance.", "location": "4000 SW 34th St Block #733C", "dimensions": "5 x 2 x 6 m", "weight": 11, "age": 1, "count": 1 } Possible status: 200, 400, 401Message format: json
Example
Code: 200 OK
Delete post
"localhost:3000" + "/delete/<post_id>"
Method: DELETE
Example
localhost:8080/delete/5
{ "ID": 5, "CreatedAt": "2022-02-04T20:42:18.1731823-05:00", "UpdatedAt": "2022-02-04T20:47:02.5941861-05:00", "DeletedAt": null, "name": "Steel Laptop Stand", "description": "Useful to put laptop in a height and at a distance.", "location": "4000 SW 34th St Block #733C", "dimensions": "5 x 2 x 6 m", "weight": 11, "age": 1, "count": 1 } Possible status: 200, 400, 401Message format: json
Example
Code: 200 OK
Get posts
"localhost:3000" + "/read"
Method: GET
Example
localhost:8080/read
Possible status: 200, 400, 401
Message format: json
Example
Code: 200 OK
Place Order
- While placing orders initially we keep it in pending state and then we move it to confirmed state.
- Once we delete we move status as cancelled state
PENDING status = 0
CONFIRMED status = 1
CANCELLED status = 2
"localhost:8080" + "/placeOrder"
Method: POST
Example
localhost:8080/placeOrder
Body :{ "posts":[ { "count": 1, "productId": 2 }, { "count": 2, "productId": 3 } ] }
{
"orderId": 8,
"result": "order successfully placed!"
}
Possible status: 200, 400, 401
Message format: json
Example
Code: 200 OK
View All Orders Of All Users
"localhost:8080" + "/allorders"
Method: GET
Example
localhost:8080/allOrders
- This API is for sellers to view all the orders.
{
"Page": 1,
"TotalPages": 1,
"Orders": [
{
"ID": 1,
"CreatedAt": "2022-04-01T17:22:12.7615198-04:00",
"UpdatedAt": "2022-04-01T17:22:12.7615198-04:00",
"DeletedAt": null,
"posts": [],
"Status": 1
},
{
"ID": 2,
"CreatedAt": "2022-04-01T17:29:50.5213792-04:00",
"UpdatedAt": "2022-04-01T17:29:50.5213792-04:00",
"DeletedAt": null,
"posts": [
{
"count": 1,
"productId": 1
}
],
"Status": 1
},
{
"ID": 3,
"CreatedAt": "2022-04-01T17:35:38.8661683-04:00",
"UpdatedAt": "2022-04-01T17:35:38.8661683-04:00",
"DeletedAt": null,
"posts": [
{
"count": 1,
"productId": 1
}
],
"Status": 1
},
]
}
Possible status: 200, 400, 401
Message format: json
Example
Code: 200 OK
View Particular Order
"localhost:8080" + "/order/:orderId"
Method: GET
Example
localhost:8080/order/5
{
"ID": 5,
"CreatedAt": "2022-04-01T17:41:37.7922598-04:00",
"UpdatedAt": "2022-04-01T17:41:37.7922598-04:00",
"DeletedAt": null,
"posts": [
{
"count": 1,
"productId": 1
}
],
"Status": 1
}
Possible status: 200, 400, 401
Message format: json
Example
Code: 200 OK
Cancel Order
"localhost:8080" + "/cancelOrder/:OrderId"
It take the user id from the session.
Method: GET
Example
localhost:8080/cancelOrder/3
{
"ID": 3,
"CreatedAt": "2022-04-01T17:35:38.8661683-04:00",
"UpdatedAt": "2022-04-01T21:08:07.3701319-04:00",
"DeletedAt": null,
"posts": [
{
"count": 1,
"productId": 1
}
],
"Status": 2
}
- Status is updated to 2 - Which means order is cancelled. Possible status: 200, 400, 401
Message format: json
Example
Code: 200 OK
View all Order of the particular user
"localhost:8080" + "/orders"
It takes the user id from the session.
Method: GET
Example
localhost:8080/orders
{
"ID": 3,
"CreatedAt": "2022-04-01T17:41:37.7922598-04:00",
"UpdatedAt": "2022-04-01T17:41:37.7922598-04:00",
"DeletedAt": null,
"posts": [
{
"count": 1,
"productId": 1
}
],
"Status": 1
}
Possible status: 200, 400, 401
Message format: json
Example
Code: 200 OK