示例#1
0
def lambda_handler(event, context):
    try:
        config.load()
        iban = get_iban_from_event(event)

        sync = Sync()
        sync.populate()
        if iban:
            result = sync.synchronize_iban(iban)
        else:
            result = sync.synchronize()
        add_callbacks(sync)
        return {"statusCode": 200, "body": result}
    except Exception as e:
        log.exception("Exception occurred")
        return {"statusCode": 500, "body": traceback.format_exc()}
示例#2
0
from lib import bunq_api
from lib.config import config

config.parser.add_argument(
    "bunq_user_name",
    nargs="?",
    help="Bunq user name (retrieve using 'python3 list_user.py')")
config.parser.add_argument(
    "bunq_account_name",
    nargs='?',
    help="Bunq account name (retrieve using 'python3 list_user.py')")
config.parser.add_argument(
    "toggle_url",
    nargs='?',
    help="URL to receive the callback (f.e. https://yourdomain.com:12345)")
config.load()

user_id = bunq_api.get_user_id(config.get("bunq_user_name"))
account_id = bunq_api.get_account_id(user_id, config.get("bunq_account_name"))
url = config.get("toggle_url")
nfs = bunq_api.get_notification_filters(user_id, account_id)
found = False
for nfi in nfs:
    cb = next(iter(nfi.values()))
    if (cb["category"] == "MUTATION" and cb["notification_target"] == url):
        found = True

if found:
    print("Removing toggle...")
    bunq_api.remove_callback(user_id, account_id, "bunq2ynab-toggle")
else: