def getAccountByName(name):
    d = dbcalls.fetchAccountByName(name)
    if (not d):  #if d is empty, make the apiCall
        d = makeApiCall(
            "https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/"
            + name + getApiKey())
        if (not "puuid" in d):
            acc = dbcalls.fetchAccountByName(name)
            if (acc):
                d = getAccountByPuuid(acc["puuid"])
                print("name change found! From " + (str)(acc["name"]) +
                      " to " + (str)(d["name"]))
                dbcalls.updateAccountName(name, d["puuid"])
        else:
            acc = dbcalls.fetchAccountByPuuid(
                d["puuid"])  #check for a potential name change
            if (acc):  #if acc is not empty, that means the user name changed
                if (not acc["name"] == d["name"]):
                    print("name change found! From " + (str)(acc["name"]) +
                          " to " + (str)(d["name"]))
                    dbcalls.updateAccountName(name, d["puuid"])
                d = dbcalls.fetchAccountByPuuid(d["puuid"])
            else:
                dbcalls.addAccountToDB(
                    d
                )  #store all the information for this account so we can store its history
    return d
def getAccountBySummId(summId):
    d = dbcalls.fetchAccountBySummId(summId)
    if (not d):  #if d is empty, make the apiCall
        d = makeApiCall(
            "https://na1.api.riotgames.com/lol/summoner/v4/summoners/" +
            summId + getApiKey())
        dbcalls.addAccountToDB(
            d
        )  #store all the information for this account so we can store it's history
    return d
def getAccountByPuuid(puuid):
    d = dbcalls.fetchAccountByPuuid(puuid)
    if (not d):  #if d is empty, make the apiCall
        puuid = "7yf54vYl811FxFsoKKV7FIv_09Vvzpf2P8ewOMbx3XX0Em1wOS530xH6chxwgdIcmzB3BvTvH4FfoA"
        d = makeApiCall(
            "https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-puuid/"
            + puuid + getApiKey())
        dbcalls.addAccountToDB(
            d
        )  #store all the information for this account so we can store it's history
    return d