steam-user 0.1.0

Steam User web client for Rust - HTTP-based Steam Community interactions
Documentation
use std::collections::HashMap;

use super::super::{GasError, GasSteamUser};
use crate::types::{Amount, AppId, AssetId, BoosterPackEntry, BoosterResult, ContextId, EconItem, GemResult, GemValue, ItemNameId, ItemOrdersHistogramResponse, MarketHistoryResponse, MarketRestrictions, MyListingsResult, PriceCents, SellItemResult};

impl GasSteamUser {
    pub async fn get_my_listings(&self) -> Result<MyListingsResult, GasError> {
        self.call("get_my_listings", &[]).await
    }
    pub async fn get_market_history(&self, start: u32, count: u32) -> Result<MarketHistoryResponse, GasError> {
        let s = start.to_string();
        let c = count.to_string();
        self.call("get_market_history", &[("start", &s), ("count", &c)]).await
    }
    pub async fn sell_item(&self, appid: AppId, contextid: ContextId, assetid: AssetId, amount: Amount, price: PriceCents) -> Result<SellItemResult, GasError> {
        let app = appid.to_string();
        let ctx = contextid.to_string();
        let asset = assetid.to_string();
        let amt = amount.to_string();
        let p = price.to_string();
        self.call("sell_item", &[("appId", &app), ("contextId", &ctx), ("assetId", &asset), ("amount", &amt), ("price", &p)]).await
    }
    pub async fn remove_listing(&self, listing_id: &str) -> Result<bool, GasError> {
        self.call("remove_listing", &[("listingId", listing_id)]).await
    }
    pub async fn get_gem_value(&self, appid: AppId, assetid: AssetId) -> Result<GemValue, GasError> {
        let app = appid.to_string();
        let asset = assetid.to_string();
        self.call("get_gem_value", &[("appId", &app), ("assetId", &asset)]).await
    }
    pub async fn turn_item_into_gems(&self, appid: AppId, assetid: AssetId, expected_value: u32) -> Result<GemResult, GasError> {
        let app = appid.to_string();
        let asset = assetid.to_string();
        let val = expected_value.to_string();
        self.call("turn_item_into_gems", &[("appId", &app), ("assetId", &asset), ("expectedValue", &val)]).await
    }
    pub async fn get_booster_pack_catalog(&self) -> Result<Vec<BoosterPackEntry>, GasError> {
        self.call("get_booster_pack_catalog", &[]).await
    }
    pub async fn create_booster_pack(&self, appid: AppId, use_untradable_gems: bool) -> Result<BoosterResult, GasError> {
        let app = appid.to_string();
        let u = if use_untradable_gems { "1" } else { "0" };
        self.call("create_booster_pack", &[("appId", &app), ("useUntradable", u)]).await
    }
    pub async fn open_booster_pack(&self, appid: AppId, assetid: AssetId) -> Result<Vec<EconItem>, GasError> {
        let app = appid.to_string();
        let asset = assetid.to_string();
        self.call("open_booster_pack", &[("appId", &app), ("assetId", &asset)]).await
    }
    pub async fn get_market_restrictions(&self) -> Result<(MarketRestrictions, Option<crate::types::WalletBalance>), GasError> {
        let restrictions = self.call("get_market_restrictions", &[]).await?;
        Ok((restrictions, None))
    }
    pub async fn get_market_apps(&self) -> Result<HashMap<u32, String>, GasError> {
        self.call("get_market_apps", &[]).await
    }
    pub async fn get_item_nameid(&self, app_id: AppId, market_hash_name: &str) -> Result<ItemNameId, GasError> {
        let app = app_id.to_string();
        self.call("get_item_name_id", &[("appId", &app), ("marketHashName", market_hash_name)]).await
    }
    pub async fn get_item_orders_histogram(&self, item_nameid: ItemNameId, country: &str, currency: u32) -> Result<ItemOrdersHistogramResponse, GasError> {
        let id = item_nameid.to_string();
        let cur = currency.to_string();
        self.call("get_item_orders_histogram", &[("itemNameId", &id), ("country", country), ("currency", &cur)]).await
    }
}