public async Task <DateTime> CreateNewSnapshotAsync(WGApiClient client) { var stats = client.GetPlayerTankStatsAsync(ID); var marks = client.GetPlayerMarksAsync(ID); await Task.WhenAll(stats, marks); var marksDict = marks.Result.ToDictionary(m => m.TankID, m => m.Mark); Func <int, int> tryGetMark = id => { if (marksDict.TryGetValue(id, out int mark)) { return(mark); } return(0); }; var newSnapshot = stats.Result.Select(s => new TankStatistics(s.TankID, s.Stats, tryGetMark(s.TankID))); DateTime now = DateTime.Now; if (false == AvailableDates.Any() || CreateIntermediateSnapshot(Load(AvailableDates.Max()), newSnapshot).Any()) { await SaveAsync(newSnapshot, now); return(now); } return(DateTime.MinValue); }
static void TestApiClient() { int[] playerIDs = { 501114475, 523993923 }; int[] clanIDs = { 500025989, 500034335 }; WGApiClient client = new WGApiClient("https://api.worldoftanks", Region.eu, "de900a7eb3e71b2c44543abdcc2ee8ea", new Logger()); var marks = client.GetPlayerMarks(playerIDs.First()); var wr = client.GetPlayerWinrateRecords(playerIDs); var vehicleStats = client.GetPlayerTankStats(playerIDs.First()); var players = client.GetPlayerStats(playerIDs); var clans = client.GetClanInformation(clanIDs); }
public StatsUpdater(WGApiClient client) { ApiClient = client; }