CSharpTradeOffers.Trading.MarketHandler.GetPriceOverview C# (CSharp) Method

GetPriceOverview() public method

Gets the price overview of an item.
public GetPriceOverview ( uint appId, string marketHashName, CultureInfo culture, string country = "US", string currency = "1" ) : CSharpTradeOffers.Trading.MarketValue
appId uint The appId of the item.
marketHashName string The market_hash_name of the item
culture System.Globalization.CultureInfo
country string Country to check in. (ISO)
currency string Currency code, I forget what. 1 = US $
return CSharpTradeOffers.Trading.MarketValue
        public MarketValue GetPriceOverview(uint appId, string marketHashName, CultureInfo culture, string country = "US", string currency = "1")
        {
            const string url = BaseUrl + "priceoverview/";
            var data = new Dictionary<string, string>
            {
                {"country", country},
                {"currency", currency},
                {"appid", appId.ToString()},
                {"market_hash_name", marketHashName}
            };

            var marketValueResponse = _web.Fetch(url, "GET", data, null, false).DeserializeJson<MarketValueResponse>();

            if (marketValueResponse == null) return null;

            var mv = new MarketValue { Success = marketValueResponse.Success, BaseResponse = marketValueResponse };

            if (!marketValueResponse.Success)
                return mv;

            if (!string.IsNullOrEmpty(marketValueResponse.LowestPrice))
                mv.LowestPrice = decimal.Parse(marketValueResponse.LowestPrice, NumberStyles.Currency, culture);
            else mv.LowestPrice = -1.0m;

            if (!string.IsNullOrEmpty(marketValueResponse.MedianPrice))
                mv.MedianPrice = decimal.Parse(marketValueResponse.MedianPrice, NumberStyles.Currency, culture);
            else
                mv.LowestPrice = -1.0m;

            if (!string.IsNullOrEmpty(marketValueResponse.Volume))
                mv.Volume = int.Parse(marketValueResponse.Volume, NumberStyles.AllowThousands, culture);
            else
                mv.Volume = -1;

            return mv;
        }

Usage Example

 /// <summary>
 /// Requests decimal worth of an Item.
 /// </summary>
 /// <param name="item">An Item object to get the value of.</param>
 /// <returns>A decimal worth in USD.</returns>
 public decimal ItemWorth(Item item)
 {
     if (item.Tradable != 1) return 0.0m;
     var handler = new MarketHandler();
     MarketValue mv = handler.GetPriceOverview(Convert.ToUInt32(item.AppId), item.MarketHashName);
     return Convert.ToDecimal(mv.MedianPrice.Substring(1));
 }
All Usage Examples Of CSharpTradeOffers.Trading.MarketHandler::GetPriceOverview