Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dominos

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dominos - npm Package Compare versions

Comparing version 0.0.8 to 0.1.1

example/order-dominos-pizza.js

134

dominos-pizza-api.js

@@ -14,3 +14,52 @@ var request = require('request');

api.order.price='https://order.dominos.com/power/price-order';
api.order.place='https://order.dominos.com/power/place-order';
function validateOrder(order, callback) {
if( !order || !callback){
if(callback)
callback(
APIError("An order object, and callback are required to validate the order")
);
return;
}
postJSONAPI(
api.order.validate,
order,
callback
);
}
function priceOrder(order, callback) {
if( !order || !callback){
if(callback)
callback(
APIError("An order object, and callback are required to price an order")
);
return;
}
postJSONAPI(
api.order.price,
order,
callback
);
}
function placeOrder(order, callback) {
if( !order || !callback){
if(callback)
callback(
APIError("An order object, and callback are required to place an order")
);
return;
}
postJSONAPI(
api.order.place,
order,
callback
);
}
function findStores(address, callback, type) {

@@ -71,3 +120,3 @@ if( !address || !callback){

requestJSONAPI(
api.store.info.replace(
api.store.menu.replace(
'${storeID}',

@@ -113,2 +162,52 @@ storeID

function postJSONAPI(url,order,callback){
if(typeof order!= "string")
order=JSON.stringify(order);
request.post(
{
uri:url,
headers:{
Referer:'https://order.dominos.com/en/pages/order/',
"Content-Type": 'application/json'
},
body: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 requestJSONAPI(url,callback){

@@ -242,4 +341,3 @@ request.get(

"PostalCode": "",
"Type": "",
"OrganizationName": ""
"Type": "House" //House or Business
},

@@ -266,3 +364,5 @@ "Coupons": [],

"NoCombine": true,
"Partners": {}
"Partners": {},
"NewUser": true,
"metaData": {}
}

@@ -274,5 +374,5 @@ }

return {
"Code": false,
"Qty": 1,
"ID": false,
"Code": "", //get from store menu
"Qty": 1, //default value
"ID": false, //will be populated during validate
"isNew": true,

@@ -283,2 +383,14 @@ "Options": {}

function Payment(){
return {
"Type": "CreditCard",
"Amount": 0,
"Number": "",
"CardType": "",//uppercase
"Expiration": "",//digits only
"SecurityCode": "",
"PostalCode": ""
}
}
function APIError(message){

@@ -296,3 +408,4 @@ return {

Order:Order,
Product:Product
Product:Product,
Payment:Payment
},

@@ -307,3 +420,8 @@ track:{

menu:getStoreMenu
},
order:{
validate:validateOrder,
price:priceOrder,
place:placeOrder
}
};

2

package.json
{
"name": "dominos",
"version": "0.0.8",
"version": "0.1.1",
"description": "API for domino's Pizza",

@@ -5,0 +5,0 @@ "main": "dominos-pizza-api.js",

@@ -1,4 +0,3 @@

node-dominos-pizza-api
======================
Node Domino's API
====
This is a node.js wrapper for the Domino's pizza APIs

@@ -20,3 +19,3 @@

### By Postal Code
*** this yeilds the least accurate information ***
***this yields the least accurate information***

@@ -31,3 +30,3 @@ dominos.store.find(

### By City and Postal Code
*** this yeilds less accurate information but is better than just using the postal code ***
***this yields less accurate information but is better than just using the postal code***

@@ -42,3 +41,3 @@ dominos.store.find(

### Using Full or Nearly Full Address
*** this yeilds the best information and sorts stores by actual distance ***
***this yields the best information and sorts stores by actual distance***

@@ -117,2 +116,101 @@ dominos.store.find(

}
);
);
Domino's Pizza Orders
====
Three classes exist to get orders started,
|Class|Description|
|-----|-----------|
|dominos.class.Order|creates a basic order object|
|dominos.class.Product|creates a basic product with a quantity of 1|
|dominos.class.Payment|creates a basic credit card payment object|
### creating an order
var order=new dominos.class.Order();
order.Order.Phone='2024561111';
order.Order.FirstName='Barack';
order.Order.LastName='Obama';
order.Order.Email='CommanderInChief@whitehouse.gov';
### creating a product and adding it to the order :
var product=new dominos.class.Product();
product.Code='14SCREEN' //14" Hand Tossed Cheese Pizza
order.Order.Products.push(product);
### Validating an Order
This step is ***Strongly** recommended
dominos.order.validate(
order,
function(data){
console.log(data);
}
);
### Validating an Order
This step is ***Strongly** recommended
dominos.order.validate(
order,
function(data){
console.log(data);
}
);
### Price an Order
dominos.order.price(
order,
function(data){
console.log(data);
}
);
### Place an Order
Before you can place an order you must create a payment method and add it to the order :
|paramater|type|required|default|
|---------|----|--------|-------|
|Amount|Float|true|0|
|Number|Credit Card Number Int/String|true||
|CardType|String|true||
|Expiration|Digits only Int/String|true||
|SecurityCode|Int/String|true||
var cardInfo=new dominos.class.Payment();
cardInfo.Amount=42.50;
//get amount from dominos.order.price request
//data.result.Order.Amounts.Customer
cardInfo.Number='4444888888888888';
cardInfo.CardType='VISA';
cardInfo.Expiration='1017';
cardInfo.SecurityCode='189';
cardInfo.PostalCode='20500';
order.Order.Payments.push(cardInfo);
Then you can place the order and catch placement failures :
dominos.order.place(
order,
function(data){
console.log(data);
if(data.result.Order.Status==-1){
console.log(
'\n###### NO PIZZA FOR YOU! ######\n',
orderData.result.Order.StatusItems,
'\n#########################\n\n'
);
return;
}
}
);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc