Models:
User
- email : string, required, unique, email format
- firstName : string, required
- lastName : string, required
- phoneNumber : integer, required
- password : string, required
- picture: url, required
- role : string
- username: string, required
Products
- name : string, required
- price : integer, required
- stock : string, required
- weight : double,required
- status : string,required
- ingridient : string,required
- picture : string,required, url format
- UserId : string,required
- CategoryId : string,required
Chats
- BuyerId : string, required
- SellerId : text, required
- Message : integer, required
list of available endpoints:
POST /buyers/register
POST /buyers/login
POST /buyers/login/google
POST /sellers/register
POST /sellers/login
GET /buyers/products
GET /buyers/products/:id
GET /brands
GET /categories
GET /ingridients
routes below need authentication & authorization
GET /buyers/carts
GET /buyers/history
POST /buyers/carts
POST /buyers/checkout
DELETE /buyers/carts
DELETE /buyers/carts/:id
GET /chats/:id
GET /sellers/chats
GET /sellers/products
GET /sellers/products/:id
POST /sellers/products
PUT /sellers/products/:id
DELETE /sellers/products/:id
description: get all brands from database
Response:
- status: 200
- body:
[
{
"id": "integer",
"name": "string",
},
...,
...,
]
description: get all categories from database
Response:
- status: 200
- body:
[
{
"id": "integer",
"name": "string",
},
...,
...,
]
description: get all ingredients from database
Response:
- status: 200
- body:
[
{
"id": "integer",
"name": "string",
},
...,
...,
]
Request:
- data:
{
"email": "string",
"firstName": "string",
"lastName": "string",
"password": "string",
"phoneNumber": "integer",
"picture": "file",
"username": "string",
}
Response:
- status: 201
- body: โ
{
"id": "integer",
"email": "string",
}
Response (400 - Bad Request)
{
"message": "<field> cannot be empty"
}
Response (400 - Bad Request)
{
"message": "Invalid email format"
}
Response (400 - Bad Request)
{
"message": "Email already exists"
}
Request:
- data:
{
"email": "string",
"password": "string"
}
Response:
- status: 200
- body: โ
{
"access_token": "jwt string",
"id": "integer",
"role": "string",
"picture": "string",
"firstName": "string",
"lastName": "string",
}
Response (401 - Unauthenticated)
{ "message": "Invalid Email or Password" }
description: get all products from database
Response:
- status: 200
- body:
[
{
"id": "integer",
"name": "string",
"price": "integer",
"stock": "Integer",
"picture": "url String",
"harmfulIngridient": ["string"],
"Category": {
"id": "integer",
"name": "string"
},
"Brands": [
{
"id": integer,
"name": "string"
}
]
},
...,
...,
]
description: get the details of a product
Response:
- status: 201
- body:
{
"id": 3,
"name": "string",
"price": "integer",
"stock": "integer",
"weight": "integer",
"status": "string",
"description": "string",
"ingridient": ["string"],
"picture": "url string",
"harmfulIngridient": ["string"],
"UsersProducts": [
{
"ProductId": "integer",
"User": {
"id": "integer",
"firstName": "string",
"lastName": "string",
"role": "string"
}
}
],
"Category": {
"id": "integer",
"name": "string"
},
"Brands": [
{
"id": "integer",
"name": "string"
}
]
}
Response (404 - Not Found)
{ "message": "ID not found !" }
description: show cart
Request:
- headers: access_token (string)
Response:
- status: 200
- body:
[
{
"Product": {
"id": "integer",
"name": "string",
"stock": "integer",
"price": "string",
"weight": "integer",
"status": "string",
"picture": "url string",
"UsersProducts": {
"User": {
"id": "integer",
"firstName": "string",
"lastName": "string"
}
},
"qty": "integer"
}
},
...,
...
]
Response (401 - Unauthorized)
{
"message": "You are not authorized!"
}
description: add product to cart
Request:
- headers: access_token (string)
- body:
{
ProductId: "integer"
}
Response:
- status: 200
- body:
{
"message": "Product is added to cart"
}
Response (401 - Unauthorized)
{
"message": "You are not authorized!"
}
description: delete items in a cart
Request:
- headers: access_token (string)
Response:
- status: 200
- body:
{
"message": "Product has been reduced by one"
}
description: checkout cart
Request:
- headers: access_token (string)
Response:
- status: 200
- body:
{
"token": "b8e4cd43-717b-49b4-b9c7-82ff1c054ff3",
"redirect_url": "https://app.sandbox.midtrans.com/snap/v2/vtweb/b8e4cd43-717b-49b4-b9c7-82ff1c054ff3"
}
description: get order history
Request:
- headers: access_token (string)
Response:
- status: 200
- body:
[
{
"Product": {
"id": "integer",
"name": "string",
"stock": "integer",
"price": "string",
"weight": "integer",
"status": "string",
"picture": "url string",
"UsersProducts": {
"User": {
"id": "integer",
"firstName": "string",
"lastName": "string"
}
},
"qty": "integer"
}
},
...,
...
]
description: get chat with another user
Request:
- headers: access_token (string)
Response:
- status: 200
- body:
[
{
"BuyerId": 'integer',
"SellerId": 'integer',
"message": "string",
"fullName": "string"
},
...,
...
]
description: get chat to another user
Request:
- headers: access_token (string)
Response:
- status: 200
- body:
[
{
"BuyerId": 'integer',
"SellerId": 'integer',
"message": "string",
"User": {
"id": 'integer',
"firstName": 'string',
"lastName": 'string'
}
},
...,
...
]
Response (401 - Unauthorized)
{ "message": "you are not authorized!" }