All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.robrua.orianna.api.dto.TeamAPI Maven / Gradle / Ivy

There is a newer version: 2.4.5
Show newest version
package com.robrua.orianna.api.dto;

import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.robrua.orianna.api.Utils;
import com.robrua.orianna.type.dto.team.Team;

public abstract class TeamAPI {
    /**
     * @param IDs
     *            the IDs of the teams
     * @return the teams
     * @see Riot
     *      API Specification
     */
    public static Map getTeamsByID(final List IDs) {
        if(IDs.size() > 10) {
            throw new IllegalArgumentException("Can only get up to 10 teams at a time!");
        }

        final String request = BaseRiotAPI.API_VERSIONS.get("team") + "/team/" + Utils.getIDString(IDs);
        final Type type = new TypeToken>() {}.getType();
        return BaseRiotAPI.GSON.fromJson(BaseRiotAPI.get(request, null, false), type);
    }

    /**
     * @param IDs
     *            the IDs of the teams
     * @return the teams
     * @see Riot
     *      API Specification
     */
    public static Map getTeamsByID(final String... IDs) {
        return getTeamsByID(Arrays.asList(IDs));
    }

    /**
     * @param summonerIDs
     *            the IDs of the summoners to get teams for
     * @return the summoners' teams
     * @see Riot
     *      API Specification
     */
    public static Map> getTeamsBySummoner(final List summonerIDs) {
        if(summonerIDs.size() > 10) {
            throw new IllegalArgumentException("Can only get teams for up to 10 summoners at a time!");
        }

        final String request = BaseRiotAPI.API_VERSIONS.get("team") + "/team/by-summoner/" + Utils.getIDString(summonerIDs);
        final Type type = new TypeToken>>() {}.getType();
        return BaseRiotAPI.GSON.fromJson(BaseRiotAPI.get(request, null, false), type);
    }

    /**
     * @param summonerIDs
     *            the IDs of the summoners to get teams for
     * @return the summoners' teams
     * @see Riot
     *      API Specification
     */
    public static Map> getTeamsBySummoner(final long... summonerIDs) {
        return getTeamsBySummoner(Utils.convert(summonerIDs));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy