public static StackData GetFlairData(Guid associationId) { var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol()); var associatedUsers = stackAuthClient.GetAssociatedUsers(associationId); associatedUsers = associatedUsers.OrderByDescending(au => au.Reputation).Where(au => au.Site.State != SiteState.Linked_Meta); int totalRep = associatedUsers.Sum(ai => ai.Reputation); string html = ""; AssociatedUser topUser = associatedUsers.First(); StackData data = new StackData() { DisplayHash = topUser.EmailHash, DisplayId = topUser.Id, DisplayName = topUser.DisplayName, DisplayUrl = topUser.Site.SiteUrl, Sites = (from u in associatedUsers select new StackSiteData() { SiteName = u.Site.Name, SiteState = u.Site.State, Reputation = u.Reputation, Url = u.Site.SiteUrl, UserId = u.Id, IsMod = u.Type == UserType.Moderator, Badges = Utility.GetBadgeCounts(u.Site, u.Id) }).ToList(), //TotalBadges = GetBadgeCounts(associatedUsers), }; return(data); }
public void GetAssociatedUsers() { var client = new StackAuthClient(); var response = client.GetAssociatedUsers(new Guid("e58345f5-0f7b-4261-b449-3959c596f91f")); Assert.Greater(response.Items.Count, 1); Assert.IsNotNull(response.Items.First(s => s.OnSite.SiteUrl == "http://stackapps.com")); }
public void GetSites() { var client = new StackAuthClient(); var response = client.GetSites(); Assert.Greater(response.Items.Count,1); Assert.IsNotNull(response.Items.First(s => s.SiteUrl == "http://stackoverflow.com")); }
public static Guid GetAssociationId(int userID, StackSite site) { var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol()); var sites = stackAuthClient.GetSites(); var siteClient = new StackyClient(version, apiKey, sites.Where(s => s.Name == site.Name).Single(), new UrlClient(), new JsonProtocol()); var associationId = siteClient.GetUser(userID).AssociationId; return associationId; }
public static Guid GetAssociationId(int userID, StackSite site) { var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol()); var sites = stackAuthClient.GetSites(); var siteClient = new StackyClient(version, apiKey, sites.Where(s => s.Name == site.Name).Single(), new UrlClient(), new JsonProtocol()); var associationId = siteClient.GetUser(userID).AssociationId; return(associationId); }
static void Main(string[] args) { var client = new StackAuthClient("1.1", new UrlClient(), new JsonProtocol()); var sites = client.GetSites(pageSize: 100); foreach (var site in sites) { Console.WriteLine(site.MainSite.Name); } Console.ReadLine(); }
private static IEnumerable<Site> GetSites() { var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol()); var sites = stackAuthClient.GetSites().Where(s => s.State != SiteState.Linked_Meta); var siteCreation = new Dictionary<DateTime, Site>(); foreach (var site in sites) { var siteClient = new StackyClient(cfg.Default.ApiVersion, cfg.Default.ApiKey, site, new UrlClient(), new JsonProtocol()); var user = siteClient.GetUser(-1); siteCreation.Add(user.CreationDate, site); } sites = siteCreation.OrderBy(s => s.Key).Select(s => s.Value); return sites; }
private static IEnumerable <Site> GetSites() { var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol()); var sites = stackAuthClient.GetSites().Where(s => s.State != SiteState.Linked_Meta); var siteCreation = new Dictionary <DateTime, Site>(); foreach (var site in sites) { var siteClient = new StackyClient(cfg.Default.ApiVersion, cfg.Default.ApiKey, site, new UrlClient(), new JsonProtocol()); var user = siteClient.GetUser(-1); siteCreation.Add(user.CreationDate, site); } sites = siteCreation.OrderBy(s => s.Key).Select(s => s.Value); return(sites); }
public static StackData GetFlairData(Guid associationId) { var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol()); var associatedUsers = stackAuthClient.GetAssociatedUsers(associationId); associatedUsers = associatedUsers.OrderByDescending(au => au.Reputation).Where(au => au.Site.State != SiteState.Linked_Meta); int totalRep = associatedUsers.Sum(ai => ai.Reputation); string html = ""; AssociatedUser topUser = associatedUsers.First(); StackData data = new StackData() { DisplayHash = topUser.EmailHash, DisplayId = topUser.Id, DisplayName = topUser.DisplayName, DisplayUrl = topUser.Site.SiteUrl, Sites = (from u in associatedUsers select new StackSiteData() { SiteName = u.Site.Name, SiteState = u.Site.State, Reputation = u.Reputation, Url = u.Site.SiteUrl, UserId = u.Id, IsMod = u.Type == UserType.Moderator, Badges = Utility.GetBadgeCounts(u.Site, u.Id) }).ToList(), //TotalBadges = GetBadgeCounts(associatedUsers), }; return data; }
public IntegrationTest() { Client = new StackyClient(Version, ApiKey, hostSite, urlClient, protocol); AuthClient = new StackAuthClient(urlClient, protocol); }
public IntegrationTest() { Client = new StackyClient(Version, ApiKey, Sites.StackOverflow, new UrlClient(), new JsonProtocol()); ClientAsync = new StackyClientAsync(Version, ApiKey, Sites.StackOverflow.ApiEndpoint, new UrlClientAsync(), new JsonProtocol()); AuthClient = new StackAuthClient(Version, new UrlClient(), new JsonProtocol()); }
public IntegrationTest() { Client = new StackyClient(Version, ApiKey, Sites.StackOverflow, new UrlClient(), new JsonProtocol()); ClientAsync = new StackyClientAsync(Version, ApiKey, Sites.StackOverflow.ApiEndpoint, new UrlClientAsync(), new JsonProtocol()); AuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol()); }