Home | Escopo | Processo | Design/Mockups | Gerência | Estudos | Arquitetura | Contratos | BD | Qualidade | Configuração | Instalação | Instruções | Utilização | Analytics | Infraestrutura | Dicas |
---|
Products - produtos
fields:
id: number;
description: string;
code: string;
sku: string;
origin: Origin;
unit_measure: Unit_Measure;
category_id: number;
group_id: number;
supplier_id: number;
nutritional_info: string;
active: boolean;
prices: Price[];
endpoints:
FindAll
GET http://localhost:3000/products/
response:
[
{
"id": 1,
"description": "batata branca",
"code": "CODE001",
"sku": "SKU001",
"origin": "RAW_MATERIAL",
"unit_measure": "KG",
"category_id": 1,
"group_id": 1,
"supplier_id": 1,
"nutritional_info": {
"fat": {
"total": 8,
"trans": 0,
"saturated": 3
},
"sodium": 150,
"protein": 10,
"calories": 200,
"vitamins": {
"iron": 10,
"calcium": 30,
"vitamin_a": 20,
"vitamin_c": 15
},
"carbohydrates": {
"fiber": 5,
"total": 30,
"sugars": 12
}
},
"active": true,
"created_at": "18/10/2024 00:09:25",
"updated_at": "18/10/2024 00:09:25"
},
{
"id": 3,
"description": "aipim",
"code": "CODE003",
"sku": "SKU002",
"origin": "RAW_MATERIAL",
"unit_measure": "KG",
"category_id": 1,
"group_id": 1,
"supplier_id": 1,
"nutritional_info": {
"fat": {
"total": 8,
"trans": 0,
"saturated": 3
},
"sodium": 150,
"protein": 10,
"calories": 200,
"vitamins": {
"iron": 10,
"calcium": 30,
"vitamin_a": 20,
"vitamin_c": 15
},
"carbohydrates": {
"fiber": 5,
"total": 30,
"sugars": 12
}
},
"active": true,
"created_at": "18/10/2024 00:09:25",
"updated_at": "18/10/2024 00:09:25"
},
{
"id": 4,
"description": "mirtilos selecionados",
"code": "CODE004",
"sku": "SKU003",
"origin": "MADE",
"unit_measure": "KG",
"category_id": 1,
"group_id": 1,
"supplier_id": 1,
"nutritional_info": {
"fat": {
"total": 8,
"trans": 0,
"saturated": 3
},
"sodium": 150,
"protein": 10,
"calories": 200,
"vitamins": {
"iron": 10,
"calcium": 30,
"vitamin_a": 20,
"vitamin_c": 15
},
"carbohydrates": {
"fiber": 5,
"total": 30,
"sugars": 12
}
},
"active": true,
"created_at": "18/10/2024 00:09:25",
"updated_at": "18/10/2024 00:09:25"
},
{
"id": 5,
"description": "laranja",
"code": "CODE005",
"sku": "SKU004",
"origin": "RAW_MATERIAL",
"unit_measure": "KG",
"category_id": 1,
"group_id": 1,
"supplier_id": 1,
"nutritional_info": {
"fat": {
"total": 8,
"trans": 0,
"saturated": 3
},
"sodium": 150,
"protein": 10,
"calories": 200,
"vitamins": {
"iron": 10,
"calcium": 30,
"vitamin_a": 20,
"vitamin_c": 15
},
"carbohydrates": {
"fiber": 5,
"total": 30,
"sugars": 12
}
},
"active": true,
"created_at": "18/10/2024 00:09:25",
"updated_at": "18/10/2024 00:09:25"
},
(...)
]
FindbyId
GET http://localhost:3000/products/2
response:
{
"id": 2,
"description": "cenoura",
"code": "CODE002",
"sku": "SKU015",
"origin": "RAW_MATERIAL",
"unit_measure": "KG",
"category_id": 1,
"group_id": 1,
"supplier_id": 1,
"nutritional_info": {
"fat": {
"total": 8,
"trans": 0,
"saturated": 3
},
"sodium": 150,
"protein": 10,
"calories": 200,
"vitamins": {
"iron": 10,
"calcium": 30,
"vitamin_a": 20,
"vitamin_c": 15
},
"carbohydrates": {
"fiber": 5,
"total": 30,
"sugars": 12
}
},
"active": true,
"created_at": "18/10/2024 00:09:25",
"updated_at": "18/10/2024 00:09:25"
}
Create
POST http://localhost:3000/products/
request:
{
"description": "banana nanica",
"code": "banana nanica",
"sku": "banana nanica",
"origin": "RAW_MATERIAL",
"unit_measure": "UN",
"category_id": 4,
"group_id": 4,
"supplier_id": 4
}
response:
{
"id": 15,
"description": "banana nanica",
"code": "banana nanica",
"sku": "banana nanica",
"origin": "RAW_MATERIAL",
"unit_measure": "UN",
"category_id": 4,
"group_id": 4,
"supplier_id": 4,
"nutritional_info": null,
"active": true,
"created_at": "19/10/2024 02:52:39",
"updated_at": "19/10/2024 02:52:39"
}
Update
PATCH http://localhost:3000/products/2
response:
{
"id": 2,
"description": "mix de folhas verdes",
"code": "CODE002",
"sku": "SKU015",
"origin": "MADE",
"unit_measure": "KG",
"category_id": 1,
"group_id": 1,
"supplier_id": 1,
"nutritional_info": {
"fat": {
"total": 999,
"trans": 999,
"saturated": 999
},
"sodium": 999,
"protein": 999,
"calories": 999,
"vitamins": {
"iron": 999,
"calcium": 999,
"vitamin_a": 999,
"vitamin_c": 999
},
"carbohydrates": {
"fiber": 999,
"total": 999,
"sugars": 999
}
},
"active": true,
"created_at": "18/10/2024 00:09:25",
"updated_at": "19/10/2024 02:49:39"
}
Delete (inactivate)
DELETE http://localhost:3000/products/2
response:
{
"message": "Product ID 2 deleted successfully"
}
Activate
POST http://localhost:3000/products/activate/2
response:
{
"message": "Product ID 2 activated successfully"
}