Пример #1
0
def get_characters():
    user = User.query.filter_by(
        bungieMembershipId=g.user.bungieMembershipId).first()
    my_api = BungieApi(user)

    get_account_res = my_api.GetCurrentBungieAccount()

    # Take values from request args- or default to stored values:
    membershipId = str(
        request.args.get(
            'membershipId',
            str(get_account_res["Response"]["destinyMemberships"][0]
                ["membershipId"])))
    membershipType = str(
        request.args.get(
            'membershipType',
            str(get_account_res["Response"]["destinyMemberships"][0]
                ["membershipType"])))

    get_characters_res = my_api.get_profile(membershipType, membershipId)

    if get_characters_res["ErrorStatus"] != "Success":
        flash(
            f"Bungies systems are down: {get_characters_res.get('message', {}).get('Message', {})}",
            "error")
        return redirect(url_for("public.home"))

    character_details = get_character_details_json(get_characters_res)

    return jsonify(character_details)
Пример #2
0
def get_profile():
    user = User.query.filter_by(
        bungieMembershipId=g.user.bungieMembershipId).first()
    my_api = BungieApi(user)

    # TODO: Hardcoded values:
    # Take values from here: GetCurrentBungieAccount
    get_account_res = my_api.GetCurrentBungieAccount()

    membershipId = int(
        request.args.get(
            'membershipId',
            str(get_account_res["Response"]["destinyMemberships"][0]
                ["membershipId"])))
    membershipType = int(
        request.args.get(
            'membershipType',
            str(get_account_res["Response"]["destinyMemberships"][0]
                ["membershipType"])))

    # print(type(get_account_res))
    # print(get_account_res.json())
    membershipId = str(
        get_account_res["Response"]["destinyMemberships"][0]["membershipId"])
    membershipType = str(
        get_account_res["Response"]["destinyMemberships"][0]["membershipType"])
    get_profile_res = my_api.get_profile(membershipType, membershipId)

    return jsonify(get_profile_res)
Пример #3
0
def get_current_bungie_account():
    print("get_current_bungie_account")
    user = User.query.filter_by(
        bungieMembershipId=g.user.bungieMembershipId).first()

    my_api = BungieApi(user)
    activity = my_api.GetCurrentBungieAccount()

    return jsonify(activity)
Пример #4
0
def get_activity():
    user = User.query.filter_by(
        bungieMembershipId=g.user.bungieMembershipId).first()
    my_api = BungieApi(user)
    # TODO: Hardcoded values:
    # Take values from here: GetCurrentBungieAccount
    activity = my_api.GetCurrentBungieAccount()
    # get_profile_res = my_api.get_activity_history(membershipType, membershipId)
    # activity = my_api.get_activity_history("2", "4611686018436136301", "2305843009260647150", mode=5, count=3)

    return jsonify(activity)
Пример #5
0
def character_select():
    user = User.query.filter_by(
        bungieMembershipId=g.user.bungieMembershipId).first()
    my_api = BungieApi(user)

    get_account_res = my_api.GetCurrentBungieAccount()
    # print(type(get_account_res))
    # print(get_account_res.json())
    # membershipId    = str(get_account_res.json()["Response"]["destinyMemberships"][0]["membershipId"])
    # membershipType  = str(get_account_res.json()["Response"]["destinyMemberships"][0]["membershipType"])
    # get_profile_res = my_api.get_profile(membershipType, membershipId)
    # # get_profile_res = my_api.character_select("2", "4611686018436136301")
    # character_details = get_character_details_json(get_profile_res)

    # return(jsonify(get_profile_res))

    # return render_template("auth/choose_account.html")
    return render_template("auth/choose_focus.html")