private async Task GetUpdatedLimits(string token, string tokenSecret) { RateLimitCache.Get[TwitterAPIEndpoint.RateLimitStatus].ResetIfNeeded(); UserRateLimitInfo userInfo = GetCurrentUserInfo(rateLimitDb, TwitterAPIEndpoint.RateLimitStatus, userManager, User); string appResponseBody = await TwitterAPIUtils.GetResponse( configuration, AuthenticationType.Application, TwitterAPIEndpoint.RateLimitStatus, TwitterAPIUtils.RateLimitStatusQuery(RateLimitResources), null, null, null); string userResponseBody = (token == null || tokenSecret == null) ? null : await TwitterAPIUtils.GetResponse( configuration, AuthenticationType.User, TwitterAPIEndpoint.RateLimitStatus, TwitterAPIUtils.RateLimitStatusQuery(RateLimitResources), token, tokenSecret, userInfo); var appResults = (appResponseBody != null) ? RateLimitResults.FromJson(appResponseBody) : null; var userResults = (userResponseBody != null) ? RateLimitResults.FromJson(userResponseBody) : null; UpdateEndpointLimits(appResults, userResults); }
private async Task <T> GetResults <T>(string query, AuthenticationType authType, Func <string, TwitterAPIEndpoint, string> buildQueryString, TwitterAPIEndpoint endpoint) where T : IQueryResults { UserRateLimitInfo userInfo = RateLimitController.GetCurrentUserInfo(rateLimitDb, endpoint, userManager, User); string responseBody = await TwitterAPIUtils.GetResponse( Configuration, authType, endpoint, buildQueryString(query, endpoint), User.GetTwitterAccessToken(), User.GetTwitterAccessTokenSecret(), userInfo); if (userInfo != null) { userInfo.ResetIfNeeded(); rateLimitDb.Update(userInfo); rateLimitDb.SaveChanges(); } if (responseBody == null) { return(default);