What about something like this (in JS)?
// Option 1
const Pizzas = {
Hawaiian: {
type: 'hawaiian',
crust: 'thin',
sauce: 'tomato',
cheese: 'regular',
toppings: ['ham', 'pineapple'],
},
Pepperoni: {
type: 'pepperoni',
crust: 'thin',
sauce: 'tomato',
cheese: 'regular',
toppings: ['pepperoni'],
},
};
// Option 2
// Pizzas could be returned from an API, so that the pizza
types are configurable outside of the code
const response = [
{
type: 'hawaiian',
crust: 'thin',
sauce: 'tomato',
cheese: 'regular',
toppings: ['ham', 'pineapple'],
},
{
type: 'pepperoni',
crust: 'thin',
sauce: 'tomato',
cheese: 'regular',
toppings: ['pepperoni'],
},
];
const makePizza = (pizza) => requests.post(PIZZA_URL, pizza);
// Then, for Option 1
makePizza(Pizzas.Hawaiian);
makePizza(Pizzas.Pepperoni);
// Or, for Option 2 (e.g. user selected via a menu)
makePizza(selectedPizza);