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

com.ibasco.agql.protocols.valve.dota2.webapi.interfaces.Dota2Econ Maven / Gradle / Ivy

There is a newer version: 1.2.2
Show newest version
/*
 * Copyright (c) 2022 Asynchronous Game Query Library
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.ibasco.agql.protocols.valve.dota2.webapi.interfaces;

import com.google.gson.JsonObject;
import com.ibasco.agql.protocols.valve.dota2.webapi.Dota2ApiConstants;
import com.ibasco.agql.protocols.valve.dota2.webapi.Dota2WebApiInterface;
import com.ibasco.agql.protocols.valve.dota2.webapi.enums.Dota2IconType;
import com.ibasco.agql.protocols.valve.dota2.webapi.interfaces.econ.GetEventStatsForAccount;
import com.ibasco.agql.protocols.valve.dota2.webapi.interfaces.econ.GetGameItems;
import com.ibasco.agql.protocols.valve.dota2.webapi.interfaces.econ.GetHeroes;
import com.ibasco.agql.protocols.valve.dota2.webapi.interfaces.econ.GetItemIconPath;
import com.ibasco.agql.protocols.valve.dota2.webapi.interfaces.econ.GetRarities;
import com.ibasco.agql.protocols.valve.dota2.webapi.interfaces.econ.GetTournamentPrizePool;
import com.ibasco.agql.protocols.valve.dota2.webapi.pojos.Dota2EventStats;
import com.ibasco.agql.protocols.valve.dota2.webapi.pojos.Dota2GameItem;
import com.ibasco.agql.protocols.valve.dota2.webapi.pojos.Dota2Hero;
import com.ibasco.agql.protocols.valve.dota2.webapi.pojos.Dota2Rarities;
import com.ibasco.agql.protocols.valve.steam.webapi.SteamWebApiClient;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 

Dota2Econ class.

* * @author Rafael Luis Ibasco */ public class Dota2Econ extends Dota2WebApiInterface { private static final Logger log = LoggerFactory.getLogger(Dota2Econ.class); private static final String LIST_NAME_ITEMS = "items"; private static final String LIST_NAME_HEROES = "heroes"; private static final String LIST_NAME_RARITIES = "rarities"; /** *

Default Constructor

* * @param client * A {@link com.ibasco.agql.protocols.valve.steam.webapi.SteamWebApiClient} instance */ public Dota2Econ(SteamWebApiClient client) { super(client); } /** *

getGameItems.

* * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture> getGameItems() { return getGameItems(Dota2ApiConstants.DEFAULT_LANG); } /** *

getGameItems.

* * @param language * a {@link java.lang.String} object * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture> getGameItems(String language) { CompletableFuture json = sendRequest(new GetGameItems(VERSION_1, language)); return json.thenApply(r -> asCollectionOf(Dota2GameItem.class, LIST_NAME_ITEMS, r)); } /** *

getGameHeroes.

* * @param itemizedOnly * a boolean * @param language * a {@link java.lang.String} object * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture> getGameHeroes(boolean itemizedOnly, String language) { CompletableFuture json = sendRequest(new GetHeroes(VERSION_1, itemizedOnly, language)); return json.thenApply(r -> asCollectionOf(Dota2Hero.class, LIST_NAME_HEROES, r)); } /** *

getItemIconPath.

* * @param iconName * a {@link java.lang.String} object * @param iconType * a {@link com.ibasco.agql.protocols.valve.dota2.webapi.enums.Dota2IconType} object * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture getItemIconPath(String iconName, Dota2IconType iconType) { CompletableFuture json = sendRequest(new GetItemIconPath(VERSION_1, iconName, iconType.getType())); return json.thenApply(r -> { JsonObject result = r.getAsJsonObject("result"); if (result.has("path")) return result.getAsJsonPrimitive("path").getAsString(); return null; }); } /** *

getRarities.

* * @param language * a {@link java.lang.String} object * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture> getRarities(String language) { CompletableFuture json = sendRequest(new GetRarities(VERSION_1, language)); return json.thenApply(r -> asCollectionOf(Dota2Rarities.class, LIST_NAME_RARITIES, r)); } /** *

getTournamentPrizePool.

* * @param leagueId * a int * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture getTournamentPrizePool(int leagueId) { CompletableFuture json = sendRequest(new GetTournamentPrizePool(VERSION_1, leagueId)); return json.thenApply(r -> getValidResult(r).getAsJsonPrimitive("prize_pool").getAsInt()); } /** *

getEventStatsForAccount.

* * @param accountId * a int * @param leagueId * a int * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture getEventStatsForAccount(int accountId, int leagueId) { CompletableFuture json = sendRequest(new GetEventStatsForAccount(VERSION_1, accountId, leagueId, null)); return json.thenApply(r -> fromJson(getValidResult(r), Dota2EventStats.class)); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy