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

com.ibasco.agql.protocols.valve.steam.webapi.interfaces.SteamEconItems Maven / Gradle / Ivy

/*
 * 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.steam.webapi.interfaces;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.ibasco.agql.protocols.valve.steam.webapi.SteamWebApiClient;
import com.ibasco.agql.protocols.valve.steam.webapi.SteamWebApiInterface;
import com.ibasco.agql.protocols.valve.steam.webapi.interfaces.econitems.GetPlayerItems;
import com.ibasco.agql.protocols.valve.steam.webapi.interfaces.econitems.GetSchema;
import com.ibasco.agql.protocols.valve.steam.webapi.interfaces.econitems.GetSchemaUrl;
import com.ibasco.agql.protocols.valve.steam.webapi.interfaces.econitems.GetStoreMetadata;
import com.ibasco.agql.protocols.valve.steam.webapi.interfaces.econitems.GetStoreStatus;
import com.ibasco.agql.protocols.valve.steam.webapi.pojos.SteamEconItemsStoreMeta;
import com.ibasco.agql.protocols.valve.steam.webapi.pojos.SteamEconPlayerItem;
import com.ibasco.agql.protocols.valve.steam.webapi.pojos.SteamEconSchema;
import java.lang.reflect.Type;
import java.util.List;
import java.util.concurrent.CompletableFuture;

/**
 * Methods relating to in-game items for supported games.
 *
 * @author Rafael Luis Ibasco
 */
public class SteamEconItems extends SteamWebApiInterface {

    /**
     * 

Default Constructor

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

getPlayerItems.

* * @param appId * a int * @param steamId * a long * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture> getPlayerItems(int appId, long steamId) { return getPlayerItems(appId, steamId, VERSION_1); } /** *

getPlayerItems.

* * @param appId * a int * @param steamId * a long * @param apiVersion * a int * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture> getPlayerItems(int appId, long steamId, int apiVersion) { CompletableFuture json = sendRequest(new GetPlayerItems(appId, steamId, apiVersion)); return json.thenApply(root -> { JsonObject result = root.getAsJsonObject("result"); int status = result.getAsJsonPrimitive("status").getAsInt(); JsonArray items = result.getAsJsonArray("items"); Type type = new TypeToken>() { }.getType(); return fromJson(items, type); }); } /** *

getSchema.

* * @param appId * a int * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture getSchema(int appId) { return getSchema(appId, VERSION_1); } /** *

getSchema.

* * @param appId * a int * @param version * a int * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture getSchema(int appId, int version) { CompletableFuture json = sendRequest(new GetSchema(appId, version)); return json.thenApply(root -> { JsonObject result = root.getAsJsonObject("result"); int status = result.getAsJsonPrimitive("status").getAsInt(); return fromJson(result, SteamEconSchema.class); }); } /** *

getSchemaUrl.

* * @param appId * a int * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture getSchemaUrl(int appId) { return getSchemaUrl(appId, VERSION_1); } /** *

getSchemaUrl.

* * @param appId * a int * @param version * a int * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture getSchemaUrl(int appId, int version) { CompletableFuture json = sendRequest(new GetSchemaUrl(appId, version)); return json.thenApply(root -> { JsonObject result = root.getAsJsonObject("result"); int status = result.getAsJsonPrimitive("status").getAsInt(); return result.getAsJsonPrimitive("items_game_url").getAsString(); }); } /** *

getStoreMetadata.

* * @param appId * a int * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture getStoreMetadata(int appId) { return getStoreMetadata(appId, VERSION_1); } /** *

getStoreMetadata.

* * @param appId * a int * @param version * a int * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture getStoreMetadata(int appId, int version) { CompletableFuture json = sendRequest(new GetStoreMetadata(appId, version)); return json.thenApply(root -> fromJson(getSteamResult(root), SteamEconItemsStoreMeta.class)); } /** *

getStoreStatus.

* * @param appId * a int * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture getStoreStatus(int appId) { return getStoreStatus(appId, VERSION_1); } /** *

getStoreStatus.

* * @param appId * a int * @param version * a int * * @return a {@link java.util.concurrent.CompletableFuture} object */ public CompletableFuture getStoreStatus(int appId, int version) { CompletableFuture json = sendRequest(new GetStoreStatus(appId, version)); return json.thenApply(root -> { JsonObject result = root.getAsJsonObject("result"); return result.getAsJsonPrimitive("store_status").getAsInt(); }); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy