-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
44 lines (38 loc) · 1.35 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var pizzapi = require('dominos');
// var food = 'pasta';
// var menuObj;
//
// var address = '1412 Market St., San Francisco, CA';
// var deliveryMethod = 'Delivery';
function findNearby(address) {
var menuNearest = new Promise(function(resolve, reject) {
pizzapi.Util.findNearbyStores(
address, // this is super dang picky!
'Delivery',
function(storeData){
var storeID = storeData.result.Stores[0];
var myStore = new pizzapi.Store({ID: storeID}); // note: this could all be wrong
myStore.ID = storeData.result.Stores[0].StoreID;
myStore.getMenu(
function(storeData){
menuObj = getMenuObj(storeData);
resolve(menuObj)
}
)
}
);
var getMenuObj = function(storeData){
var menuObj = {};
for(var item in storeData.menuByCode){
if(isNaN(parseInt(storeData.menuByCode[item].menuData.Code)) && storeData.menuByCode[item].menuData.ProductType){
menuObj[storeData.menuByCode[item].menuData.Name]=storeData.menuByCode[item].menuData;
}
}
return menuObj
}
})
return menuNearest
}
module.exports = {
findNearby: findNearby
}