Ejemplo n.º 1
0
def create_wishlist(cust_id):
    # """ create the wishlist with the provided id"""
    """
    Create a Wishlist
    This endpoint will create a Wishlist based on the customer id specified in the path
    ---
    tags:
      - Wishlists
    consumes:
      - application/json
    produces:
      - application/json
    parameters:
      - name: cust_id
        in: path
        description: ID of customer who wants to create his/her wishlist
        required: true
        type: integer
      - in: body
        name: body
        required: true
        schema:
          type: object
          required:
            - name
            - Product List
          properties:
            name:
              type: string
              description: name for the Wishlist
            Product List:
              type: array
              items:
                type: string
              description: the list of products in a Wishlist
    responses:
      201:
        description: Wishlist created
        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
      400:
        description: Bad Request (the posted data was not valid)
    """
    wishlist = Customer(cust_id, "", [])
    wishlist.deserialize(request.get_json())
    message = wishlist.save()

    location_url = url_for('create_wishlist', cust_id=wishlist.cust_id)
    return make_response(jsonify(message), status.HTTP_201_CREATED,
                         {'Location': location_url})