Materials
Get All Materials
GET /adminapi/materials
Query Parameters:
limit: Number of materials to return (default: 10).offset: Number of materials to skip (default: 0).all: Get all materials (default: false).DEB: Get materials by DEB (thickness).
Response:
{
"materials": [
{
"_id": "60d5ec49f1b2c72d88f8e8b5",
"name": "Wood",
"CIJENA": "50" // price
}
],
"totalMaterials": 1
}
Get Material by ID
GET /adminapi/materials/:id
Response:
{
"_id": "60d5ec49f1b2c72d88f8e8b5",
"name": "Wood",
"CIJENA": "50" // price
}
Get Materials by SIFRA
GET /adminapi/materials/materialsBySIFRA
Query Parameters:
SIFRAs: Comma-separated list of SIFRA codes.
Response:
{
"materials": [
{
"_id": "60d5ec49f1b2c72d88f8e8b5",
"name": "Wood",
"price": 50
}
],
"totalMaterials": 1
}
Create Material
Create a new material.
POST /adminapi/materials
Request Body:
Upload Material Image
Upload an image for a material.
POST /adminapi/materials/upload_image
Request:
-
Set the request headers
Content-Type: multipart/form-dataAuthorization: Bearer ${accessToken}
-
Add the image file to the request body under the field name
image.
Response:
{
"message": "Image uploaded successfully!",
"files": [
{
"fieldname": "image",
"originalname": "material.jpg",
"encoding": "7bit",
"mimetype": "image/jpeg",
"destination": "uploads/materials",
"filename": "material.jpg",
"path": "relative/path/to/material.jpg",
"size": 12345
}
]
}
Update Material
Update an existing material by its ID.
PATCH /adminapi/materials/:id
Request Body:
Delete Material
Delete a material by its ID.
DELETE /adminapi/materials/:id