-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
28 lines (22 loc) · 817 Bytes
/
Copy pathexample.py
File metadata and controls
28 lines (22 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
example.py — Log in to Netspend and print recent transactions.
"""
import getpass
from netspend import NetspendClient, login, OOBARequired, verify_ooba
username = input("Netspend username (email): ").strip()
password = getpass.getpass("Password: ")
print("Logging in...")
try:
token = login(username, password)
except OOBARequired as e:
code = input("Enter the one-time code from your phone/email: ").strip()
token = verify_ooba(e.partial_token, code)
client = NetspendClient(token)
txns = client.get_transactions(months_back=2)
for t in txns:
sign = "+" if t["credit"] else "-"
flag = " [pending]" if t["pending"] else ""
print(
f"{t['ts'][:10]} {sign}${abs(t['amount']):.2f} bal=${t['balance']:.2f} {t['memo']}{flag}"
)
print(f"\n{len(txns)} transactions total.")