Пример #1
0
def get_nearby_restaurants():
    if request.method == 'POST':
        zatiq_restaurants = ZatiqUsersMongoDBClient()
        jsonData = request.get_json()
        api_token = jsonData['api_token']
        response = zatiq_restaurants.get_nearby_restaurants(api_token)
        return (jsonify(response=response))
Пример #2
0
def get_restaurant_interior():
    if request.method == 'POST':
        zatiq_users = ZatiqUsersMongoDBClient()
        jsonData = request.get_json()
        restaurant_id = jsonData['restaurant_id']
        response = zatiq_users.get_interior_pictures(restaurant_id)
        return (jsonify(response=response))
Пример #3
0
def get_restaurant_by_name():
    if request.method == 'POST':
        zatiq_users = ZatiqUsersMongoDBClient()
        jsonData = request.get_json()
        api_token = jsonData['api_token']
        text = jsonData['text']
        response = zatiq_users.get_restaurant_by_name(api_token, text)
        return (jsonify(response=response))
Пример #4
0
def get_restaurant_menu():
    if request.method == 'POST':
        zatiq_users = ZatiqUsersMongoDBClient()
        jsonData = request.get_json()
        api_token = jsonData['api_token']
        restaurant_id = jsonData['restaurant_id']
        response = zatiq_users.get_menu_pictures(api_token, restaurant_id)
        return (jsonify(response=response))
Пример #5
0
def update_user_preferences():
    if request.method == 'POST':
        zatiq_users = ZatiqUsersMongoDBClient()
        jsonData = request.get_json()
        api_token = jsonData['api_token']
        user_preferences = jsonData['preferences']
        response = zatiq_users.update_user_preferences(api_token,
                                                       user_preferences)
        return (jsonify(user_email=response[0],
                        auth_token=response[1],
                        user_name=response[2],
                        preferences=response[3]))
Пример #6
0
def login_as_user():
    if request.method == 'POST':
        zatiq_users = ZatiqUsersMongoDBClient()
        jsonData = request.get_json()
        user_auth_token = jsonData['accessToken']
        user_email = jsonData['email']
        login_method = jsonData['method']
        response = zatiq_users.user_register(user_auth_token, login_method,
                                             user_email)
        return (jsonify(user_name=response[0],
                        user_email=response[1],
                        api_token=response[2]))
Пример #7
0
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"}
Пример #8
0
def get_user_profile():
    if request.method == 'POST':
        zatiq_users = ZatiqUsersMongoDBClient()
        jsonData = request.get_json()
        api_token = jsonData['api_token']
        response = zatiq_users.get_user_profile(api_token)
        if len(response) == 4:
            return (jsonify(user_email=response[0],
                            auth_token=response[1],
                            user_name=response[2],
                            preferences=response[3]))
        elif len(response) == 3:
            return (jsonify(user_email=response[0],
                            user_name=response[1],
                            preferences=response[2]))
        else:
            return (jsonify(response=response))
Пример #9
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')