Meal Plan - MealsMadeEasy/Backend GitHub Wiki

/user/plan

This endpoint contains the user's meal plan. There are two representations of a meal plan, a MealPlan and a SparseMealPlan. These two models are structured in the same way, but a MealPlan contains full details for the meals in the meal plan where a SparseMealPlan only contains the IDs for meals in the meal plan:

class MealPlan {
    meals: List<MealPlanEntry>
}

class MealPlanEntry {
    date: Long, // A timestamp in milliseconds since January 1, 1970 (UTC). The time that this value represents will always be midnight.
    mealPeriod: String, // one of either "BREAKFAST", "LUNCH", or "DINNER"
    meals: List<MealPortion>
}

class MealPortion {
    servings: Int,
    meal: Meal // See the /meals/ endpoint for more details on this model
}
class SparseMealPlan {
    meals: List<SparseMealPlanEntry>
}

class SparseMealPlanEntry {
    date: Long, // A timestamp in milliseconds since January 1, 1970 (UTC). The time that this value represents will always be midnight.
    mealPeriod: String, // one of either "BREAKFAST", "LUNCH", or "DINNER"
    meals: List<SparseMealPortion>
}

class SparseMealPortion {
    servings: Int,
    mealId: String
}

Read (GET)

Requires Authentication

To get the user's current meal plan, use the GET verb on the /user/plan endpoint. If this operation is successful, you'll receive a MealPlan in JSON format. Note that this endpoint will not include meal plan entries for days in the past. If the user hasn't created a meal plan or doesn't have any future meals in their meal plan, this endpoint will return an empty MealPlan. This endpoint will never return null.

Write (POST)

Requires Authentication

To set the user's current meal plan, use the POST verb on the /user/plan endpoint. The body of this request must contain a valid, non-null SparseMealPlan object in JSON format with all fields. Any meals that are scheduled for days in the past will be ignored. If the operation is successful, the endpoint will return the message Ok with a 200 OK HTTP response code. If any meal plan entry has a time that is not midnight in UTC, this endpoint will return a 400 BAD REQUEST response code.