Workflow is an Apple app that lets you create a series of steps or actions to run on your iPhone or iPad. You can create your own workflows to automate steps you'd normally take manually.
MealPlan has basic support for URL Schemes, a mechanism for iOS apps to call out to other iOS apps, asking them to perform operations or return data. MealPlan's URL Scheme lets you work with your meal plan, recipes, and grocery list.
This article isn't intended to be a tutorial on Workflow, URL Schemes, JSON, Dictionaries or X-Callback-URL. While this is an advanced topic, you may find the pre-built workflow links here useful without any modification, or use them as a starting point to build your own workflows.
Because the chance of a name collision was too great if I used the just the app name, the MealPlan URL scheme is falldaysoftware-mealplan://.
Sample Workflows
Here's a simple workflow that will fetch your current grocery list from MealPlan, and format it as a text message, ready to send to whoever's buying the groceries.
Get a list of Breakfast recipes in your recipe database:
The URL Scheme uses JSON dictionaries to pass data back. You can use the "View Content Graph" step in Workflow to see what data you're getting back from a request.
Supported URL Schemes
Get Grocery List
falldaysoftware-mealplan://x-callback-url/get-grocery-list
Add Grocery
falldaysoftware-mealplan://x-callback-url/add-grocery?name=Milk
Add a grocery from the grocery list.
Remove Grocery
falldaysoftware-mealplan://x-callback-url/remove-grocery?name=Milk
Remove a grocery to the grocery list.
Get Planned Meals
falldaysoftware-mealplan://x-callback-url/get-planned-meals
Get all the planned meals for the next 30 days. This is returned as JSON in this format:
{
"days": [
{
"date": "2017-04-14T12:00:00-04:00",
"meals": [
{
"items": [
"Ham Sandwiches"
],
"name": "Dinner"
}
]
},
{
"date": "2017-04-16T12:00:00-04:00",
"meals": [
{
"items": [
"Roast Beef",
"Potatoes"
],
"name": "Dinner"
}
]
}
]
}
This represents the planned meals for two days:
April 14th, where "Ham Sandwiches" were planned for "Dinner", and April 16th, where "Roast Beef" and "Potatoes" were also planned for "Dinner".
Add a Meal to your Meal Plan
falldaysoftware-mealplan://x-callback-url/plan-meal?date=Sunday&meal=Dinner&recipe=Roast+Beef
The date is interpreted by Workflow and sent to MealPlan as a date using this format: "Apr 16, 2017, 12:00 PM". This means that in Workflow you can use a string like "Sunday" for the upcoming Sunday.
The "meal" parameter must be a meal that exists in your MealPlan database. If you specify "Snacks" but you don't have a "Snacks" meal, the request will fail.
If the recipe exists, your planned meal will reference it. If it doesn't exist, a new, empty recipe will be created with this name.
Get All Recipes
falldaysoftware-mealplan://x-callback-url/get-recipes
Return a list of all the recipes in your database, as dictionaries.
Get Matching Recipes
falldaysoftware-mealplan://x-callback-url/get-recipes?name=foo
Return a list of all the recipes in your MealPlan database that contain the substring "foo".
Get Recipes in Category
falldaysoftware-mealplan://x-callback-url/get-recipes?category=foo
Return a list of all the recipes in your MealPlan database in the category "foo".
Example Recipes Response
Displayed here as JSON, this can be used in Workflow as a Dictionary. This particular response shows 3 recipes, "Bacon", "Basic Crepes Recipe" (an imported recipe from allrecipes.com), and "Waffles".
{
"recipes": [
{
"recipes": [
{
"categories": [
"Breakfast",
"Lunches"
],
"groceries": [
{
"name": "Bacon"
}
],
"name": "Bacon",
"uuid": "6B78AA81-B75E-41D3-8305-4C3D532D701A"
}
]
},
{
"recipes": [
{
"calories": "216 kcal",
"categories": [
"Breakfast"
],
"groceries": [
{
"name": "cup all-purpose flour"
},
{
"name": "cup milk"
},
{
"name": "Eggs"
},
{
"name": "cup water"
},
{
"name": "teaspoon salt"
},
{
"name": "tablespoons butter, melted"
}
],
"links": [
{
"title": "Basic Crepes Recipe - Allrecipes.com",
"url": "http://m.allrecipes.com/recipe/16383/basic-crepes/"
}
],
"name": "Basic Crepes Recipe",
"uuid": "13D94C82-42BA-4F3E-BDC2-2FC75DAC303E"
}
]
},
{
"recipes": [
{
"categories": [
"Breakfast"
],
"groceries": [
{
"name": "Frozen Waffles"
}
],
"name": "Waffles",
"uuid": "045C3D95-71D0-487A-91A9-BAC843FF3CC6"
}
]
}
]
}
Comments
0 comments
Article is closed for comments.