def handler(event, context): amount = json.loads(event['body']) new_balance = DBHelper.update_balance(amount["amount"], credit=True) transaction = DBHelper.deposit(credit=amount["amount"], balance=new_balance) print("Transaction: {0}".format(transaction)) return {"statusCode": 200, "body": json.dumps(transaction)}
def post(self): amount = Deposit.parser.parse_args() new_balance = DBHelper.update_balance(amount["amount"], credit=True) transaction = DBHelper.deposit(credit=amount["amount"], balance=new_balance) return transaction
def post(self): amount = Withdraw.parser.parse_args() new_balance = DBHelper.update_balance(amount["amount"], credit=False) if not new_balance: return { 'error': 'Cannot perform withdrawal. Balance would be below 0.' }, 403 else: transaction = DBHelper.withdraw(debit=amount["amount"], balance=new_balance) return transaction
def handler(event, context): print("Event: {0}".format(json.loads(event['body']))) amount = json.loads(event['body']) new_balance = DBHelper.update_balance(amount["amount"], credit=False) if not new_balance: return { "statusCode": 403, "body": json.dumps({ 'error': 'Cannot perform withdrawal. Balance would be below 0.' }) } else: transaction = DBHelper.withdraw(debit=amount["amount"], balance=new_balance) return {"statusCode": 200, "body": json.dumps(transaction)}
def handler(event, context): return {"statusCode": 200, "body": json.dumps(DBHelper.get_transactions())}
def get(self): return {'balance': DBHelper.get_balance()}
def get(self): return DBHelper.get_transactions()
def handler(event, context): return { "statusCode": 200, "body": json.dumps({'balance': DBHelper.get_balance()}) }