Skip to main content

Fittings

Get All Fittings

GET /fittings

Query Parameters:

  • limit: Number of fittings to return (default: 10).
  • offset: Number of fittings to skip (default: 0).
  • all: Get all fittings (default: false).

Response:

{
"fittings": [
{
"_id": "60d5ec49f1b2c72d88f8e8b5",
"name": "Screw",
"price": "5"
}
],
"totalFittings": 1
}

Get Fitting by ID

GET /fittings/:id

Retrieves a single fitting by its ID.

Response:

{
"_id": "60d5ec49f1b2c72d88f8e8b5",
"name": "Screw",
"price": "5"
}

Get multiple Fittings by IDs

GET /fittings/bulk

Retrieves multiple fittings by their IDs.

Query Parameters:

  • ids - Comma-separated list of fitting IDs.

Get Fitting by Kod

GET /fittings/getByKod/:kode

Retrieves a fitting by its unique kod (code).

Response:

{
"_id": "60d5ec49f1b2c72d88f8e8b5",
"name": "Screw",
"price": "5",
"kod": "SCREW123"
}

Create Fitting

POST /fittings

Create a new fitting.

Fitting Model

Request Body:

{
"name": "Screw",
"price": "5",
"status": "1",
"id": "12345",
"UID": "UID123",
"kod": "SCREW123",
"grupa": "Creatix",
"akcesoria": "false",
"producent": "default",
"kategoria": "default",
"podkategoria": "default",
"kod_producenta": "PROD123",
"kod_dostawcy": "SUPP123",
"minX": "0",
"minY": "0",
"minZ": "0",
"maxX": "0",
"maxY": "0",
"maxZ": "0",
// Fitting dimensions
"wymiary": { "x": "5", "y": "5", "z": "5" },
// Packaging dimensions
"wymiary_opakowania": { "x": "10", "y": "10", "z": "10" },
// Weight of the fitting
"waga": "0.5",
"description": "A high-quality screw",
"parametry": "parameters",
"stock": 100,
"stock_limits": { "small": 10, "medium": 50 },
"connected": [],
"replacement": [],
// 3D model
"mdrl": {
"x": "7.37",
"y": "0",
"z": "12.91",
"scale": "10"
},
"direction_vector": {
"x": "0",
"y": "1",
"z": "0"
}
}

Response

{
"_id": "60d5ec49f1b2c72d88f8e8b5",
"name": "Screw",
"price": "5"
}

Update Fitting

PATCH /fittings/:id

Updates an existing fitting by its ID.

Request Body:

{
"name": "Updated Screw",
"price": 10,
"newImagePath": "path/to/new/image",
"imageOperation": "replace",
"oldImagePath": "path/to/old/image",
"newModelPath": "path/to/new/model",
"modelOperation": "replace",
"oldModelPath": "path/to/old/model"
}

Upload Fitting Image

POST /fittings/upload_image

Uploads one or more images for a fitting.

Request:

  • Files: image (array of files).

Response

{
"message": "Images uploaded successfully!",
"files": [
{
"fieldname": "image",
"originalname": "screw.jpg",
"encoding": "7bit",
"mimetype": "image/jpeg",
"destination": "uploads/fittings",
"filename": "screw.jpg",
"path": "relative/path/to/screw.jpg",
"size": 12345
}
]
}

Delete Fitting

DELETE /fittings/:id

Deletes a fitting by its ID.

Response

{
"message": "Deleted Fitting"
}

Error Responses

400 Bad Request

{
"message": "Validation error message"
}

401 Unauthorized

{
"message": "Unauthorized"
}

404 Not Found

{
"message": "Fitting not found"
}

500 Internal Server Error

{
"message": Error message"
}