예제 #1
0
def get_business_reviews(business_id):
    """
        Business reviews
    """
    if business_id in [business['id'] for business in Store.businesses]:
        if business_id in Store.reviews:
            reviews = Store.reviews[business_id]
            business = Business.get_business(
                business_id)  # Get business details
            response = jsonify({
                'status': 'ok',
                'message': str(len(reviews)) + " reviews found",
                'business': business,
                'reviews': reviews
            })
            response.status_code = 200
            return response
        response = jsonify({
            'status': 'ok',
            'message': "No business review yet"
        })
        response.status_code = 204
        return response
    response = jsonify({
        'status': 'error',
        'message': "This business doesn't exist"
    })
    response.status_code = 400
    return response
예제 #2
0
def get_business(business_id):
    """
        Get business
    """
    if business_id in [business['id'] for business in Store.businesses]:
        business = Business.get_business(
            business_id)  # Get business details
        response = jsonify({
            'status': 'ok',
            'message': 'Business found',
            'business': business,
        })
        response.status_code = 200
        return response
    response = jsonify({
        'status': 'error',
        'message': "Business not found"
    })
    response.status_code = 400
    return response