Grocery List - MealsMadeEasy/Backend GitHub Wiki
This endpoint contains and manages the collection of ingredients that the user's meal plan calls for. The contents of a user's meal plan are managed internally – whenever a meal is added to the user's meal plan, it will appear in his or her grocery list. It is not possible for clients to manually add or remove ingredients from the grocery list. This endpoint contains a GroceryList object:
class GroceryList(
items: List<GroceryListEntry>
)
GroceryLists contain GroceryListEntries:
class GroceryListEntry(
ingredient: Ingredient,
purchased: Boolean,
dependants: List<String> // The names of every meal in the user's meal plan that calls for the ingredient
)
A GroceryList stores information about the required item in an Ingredient object:
class Ingredient(
quantity: Float, // A user-presentable quantity for this ingredient
unit: String, // A user-presentable unit name for this ingredient
name: String // A user-presentable name for this ingredient
)
Note that if an ingredient is partially purchased (e.g. a user marks an ingredient as purchased and later adds another meal to their meal plan that calls for the same ingredient), it will have two separate entries in the GroceryList: one for the purchased quantity, and one for the unpurchased quantity.
Requires Authentication
To get the user's current current grocery list, use the GET
verb on the /user/groceries
endpoint. If the operation is successful, you'll receive a GrocerryList object in JSON format. Note that ingredients will only show up on this list if they are a component in a meal that the user has scheduled at any point in the future on their meal plan. If no such meals exist, then the GroceryList object returned will contain an empty list.
To mark groceries as purchased (or unpurchased), use the /user/groceries/purchased
endpoint.
Requires Authentication
To mark an ingredient as purchased, use the PUT
verb on /user/groceries/purchased
endpoint, with the ingredient argument sent in the body of the request as an Ingredient
object in JSON format. The server will then mark the entire ingredient as purchased, regardless of the quantity field in the specified object. If the request is successful, a 200 OK
response will be returned with the body Ok
.
Requires Authentication
Using the DELETE verb on /user/groceries/purchased
marks an ingredient as not purchased for a user's meal plan. It otherwise behaves exactly the same as PUT on this endpoint.