Add Product - MarcoLagalla/marette_backend GitHub Wiki
Name | Add Product |
---|---|
Description | List all products for the restaurant |
URL | api/v1/webapp/restaurant/<int:id> /products/add |
Allowed methods | POST |
Authorizations | IsAuthenticated, IsBusiness, IsOwner |
Allows the owner of the restaurant to add a Product to the available products. The users that make the request must have the authorization token associated with the owner of the activity.
Field | Type | Required | Unique | Comments |
---|---|---|---|---|
name |
string | yes | no | |
description |
string | yes | no | |
image |
File | no | no | If null returns a placeholder based on Category |
category |
string | yes | no | FOOD_CATEGORY_CHOICES |
price |
decimal | yes | no | |
iva |
integer | yes | no | Range [0-100]%, default=22% |
tags |
list | no | no | List of ProductTag id |
discounts |
list | no | no | List of ProductDiscount id |
show_image |
bool | no | no | default=True |
available |
bool | no | no | default=True |
The backend look for MultiPartParser
, FormParser
, FileUploadParser
because of the different type of input data, so it must be setted an Header:
"Content-Type": "multipart/form-data;"
N.B. The request has to be stacked in two-level, to handle the presence of the image file.
{
"image": <FormData File>,
"data": {
"name": "Semplice col cotto",
"description": "Panino semplice ma buono",
"category": "Panini e Piadine",
"price": "5",
"iva": 22,
"tags": [1,2], <-- These IDs must be retrieved with a Call To ProductTagsList
"discounts" : [3] <-- These IDs must be retrieved with a Call To ProductDiscountsList
}
}
Status | Description |
---|---|
HTTP_201_CREATED |
Product added |
HTTP_404_NOT_FOUND |
Restaurant/Token not found |
HTTP_401_UNAUTHORIZED |
Wrong Token for this restaruant |
HTTP_400_BAD_REQUEST |
Error in parameters |