Beispiel #1
0
def tags():
    account_id = helper.validate_request(request)
    if account_id:
        result = [tag[0] for tag in data.tags(account_id)]
        return jsonify({'result': result})

    return abort(400)
Beispiel #2
0
def create_budgets():
    budget_update_request = request.json
    account_id = helper.validate_request(request)
    if account_id:
        updated = manager.update_budgets(account_id, budget_update_request)
        return jsonify({'result': {'updated_count': updated}})
    return abort(400)
Beispiel #3
0
def create_category_rule():
    rule = request.json
    account_id = helper.validate_request(request)
    if account_id:
        data.create_category(account_id, rule['category'])
        updated = data.create_category_rule(account_id, rule)
        return jsonify({'result': {'updated_count': updated}})
    return abort(400)
Beispiel #4
0
def categories():
    account_id = helper.validate_request(request)

    if account_id:
        result = [category[0] for category in data.categories(account_id)]
        return jsonify({'result': result})

    return abort(400)
Beispiel #5
0
def plaid_accounts():
    account_id = helper.validate_request(request)

    if account_id:
        accounts_result = manager.get_plaid_accounts(account_id)
        return jsonify(accounts_result)

    return abort(400)
Beispiel #6
0
def clear_budgets():
    account_id = helper.validate_request(request)
    clear_request = request.json
    if account_id:
        updated = data.delete_budgets(account_id, clear_request['month'],
                                      clear_request['year'])
        return jsonify({'result': {'updated_count': updated}})
    return abort(400)
Beispiel #7
0
def transactions():
    month = request.args.get('month')
    account_id = helper.validate_request(request)

    if account_id:
        transaction_result = manager.get_transactions(account_id, month)
        return jsonify(transaction_result)

    return abort(400)
Beispiel #8
0
def create_plaid_accounts():
    public_token = request.json['publicToken']
    account_id = helper.validate_request(request)

    if account_id:
        accounts = manager.create_plaid_accounts(account_id, public_token)
        return jsonify({'result': accounts})

    return abort(400)
Beispiel #9
0
def annual_transactions():
    year = request.args.get('year')
    account_id = helper.validate_request(request)

    if account_id:
        transaction_result = manager.get_annual_transactions(account_id, year)
        return jsonify(transaction_result)

    return abort(400)
Beispiel #10
0
def create_tag_rule():
    rule = request.json
    account_id = helper.validate_request(request)

    if account_id:
        updated = data.create_tag_rule(account_id, rule)
        data.create_tag(account_id, rule['tag'])
        return jsonify({'result': {'updated_count': updated}})

    return abort(400)
Beispiel #11
0
def category_rules():
    account_id = helper.validate_request(request)
    if account_id:
        result = [{
            'target_type': rule[0],
            'target_value': rule[1],
            'category': rule[2]
        } for rule in data.category_rules(account_id)]
        return jsonify({'result': result})

    return abort(400)
Beispiel #12
0
def budgets():
    month = request.args.get('month')
    year = request.args.get('year')
    account_id = helper.validate_request(request)

    if account_id:
        result = [{
            'category_name': budget[0],
            'budget': budget[1],
        } for budget in manager.get_budgets(account_id, month, year)]
        return jsonify({'result': result})

    return abort(400)
Beispiel #13
0
def validate_account():
    account_id = helper.validate_request(request)
    response = jsonify({'result': account_id}) if account_id else abort(400)
    return response