public ConquestCap GetConquestCap(BattleDotSwag.Region region, string host, BattleDotSwag.Game game, BattleDotSwag.Locale locale, int arenaRating, int bgRating) { var endpoint = new ConquestEndpoint(locale, arenaRating, bgRating); BattleNetRequest newRequest = new BattleNetRequest() { Locale = locale.ToString(), RegionID = (int)region, RequestDate = DateTime.Now, RequestType = "leaderboards", Bracket = "", Url = conquestCapService.GetUri(endpoint, region).ToString() }; // BattleNetRequest request = data.BattleNetRequests.Add(newRequest); data.SaveChanges(); ConquestCap cap = new ConquestCap(); // TODO: Fix Conquest Cap call. //requests.Perform(10, 2, 5, request, () => //{ // cap = conquestCapService.Get(endpoint, host, region, game).Result; //}); return cap; }
private Uri GetCheckTokenUri(BattleDotSwag.Region region) { switch (region) { case BattleDotSwag.Region.us: case BattleDotSwag.Region.eu: case BattleDotSwag.Region.kr: case BattleDotSwag.Region.tw: case BattleDotSwag.Region.cn: return new Uri("https://" + region.ToString() + ".battle.net/oauth/check_token"); default: throw new NotSupportedException("This region is not supported yet."); } }
private Uri GetAuthorizationUri(BattleDotSwag.Region region) { switch (region) { case BattleDotSwag.Region.us: case BattleDotSwag.Region.eu: case BattleDotSwag.Region.kr: case BattleDotSwag.Region.tw: return new Uri("https://" + region.ToString() + ".battle.net/oauth/authorize"); case BattleDotSwag.Region.cn: return new Uri("https://www.battlenet.com.cn/oauth/authorize"); default: throw new NotSupportedException("This region is not supported yet."); } }
public async Task GetRecentActivity( string bracket, BattleDotSwag.Locale locale, BattleDotSwag.Region region, string key, IMemoryCache cache, Func<string, Task> Send) { var endpoint = new LeaderboardEndpoint(bracket, locale, key); var requestor = new BattleNetService(); var leaderboard = new List<LadderEntry>(); var request = new QueueDodge.Models.BattleNetRequest() { Bracket = bracket, Locale = locale.ToString(), RegionID = (int)region, RequestDate = DateTime.Now, RequestType = "leaderboard", Url = requestor.GetUri(endpoint, region).ToString(), Duration = 0 }; var addedRequest = data.BattleNetRequests.Add(request).Entity; data.SaveChanges(); var json = requestor.Get(endpoint, region).Result; var ladder = JsonConvert.DeserializeObject<Leaderboard>(json); foreach(var entry in ladder.Rows) { var ladderEntry = new LadderEntry(entry, addedRequest); leaderboard.Add(ladderEntry); CompareWithCache(ladderEntry, cache, Send); }; cache.Set(region + ":" + bracket, leaderboard); }