Skip to content

Instantly share code, notes, and snippets.

@JoseAlba
Created July 21, 2019 00:32
Show Gist options
  • Save JoseAlba/24a055fdb927eb63769509832ad0a5fc to your computer and use it in GitHub Desktop.
Save JoseAlba/24a055fdb927eb63769509832ad0a5fc to your computer and use it in GitHub Desktop.
var pizzaApi = require('dominos');
var util = require('util');
// ID 10532, represents a Dominos store in the Kitchener/Waterloo area.
// You have to find the store ID close to you.
var myStore = new pizzaApi.Store(
{
ID: 10532,
}
);
// Print the Menu from that exact Store.
myStore.getFriendlyNames(
function(result) {
console.log(['Get Friendly Names']);
console.log(result);
}
);
// An example of a working example "1234 White House Road, Ottawa, ON, N9B 5T6".
var jsonAddress = new pizzaApi.Address('1234 White House Road, Ottawa, ON, N9B 5T6');
// A working example of a customer object.
var customer = new pizzaApi.Customer(
{
firstName: 'Bob',
lastName: 'Lossed',
address: jsonAddress,
email: 'boblossed@hotmail.com',
phone: '4164856532'
}
);
var order = new pizzaApi.Order(
{
customer: customer,
storeID: myStore.ID,
deliveryMethod: 'Delivery',
}
);
order.StoreID = myStore.ID;
order.addItem(
new pizzaApi.Item(
{
code: '12SCDELUX',
options: [],
quantity: 1,
}
)
);
// Coupon code is highly recommended when ordering Dominos.
order.addCoupon(new pizzaApi.Coupon({code:'8700', quantity:1}));
order.StoreOrderID = order.StoreID;
order.validate(
function(result) {
console.log('One 10 inch Pizza is on delivery');
console.log(util.inspect(result, false, null, true));
}
)
order.price(
function(result){
console.log('Price');
console.log(util.inspect(result, false, null, true));
}
);
// This command completes the request. Enjoy the pizza!
order.place(
function(result){
console.log('Order placed!');
console.log(util.inspect(result, false, null, true));
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment