예제 #1
0
def get_average_menu_item_price(restaurant_id):
    ordrin_api = ordrin.APIs("SvMY8WkSk78OHhgYSs55FVkUev7FOrdtEXF_1bExeUc",
                             ordrin.TEST)
    restaurant_details = ordrin_api.restaurant_details(str(restaurant_id))
    price = float(0)
    for index in range(len(restaurant_details["menu"])):
        for index2 in range(len(
                restaurant_details["menu"][index]["children"])):
            price += float(
                restaurant_details["menu"][index]["children"][index2]["price"])

    return float(price) / float(len(restaurant_details["menu"]))
예제 #2
0
def order(food, location, city, zipcode):
    ordrin_api = ordrin.APIs('VP0cjZmpyVPNAFJUJkBWDIETChyTTwp7mX3jlPzfn4Q',
                             ordrin.TEST)
    restaurants = ordrin_api.delivery_list("ASAP", location, city, zipcode)

    priorityQ = PriorityQueue()
    restauPair = {}
    for r in restaurants:
        #pprint(r)
        rid = str(r['id'])
        temp = ordrin_api.restaurant_details(str(r['id']))
        #pprint(temp)
        cuisines = temp['cuisine']
        highpriority = False
        j = 0
        for j in range(len(cuisines)):
            #print cuisines[j]
            if cuisines[j] is food:
                highpriority = True

        if highpriority:
            priority = 1
        else:
            priority = 2

        #newRest = Eatery(temp['name'], priority)
        foodList = []
        #pprint(temp)
        menuItems = (temp['menu'])[0]  #go through ALL menu Items
        #pprint(menuItems)
        additionalfee = menuItems['additional_fee']
        children = menuItems['children']
        #print(additionalfee)
        #pprint(menu)
        for child in children:  #each individual plate of food #Go through ALL combinations of individual plate of food
            addFeePerItem = child['additional_fee']
            descrip = child['descrip']
            ID = child['id']
            name = child['name']
            price = child['price']
            newFood = Food(addFeePerItem, descrip, ID, name, price, rid)
            foodList.append(newFood)
            #print newFood.ID
            #pprint (child)

        restauPair[temp['name']] = foodList
        priorityQ.put(temp, priority)
        #restauPair[newRest] = foodList
    finalOrder(restauPair, priorityQ, ordrin_api)
예제 #3
0
def get_menu_items(restaurant_id):
    ordrin_api = ordrin.APIs("SvMY8WkSk78OHhgYSs55FVkUev7FOrdtEXF_1bExeUc",
                             ordrin.TEST)
    restaurant_details = ordrin_api.restaurant_details(str(restaurant_id))

    menu_items = []

    #for index in range(len(restaurant_details['menu'])):
    for index in range(5):
        #for index2 in range(len(restaurant_details["menu"][index]["children"])):
        for index2 in range(1):
            menu_items.append(
                restaurant_details['menu'][index]['children'][index2]['name'])

    return menu_items
예제 #4
0
def find_restaurant(user):

    ordrin_api = ordrin.APIs(ordrin_secret, ordrin.TEST)
    address = ordrin_api.get_saved_addr(user["email"], "address", "password")
    cc = ordrin_api.get_saved_cc(user["email"], "card", "password")

    delivery_list = ordrin_api.delivery_list("ASAP", address["addr"],
                                             address["city"], address["zip"])

    for restaurant in delivery_list:
        rid = str(restaurant["id"])
        args = {"rid": rid, "target": "cake", "size": "3"}
        details = requests.get('http://foodbot.ordr.in:8000/TextSearch',
                               params=args)
        tray = find_dessert(details)
        if tray:
            order_food(tray, rid, user, ordrin_api)
    return False
예제 #5
0
        except BaseException as e:
            print "The API returned the following error:"
            print e

    return g


#
# Global Variables
#
api_key = raw_input("Please input your API key: ")

if not api_key:
    api_key = "2HGAzwbK5IWNJPRN_c-kvbqtfGhS-k2a6p-1Zg2iNN4"

api = ordrin.APIs(api_key, ordrin.TEST)  # Create an API object

addr = "900 Broadway"
city = "New York"
addr_zip = "10003"

address = {
    'addr': addr,
    'city': city,
    'state': 'NY',
    'zip': addr_zip,
    'phone': '555-555-5555'
}
address_nick = 'addr1'

first_name = 'Test'
예제 #6
0
def get_nearby_restaurants(street_address, city, zip_code):
    ordrin_api = ordrin.APIs("SvMY8WkSk78OHhgYSs55FVkUev7FOrdtEXF_1bExeUc",
                             ordrin.TEST)
    data = ordrin_api.delivery_list("ASAP", street_address, city, zip_code)
    return data[0:5]
예제 #7
0
def get_name(restaurant_id):
    ordrin_api = ordrin.APIs("SvMY8WkSk78OHhgYSs55FVkUev7FOrdtEXF_1bExeUc",
                             ordrin.TEST)
    restaurant_details = ordrin_api.restaurant_details(str(restaurant_id))
    return restaurant_details["name"]
예제 #8
0
import ordrin
import random

ordrin_api = ordrin.APIs('GI2veJjbDGAu1eiraCCz12CcKKbviCa6lsWU4NrjgHk',
                         ordrin.TEST)


def get_cheapest_food(addr, city, zip_code):
    #gives list of restaurant objects
    nb_list = ordrin_api.delivery_list('ASAP', addr, city, zip_code)

    #random restaurant index
    rand_restaurant_index = random.randint(0, len(nb_list) - 1)

    #gets restaurant details for restaurant id
    rand_restaurant = ordrin_api.restaurant_details(
        str(nb_list[rand_restaurant_index]['id']))
    menu = rand_restaurant['menu']
    rid = rand_restaurant['restaurant_id']
    print 'Restaurant name: ' + rand_restaurant['name']

    #list that wlil contain all the food items
    food_list = []

    for menu_item in menu:
        if menu_item['is_orderable'] == 1:
            for child in menu_item['children']:
                if child['is_orderable'] == 1:
                    if not child['price'] == '0.00':
                        food_list.append(child)
예제 #9
0
import ordrin
import urllib2

ordrin_api = ordrin.APIs("SvMY8WkSk78OHhgYSs55FVkUev7FOrdtEXF_1bExeUc", ordrin.TEST)

data = ordrin_api.delivery_list("ASAP", "715 Techwood Drive", "Atlanta", "30332")

name_list = []
id_list = []

for index in range(len(data)):
    id_list.append(data[index]['id'])
    name_list.append(data[index]['na'])

for i in range(len(id_list)):
    string_id = str(id_list[i])
    print(string_id)
    details = ordrin_api.restaurant_details(string_id)

yummly_info = urllib2.urlopen("http://api.yummly.com/v1/api/recipes?_app_id=69189240&_app_key=9e160e5cce7ff68eab06dc8b9b99de71&param[]=pizza").read()
print(yummly_info)
예제 #10
0
    time.sleep(10) 

def placeOrder(tray):
    rez = False
    GPIO.output(DELIVERING_LED, False)        
    try:
        print "yo it's order time"
        print "TRAY: %s RESTAURANT_ID: %s" %(tray, RESTAURANT_ID) 
        stuff = oapi.order_user(rid = RESTAURANT_ID, tray = tray, tip =  "3.00", first_name = FIRST_NAME,
                                last_name = LAST_NAME, email = EMAIL,
                                current_password = CURRENT_PASSWORD,
                                nick = ADDR_NICK, card_nick = CARD_NICK , delivery_date = "ASAP") 
        print stuff        
        if stuff["msg"] == "Success":
            print "yo you a winner."
            rez = True            
    except requests.ConnectionError:
        print "Oh snap, bad connection"
        CONNECTION_GOOD = False
    except Exception, val:
        print "Giant fail: %s val: %s" %(Exception, val)
    return rez

if __name__ == "__main__":
    oapi = ordrin.APIs(PRIVATE_KEY, ordrin.TEST)

    t = threading.Thread(target=deliveryCheckThread, args = ())
    u = threading.Thread(target=checkInputs, args = ())
    t.start()
    u.start()   
예제 #11
0
from flask import Flask, render_template, request, json
from key import  ordrin_secret
from pymongo import MongoClient
import ordrin

app = Flask(__name__) 
ordrin_api = ordrin.APIs(ordrin_secret, ordrin.TEST)
client = MongoClient()
db = client['ordrin']
user_collection = db['users']
 
@app.route("/") 
def home(): 
	return render_template('index.html', list=[0,1,2,3,4,5]) 

@app.route("/confirm", methods=['post'])
def confirm():
	ordrin_api.create_account(request.form['email'], "password", request.form['first_name'], request.form['last_name'])
	
	ordrin_api.create_addr(request.form['email'], "address", request.form['billing_phone_number'], request.form['zip'], 
			request.form['street'], request.form['city'], request.form['state'], "password", addr2=None)
	
	ordrin_api.create_cc(request.form['email'], "card", request.form['credit_card'], request.form['cvc'], 
			request.form['expiration_month'] + "/" + request.form['expiration_year'], request.form['billing_street'], 
			request.form['billing_city'], request.form['billing_state'], request.form['billing_zip'], 
			request.form['billing_phone_number'], "password", bill_addr2=None)
    
    user_collection.insert({"twitter": request.form['twitter'], "email": request.form['email']})	
	return render_template('confirm.html')

if __name__ == "__main__": 
예제 #12
0
from flask import Flask, render_template, request
import ordrin
from decimal import *

app = Flask(__name__)
api_key = '-HgyKdNLalGrm_T0x3ABYN2ABtCGOlqBzxK1xDy391s'
ordrin_api = ordrin.APIs(api_key, ordrin.TEST)

street_address = ''
city = ''
state = ''
zipcode = ''
choice_id = ''
total = ''


@app.route('/')
def home():
    #nothing here, just a continue button
    return render_template('index.html')


@app.route('/address')
def address():
    #Get STREET, CITY, STATE, ZIP, EMAIL, PHONE number, FIRSTNAME, LASTNAME; send onward
    return render_template('address.html')


@app.route('/restaurants', methods=['POST'])
def list():
    #Use ADDRESS to send ordrin request to get list of all restaurants that deliver to that addr