- Overview
- Features
- Create new User
- Get User By ID
- Get User Purchases By ID
- Get all Users
- Edit User By ID
- Delete User By ID
- Create new Product
- Get Product By NAME
- Get Product By ID
- Get all Products
- Edit Product By ID
- Delete Product By ID
- Create new Purchase
- Get Purchase By ID
- Get all Purchases
- Edit Purchase By ID
- Delete Purchase By ID
- Get all Purchases Products
- Process
- Author
A API to my portfolio made based on a Ecommerce backend. See more below :)
- Users CRUD
- Products CRUD
- Purchases CRUD
// Request
// POST /users
// body JSON
{
"id": "u001",
"name": "Ruan",
"email": "ruan@gmail.com",
"password": "Ruan@123"
}
// Response
// status 201 CREATED
{
message: "Cadastro realizado com sucesso"
}
// Request
// path params = :id
// GET /users/u001
// Response
// status 200 OK
{
"id": "u001",
"name": "Ruan",
"email": "ruan@gmail.com",
"password": "Ruan@12345",
"created_at": "2023-07-13 15:15:21"
}
// Request
// path params = :id
// GET /users/u001/purchases
// Response
// status 200 OK
[
{
"id": "pur001",
"buyer": "u001",
"total_price": 4600,
"created_at": "2023-07-13 15:21:13"
},
{
"id": "pur002",
"buyer": "u001",
"total_price": 4500,
"created_at": "2023-07-13 15:23:18"
}
]
// Request
// GET /users
// Response
// status 200 OK
[
{
"id": "u001",
"name": "Ruan",
"email": "ruan@gmail.com",
"password": "Ruan@12345",
"created_at": "2023-07-13 15:15:21"
},
{
"id": "u002",
"name": "Teste",
"email": "teste@gmail.com",
"password": "Te
ste@
123",
"created_at": "2023-07-13 15:17:23"
}
]
// Request
// path params = :id
// PUT /users/u001
// body JSON
{
"password": "Ruan@12345"
}
// Response
// status 200 OK
{
message: "Usuário atualizado com sucesso!"
}
// Request
// path params = :id
// DELETE /users/u002
// Response
// status 200 OK
{
message: "Usuário apagado com sucesso!"
}
// Request
// POST /products
// body JSON
{
"id": "prod001",
"name": "Cadeira gamer",
"price": 900,
"description": "Melhor cadeira do mercado!",
"imageUrl": "https://picsum.photos/seed/Cadeira%20gamer/400"
}
// Response
// status 201 CREATED
{
message: "Produto cadastrado com sucesso!"
}
// Request
// query params = name
// GET /products?name=monitor
// Response
// status 200 OK
[
{
"id": "prod002",
"name": "Monitor gamer",
"price": 700,
"description": "Melhor monitor do mercado!",
"image_url": "https://picsum.photos/seed/Monitor%20gamer/400"
}
]
// Request
// path params = :id
// GET /products/prod001
// Response
// status 200 OK
[
{
"id": "prod001",
"name": "Cadeira gamer",
"price": 800,
"description": "Melhor cadeira do mercado!",
"image_url": "https://picsum.photos/seed/Cadeira%20gamer/400"
}
]
// Request
// GET /products
// Response
// status 200 OK
[
{
"id": "prod001",
"name": "Cadeira gamer",
"price": 800,
"description": "Melhor cadeira do mercado!",
"image_url": "https://picsum.photos/seed/Cadeira%20gamer/400"
},
{
"id": "prod002",
"name": "Monitor gamer",
"price": 700,
"description": "Melhor monitor do mercado!",
"image_url": "https://picsum.photos/seed/Monitor%20gamer/400"
}
]
// Request
// path params = :id
// PUT /products/prod001
// body JSON
{
"price": 800
}
// Response
// status 200 OK
{
message: "Produto atualizado com sucesso!"
}
// Request
// path params = :id
// DELETE /products/u002
// Response
// status 200 OK
{
message: "Produto apagado com sucesso!"
}
// Request
// POST /purchases
// body JSON
{
"id": "pur002",
"buyer": "u001",
"products": [
{
"id": "prod001",
"quantity": 2
},
{
"id": "prod002",
"quantity": 1
}
]
}
// Response
// status 201 CREATED
{
message: "Pedido realizado com sucesso!"
}
// Request
// path params = :id
// GET /purchases/pur001
// Response
// status 200 OK
{
"purchaseId": "pur001",
"buyerId": "u001",
"buyerName": "Ruan",
"buyerEmail": "ruan@gmail.com",
"totalPrice": 2300,
"createdAt": "2023-07-13 15:21:13",
"products": [
{
"id": "prod001",
"name": "Cadeira gamer",
"price": 800,
"description": "Melhor cadeira do mercado!",
"imageUrl": "https://picsum.photos/seed/Cadeira%20gamer/400",
"quantity": 2
},
{
"id": "prod002",
"name": "Monitor gamer",
"price": 700,
"description": "Melhor monitor do mercado!",
"imageUrl": "https://picsum.photos/seed/Monitor%20gamer/400",
"quantity": 1
}
]
}
// Request
// GET /purchases
// Response
// status 200 OK
[
{
"id": "pur001",
"buyer": "u001",
"total_price": 4600,
"created_at": "2023-07-13 15:21:13"
},
{
"id": "pur002",
"buyer": "u001",
"total_price": 4500,
"created_at": "2023-07-13 15:23:18"
}
]
// Request
// path params = :id
// PUT /purchases/pur001
// body JSON
{
"products": [
{
"id": "prod001",
"quantity": 4
},
{
"id": "prod002",
"quantity": 2
}
]
}
// Response
// status 200 OK
{
message: "Pedido atualizado com sucesso!"
}
// Request
// path params = :id
// DELETE /purchases/pur002
// Response
// status 200 OK
{
message: "Pedido cancelado com sucesso!"
}
// Request
// GET /purchasesProducts
// Response
// status 200 OK
[
{
"purchase_id": "pur001",
"product_id": "prod001",
"quantity": 4
},
{
"purchase_id": "pur001",
"product_id": "prod002",
"quantity": 2
},
{
"purchase_id": "pur002",
"product_id": "prod001",
"quantity": 3
},
{
"purchase_id": "pur002",
"product_id": "prod002",
"quantity": 3
}
]
![]() Ruan Heleno |