public static async Task GetCommitDetailsForPushEvents(GitHubUserData userData) { foreach (Event evt in userData.GetEventsOfType(EventType.PushEvent).Where(e => e.isPublic)) { PushEventPayload payload = evt.payload as PushEventPayload; foreach (Commit commit in payload.Commits) { string jsonString = await HttpRequestHelper.DoRequestCommitDetailsAsync(userData.UserName, evt.repository.name, commit.sha); commit.details = JsonConvert.DeserializeObject <CommitDetails>(jsonString, new JsonSerializerSettings { Error = Program.HandleDeserializationError }); } } }
public static async Task <GitHubUserData> RetrieveUserDataAsync(string gitHubUserName) { string jsonString = await HttpRequestHelper.DoRequestAsync(gitHubUserName); Console.WriteLine(jsonString); GitHubUserData userData = new GitHubUserData(); userData.UserName = gitHubUserName; userData.Events = JsonConvert.DeserializeObject <IList <Event> >(jsonString, new JsonSerializerSettings { Error = Program.HandleDeserializationError }); // $todo We'll hit rate-limits for non-authenticated callers of the GitHub APIs! We'll // need to support authenticated calls to GitHub before we uncomment the below. // Details on the rate limiting here: https://developer.github.com/v3/#rate-limiting // await GetCommitDetailsForPushEvents(userData); return(userData); }