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

com.robrua.orianna.api.dto.SummonerAPI 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.summoner.MasteryPages;
import com.robrua.orianna.type.dto.summoner.RunePages;
import com.robrua.orianna.type.dto.summoner.Summoner;

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

        final String request = BaseRiotAPI.API_VERSIONS.get("summoner") + "/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
     * @return the summoners
     * @see Riot
     *      API Specification
     */
    public static Map getSummonersByID(final long... summonerIDs) {
        return getSummonersByID(Utils.convert(summonerIDs));
    }

    /**
     * @param summonerNames
     *            the names of the summoners to get
     * @return the summoners
     * @see Riot
     *      API Specification
     */
    public static Map getSummonersByName(final List summonerNames) {
        if(summonerNames.size() > 40) {
            throw new IllegalArgumentException("Can only get up to 40 summoners at a time!");
        }

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

    /**
     * @param summonerNames
     *            the names of the summoners to get
     * @return the summoners
     * @see Riot
     *      API Specification
     */
    public static Map getSummonersByName(final String... summonerNames) {
        return getSummonersByName(Arrays.asList(summonerNames));
    }

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

        final String request = BaseRiotAPI.API_VERSIONS.get("summoner") + "/summoner/" + Utils.getIDString(summonerIDs) + "/masteries";
        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 masteries for
     * @return the summoners' masteries
     * @see Riot
     *      API Specification
     */
    public static Map getSummonersMasteries(final long... summonerIDs) {
        return getSummonersMasteries(Utils.convert(summonerIDs));
    }

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

        final String request = BaseRiotAPI.API_VERSIONS.get("summoner") + "/summoner/" + Utils.getIDString(summonerIDs) + "/name";
        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 names of
     * @return the summoners' names
     * @see Riot
     *      API Specification
     */
    public static Map getSummonersNames(final long... summonerIDs) {
        return getSummonersNames(Utils.convert(summonerIDs));
    }

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

        final String request = BaseRiotAPI.API_VERSIONS.get("summoner") + "/summoner/" + Utils.getIDString(summonerIDs) + "/runes";
        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 runes for
     * @return the summoners' runes
     * @see Riot
     *      API Specification
     */
    public static Map getSummonersRunes(final long... summonerIDs) {
        return getSummonersRunes(Utils.convert(summonerIDs));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy