def getPurchaseInfo(): error = False result = {} id = request.json['id'] purch = Purchase() purch.id = id try: purch.get() result['purchase'] = purch.json() ship = Shipping() ship.id = id ship.get() if (ship.id != None): result['shipping'] = ship.json() if (purch.id_coupon != None): coup = Coupon() coup.id = purch.id_coupon coup.get() result['coupon'] = coup.json() except (Exception) as err: error = True return handleError(err) finally: if not (error): return jsonify({'result': 'success', 'data': result})
def deleteCoupon(): error = False id = request.json['id'] new = Coupon() new.id = id try: new.delete() except (Exception) as err: error = True return handleError(err) finally: if not (error): return jsonify({'result': 'success'})
def getCoupon(): error = False id = request.json['id'] new = Coupon() new.id = id try: new.get() except (Exception) as err: error = True return handleError(err) finally: if not (error): result = new.json() return jsonify({'result': 'success', 'data': result})