[
  {
    "path": ".gitignore",
    "content": "# Dependency directory\n# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git\nnode_modules\n\n**/.DS_Store\n\n# ignore the order files,\n*.json\n# except exampleorder.json\n!exampleorder.json\n!package.json\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Brody Berson\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n"
  },
  {
    "path": "README.md",
    "content": "![Pizza Dash](http://i.imgur.com/DD944Cz.jpg)\nPizzaDash\n====\n[![Join the chat at https://gitter.im/bhberson/pizzadash](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bhberson/pizzadash?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n\nThis is a node.js application that \"hacks\" your [Amazon Dash Button](http://www.amazon.com/dashbutton) to order you a [Domino](https://www.dominos.com/)'s pizza!\nI was inspired by [this article by Edward Bensen](https://medium.com/@edwardbenson/how-i-hacked-amazon-s-5-wifi-button-to-track-baby-data-794214b0bdd8).\nI am using a few npm modules to listen for the button press and place the order: [RIAEvangelist](https://github.com/RIAEvangelist)'s [dominos](https://github.com/RIAEvangelist/node-dominos-pizza-api) and also [hortinstein](https://github.com/hortinstein)'s [Node-Dash-Button](https://github.com/hortinstein/node-dash-button).\n\nOne idea would be to have this [always running](#always-running) via a local server such as a Raspberry Pi and have on demand pizza ordering whenever you just need a pizza!\n\nI wrote a blog post about my experience here on [Medium](https://medium.com/@brody_berson/hacking-amazon-s-5-dash-button-to-order-domino-s-pizza-9d19c9d04646)!\n\nRequirements\n====\n__pcap__\nIf you are running ubuntu you will need to run ` sudo apt-get install libpcap0.8-dev `\n\nContributing\n====\n\n1. Pull or Fork code.\n2. Do cool stuff.\n3. Submit a PR.\n\nSetup/Run\n====\n1. Run ` npm install ` the first time so all npm requirements will be installed.\n2. Find Closest Store\n  - Run ` node findStore.js ` and input your 5 digit zipcode, this will return closest store info (Store ID) and their menu.\n3. Find Dash Button\n  - Run ` sudo node node_modules/node-dash-button/bin/findbutton ` and press the button\n4. Create your ` order.json ` file by copying ` exampleorder.json `\n  - Add your store from step 2\n  - Edit your address and personal/customer information\n  - Edit your order using menu from step 2\n  - Add credit card information\n  - Add your Amazon Dash Button's address from step 3\n5. Run` npm start ` and press your Dash Button that you have set up and BAM pizza will be coming soon!\n\nIssues\n====\nIf you run into any issues with Socket Watcher please try this: Looks like socketwatcher was using the legacy \"node\" command instead of nodejs. It is solved on ubuntu by installing nodejs-legacy that clears up those conflicts.\n`sudo apt-get install nodejs-legacy`\n\n\nAlways Running\n----\nThis [article](http://weworkweplay.com/play/raspberry-pi-nodejs/) shows you what you can do with a [Raspberry Pi](https://www.raspberrypi.org/) to set this up as a node server running all the time on your network and it literally would be the press of a button *whenever* you wanted!\n\nOr you can view this [Gist](https://gist.github.com/bhberson/7a2847888596e67fd69b) to view how to create an AWS Lambda function if you own an Amazon AWS IoT Button. They basically handle the \"always on\" use case for us!\n\nTo do\n----\n- Create a Web Interface to assist in creating orders easily.\n- Other ideas?\n"
  },
  {
    "path": "app.js",
    "content": "var dash_button = require('node-dash-button');\nvar pizzapi = require('dominos');\nvar orderconfig = require('./order.json');\n\n//Input order from json\nconsole.log(\"Getting order from file...\");\nvar order = new pizzapi.Order(\n  orderconfig[\"order\"]\n);\n//Add items to order\nconsole.log(\"Adding items to order...\")\nvar items = orderconfig[\"items\"];\nfor (var i=0; i<items.length; i++) {\n  order.addItem(\n    new pizzapi.Item(\n      items[i]\n    )\n  );\n}\n\n// Setup your Credit Card Info\nconsole.log(\"Setting up credit card info...\")\nvar cardInfo = new order.PaymentObject();\ncardInfo.Amount = order.Amounts.Customer;\ncardInfo.Number = orderconfig[\"cardNum\"];\ncardInfo.CardType = order.validateCC(orderconfig[\"cardNum\"]);\ncardInfo.Expiration = orderconfig[\"cardExp\"];//  01/15 just the numbers \"01/15\".replace(/\\D/g,'');\ncardInfo.SecurityCode = orderconfig[\"cardSec\"];\ncardInfo.PostalCode = orderconfig[\"cardPost\"]; // Billing Zipcode\n\nconsole.log(\"Adding card to order...\");\norder.Payments.push(cardInfo);\n\n//TODO: if no mac address, find one and save it\nconsole.log(\"Searching for Dash Button...\");\nvar dash = dash_button(orderconfig[\"dashMacAddress\"]);\ndash.on(\"detected\", function (){\n    console.log(\"Dash Button Found\");\n    console.log(\"Configuring Dash Button...\");\n\t//Validate, price, and place order!\n\torder.validate(\n\t    function(result) {\n\t        console.log(\"Order is Validated\");\n\t    }\n\t);\n\torder.price(\n\t    function(result) {\n            console.log(\"Order is Priced\");\n\t    }\n\t);\n\torder.place(\n\t    function(result) {\n            console.log(\"Price is\", result.result.Order.Amounts, \"\\nEstimated Wait Time\",result.result.Order.EstimatedWaitMinutes, \"minutes\");\n\t        console.log(\"Order placed!\");\n\t    }\n\t);\n\tconsole.log(\"Listening...\");\n});"
  },
  {
    "path": "exampleorder.json",
    "content": "{\n  \"order\":{\n    \"customer\":{\n      \"firstName\":\"John\",\n      \"lastName\":\"Smith\",\n      \"address\":{\n        \"Street\": \"JohnSmith Lane\",\n        \"City\": \"JohnSmithville\",\n        \"Region\": \"NY\",\n        \"PostalCode\": \"90210\"\n      },\n      \"email\":\"johnsmith@johnsmith.gov\",\n      \"phone\":\"15181231234\"\n    },\n    \"storeID\":3302,\n    \"deliveryMethod\":\"Delivery\"\n  },\n  \"items\":[\n    {\n      \"code\":\"P_14SCREEN\",\n      \"options\":{},\n      \"quantity\":1\n    }\n  ],\n  \"cardNum\":4100123422343234,\n  \"cardExp\":\"0115\",\n  \"cardSec\":777,\n  \"cardPost\":90210,\n  \"dashMacAddress\":\"ff:ff:ff:ff:ff:ff\"\n}\n"
  },
  {
    "path": "findStore.js",
    "content": "var pizzapi = require('dominos');\nvar prompt = require('prompt');\n\nvar myStore;\n\nprompt.start();\n\nprompt.get(['zip'], function (err, result) {\n    if (err) { return onErr(err); }\n    //Get stores by postal code, distance is not as accurate this way\n    pizzapi.Util.findNearbyStores(\n        result.zip,\n        'Delivery',\n        function(storeData) {\n            myStore = new pizzapi.Store(\n                {\n                    ID: storeData.result.Stores[0].StoreID\n                }\n            );\n\n            //Get Info for first store\n            myStore.getInfo(\n                function(storeData) {\n                    console.log('\\n\\n##################\\nClosest Store Info\\n##################\\n\\n',storeData.result);\n                }\n            );\n            //Get Menu for first store\n            myStore.getFriendlyNames(\n                function(storeData) {\n                    console.log('\\n\\n##################\\nClosest Store Menu\\n##################\\n\\n',storeData.result);\n                }\n            );\n        }\n    );\n});\n\nfunction onErr(err) {\n    console.log(err);\n    return 1;\n}"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"pizzadash\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Order Pizza with Amazon Dash Button\",\n  \"main\": \"app.js\",\n  \"dependencies\": {\n    \"node-dash-button\": \"^0.4.0\",\n    \"dominos\": \"^2.0.1\",\n    \"prompt\": \"^1.0.0\"\n  },\n  \"devDependencies\": {},\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\",\n    \"start\": \"sudo node app.js\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://bhberson@github.com/bhberson/pizzadash.git\"\n  },\n  \"keywords\": [\n    \"Dominos\",\n    \"Domino's\",\n    \"Pizza\",\n    \"API\",\n    \"Pie\",\n    \"PizzaPI\",\n    \"Amazon\",\n    \"AmazonDash\",\n    \"Dash\",\n    \"Button\"\n  ],\n  \"author\": {\n    \"name\": \"Brody Berson\",\n    \"email\": \"brody.berson@gmail.com\",\n    \"url\": \"http://www.brodyberson.com\"\n  },\n  \"contributors\": [\n    {\n      \"name\": \"Brandon Miller\",\n      \"email\": \"brandon@diginow.it\",\n      \"url\": \"http://www.diginow.it\"\n    },\n    {\n      \"name\": \"Joseph Iaquinto\",\n      \"email\": \"iaquinto.joe@gmail.com\",\n      \"url\": \"http://joeiaquinto.github.io/\"\n    },\n    {\n      \"name\": \"Dan Gorman\",\n      \"email\": \"danthemangorman@gmail.com\",\n      \"url\": \"http://dangothemango.github.io/\"\n    }\n  ],\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/bhberson/pizzadash/issues\"\n  },\n  \"homepage\": \"https://github.com/bhberson/pizzadash#readme\"\n}\n"
  }
]