/// <summary> /// Gets a list of trade offers for the specified trade offer state. /// </summary> /// <param name="states">A TradeOfferState containing the state to get trade offers for.</param> /// <param name="state">A TradeOfferTypes indicating the types of trade offer to get.</param> public List <TradeOffer> GetTradeOffers(TradeOfferState state, TradeOfferTypes tradeOfferTypes) { List <TradeOfferState> States; States = new List <TradeOfferState> { state }; return(GetTradeOffers(States, tradeOfferTypes)); }
/// <summary> /// Gets a list of trade offers for the specified trade offer states. /// </summary> /// <param name="states">A List of TradeOfferState containing the states to get trade offers for.</param> /// <param name="state">A TradeOfferTypes indicating the types of trade offer to get.</param> public List <TradeOffer> GetTradeOffers(List <TradeOfferState> states, TradeOfferTypes tradeOfferTypes) { List <TradeOffer> ReturnValue = null; int Retries = 0; while (Retries++ < 3) { try { NameValueCollection RequestData; ApiResponse <GetOffersResponse> Result; // Build the post data RequestData = new NameValueCollection { { "twofactor_code", Authenticator.Compute2FA(_2FA) } }; if (states != null && states.Count > 0) { string StateList = string.Empty; foreach (TradeOfferState State in states) { StateList += string.Format("{0},", (int)State); } StateList = StateList.TrimEnd(new char[] { ',' }); RequestData.Add("state", StateList); } // Add the trade offer type switch (tradeOfferTypes) { case TradeOfferTypes.Received: RequestData.Add("type", "received"); break; case TradeOfferTypes.Sent: RequestData.Add("type", "sent"); break; } // Execute the request Result = OpSkinsWebRequest <GetOffersResponse> .ExecuteGet(BuildUrl("ITrade/GetOffers/v1/"), _AuthToken, RequestData); if (Result != null && Result.Response != null) { ReturnValue = Result.Response.TradeOffers; } else { throw new InvalidOperationException("No result data was received"); } } catch (Exception ex) { Console.WriteLine("Could not get trade offers: {0}", ex); } } return(ReturnValue); }