コード例 #1
0
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)}
コード例 #2
0
    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
コード例 #3
0
    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
コード例 #4
0
ファイル: withdraw.py プロジェクト: shasui2/banking-api
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)}
コード例 #5
0
ファイル: transactions.py プロジェクト: shasui2/banking-api
def handler(event, context):
    return {"statusCode": 200, "body": json.dumps(DBHelper.get_transactions())}
コード例 #6
0
 def get(self):
     return {'balance': DBHelper.get_balance()}
コード例 #7
0
 def get(self):
     return DBHelper.get_transactions()
コード例 #8
0
ファイル: account.py プロジェクト: shasui2/banking-api
def handler(event, context):
    return {
        "statusCode": 200,
        "body": json.dumps({'balance': DBHelper.get_balance()})
    }