Product Report‐ Class UML & API Endpoints - FEUP-MEIC-DS-2025-26/madeinportugal.store GitHub Wiki
Class UML
API — Endpoints
The endpoints use Next.js App Router locations (app/api/...). Below is a short reference and example responses.
GET /api/products
Description: Returns the list of all products.
Response:
200 OK: Array of Product objects.
POST /api/reports/add
Description: Creates a report for a product.
Body: JSON with: { reasons: string[], additionalInfo?: string, productId: number, userId?: number }
Response:
200 OK: { success: true, report: Report }
400 Bad Request: If reasons or productId is missing.
500 Internal Server Error: Unexpected server error.
Common errors
400 Bad Request: Invalid input.
500 Internal Server Error: Server error.
Example objects
Example Product Object
{
"id": 1,
"external_id": 12345,
"product_name": "Portuguese Extra Virgin Olive Oil",
"description": "Organic extra virgin olive oil produced using traditional methods in Portugal.",
"price": 12.99,
"discount": 0,
"stock": 50,
"stock_unlimited": false,
"sku": "AZ-PT-001",
"brand": "Oliveira",
"status": "available",
"permalink": "https://example.com/products/1",
"image_url": "https://example.com/images/olive_oil.jpg"
}
Example Report Object
{
"id": 10,
"type": "Incorrect information, Missing image",
"description": "The product has outdated information and the image is missing.",
"user_id": 2,
"product_id": 1
}