private static EventsTimeline GetMatchTimeline(long gameId, string region, int participantId) { var pathBuilder = new UrlPathBuilder(); var timeline = new EventsTimeline(); using (var client = new HttpClient()) { try { client.DefaultRequestHeaders.Add("X-Riot-Token", ConfigWrapper.ApiKey); var response = client.GetAsync(new Uri(pathBuilder.GetMatchTimelineUrl(gameId, region))); response.Wait(); if (response.Result.IsSuccessStatusCode) { var readData = response.Result.Content.ReadAsStringAsync(); readData.Wait(); var jsonObject = JObject.Parse(readData.Result); foreach (var frame in jsonObject["frames"]) { var events = frame.Children <JProperty>().FirstOrDefault(x => x.Name == "events"); var timestamp = frame.Children <JProperty>().FirstOrDefault(x => x.Name == "timestamp"); if (events == null || timestamp == null) { return(null); } var intervalTimestamp = timestamp.Value.ToObject <long>(); var matchEvents = events.Value.ToObject <List <MatchEvent> >(); var eventsInsideTimestampWindow = new List <MatchEvent>(); foreach (var e in matchEvents) { if (e.Type == "ITEM_PURCHASED" && e.ParticipantId == participantId) { e.ItemUrl = pathBuilder.GetItemIcon(e.ItemId); eventsInsideTimestampWindow.Add(e); } if (e.Type == "SKILL_LEVEL_UP" && e.ParticipantId == participantId) { timeline.SkillEvents.Add(e); } } timeline.ItemPurchaseEventsByTimestamp.Add(intervalTimestamp, eventsInsideTimestampWindow); } } return(timeline); } catch (Exception) { return(null); } } }