• Stars
    star
    511
  • Rank 84,312 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This is a node.js wrapper for the dominos pizza apis

Domino's Pizza API

Sponsor RIAEvangelist to help development of node-dominos-pizza-api

This is a node.js API for integrating with the Domino's pizza APIs. See the pretty Domino's Pizza API documentation

npm dominos info : See npm trends and stats for dominos
Package Quality
dominos npm version supported node version for dominos api total npm downloads for dominos monthly npm downloads for dominos npm licence for dominos

RIAEvangelist

GitHub info : node-dominos-pizza-api GitHub Release GitHub license node-dominos-pizza-api license open issues for node-dominos-pizza-api on GitHub

Build Info :
Mac & Linux & Windows : Build Status

This work is licenced via the MIT Licence. It is a derivative work from Dominos API.

Install the Dominos pizza api

npm i dominos

Contributing

  1. Pull or Fork code.
  2. From the cloned directory run npm i (this will install required dependancies, depending on your system may require)
  3. Be awesome!

Examples

See the examples directory for simple apps and demonstrations on using the basic functionality.

Testing

For testing we have started using the extremely light vanilla-test testing suite. It is a pretty bare bones testing framework, but it works really well and simply with native ES6 and ESM. vanilla-test on npm

Simply run npm test

This will setup everything that is needed to run the tests, install the modules required and run the tests for you.

Remember, the Dominos API is rate limited, so if you make too many requests, like running tests back to back too many times, you may need to wait a short while before making new requests.


Code Coverage

For coverage we are using the amazing c8 coverage suite. It produces awesom instanbul style reports as well as lcov and much mmore. It allows testing of pure ES6 code without transpiling, and does not modify the code at all for coverage. It uses the built in node coverage tools to test the execution directly inside v8 c8 on npm

Simply run npm test and the coverage files will be added to the ./coverage directory automatically. You can start a local coverage server to view your results by running npm run coverage. This will start a simple node-http-server for your local coverage directory.

See the public c8 & vanilla-test code coverage


TLDR; Order & Track a Pizza

import {Order,Customer,Item,Payment,NearbyStores,Tracking} from 'dominos';

//extra cheese thin crust pizza
const pizza=new Item(
    {
        //16 inch hand tossed crust
        code:'16SCREEN',
        options:{
            //sauce, whole pizza : normal
            X: {'1/1' : '1'}, 
            //cheese, whole pizza  : double 
            C: {'1/1' : '1.5'},
            //pepperoni, whole pizza : double 
            P: {'1/2' : '1.5'}
        }
    }
);

const customer = new Customer(
    {
        //this could be an Address instance if you wanted 
        address: '2 Portola Plaza, Monterey, Ca, 93940',
        firstName: 'Brandon',
        lastName: 'Miller',
        //where's that 555 number from?
        phone: '941-555-2368',
        email: '[email protected]'
    }
);

let storeID=0;
let distance=100;
//find the nearest store
const nearbyStores=await new NearbyStores(customer.address);
//inspect nearby stores
//console.log('\n\nNearby Stores\n\n')
//console.dir(nearbyStores,{depth:5});


//get closest delivery store
for(const store of nearbyStores.stores){
    //inspect each store
    //console.dir(store,{depth:3});
    
    if(
        //we check all of these because the API responses seem to say true for some
        //and false for others, but it is only reliably ok for delivery if ALL are true
        //this may become an additional method on the NearbyStores class.
        store.IsOnlineCapable 
        && store.IsDeliveryStore
        && store.IsOpen
        && store.ServiceIsOpen.Delivery
        && store.MinDistance<distance
    ){
        distance=store.MinDistance;
        storeID=store.StoreID;
        //console.log(store)
    }
}

if(storeID==0){
    throw ReferenceError('No Open Stores');
}

//console.log(storeID,distance);


//create
const order=new Order(customer);

// console.log('\n\nInstance\n\n');
// console.dir(order,{depth:0});

order.storeID=storeID;
// add pizza
order.addItem(pizza);
//validate order
await order.validate();

// console.log('\n\nValidate\n\n');
//console.dir(order,{depth:3});

//price order
await order.price();

// console.log('\n\nPrice\n\n');
// console.dir(order,{depth:0});

//grab price from order and setup payment
const myCard=new Payment(
    {
        amount:order.amountsBreakdown.customer,
        
        // dashes are not needed, they get filtered out
        number:'4100-1234-2234-3234',
        
        //slashes not needed, they get filtered out
        expiration:'01/35',
        securityCode:'867',
        postalCode:'93940',
        tipAmount:4
    }
);

order.payments.push(myCard);

//place order

try{
    //will throw a dominos error because
    //we used a fake credit card
    await order.place();

    console.log('\n\nPlaced Order\n\n');
    console.dir(order,{depth:3});

    const tracking=new Tracking();

    const trackingResult=await tracking.byPhone(customer.phone);

    console.dir(trackingResult,{depth:1});
}catch(err){
    console.trace(err);

    //inspect Order Response to see more information about the 
    //failure, unless you added a real card, then you can inspect
    //the order itself
    console.log('\n\nFailed Order Probably Bad Card, here is order.priceResponse the raw response from Dominos\n\n');
    console.dir(
        order.placeResponse,
        {depth:5}
    );
}


Legacy CommonJS support

This is for those who wish to use the domnios api in older code bases still using require. While node v12+ is still required, see the detailed info and order example in CommonJS.md for how to include and use the module in your code.

(async () => {
    const dominos=await import('dominos');

    //importing variables into the global like this just allows us to use the same code
    //from the ESM implementation for the commonJS implementation
    //This is the same as an ESM import of
//import {Address,NearbyStores,Store,Menu,Customer,Item,Image,Order,Payment,Tracking,urls,IsDominos} from 'dominos'

    Object.assign(global,dominos);

    //need to await dominos promise completion
    //because ES6 is async by nature
    start();
})()

function start(){
    //any of the ESM examples from the other docs will work as is here
    //because we mimiced an ESM import above.
     
    const n='\n';
    console.log(
        n,
        Address,n,
        NearbyStores,n,
        Store,n,
        Menu,n,
        Customer,n,
        Item,n,
        Image,n,
        Order,n,
        Payment,n,
        Tracking,n,
        urls,n,
        IsDominos,n
    );
}

International Support

The module now supports using multiple sets of endpoints that we have in ./utils/urls.js or even custom endpoints. However, if you get hyour country working with custom endpoints, PLEASE CONTRIBUTE THEM BACK! You will get credit as soon as your endpoints are merged back in.

See detailed information on how to use the international endpoints or custom endpoints here : International Dominos Endpoints and how to use them

USA

USA is default so you really dont need to do anything other than import {urls} from 'dominos'; if you want access to the usa endpoints.

  import {urls} from 'dominos';
  console.dir(urls);



  //Or to reset the usa if you switched to custom or another country
  
  
  import {urls} from 'dominos';
  import {useInternational,canada,usa} from 'dominos/utils/urls.js';
  
  //first set to canada so we can see it work since USA is default
  useInternational(canada);
  console.dir(urls);
  
  //then set it back to usa so we can confirm it works
  useInternational(usa);
  console.dir(urls);
  

Canada

  import {urls} from 'dominos';
  import {useInternational,canada} from 'dominos/utils/urls.js';
  useInternational(canada);

  console.dir(urls);

Custom

  import {urls} from 'dominos';
  import {useInternational,canada} from 'dominos/utils/urls.js';
  
  const myCountriesURLs={
      referer   :"https://order.dominos.nz/en/pages/order/",
      sourceUri :"order.dominos.nz",
          location:{
          find:urls.location.find
      },
      store     : {
          find    : "https://order.dominos.nz/power/store-locator?s=${line1}&c=${line2}&type=${type}",
          info    : "https://order.dominos.nz/power/store/${storeID}/profile",
          menu    : "https://order.dominos.nz/power/store/${storeID}/menu?lang=${lang}&structured=true"
      },
      order     : {
          validate: "https://order.dominos.nz/power/validate-order",
          price   : "https://order.dominos.nz/power/price-order",
          place   : "https://order.dominos.nz/power/place-order"
      },
      track   : "https://order.dominos.nz/orderstorage/GetTrackerData?"
  }


  useInternational(myCountriesURLs);

  console.log('MY COUSTOM FAKE NZ ENDPOINTS');
  console.dir(urls);

Address

See the detailed docs on addresses here : Address.md

  import {Address} from 'dominos';

  //full address examples
  const address = new Address(
      {
          street:'900 Clark Ave',
          city:'St. Louis',
          region:'MO',
          postalCode:'63102'
      }
  );

  const address=new Address('900 Clark Ave, St. Louis, MO, 63102');
  


  //partial address examples
  const address = new Address(
      {
          street:'900 Clark Ave',
          city:'St. Louis',
          postalCode:'63102'
      }
  );
  
  const address=new Address('900 Clark Ave, St. Louis, 63102');



  //street and zip only examples
  const fullAddressObject = new Address(
      {
          street:'900 Clark Ave',
          postalCode:'63102'
      }
  );
  
  const address=new Address('900 Clark Ave, 63102'); 

  //zip only examples
  const fullAddressObject = new Address(
      {
          postalCode:'63102'
      }
  );

  const onlyZip = new Address('63102');

NearbyStores

This provides a list of basic info on stores that are nearby an address.

See the detailed docs on finding nearby stores here : NearbyStores.md

    import {NearbyStores, Store} from 'dominos';
  
    const nearbyStores=await new NearbyStores('88 Colin P Kelly Jr St, 94107');

    console.dir(nearbyStores,{depth:1});
    
    console.log('\n\nFirst nearby store');
    console.dir(nearbyStores.stores[0],{depth:1});

    //initialize the frst of the nearbyStores.stores
    const store=await new Store(nearbyStores.stores[0].StoreID);

    console.log('\n\nFull Store info called from the first nearby stores ID');
    console.dir(store,{depth:1});

Menu

This provides a detailed menu for a given store.

See the detailed docs on menus here : Menu.md

import {Menu} from 'dominos';

const menu=await new Menu(4337);

console.dir(menu,{depth:1});

Store

This provides detailed store information.

See the detailed docs on stores here : Store.md

    import {Store} from 'dominos';

    const store=await new Store(4337);

    console.dir(store,{depth:1});

Item

Items are used to place orders.

See the detailed docs on items here : Item.md

import {Item} from 'dominos';

const pepperoniPizza=new Item(
    {
        code:'P_14SCREEN'
    }
)

console.dir(pepperoniPizza);

Customer

This creates a customer object for use when making an order.

See the detailed docs on customers here : Customer.md

import {Customer} from 'dominos';

const customer = new Customer(
    {
        address: '900 Clark Ave, 63102',
        firstName: 'Barack',
        lastName: 'Obama',
        phone: '1-800-555-2368',
        email: '[email protected]'
    }
);

console.dir(customer);

Image

The Image class will grab the image for a product code and base 64 encode it. It extends the js-base64-file class.

Pizza image

See the detailed docs on image here : Image.md

import {Image} from 'dominos';

const productCode='S_PIZPX';
const savePath='./';

const pepperoniPizza=await new Image(productCode);
console.log(pepperoniPizza.base64Image);

//you could pass this to a user via sms, web socket, http, tcp, make an ascii art for the terminal, OR save it to disk or a database
//here we just save it to disk as an example.
//this is part of the js-base64-file class refrence, there is a link at the top of this file
pepperoniPizza.saveSync(pepperoniPizza.base64Image,savePath,productCode+'.jpg');

Payment

This class will initialize a creditcard payment object for an order.

See the detailed docs on payment here : Payment.md

import {Payment} from 'dominos';

const myCard=new Payment(
    {
        amount:10.77,
        //dashes are not needed, they just make it easier to read
        //the class sanitizes the data
        number:'4444-4444-4444-4444',
        expiration:'01/12',
        securityCode:'867',
        postalCode:'93940'
    }
)

Order

Finally... This class will order you pizza, and other things from the menu.

See the detailed docs on order here : Order.md

import {Order,Customer,Item,Payment} from 'dominos';

//extra cheese thin crust pizza
const pizza=new Item(
    {
        code:'14THIN',
        options:{
            //sauce, whole pizza : normal
            X: {'1/1' : '1'}, 
            //cheese, whole pizza  : double 
            C: {'1/1' : '1.5'}
        }
    }
);

const customer = new Customer(
    {
        //this could be an Address instance if you wanted 
        address: '110 S Fairfax Ave, 90036',
        firstName: 'Barack',
        lastName: 'Obama',
        //where's that 555 number from?
        phone: '1-800-555-2368',
        email: '[email protected]'
    }
);

//create
const order=new Order(customer);
order.storeID=8244;
// add pizza
order.addItem(pizza);
//validate order
await order.validate();
//price order
await order.price();

//grab price from order and setup payment
const myCard=new Payment(
    {
        amount:order.amountsBreakdown.customer,
        
        // dashes are not needed, they get filtered out
        number:'4100-1234-2234-3234',
        
        //slashes not needed, they get filtered out
        expiration:'01/35',
        securityCode:'867',
        postalCode:'93940'
    }
);

order.payments.push(myCard);

//place order
await order.place();

//inspect Order
console.dir(order,{depth:5});

//you probably want to add some tracking too...

Tracking

This is how you track Pizzas! (and other things)

You can track its progress, who is working on it, who your delivery person is, and how many stops they have before you using this Class.

If there are no orders for a given phone number, it will throw a DominosTrackingError.

import {Tracking} from 'dominos';

const tracking=new Tracking();

const trackingResult=await tracking.byPhone('3108675309');

console.dir(trackingResult,{depth:1});

Dominos Custom Type Checking

This class extends strong-type to allow strong and weak type checking of dominos specific types, errors and classes. It is used a lot in the dominos module to ensure correct types of arguments and errors. The strong-type module is really cool.

See the DominosTypes.md for more information.

import {IsDominos,Address} from 'dominos'

isDominos=new IsDominos;

let address='bob';

//address is a string so this will throw an Error
try{
    isDominos.address(address);
}catch(err){
    console.trace(err);
}

address=new Address('1 alvarado st, 93940');

//will not throw because this is an Address instance
isDominos.address(address);

Global DominosErrors

These custom errors are added to the global object for use in your code and the dominos api. You can use them to validate errors or even throw your own if you are making a module ontop of this one.

See the detailed docs on DominosErrors here : DominosErrors.md

error parameters description
DominosValidationError .validationResponse this error is thrown when a dominos validation request fails
DominosPriceError .priceResponse this error is thrown when a dominos price request fails
DominosPlaceOrderError .placeOrderResponse this error is thrown when a dominos place request fails
DominosTrackingError message string this error is thrown when no trackable orders are found for a phone number
DominosAddressError message string this error is thrown when an issue is detected with a dominos address
DominosDateError message string this error is thrown when an issue is detected with a date being used for a dominos order
DominosStoreError message string this error is thrown when an issue is detected with a store being used for a dominos order
DominosProductsError message string this error is thrown when an issue is detected with an orders product list

Code, Order, Eat, Be Happy!

Tatsu Ninja Turtles Go Play

More Repositories

1

node-cmd

Simple commandline interface to allow you to run cli or bash style commands as if you were in the terminal.
JavaScript
282
star
2

peacenotwar

JavaScript
154
star
3

electron-video-player

[DEPRECATED] electron based video player for all platforms
JavaScript
143
star
4

node-http-server

Simple to use node HTTP Server
JavaScript
51
star
5

serialport-js

pure javascript serial port implementation for node.js, electron and nw.js
JavaScript
50
star
6

js-queue

Simple JS queue for node and browsers
JavaScript
47
star
7

node-ipc

A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.
JavaScript
42
star
8

insane-alarm

This alarm will wake you up no matter what!
JavaScript
23
star
9

node-parrot-drone

extendable node module to allow control of any Parrot drone.
JavaScript
23
star
10

event-pubsub

Event Pubsub for Javascript will work in node js or browser
JavaScript
21
star
11

nwjs-browser-framework

JavaScript
15
star
12

awesome-webcomponents

JavaScript
13
star
13

chrome-app-user-agent-and-bookmarklet-webview

webviewJS can be used to build communication between a chrome app and a webveiw. It can be called from an app to modify the user agent for analytics if executed at the proper time. Also webviewJS can be used to run bookmarklets in the webview, as well as pass whole js files, or raw, non stringified functions.
JavaScript
12
star
14

node-phidget-API

Node.JS Phidget API supporting all phidgets!
JavaScript
10
star
15

js-message

Normalized JS & JSON Message Protocol
JavaScript
10
star
16

strong-type

Strongly Typed native JS without a hard requirement for transpiling. What TypeScript should have been.
JavaScript
9
star
17

Chrome-Serial-App

Chrome App for connecting to serial devices and serial USB
JavaScript
9
star
18

Bluetooth-To-Serial-Programming

Diagrams and documents on hooking up bluetooth and serial boards
JavaScript
8
star
19

ws-share

A module allowing sharing of websockets between different functions, modules, scripts, actions, stores, and/or components with vanilla js (plain javascript), react, webpack or browserify
JavaScript
8
star
20

zero-motorcycle-canbus

CANbus message discovery on Zero motorcycles
C++
7
star
21

easy-stack

js stack for node and the browser which is super easy LIFO
JavaScript
6
star
22

SCv2-sketches

Sketches for SCv2
C++
6
star
23

js-base64-file

node loading, converting and saving of local and remote files as base64 images or files. Perfect for image data uri use!
JavaScript
6
star
24

nozaki-components

modern vanilla components designed with ES6+ ESM first works in all modern browsers without transpiling.
CSS
5
star
25

nwjs-cast

Chromecast implementation for nw.js and node.js
JavaScript
4
star
26

declassified-zero-sdk

Development Kit for Zero Motorcycles
JavaScript
4
star
27

cloud9-server-chrome-app

This is a Chrome app which you can use to run your own installed version of Cloud9 ( c9.io )
JavaScript
4
star
28

PHP-Grepolis-JSON-API

A JSON API for the Grepolis game built in PHP
JavaScript
4
star
29

is-my-node-supply-chain-secure

Scans your computer for node modules that are potentially vulnerable to supply chain attacks. You still need to review the code of modules that are not vulnerable, but this helps.
JavaScript
4
star
30

nozaki-colors

Another node cli colors module. Done simply and with native syntax. It's ment to make sense to engineers, not script kiddies.
JavaScript
4
star
31

parrot-jumping-drone

Control all the Parrot jumping mini drones! Sumo drone, Night drone and Race mini drones!
JavaScript
3
star
32

csun-fsae-controls

control and data acquisition for CSUN fsae race car
JavaScript
3
star
33

learning-RIA

Some basic lessons on learning RIA
JavaScript
3
star
34

diginow-cdn

diginow cdn for hosting browser modules
JavaScript
3
star
35

anonymous-communication

A desktop application for direct messaging anonymously.
JavaScript
3
star
36

node-error-classes

Custom error classes for node.js
HTML
3
star
37

delete-github-issue-bookmarklet

Use this bookmarklet to quickly delete an issue
HTML
3
star
38

ria-app-framework

Modular HTML5 & JavaScript RIA Framework. Designed for maintainability, simplicity, and rapid development.
JavaScript
3
star
39

vanilla-test

minimalistic pure js es6 module for testing node, electron and the browser
JavaScript
3
star
40

getUserMedia-notification

This HTML module or plugin is designed to help make the getUserMedia ( audio and video) and other HTML5 prompts more noticeable to the user. The idea was thought up by and created for Alexander De Ridder.
JavaScript
2
star
41

electron-github

electron GitHub desktop app for all platforms
JavaScript
2
star
42

RIAEvangelist

2
star
43

eslint-settings

Full rule set of eslint with my settings
JavaScript
2
star
44

range-class-js

ES6 Range module for node and commonjs browser frameworks like react
HTML
2
star
45

browser-error-classes

Better Javascript error classes for the browser that follow the standards.
JavaScript
2
star
46

touch-drag

Drag, drop and sotable functionality built to work on all platforms, mobile, tablet and desktop
JavaScript
2
star
47

SimonSays

Simon says google app
JavaScript
2
star
48

Octopi

Offline community tool for an organized personnel infrastructure during crisis
JavaScript
2
star
49

EV-J1772

Ev pilot reading.
Arduino
2
star
50

electron-server-update-ui-on-request

Simple example of an electron server which updates its ui based on an http request to it. Made for g10dras on #electron in the atom-shell slack
JavaScript
2
star
51

heart-attack

node js virus example. Only install on VM for testing. Never install on any primary computer or server.
JavaScript
1
star
52

digital-ocean-dashboard-app

electron react app to keep your Digital Ocean droplet data handy whenever you need it.
JavaScript
1
star
53

adyen-web-dropin-prototype

This is a quick and dirty implementation and experiential report on implementing the Adyen Drop-in via native ES6/ESM
JavaScript
1
star
54

node-carlsjr-api

A node JS API for Carl's Jr. fast food restaurants
JavaScript
1
star
55

node-webcam-photo

capture photos from a webcam via node
1
star
56

nozaki

nozaki cli for creating boilerplate web components
JavaScript
1
star
57

cdn

Digital Ocean CDN app for my npm modules that can be used in the browser
HTML
1
star
58

tourPlanner

Determine trip info for long rides
JavaScript
1
star
59

declassified-SC-v1-Firmware

Firmware for Super Charger
C++
1
star
60

node-papajohns-api

An API for ordering papajohns pizza
JavaScript
1
star
61

node-hardees-api

A Node JS API for Hardee's fast food chains
JavaScript
1
star
62

declassified-SC-v1-Server

BBG code for SC controls and External coms
JavaScript
1
star
63

nodejs-vw

Módulo principal de vw. Este es el punto de partida de aplicación
JavaScript
1
star
64

online-offline-alarm-chrome-app

An online and offline chrome app programmed one night after drinking too much
JavaScript
1
star
65

undefined

A proxy to use with objects or arrays that allows you to access keys and functions that are not defined without throwing errors or crashing your app.
1
star
66

node-veggiegrill-api

nodejs veggiegrill api
JavaScript
1
star
67

encrypted-chat

JavaScript
1
star
68

nozaki.ninja

nozaki.ninja website
JavaScript
1
star
69

agent-smith

An agent to monitor your github account and others interactions with it.
JavaScript
1
star