Ejemplo n.º 1
0
        public async Task Load(PreSearch preSearch)
        {
            Items = new List <SearchResultItem>();

            if (PreSearchResult == null)
            {
                PreSearchResult = await PreSearchResult.Load(preSearch);
            }

            await LoadMore();
        }
Ejemplo n.º 2
0
        public async void Load(Search search)
        {
            if (PreSearchResult == null)
            {
                PreSearchResult = await PreSearchResult.Load(search);
            }

            int size = PageSize;

            TotalAvailableToLoad = PreSearchResult.Total - TotalLoaded;
            if (TotalAvailableToLoad < PageSize)
            {
                size = TotalAvailableToLoad;
            }

            if (size != 0)
            {
                List <string> idsToLoad = PreSearchResult.ItemIds.Take(size).ToList();
                PreSearchResult.ItemIds.RemoveRange(0, size);

                string url = "https://www.pathofexile.com/api/trade/fetch/" + string.Join(",", idsToLoad) + "?query=" + PreSearchResult.Id;

                string response = await Api.GetAsync(url);

                dynamic o = JsonConvert.DeserializeObject(response);

                foreach (var r in o.result)
                {
                    SearchResultItem i = new SearchResultItem();

                    i.Id = r.id;

                    i.Account.Name              = r.account.name;
                    i.Account.Language          = r.account.language;
                    i.Account.Whisper           = r.account.whisper;
                    i.Account.LastCharacterName = r.account.lastCharacterName;

                    i.Price.Amount   = r.info.price.ammount;
                    i.Price.Currency = r.info.price.currency;
                    i.Price.Type     = r.info.price.type;

                    i.Item.Icon       = r.item.icon;
                    i.Item.Identified = r.item.identified;
                    i.Item.Name       = r.item.name;
                    i.Item.ILvl       = r.item.ilvl;
                    i.Item.Verified   = r.item.verified;
                    i.Item.Corrupted  = r.item.corruped;

                    Items.Add(i);
                }
            }
        }
Ejemplo n.º 3
0
        public static async Task <PreSearchResult> Load(PreSearch search)
        {
            string url = $"https://www.pathofexile.com/api/trade/search/" + search.League.LeagueId;

            string response = "";

            using (var bench = new Benchmark("Pre search raw response: "))
            {
                response = await Api.PostAsync(url, search);
            }
            PreSearchResult ok = null;

            using (var bench = new Benchmark("Pre search deserialization: "))
            {
                ok = JsonConvert.DeserializeObject <PreSearchResult>(response);
            }
            return(ok);
        }