def search_food_items_by_cuisine_type(cuisine_type):
    zatiq_food_items = ZatiqUsersMongoDBClient()
    jsonData = request.get_json()
    print(jsonData)
    if 'api_token' not in jsonData:
        return {"error": "Error! No api_token in request.body"}
    else:
        api_token = jsonData['api_token']
    cuisine_type = cuisine_type.replace(' ', '_').lower()
    if cuisine_type in timely_meals:
        zatiq_food_items = ZatiqFoodItemsMongoDBClient()
        response = zatiq_food_items.get_food_items_by_time_of_day(
            api_token, cuisine_type)
        return (jsonify(food_items=response))
    elif cuisine_type in cuisine_types:
        zatiq_food_items = ZatiqFoodItemsMongoDBClient()
        response = zatiq_food_items.get_food_items_by_cuisine_type(
            api_token, cuisine_type)
        return (jsonify(food_items=response))
    elif cuisine_type in buttons:
        zatiq_food_items = ZatiqFoodItemsMongoDBClient()
        response = zatiq_food_items.get_food_items_by_button(
            api_token, cuisine_type)
        return (jsonify(food_items=response))
    else:
        return {"error": "Error! Could not find that category"}
Exemple #2
0
def get_food_grid():
    if request.method == 'POST':
        zatiq_food_items = ZatiqFoodItemsMongoDBClient()
        jsonData = request.get_json()
        api_token = jsonData['api_token']
        response = zatiq_food_items.find_food_grid(api_token)
        return (jsonify(food_items=response))
def edit_food_item():
    if request.method == 'POST':
        zatiq_food_items = ZatiqFoodItemsMongoDBClient()
        jsonData = request.get_json()
        food_item_id = jsonData['food_item_id']
        api_token = jsonData['api_token']
        image = jsonData['image']
        logging.debug(image)
        overview = jsonData['overview']
        item_name = jsonData['item_name']
        tags = jsonData['tags']
        meat = jsonData['meat']
        seafood = jsonData['seafood']
        calories = jsonData['calories']
        meal_type = jsonData['meal_type']
        item_price = jsonData['item_price']
        if len(image) < 100:
            response = zatiq_food_items.update_food_item_without_image(
                api_token, food_item_id, overview, item_name, meal_type, tags,
                item_price, meat, seafood, calories)
        else:
            response = zatiq_food_items.update_food_item_with_image(
                api_token, food_item_id, image, overview, item_name, meal_type,
                tags, item_price, meat, seafood, calories)
        return (jsonify(response=response[0], food_item_id=response[1]))
def get_food_item_by_id():
    if request.method == 'POST':
        zatiq_food_items = ZatiqFoodItemsMongoDBClient()
        jsonData = request.get_json()
        food_item_id = jsonData['food_item_id']
        food_item = zatiq_food_items.get_food_by_id(food_item_id)
        return (jsonify(food_item=food_item))
Exemple #5
0
def get_food_grid_by_name():
    if request.method == 'POST':
        zatiq_food_items = ZatiqFoodItemsMongoDBClient()
        jsonData = request.get_json()
        api_token = jsonData['api_token']
        text = jsonData['text']
        response = zatiq_food_items.find_food_grid_by_name(api_token, text)
        return (jsonify(response=response))
Exemple #6
0
def delete_food_item():
    if request.method == 'POST':
        zatiq_food_items = ZatiqFoodItemsMongoDBClient()
        jsonData = request.get_json()
        food_item_id = jsonData['food_item_id']
        api_token = jsonData['api_token']
        response = zatiq_food_items.delete_food_item(api_token, food_item_id)
        return (jsonify(response=response))
Exemple #7
0
def get_food_items_by_restaurant_id():
    if request.method == 'POST':
        zatiq_food_items = ZatiqFoodItemsMongoDBClient()
        jsonData = request.get_json()
        api_token = jsonData['api_token']
        if 'restaurant_id' in jsonData:
            restaurant_id = jsonData['restaurant_id']
        else:
            restaurant_id = None
        food_items = zatiq_food_items.get_food_items_by_restaurant_id(
            api_token, restaurant_id)
        return (jsonify(food_items=food_items))
Exemple #8
0
def add_food_item_as_business():
    if request.method == 'POST':
        zatiq_food_items = ZatiqFoodItemsMongoDBClient()
        jsonData = request.get_json()
        api_token = jsonData['api_token']
        image = jsonData['image']
        overview = jsonData['overview']
        item_name = jsonData['item_name']
        tags = jsonData['tags']
        meat = jsonData['meat']
        seafood = jsonData['seafood']
        meal_type = jsonData['meal_type']
        item_price = jsonData['item_price']
        response = zatiq_food_items.add_food_item(image, overview, item_name,
                                                  api_token, meal_type, tags,
                                                  item_price, meat, seafood)
        return (jsonify(response=response))
Exemple #9
0
def edit_food_item():
    if request.method == 'POST':
        zatiq_food_items = ZatiqFoodItemsMongoDBClient()
        jsonData = request.get_json()
        food_item_id = jsonData['food_item_id']
        api_token = jsonData['api_token']
        image = jsonData['image']
        overview = jsonData['overview']
        item_name = jsonData['item_name']
        tags = jsonData['tags']
        meat = jsonData['meat']
        seafood = jsonData['seafood']
        meal_type = jsonData['meal_type']
        item_price = jsonData['item_price']
        response = zatiq_food_items.update_food_item(api_token, food_item_id,
                                                     image, overview,
                                                     item_name, meal_type,
                                                     tags, item_price, meat,
                                                     seafood)
        return (jsonify(response=response[0], food_item_id=response[1]))
Exemple #10
0
def search_food_items_by_cuisine_type(cuisine_type):
    if request.method == 'POST':
        zatiq_food_items = ZatiqUsersMongoDBClient()
        jsonData = request.get_json()
        api_token = jsonData['api_token']
        cuisine_type = cuisine_type.replace(' ', '_').lower()
        if cuisine_type in timely_meals:
            zatiq_food_items = ZatiqFoodItemsMongoDBClient()
            response = zatiq_food_items.get_food_items_by_time_of_day(
                api_token, cuisine_type)
            return (jsonify(food_items=response))
        elif cuisine_type in cuisine_types:
            zatiq_food_items = ZatiqFoodItemsMongoDBClient()
            response = zatiq_food_items.get_food_items_by_cuisine_type(
                api_token, cuisine_type)
            return (jsonify(food_items=response))
        elif cuisine_type in buttons:
            zatiq_food_items = ZatiqFoodItemsMongoDBClient()
            response = zatiq_food_items.get_food_items_by_button(
                api_token, cuisine_type)
            return (jsonify(food_items=response))
        else:
            return ('Could not find that category')