Beispiel #1
0
 def delete(order_id=None):
     """ Delte an order by order_id """
     if not order_id:
         return "Must specify an order_id"
     repository = OrderCommands()
     repository.delete(order_id=order_id)
     return {"order": {"order_id": order_id}}
Beispiel #2
0
 def put(order_id):
     """ Update an order based on the sent information """
     if not order_id:
         return "Must specify an order_id"
     json_data = request.get_json(force=True)
     items = OrderResource._get_items_data(items=json_data.get('items', []))
     total_price = OrderResource._get_total_price(items=items)
     repository = OrderCommands()
     order = repository.update(order_id=order_id,
                               items=items,
                               delivery=json_data.get('delivery', None),
                               total_price=total_price)
     return jsonify({"order": order.json})