Skip to content

Instantly share code, notes, and snippets.

@mreid1130
Last active May 14, 2019 16:21
Show Gist options
  • Save mreid1130/1a1bb76c6911e4fd30cb2ff57811898b to your computer and use it in GitHub Desktop.
Save mreid1130/1a1bb76c6911e4fd30cb2ff57811898b to your computer and use it in GitHub Desktop.
updated meal APIs (2019-05-14)

Generate/plan meal preview for new, uncreated order

POST /api/orders/order/plan-meal/new/

For planning a meal on an order that does not exist. This does not create the order, simply outputs the data of what the order would look like given an event, meal, and delivery date.

Request Payload:

{
    "event_id": 9362,
    "meal_id": 2,
    "delivery_datetime": "2019-05-16 17:00:00+00:00"
}

Response:

{
    "id": 0,
    "delivery_datetime": "2019-05-16 17:00:00+00:00",
    "dietary_restrictions": [
        {
            "id": 1,
            "count": 11
        },
        {
            "id": 2,
            "count": 2
        },
        {
            "id": 3,
            "count": 0
        },
        {
            "id": 4,
            "count": 2
        },
        {
            "id": 5,
            "count": 0
        },
        {
            "id": 6,
            "count": 0
        }
    ],
    "guests": 66,
    "items": [
        {
            "id": 0,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 17,
            "key": "17-1-1",
            "meal_component_id": 1,
            "name": "Beef Gyros.",
            "portion_amount": 5.5,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 1,
            "quantity": 27,
            "total_amount": 148,
            "vendor_cost": 3,
            "dietary_restriction_groups": [
                6,
                4
            ]
        },
        {
            "id": 0,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 18,
            "key": "18-1-2",
            "meal_component_id": 1,
            "name": "Chicken Kebob",
            "portion_amount": 5.5,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 2,
            "quantity": 27,
            "total_amount": 148,
            "vendor_cost": 3,
            "dietary_restriction_groups": [
                6,
                4
            ]
        },
        {
            "id": 0,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 20,
            "key": "20-1-3",
            "meal_component_id": 1,
            "name": "Falafels",
            "portion_amount": 2,
            "portion_unit": {
                "id": 4,
                "name": "pc."
            },
            "priority": 3,
            "quantity": 13,
            "total_amount": 26,
            "vendor_cost": 1.5,
            "dietary_restriction_groups": [
                1,
                2
            ]
        },
        {
            "id": 0,
            "client_price": 0,
            "included_item_ids": [
                5,
                4
            ],
            "is_included_item": false,
            "item_id": 2,
            "key": "2-2-1",
            "meal_component_id": 2,
            "name": "Greek Salad",
            "portion_amount": 3.5,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 1,
            "quantity": 66,
            "total_amount": 231,
            "vendor_cost": 1.5,
            "dietary_restriction_groups": [
                6,
                1,
                2,
                4
            ]
        },
        {
            "id": 0,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 6,
            "key": "6-2-2",
            "meal_component_id": 2,
            "name": "Pita bread",
            "portion_amount": 0.5,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 2,
            "quantity": 64,
            "total_amount": 32,
            "vendor_cost": 0.53,
            "dietary_restriction_groups": [
                6,
                1,
                2
            ]
        },
        {
            "id": 0,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 7,
            "key": "7-2-3",
            "meal_component_id": 2,
            "name": "Side Falafels",
            "portion_amount": 1,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 3,
            "quantity": 66,
            "total_amount": 66,
            "vendor_cost": 0.53,
            "dietary_restriction_groups": [
                6,
                1,
                2,
                4
            ]
        },
        {
            "id": 0,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 10,
            "key": "10-2-4",
            "meal_component_id": 2,
            "name": "Babaganoush",
            "portion_amount": 3,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 4,
            "quantity": 66,
            "total_amount": 198,
            "vendor_cost": 1.25,
            "dietary_restriction_groups": [
                6,
                1,
                2,
                4
            ]
        },
        {
            "id": 0,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 1,
            "key": "1-3-1",
            "meal_component_id": 3,
            "name": "Hummus",
            "portion_amount": 0.5,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 1,
            "quantity": 66,
            "total_amount": 33,
            "vendor_cost": 0.53,
            "dietary_restriction_groups": [
                6,
                1,
                2,
                4
            ]
        },
        {
            "id": 0,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 3,
            "key": "3-3-2",
            "meal_component_id": 3,
            "name": "Chili Sauce",
            "portion_amount": 0.5,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 2,
            "quantity": 66,
            "total_amount": 33,
            "vendor_cost": 0.53,
            "dietary_restriction_groups": [
                6,
                1,
                2,
                4
            ]
        },
        {
            "id": 0,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": true,
            "item_id": 4,
            "key": "4-2-5",
            "meal_component_id": 2,
            "name": "Balsamic Vinaigrette",
            "portion_amount": 1,
            "portion_unit": {
                "id": 1,
                "name": "oz. (volume)"
            },
            "priority": 5,
            "quantity": 66,
            "total_amount": 66,
            "vendor_cost": 0,
            "dietary_restriction_groups": [
                6,
                1,
                2,
                4
            ]
        },
        {
            "id": 0,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": true,
            "item_id": 5,
            "key": "5-2-6",
            "meal_component_id": 2,
            "name": "Feta Cheese",
            "portion_amount": 1,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 6,
            "quantity": 66,
            "total_amount": 66,
            "vendor_cost": 0,
            "dietary_restriction_groups": [
                6,
                1,
                2,
                4
            ]
        }
    ],
    "meal": {
        "id": 2,
        "name": "Mediterranean Meal (Variety)",
        "package": "VARIETY"
    },
    "menu": {
        "id": 2,
        "name": "Mediterranean Lunch Menu"
    },
    "notes": "",
    "organization": {
        "id": 7724,
        "name": "Chewse HQ",
        "ops_notes": ""
    },
    "schedule_ruleset": {
        "id": 9362,
        "name": "Lunch Time",
        "ops_notes": ""
    },
    "vendor": {
        "id": 743,
        "name": "ACME TEST ACCOUNT"
    }
}

Generate/plan meal preview for an existing order.

PUT/PATCH /api/orders/order/plan-meal/253548/

Previously was/moved from PUT/PATCH /api/orders/order/253548/generate-preview/

Payload and response will be identical to the old endpoint.

Retrieve an existing order.

GET /api/orders/order/plan-meal/253548/

Previously was/moved from GET /api/orders/order/meal-detail/253548/

Payload and response will be identical to the old endpoint.

Place (save) a new or existing order.

POST /api/orders/order/place/ (save new)

PUT/PATCH /api/orders/order/place/253548 (update)

Previously was/moved from PUT/PATCH /api/orders/order/meal-detail/253548.

Example payload to create a NEW order

{
    "id": 0,
    "delivery_datetime": "2019-05-29 19:00:00+00:00",
    "dietary_restrictions": [
        {
            "id": 1,
            "count": 100
        },
        {
            "id": 2,
            "count": 5
        },
        {
            "id": 3,
            "count": 5
        },
        {
            "id": 4,
            "count": 0
        },
        {
            "id": 5,
            "count": 0
        }
    ],
    "guests": 55,
    "items": [
        {
            "id": 12,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 17,
            "key": "17-1-1",
            "meal_component_id": 1,
            "name": "Beef Gyros.",
            "portion_amount": 5.5,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 1,
            "quantity": 18,
            "total_amount": 99,
            "vendor_cost": 3,
            "dietary_restriction_groups": [
                6,
                4,
                5
            ]
        },
        {
            "id": 13,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 18,
            "key": "18-1-2",
            "meal_component_id": 1,
            "name": "Chicken Kebob",
            "portion_amount": 5.5,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 2,
            "quantity": 18,
            "total_amount": 99,
            "vendor_cost": 3,
            "dietary_restriction_groups": [
                6,
                4,
                5
            ]
        },
        {
            "id": 14,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 20,
            "key": "20-1-3",
            "meal_component_id": 1,
            "name": "Falafels",
            "portion_amount": 2,
            "portion_unit": {
                "id": 4,
                "name": "pc."
            },
            "priority": 3,
            "quantity": 20,
            "total_amount": 40,
            "vendor_cost": 1.5,
            "dietary_restriction_groups": [
                1,
                2,
                3
            ]
        },
        {
            "id": 15,
            "client_price": 0,
            "included_item_ids": [
                5,
                4
            ],
            "is_included_item": false,
            "item_id": 2,
            "key": "2-2-1",
            "meal_component_id": 2,
            "name": "Greek Salad",
            "portion_amount": 3.5,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 1,
            "quantity": 55,
            "total_amount": 192,
            "vendor_cost": 1.5,
            "dietary_restriction_groups": [
                6,
                1,
                2,
                3,
                4,
                5
            ]
        },
        {
            "id": 16,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 6,
            "key": "6-2-2",
            "meal_component_id": 2,
            "name": "Pita bread",
            "portion_amount": 0.5,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 2,
            "quantity": 50,
            "total_amount": 25,
            "vendor_cost": 0.53,
            "dietary_restriction_groups": [
                6,
                1,
                2,
                5
            ]
        },
        {
            "id": 17,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 7,
            "key": "7-2-3",
            "meal_component_id": 2,
            "name": "Side Falafels",
            "portion_amount": 1,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 3,
            "quantity": 55,
            "total_amount": 55,
            "vendor_cost": 0.53,
            "dietary_restriction_groups": [
                6,
                1,
                2,
                3,
                4,
                5
            ]
        },
        {
            "id": 18,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 10,
            "key": "10-2-4",
            "meal_component_id": 2,
            "name": "Babaganoush",
            "portion_amount": 3,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 4,
            "quantity": 55,
            "total_amount": 165,
            "vendor_cost": 1.25,
            "dietary_restriction_groups": [
                6,
                1,
                2,
                3,
                4,
                5
            ]
        },
        {
            "id": 19,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 1,
            "key": "1-3-1",
            "meal_component_id": 3,
            "name": "Hummus",
            "portion_amount": 0.5,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 1,
            "quantity": 55,
            "total_amount": 27,
            "vendor_cost": 0.53,
            "dietary_restriction_groups": [
                6,
                1,
                2,
                3,
                4,
                5
            ]
        },
        {
            "id": 20,
            "client_price": 0,
            "included_item_ids": [],
            "is_included_item": false,
            "item_id": 3,
            "key": "3-3-2",
            "meal_component_id": 3,
            "name": "Chili Sauce",
            "portion_amount": 0.5,
            "portion_unit": {
                "id": 8,
                "name": "oz. (weight)"
            },
            "priority": 2,
            "quantity": 55,
            "total_amount": 27,
            "vendor_cost": 0.53,
            "dietary_restriction_groups": [
                6,
                1,
                2,
                3,
                4,
                5
            ]
        }
    ],
    "meal": {
        "id": 2,
        "name": "Mediterranean Meal (Variety)",
        "package": "VARIETY"
    },
    "menu": {
        "id": 2,
        "name": "Mediterranean Lunch Menu"
    },
    "notes": "test\n\nA place for people to practice building orders",
    "organization": {
        "id": 7334,
        "name": "Chewse Practice Space",
        "ops_notes": "A place for people to practice building orders"
    },
    "schedule_ruleset": {
        "id": 9099,
        "name": "Ad Hoc Lunch",
        "ops_notes": "test"
    },
    "vendor": {
        "id": 743,
        "name": "ACME TEST ACCOUNT"
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment