Ejemplo n.º 1
0
def auth_complete():
    http = util.init_http_api(session)

    req = {"code": request.args.get("code")}

    j = http.post("v1/authentication/tokens", json=req).json()
    return complete_login(j)
Ejemplo n.º 2
0
def get_categorization(accounts, transactions):
    body = {"accounts": []}

    counter = 0
    while counter < len(accounts):
        new_account = {
            "account": accounts[counter],
            "transactions": transactions[counter]
        }
        body.get("accounts").append(new_account)
        counter = counter + 1
    http = util.init_http_api(session)
    return http.post("v2/category-sets/DK/categorize", json=body).json()
Ejemplo n.º 3
0
def auth_unattended():

    if request.method == "POST":
        http = util.init_http_api(session)

        req = {
            "userHash": config.USERHASH,
            "loginToken": request.form["loginToken"],
        }

        j = http.post("v1/authentication/unattended", json=req).json()
        return complete_login(j)

    return render_template("login_with_token.html")
Ejemplo n.º 4
0
def auth_init():
    http = util.init_http_api(session)

    req = {
        "userHash": config.USERHASH,
        "redirectUrl": "http://localhost:5000/auth/complete",
        "language": "en",
    }

    j = http.post("v1/authentication/initialize", json=req).json()
    if "authUrl" not in j:
        session.errorMessage = "Authentication failed. Check you credentials in config.py"
        return render_template("error.html")
    return redirect(j["authUrl"])
Ejemplo n.º 5
0
def query_transactions(account_id):
    http = util.init_http_api(session)
    url = "v2/accounts/%s/transactions" % account_id

    query_params = {}

    if config.INCLUDE_TRANSACTION_DETAILS is True:
        query_params["withDetails"] = "true"

    pagingtoken = request.args.get('pagingToken')
    if pagingtoken is not None:
        query_params["pagingtoken"] = pagingtoken

    encoded_params = build_query_string(query_params)
    url = url + encoded_params

    j = http.get(url).json()
    return jsonify(j)
Ejemplo n.º 6
0
def get_transactions(account_id, pagingtoken, from_date):
    http = util.init_http_api(session)
    url = "v2/accounts/%s/transactions" % account_id

    query_params = {}

    if config.INCLUDE_TRANSACTION_DETAILS is True:
        query_params["withDetails"] = "true"

    if pagingtoken is not None:
        query_params["pagingtoken"] = pagingtoken

    if from_date is not None:
        query_params["fromDate"] = from_date

    encoded_params = build_query_string(query_params)
    url = url + encoded_params

    return http.get(url).json()
Ejemplo n.º 7
0
def get_accounts():
    http = util.init_http_api(session)
    return http.get("v2/accounts").json()
Ejemplo n.º 8
0
def get_categories():
    http = util.init_http_api(session)
    return http.get("v2/category-sets/DK/categories").json()
Ejemplo n.º 9
0
def query_accounts():
    http = util.init_http_api(session)
    j = http.get("v2/accounts").json()
    return jsonify(j)