Example #1
0
def bundle_batch(session, grant, guids):
    # Validate the guids given
    if len(guids) == 0:
        raise ValueError("List of bundle GUIDs cannot be empty")
    for guid in guids:
        if not verify_guid(guid):
            raise ValueError("Invalid bundle GUID given")

    data = []
    # Perform a chunked request
    for chunk in chunks(guids, BATCH_LIMIT):
        # Retrieve a chunk and add the response to the data set
        data.extend(
            session.api_get(endpoints.bundle, grant=grant,
                            batch=chunk).json()["Result"])

    # Return data set
    return data
Example #2
0
def achievement_rewards_batch(session, grant, guids, countrycode=None):
    # Validate the guids given
    if len(guids) == 0:
        raise ValueError("List of achievement reward GUIDs cannot be empty")
    for guid in guids:
        if not verify_guid(guid):
            raise ValueError("Invalid achievement reward GUID given")

    data = []
    # Perform a chunked request
    for chunk in chunks(guids, BATCH_LIMIT):
        # Retrieve a chunk and add the response to the data set
        data.extend(
            session.api_get(endpoints.achievement_reward_batch,
                            grant=grant,
                            batch=chunk,
                            countrycode=countrycode).json()["Result"])

    # Return data set
    return data
Example #3
0
def user_stats_batch(session, grant, guids):
    # Validate the guids given
    if len(guids) == 0:
        raise ValueError("List of user GUIDs cannot be empty")
    for guid in guids:
        if not verify_guid(guid):
            raise ValueError("Invalid user GUID given")

    data = []
    # Perform a chunked request
    # BUG: API breaks at anything more than 100 users at a time
    for chunk in chunks(guids, 100):
        # Retrieve a chunk and add the response to the data set
        data.extend(
            session.api_get(endpoints.user_stat_batch,
                            grant=grant,
                            batch=chunk).json()["Result"])

    # Return data set
    return data