Beispiel #1
0
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})
Beispiel #2
0
def useCoupon():
    error = False
    id = request.json['id']
    new = Coupon()
    new.id = id
    try:
        new.get()
        new.use()
    except (Exception) as err:
        error = True
        return handleError(err)
    finally:
        if not (error):
            return jsonify({'result': 'success'})