Example #1
0
def leaderboards(apikey):
    username = model.api_authenticate(apikey)
    lb = model.leaderboard(username)
    if not username:
        return jsonify({'error': 'could not authenticate'})
    if not lb:
        return jsonify({'error': 'No leaderboards yet...'})
    return jsonify({'leaderboards': lb})
Example #2
0
def get_balance(apikey):
    user_name = model.api_authenticate(apikey)
    if not user_name:
        return (jsonify({"error": "count not authenticate"}))
    return jsonify({
        "username": user_name,
        "balance": model.get_balance(user_name)
    })
Example #3
0
def current_balance(apikey):
    username = model.api_authenticate(apikey)
    if not username:
        return jsonify({'error': 'could not authenticate'})
    return jsonify({
        'username': username,
        'balance': model.current_balance(username)
    })
    return ('API Trader')
Example #4
0
def lookup(apikey, company_name):
    username = model.api_authenticate(apikey)
    if not username:
        return jsonify({'error': 'could not authenticate'})
    return jsonify({
        'Username': username,
        'balance': model.current_balance(username),
        'Results': model.get_lookup(company_name)
    })
Example #5
0
def get_quote(apikey):
    if not request.json or not 'Ticker' in request.json:
        abort(400)
    if not isinstance(request.json['Ticker'], (str)):
        abort(400)
    user_name = model.api_authenticate(apikey)

    if not user_name:
        return (jsonify({"error": "count not authenticate"}))
    ticker = request.json['Ticker']
    return jsonify({"Ticker": ticker, "price": model.quote(ticker)})
Example #6
0
def get_lookup(apikey):
    if not request.json or not 'Company' in request.json:
        abort(400)
    if not isinstance(request.json['Company'], (str)):
        abort(400)

    user_name = model.api_authenticate(apikey)
    if not user_name:
        return (jsonify({"error": "count not authenticate"}))

    company = request.json['Company']
    return jsonify({"Ticker": model.lookup(company)})
Example #7
0
def get_buy(apikey):
    if not request.json or not 'Ticker' and 'Shares' in request.json:
        abort(400)
    if not isinstance(request.json['Ticker'], (str)):
        abort(400)
    if not isinstance(request.json['Shares'], (int)):
        abort(400)
    user_name = model.api_authenticate(apikey)
    if not user_name:
        return (jsonify({"error": "count not authenticate"}))
    ticker = request.json['Ticker']
    shares = request.json['Shares']
    return jsonify(model.buy(ticker, shares, user_name))
Example #8
0
def get_deposit(apikey):
    if not request.json or not 'Deposit' in request.json:
        abort(400)
    if not isinstance(request.json['Deposit'], (float, int)):
        abort(400)
    user_name = model.api_authenticate(apikey)
    if not user_name:
        return (jsonify({"error": "count not authenticate"}))
    money = request.json['Deposit']
    model.deposit(user_name, money)
    return jsonify({
        "username": user_name,
        "Deposit": money,
        "Balance": model.get_balance(user_name)
    })
Example #9
0
def get_holdings(apikey):
    user_name = model.api_authenticate(apikey)
    if not user_name:
        return (jsonify({"error": "count not authenticate"}))

    return jsonify(model.print_holdings(user_name))
Example #10
0
def get_dashboard(apikey):
    user_name = model.api_authenticate(apikey)
    if not user_name:
        return (jsonify({"error": "count not authenticate"}))
    return jsonify(model.dashboard(user_name))
def api_authenticate(apikey):
    row = m.api_authenticate(apikey)
    if row is None:
        return None, None
    else:
        return row