Gavin Dinubilo
Published

Press For Pizza

Dramatically order pizza from a switch on your Pinoccio

Full instructions provided851
Press For Pizza

Things used in this project

Hardware components

Pinoccio Scout
×1
Button
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Code

file_6548.txt

JavaScript
        var pinocc = require("pinoccio");
var ordrinapi = require("ordrin-api");
require('console.alert')();

var api = pinocc("{{ pinoccio api }}");

var api_secret_key = "{{ ordr.in api }}";

var ordrin = new  ordrinapi.APIs(api_secret_key, ordrinapi.TEST); // When you're ready to start using the program, change "ordrinapi.TEST" to "ordrinapi.PRODUCTION"

// This is to clear the screen, to only have the console alert
var lines = process.stdout.getWindowSize()[1];
for(var i = 0; i < lines; i++) {
	console.log('\r\n');
}

console.alert("Waiting for Pizza time");

var args = {
	rid: "27624",
	em: "gavin_dinubilo@mail.tmcc.edu",
	tray: "22991598/1",
	tip: "3.00",
	first_name: "Gavin",
	last_name: "Dinubilo",
	phone: "",
	zip: "89501",
	addr: "105 Arlington avenue",
	city: "Reno",
	state: "NV",
	card_name: "Gavin A Dinubilo",
	card_number: "4111111111111111",
	card_cvc: "123",
	card_expiry: "02/2016",
	card_bill_addr: "105 Arlington avenue",
	card_bill_city: "Reno",
	card_bill_state: "NV",
	card_bill_zip: "89501",
	card_bill_phone: "7753762948",
	delivery_date: "ASAP"
};

var s = api.sync();

s.on("data", function(data){
	data = data.data;
	if(data.type === "digital" && data.troop === '1' && data.scout === '1'){
		if (data.value.state[0] === 0) {
			orderPizza();	
		}
	}
});

function orderPizza() {
	for(var i = 0; i < lines; i++) {
    		console.log('\r\n');
	}
	console.alert("PIZZA TYME!!!!!");
	ordrin.order_guest(args, function(error, data){
		for(var i = 0; i < lines; i++) {
    		console.log('\r\n');
		}
		console.alert("Pizza will be here ASAP!!");
	});
}

Credits

Gavin Dinubilo

Gavin Dinubilo

8 projects • 7 followers

Comments

Add projectSign up / Login