Ejemplo n.º 1
0
def display_all_wishlists():
    # """ Display wishlists of all customers if created"""
    """
    Retrieve a list of Wishlists of all customers
    This endpoint will return all Wishlists of all customers
    ---
    tags:
      - Wishlists
    description: The Wishlists endpoint allows you to query all Wishlists of all customers
    responses:
      200:
        description: All Wishlists retrieved
        schema:
          id: Wishlist
          properties:
            Customer ID:
              type: integer
              description: ID of customer
            Wishlist:
              type: array
              items:
                type: object
                properties:
                  wishlist name:
                    type: string
                    description: the Wishlists's name
                  Product list:
                    type: array
                    items:
                      type: string
                    description: the list of products in a Wishlist
      404:
        description: Not Found (No wishlist created for any customer)
    """
    if Customer.display_all():
        message = [Customer.find_by_custid(k) for k in Customer.redis.keys()]
        return make_response(jsonify(message), status.HTTP_200_OK)
    else:
        message = {'Error': 'No wishlist created for any customer'}
        return make_response(jsonify(message), status.HTTP_404_NOT_FOUND)