Replace one dish with another everywhere, then delete it
meals.dish.merge
POST/api/v1/households/{household_id}/commands/meals.dish.merge
- Command
- Rigel runs it
- Applies offline
Every meal that has dish_id gets into_dish_id instead, in the same place (a meal that already has both just loses dish_id). into_dish_id keeps its own recipe; if it has none and dish_id has one, it takes that recipe and its own ingredients are deleted (a dish with a recipe has none). Otherwise, if into_dish_id has no recipe and no ingredients yet, it takes dish_id's ingredients. Then dish_id is deleted. Use this to clean up duplicates such as "taco" and "tacos".
Parameters#
| Field | Description |
|---|---|
household_idpathstringrequired | The household's ID. |
Idempotency-Keyheaderstringoptional | The command's ID. Reuse it when retrying the same command. |
Request body#
JSON, as application/json.
| Field | Description |
|---|---|
dish_idstringrequired | The dish to replace and delete. |
into_dish_idstringrequired | The dish that takes its place. |
Response#
200 The command was applied.
| Field | Description |
|---|---|
resultobjectrequired | What the command returned, such as the IDs it created. |
result.meals_changedintegerrequired | How many meals had the replaced dish. |
versionintegerrequired | The household version after the command. |
Errors#
Every error has the same envelope: error.code, error.message, error.details, error.recovery and error.request_id.
| Status | Code | When |
|---|---|---|
400 | validation_failed | A field is missing, misspelled or out of range. details.fields lists each problem. |
401 | unauthenticated | The request has no valid session. |
404 | dish_not_found |
|
404 | not_found | The household doesn't exist, or you aren't a member of it. |
409 | idempotency_key_reused | The Idempotency-Key was already used for a different command. |
Examples#
These are real. Each scenario is one of the command's test cases, run on a household when this site was built, and the response is what the API returned.
Meals with the dish get the other one in the same place; the dish and its combo icons go
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
dish_id: "dsh_01JC000000000000000000000A",
into_dish_id: "dsh_01JC000000000000000000000D",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0NQ5MWQX6YAXDGH19
{
"result": {
"meals_changed": 2
},
"version": 1
}A meal that already has both just loses the merged dish
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
dish_id: "dsh_01JC000000000000000000000A",
into_dish_id: "dsh_01JC000000000000000000000D",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R026DP93XVN1BD32HT
{
"result": {
"meals_changed": 1
},
"version": 1
}Ingredients move to a dish that has none
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
dish_id: "dsh_01JC000000000000000000000A",
into_dish_id: "dsh_01JC000000000000000000000D",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0G2GDCNFKHGWS21G5
{
"result": {
"meals_changed": 0
},
"version": 1
}A dish that already has ingredients keeps them, and the merged dish's go with it
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
dish_id: "dsh_01JC000000000000000000000A",
into_dish_id: "dsh_01JC000000000000000000000D",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0BANN9HWAWSDCW27H
{
"result": {
"meals_changed": 0
},
"version": 1
}The kept dish keeps its own recipe and does not take the merged dish's ingredients
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
dish_id: "dsh_01JC000000000000000000000A",
into_dish_id: "dsh_01JC000000000000000000000D",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0PSJG2D0CDBCTDAR1
{
"result": {
"meals_changed": 0
},
"version": 1
}A kept dish with no recipe takes the merged dish's recipe, and its own ingredients go
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
dish_id: "dsh_01JC000000000000000000000A",
into_dish_id: "dsh_01JC000000000000000000000D",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0A3XYCR3RX8M5NF0M
{
"result": {
"meals_changed": 0
},
"version": 1
}Two different recipes: the kept dish's recipe wins
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
dish_id: "dsh_01JC000000000000000000000A",
into_dish_id: "dsh_01JC000000000000000000000D",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0A06JBAA4MNSGKEWX
{
"result": {
"meals_changed": 0
},
"version": 1
}The dish to merge is missing
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
dish_id: "dsh_01JC000000000000000000000A",
into_dish_id: "dsh_01JC000000000000000000000D",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R02R6J8GGN6CZ5KAX8
{
"error": {
"code": "dish_not_found",
"message": "The dish to merge isn't there any more. No changes were applied.",
"details": {
"dish_id": "dsh_01JC000000000000000000000A",
"which": "dish_id"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R02R6J8GGN6CZ5KAX8"
}
}The dish to merge into is missing
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
dish_id: "dsh_01JC000000000000000000000A",
into_dish_id: "dsh_01JC000000000000000000000D",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/meals.dish.merge HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"dish_id": "dsh_01JC000000000000000000000A",
"into_dish_id": "dsh_01JC000000000000000000000D"
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0KEEQ9F4QMZJRVAA8
{
"error": {
"code": "dish_not_found",
"message": "The dish to merge into isn't there any more. No changes were applied.",
"details": {
"dish_id": "dsh_01JC000000000000000000000D",
"which": "into_dish_id"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0KEEQ9F4QMZJRVAA8"
}
}Combine two dishes that are the same
Every meal that had the first dish gets the second, then the first is deleted.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/meals.dish.merge' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CSFM0YR51AFD4K2E48H4' \
-d '{
"dish_id": "dsh_01M6V9CSF86119KTCG5SQ9QS9G",
"into_dish_id": "dsh_01M6V9CSF42115AECDV14HYQ9G"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/meals.dish.merge", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CSFM0YR51AFD4K2E48H4",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
dish_id: "dsh_01M6V9CSF86119KTCG5SQ9QS9G",
into_dish_id: "dsh_01M6V9CSF42115AECDV14HYQ9G",
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/meals.dish.merge HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CSFM0YR51AFD4K2E48H4
{
"dish_id": "dsh_01M6V9CSF86119KTCG5SQ9QS9G",
"into_dish_id": "dsh_01M6V9CSF42115AECDV14HYQ9G"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CSFNY16WB90KP85912A5
{
"result": {
"meals_changed": 0
},
"version": 75
}For Rigel#
Rigel's tool for this command is meals_dish_merge. Rigel runs this on its own, then says what it did. The agent guide has the rest.