/// <summary> /// Creates a new trade offer with a token /// </summary> /// <param name="message">A message to include with the trade offer</param> /// <param name="otherSteamId">The SteamID of the partner we are trading with</param> /// <param name="status">The list of items we and they are going to trade</param> /// <param name="token">The token of the partner we are trading with</param> /// <param name="newTradeOfferId">The trade offer Id that will be created if successful</param> /// <returns>True if successfully returns a newTradeOfferId, else false</returns> public bool SendTradeOfferWithToken(string message, SteamID otherSteamId, TradeOffer.TradeStatus status, string token, out string newTradeOfferId) { if (String.IsNullOrEmpty(token)) { throw new ArgumentNullException("token", "Partner trade offer token is missing"); } var offerToken = new OfferAccessToken() { TradeOfferAccessToken = token }; var data = new NameValueCollection(); data.Add("sessionid", SessionId); data.Add("partner", otherSteamId.ConvertToUInt64().ToString()); data.Add("tradeoffermessage", message); data.Add("json_tradeoffer", JsonConvert.SerializeObject(status, JsonSerializerSettings)); data.Add("trade_offer_create_params", JsonConvert.SerializeObject(offerToken, JsonSerializerSettings)); string referer = string.Format("http://steamcommunity.com/tradeoffer/new/?partner={0}&token={1}", otherSteamId.AccountID, token); return(Request(SendUrl, data, referer, null, out newTradeOfferId)); }
/// <summary> /// Creates a new counter offer /// </summary> /// <param name="message">A message to include with the trade offer</param> /// <param name="otherSteamId">The SteamID of the partner we are trading with</param> /// <param name="status">The list of items we and they are going to trade</param> /// <param name="newTradeOfferId">The trade offer Id that will be created if successful</param> /// <param name="tradeOfferId">The trade offer Id of the offer being countered</param> /// <returns></returns> public bool CounterOffer(string message, SteamID otherSteamId, TradeOffer.TradeStatus status, out string newTradeOfferId, string tradeOfferId) { if (String.IsNullOrEmpty(tradeOfferId)) { throw new ArgumentNullException("tradeOfferId", "Trade Offer Id must be set for counter offers."); } var data = new NameValueCollection(); data.Add("sessionid", SessionId); data.Add("partner", otherSteamId.ConvertToUInt64().ToString()); data.Add("tradeoffermessage", message); data.Add("json_tradeoffer", JsonConvert.SerializeObject(status, JsonSerializerSettings)); data.Add("tradeofferid_countered", tradeOfferId); data.Add("trade_offer_create_params", "{}"); string referer = string.Format("http://steamcommunity.com/tradeoffer/{0}/", tradeOfferId); if (!Request(SendUrl, data, referer, tradeOfferId, out newTradeOfferId)) { var state = WebApi.GetOfferState(tradeOfferId); if (state == TradeOfferState.TradeOfferStateCountered) { return(true); } return(false); } return(true); }
/// <summary> /// Creates a new trade offer /// </summary> /// <param name="message">A message to include with the trade offer</param> /// <param name="otherSteamId">The SteamID of the partner we are trading with</param> /// <param name="status">The list of items we and they are going to trade</param> /// <param name="newTradeOfferId">The trade offer Id that will be created if successful</param> /// <returns>True if successfully returns a newTradeOfferId, else false</returns> public bool SendTradeOffer(string message, SteamID otherSteamId, TradeOffer.TradeStatus status, out string newTradeOfferId) { var data = new NameValueCollection(); data.Add("sessionid", SessionId); data.Add("partner", otherSteamId.ConvertToUInt64().ToString()); data.Add("tradeoffermessage", message); data.Add("json_tradeoffer", JsonConvert.SerializeObject(status, JsonSerializerSettings)); data.Add("trade_offer_create_params", "{}"); string referer = string.Format("http://steamcommunity.com/tradeoffer/new/?partner={0}", otherSteamId.AccountID); return(Request(SendUrl, data, referer, null, out newTradeOfferId)); }