public static BadgeCounts GetBadgeCounts(Site site, int userId) { var client = new StackyClient(cfg.AppSettings["ApiVersion"], cfg.AppSettings["ApiKey"], site, new UrlClient(), new JsonProtocol()); var siteUser = client.GetUser(userId); return(siteUser.BadgeCounts); }
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); }
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); }