Ejemplo n.º 1
0
def clear_wishlist(cust_id, wishlist_id):
    # """ Clear the contents of the wishlist with the given id"""
    """
    Clear all products of a Wishlist
    This endpoint will clear all products of a Wishlist based on the customer id and Wishlist id specified in the path
    ---
    tags:
      - Wishlists
    parameters:
      - name: cust_id
        in: path
        description: ID of customer who wants to view his/her wishlist
        required: true
        type: integer
      - name: wishlist_id
        in: path
        description: ID of wishlist to be retrieved
        required: true
        type: integer
    responses:
      200:
        description: Wishlist cleared
        schema:
          id: Wishlist
          properties:
            Customer ID:
              type: integer
              description: ID of customer
            Wishlist:
              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 (either customer ID or wishlist ID is not valid, no record found)
    """
    if Customer.check_custid(cust_id):
        message = Customer.find_by_id(cust_id, wishlist_id)
        if message:
            res = Customer.clear_list(cust_id, wishlist_id)
            return make_response(jsonify(message), status.HTTP_200_OK)
        else:
            message = {'Error': 'Wishlist with the given ID not found'}
            return make_response(jsonify(message), status.HTTP_404_NOT_FOUND)
    else:
        message = {'Invalid': 'Invalid customer ID'}
        return make_response(jsonify(message), status.HTTP_404_NOT_FOUND)