Comparing version 0.0.4 to 0.0.7
var request = require('request'); | ||
var parser = require('xml2json'); | ||
var apiURL="https://trkweb.dominos.com/orderstorage/GetTrackerData?" | ||
var api={}; | ||
api.track="https://trkweb.dominos.com/orderstorage/GetTrackerData?" | ||
api.store={}; | ||
api.store.find='https://order.dominos.com/power/store-locator?s=${address}&type=${type}'; | ||
api.store.info='https://order.dominos.com/power/store/${storeID}/profile'; | ||
api.store.menu='https://order.dominos.com/power/store/${storeID}/menu?lang=${lang}&structured=true'; | ||
api.order={}; | ||
api.order.validate='https://order.dominos.com/power/validate-order'; | ||
api.order.price='https://order.dominos.com/power/price-order'; | ||
function findStores(address, callback, type) { | ||
if( !address || !callback){ | ||
if(callback) | ||
callback( | ||
APIError("At least a partial address ( minimum accepted is zipcode ), and callback are required to find stores") | ||
); | ||
return; | ||
} | ||
if(!type) | ||
type='all'; | ||
requestJSONAPI( | ||
api.store.find.replace( | ||
'${address}', | ||
encodeURI(address) | ||
).replace( | ||
'${type}', | ||
type | ||
), | ||
callback | ||
); | ||
} | ||
function getStoreInfo(storeID, callback) { | ||
if( !storeID || !callback){ | ||
if(callback) | ||
callback( | ||
APIError("A storeID, and callback are required to get store info") | ||
); | ||
return; | ||
} | ||
requestJSONAPI( | ||
api.store.info.replace( | ||
'${storeID}', | ||
storeID | ||
), | ||
callback | ||
); | ||
} | ||
function getStoreMenu(storeID, callback, lang) { | ||
if( !storeID || !callback){ | ||
if(callback) | ||
callback( | ||
APIError("A storeID, and callback are required to get a store menu") | ||
); | ||
return; | ||
} | ||
if(!lang) | ||
lang='en'; | ||
requestJSONAPI( | ||
api.store.info.replace( | ||
'${storeID}', | ||
storeID | ||
).replace( | ||
'${lang}', | ||
lang | ||
), | ||
callback | ||
); | ||
} | ||
function trackPizzaByPhone(phone, callback) { | ||
@@ -9,9 +85,4 @@ if(!phone || !callback){ | ||
callback( | ||
{ | ||
success:false, | ||
error:{ | ||
message:"A phone number, and callback are required to get pizza info using a phone number" | ||
} | ||
} | ||
); | ||
APIError("A phone number, and callback are required to get pizza info using a phone number") | ||
); | ||
return; | ||
@@ -21,3 +92,3 @@ } | ||
trackPizza( | ||
apiURL+"Phone=" + phone, | ||
api.track+"Phone=" + phone, | ||
callback | ||
@@ -31,9 +102,4 @@ ); | ||
callback( | ||
{ | ||
success:false, | ||
error:{ | ||
message:"storeID, orderKey, and callback are all required to get pizza info using the orderKey" | ||
} | ||
} | ||
); | ||
APIError("storeID, orderKey, and callback are all required to get pizza info using the orderKey") | ||
); | ||
return; | ||
@@ -43,3 +109,3 @@ } | ||
trackPizza( | ||
apiURL+"StoreID="+storeID+"&OrderKey="+orderKey, | ||
api.track+"StoreID="+storeID+"&OrderKey="+orderKey, | ||
callback | ||
@@ -49,2 +115,47 @@ ); | ||
function requestJSONAPI(url,callback){ | ||
request.get( | ||
{ | ||
uri:url, | ||
headers:{ | ||
'Referer':'https://order.dominos.com/en/pages/order/' | ||
} | ||
}, | ||
function (error, response, body) { | ||
var data={ | ||
success:true | ||
}; | ||
if (error){ | ||
data.success=false; | ||
data.error=error; | ||
callback(data); | ||
return; | ||
} | ||
if (response.statusCode !== 200){ | ||
data.success=false; | ||
data.error={ | ||
message:'HTML Status Code Error', | ||
code:response.statusCode | ||
}; | ||
callback(data); | ||
return; | ||
} | ||
try{ | ||
data.result=JSON.parse(body); | ||
}catch(err){ | ||
data.success=false; | ||
data.error={ | ||
message:'Could not parse API return', | ||
err:err | ||
}; | ||
} | ||
callback(data); | ||
} | ||
); | ||
} | ||
function trackPizza(url,callback){ | ||
@@ -125,7 +236,71 @@ request.get( | ||
function Order(){ | ||
return { | ||
"Order": { | ||
"Address": { | ||
"Street": "", | ||
"City": "", | ||
"Region": "", | ||
"PostalCode": "", | ||
"Type": "", | ||
"OrganizationName": "" | ||
}, | ||
"Coupons": [], | ||
"CustomerID": "", | ||
"Email": "", | ||
"Extension": "", | ||
"FirstName": "", | ||
"LastName": "", | ||
"LanguageCode": "en", | ||
"OrderChannel": "OLO", | ||
"OrderID": "", | ||
"OrderMethod": "Web", | ||
"OrderTaker": null, | ||
"Payments": [], | ||
"Phone": "", | ||
"Products": [], | ||
"ServiceMethod": "Delivery", | ||
"SourceOrganizationURI": "order.dominos.com", | ||
"StoreID": "", | ||
"Tags": {}, | ||
"Version": "1.0", | ||
"NoCombine": true, | ||
"Partners": {} | ||
} | ||
} | ||
} | ||
function Product(){ | ||
return { | ||
"Code": false, | ||
"Qty": 1, | ||
"ID": false, | ||
"isNew": true, | ||
"Options": {} | ||
} | ||
} | ||
function APIError(message){ | ||
return { | ||
success:false, | ||
error:{ | ||
message:message | ||
} | ||
} | ||
} | ||
module.exports={ | ||
class:{ | ||
Order:Order, | ||
Product:Product | ||
}, | ||
track:{ | ||
phone:trackPizzaByPhone, | ||
orderKey:trackPizzaByID | ||
}, | ||
store:{ | ||
find:findStores, | ||
info:getStoreInfo, | ||
menu:getStoreMenu | ||
} | ||
}; |
{ | ||
"name": "dominos", | ||
"version": "0.0.4", | ||
"version": "0.0.7", | ||
"description": "API for domino's Pizza", | ||
@@ -5,0 +5,0 @@ "main": "dominos-pizza-api.js", |
node-dominos-pizza-api | ||
====================== | ||
This is a node.js wrapper for the dominos pizza apis | ||
This is a node.js wrapper for the Domino's pizza APIs | ||
Install | ||
Install Domino's API | ||
==== | ||
npm install dominos | ||
Tracking | ||
Finding Nearby Domino's Locations | ||
==== | ||
|argument|type|default|required| | ||
|--------|----|-------|--------| | ||
|address|full or partial address string|null|true| | ||
|callback|function to pass the api result to|null|true| | ||
### By Postal Code | ||
*** this yeilds the least accurate information *** | ||
dominos.store.find( | ||
'20500', | ||
function(storeData){ | ||
console.log(storeData); | ||
} | ||
); | ||
### By City and Postal Code | ||
*** this yeilds less accurate information but is better than just using the postal code *** | ||
dominos.store.find( | ||
'Beverly Hills 90210', | ||
function(storeData){ | ||
console.log(storeData); | ||
} | ||
); | ||
### Using Full or Nearly Full Address | ||
*** this yeilds the best information and sorts stores by actual distance *** | ||
dominos.store.find( | ||
'1600 Pennsylvania Ave NW, 20500', | ||
function(storeData){ | ||
console.log(storeData); | ||
} | ||
); | ||
Domino's Store Info | ||
==== | ||
|argument|type|default|required| | ||
|--------|----|-------|--------| | ||
|storeID|string or int|null|true| | ||
|callback|function to pass the api result to|null|true| | ||
//Get Store Info for Store #4336 | ||
dominos.store.info( | ||
4336, | ||
function(storeData){ | ||
console.log(storeData); | ||
} | ||
); | ||
Menu for Specific Domino's Store Location | ||
==== | ||
//Get Menu for Store #4336 | ||
dominos.store.menu( | ||
4336, | ||
function(storeData){ | ||
console.log(storeData); | ||
} | ||
); | ||
Tracking Domino's Pizza | ||
==== | ||
### By Phone | ||
|argument|type|default|required| | ||
|--------|----|-------|--------| | ||
|phone|Phone number string or int|null|true| | ||
|callback|function to pass the api result to|null|true| | ||
dominos.track.phone( | ||
2024561111, //phone number pizza is associated with | ||
function(pizzaData){ //callback to run when api returns | ||
2024561111, | ||
function(pizzaData){ | ||
console.log(pizzaData); | ||
@@ -24,8 +95,14 @@ } | ||
|argument|type|default|required| | ||
|--------|----|-------|--------| | ||
|orderKey|string or int|null|true| | ||
|storeID|sting or int|null|true| | ||
|callback|function to pass the api result to|null|true| | ||
dominos.track.orderKey( | ||
123456, //pizza orderKey | ||
12345,//store ID | ||
function(pizzaData){ //callback to run when api returns | ||
123456, | ||
12345, | ||
function(pizzaData){ | ||
console.log(pizzaData) | ||
} | ||
); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12562
6
307
107
1