Exemple #1
0
import argparse
from decimal import Decimal
import json
import sys
from cgi import parse_qs

import bunq
import db

bunq.set_log_level(0)


def process_account(row, user_id, account_id):
    result = ""
    method = ("v1/user/{0}/monetary-account/{1}/payment?count=24".format(
        user_id, account_id))
    payments = bunq.get(row, method)
    for v in [p["Payment"] for p in payments]:
        result += "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}\n".format(
            v["amount"]["value"], v["amount"]["currency"], v["created"][:16],
            v["type"], v["sub_type"], v["description"], v["alias"]["iban"],
            v["alias"]["display_name"], v["counterparty_alias"]["iban"],
            v["counterparty_alias"]["display_name"])
    return result


def process_user(row, user_id):
    result = ""
    method = 'v1/user/{0}/monetary-account'.format(user_id)
    for a in bunq.get(row, method):
        for k, v in a.items():
import argparse
import json
import sys

import bunq


parser = argparse.ArgumentParser()
parser.add_argument("-v", action="store_true",
    help="Show content of JSON messages")
parser.add_argument("-vv", action="store_true",
    help="Show JSON messages and HTTP headers")
args = parser.parse_args()
log_level = 2 if args.vv else 1 if args.v else 0
bunq.set_log_level(log_level)


def print_notification_filter(e):
    nfs = e["notification_filters"]
    if not nfs:
        print("  No callbacks")
        return
    for nf in nfs:
        print('  {0:35} {1:10} {2}'.format(
            nf["category"],
            nf["notification_delivery_method"],
            nf.get("notification_target", "-")))


users = bunq.get("v1/user")
for u in users: