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

EligibilityCheck() public method

Sets the container to contain a MarketEligibility cookie. Required before trading.
public EligibilityCheck ( ulong steamId, CookieContainer container ) : void
steamId ulong The SteamId of the bot.
container System.Net.CookieContainer The bot CookieContainer
return void
        public void EligibilityCheck(ulong steamId, CookieContainer container)
        {
            const string url = BaseUrl + "eligibilitycheck/";
            var data = new Dictionary<string, string> { { "goto", "/profiles/" + steamId + "/tradeoffers/" } };
            _web.Fetch(url, "GET", data, container, false);
        }

Usage Example

        private static void PollOffers()
        {
            Console.WriteLine("Polling offers every ten seconds.");

            bool isPolling = true;

            var offerHandler = new EconServiceHandler(_apiKey);
            var marketHandler = new MarketHandler();

            marketHandler.EligibilityCheck(_account.SteamId, _account.AuthContainer);
            //required to perform trades (?). Checks to see whether or not we're allowed to trade.

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            // ReSharper disable once LoopVariableIsNeverChangedInsideLoop
            while (isPolling) //permanent loop, can be changed
            {
                Thread.Sleep(10000);

                var recData = new Dictionary<string, string>
                {
                    {"get_received_offers", "1"},
                    {"active_only", "1"},
                    {"time_historical_cutoff", "999999999999"}
                    //arbitrarily high number to retrieve latest offers
                };

                var offers = offerHandler.GetTradeOffers(recData).TradeOffersReceived;

                if (offers == null) continue;

                foreach (CEconTradeOffer cEconTradeOffer in offers)
                {
                    if (cEconTradeOffer.ItemsToGive == null)
                    {
                        offerHandler.AcceptTradeOffer(Convert.ToUInt64(cEconTradeOffer.TradeOfferId),
                            _account.AuthContainer,
                            cEconTradeOffer.AccountIdOther, "1");
                        Console.WriteLine("Accepted a donation!");
                    }
                    else
                    {
                        offerHandler.DeclineTradeOffer(Convert.ToUInt64(cEconTradeOffer.TradeOfferId));
                        Console.WriteLine("Refused a \"donation\" that would have taken items from us.");
                    }
                }
            }
        }
All Usage Examples Of CSharpTradeOffers.Trading.MarketHandler::EligibilityCheck