-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathlist_callbacks.py
57 lines (45 loc) · 1.46 KB
/
list_callbacks.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import json
import sys
from lib import bunq
from lib import bunq_api
from lib.config import config
config.load()
def print_notification_filter(nfs):
if not nfs:
print(" No callbacks")
return
for nfi in nfs:
nf = nfi["NotificationFilterUrl"]
print(' {} -> {}'.format(
nf["category"],
nf.get("notification_target", "-")))
def process_account(u, ac):
if ac["status"] != "ACTIVE":
return
print("Callbacks for account {} ({}):".format(
ac["id"], ac["description"]))
method = ("v1/user/{}/monetary-account/{}/" +
"notification-filter-url").format(u["id"], ac["id"])
nfs = bunq.get(method)
print_notification_filter(nfs)
def process_user(k, u):
if k == "UserApiKey":
#x = print(next(iter(v["requested_by_user"].values())))
#print(x)
#name = x["display_name"]
name = next(iter(v["requested_by_user"].values()))["display_name"]
else:
name = u["display_name"]
print(f"Callbacks for user {name}:")
method = "v1/user/{}/notification-filter-url".format(u["id"])
nfs = bunq.get(method)
print_notification_filter(nfs)
method = "v1/user/{}/monetary-account".format(u["id"])
for acs in bunq.get(method):
for ac in acs.values():
process_account(u, ac)
method = "v1/user"
users = bunq.get(method)
for u in users:
for k, v in u.items():
process_user(k, v)