private ITokenRateLimits GetTokenRateLimitsFromTwitter(ITwitterCredentials credentials) { if (_isRetrievingData) { return(null); } var isApplicationOnlyCreds = string.IsNullOrEmpty(credentials.AccessToken) || string.IsNullOrEmpty(credentials.AccessTokenSecret); if (isApplicationOnlyCreds && string.IsNullOrEmpty(credentials.ApplicationOnlyBearerToken)) { return(null); } _isRetrievingData = true; var result = _credentialsAccessor.ExecuteOperationWithCredentials(credentials, () => { var twitterQuery = _twitterQueryFactory.Create(_helpQueryGenerator.GetCredentialsLimitsQuery(), HttpMethod.GET, credentials); try { string jsonResponse = _twitterRequester.ExecuteQuery(twitterQuery); return(_jsonObjectConverter.DeserializeObject <ITokenRateLimits>(jsonResponse)); } catch (TwitterException) { return(null); } }); _isRetrievingData = false; return(result); }
private ICredentialsRateLimits GetTokenRateLimitsFromTwitter(ITwitterCredentials credentials) { var isApplicationOnlyCreds = string.IsNullOrEmpty(credentials.AccessToken) || string.IsNullOrEmpty(credentials.AccessTokenSecret); if (isApplicationOnlyCreds && string.IsNullOrEmpty(credentials.ApplicationOnlyBearerToken)) { return(null); } var result = _credentialsAccessor.ExecuteOperationWithCredentials(credentials, () => { var twitterQuery = _twitterQueryFactory.Create(_helpQueryGenerator.GetCredentialsLimitsQuery(), HttpMethod.GET, credentials); try { var webRequestResult = _webRequestExecutor.ExecuteQuery(twitterQuery); var json = webRequestResult.Text; return(_jsonObjectConverter.DeserializeObject <ICredentialsRateLimits>(json)); } catch (TwitterException) { return(null); } }); return(result); }
// Get User public IAuthenticatedUser GetAuthenticatedUser(ITwitterCredentials credentials = null, IGetAuthenticatedUserParameters parameters = null) { IUserDTO userDTO; if (credentials == null) { credentials = _credentialsAccessor.CurrentThreadCredentials; userDTO = _userFactoryQueryExecutor.GetAuthenticatedUser(parameters); } else { userDTO = _credentialsAccessor.ExecuteOperationWithCredentials(credentials, () => { return(_userFactoryQueryExecutor.GetAuthenticatedUser(parameters)); }); } var authenticatedUser = GenerateAuthenticatedUserFromDTO(userDTO); if (authenticatedUser != null) { authenticatedUser.SetCredentials(credentials); } return(authenticatedUser); }
public ILoggedUser GetLoggedUser(IOAuthCredentials credentials) { var userDTO = _credentialsAccessor.ExecuteOperationWithCredentials(credentials, () => { return(_userFactoryQueryExecutor.GetLoggedUser()); }); return(GenerateLoggedUserFromDTO(userDTO)); }
public ILoggedUser GetLoggedUser(ITwitterCredentials credentials) { var userDTO = _credentialsAccessor.ExecuteOperationWithCredentials(credentials, () => { return(_userFactoryQueryExecutor.GetLoggedUser()); }); var loggedUser = GenerateLoggedUserFromDTO(userDTO); loggedUser.SetCredentials(credentials); return(loggedUser); }
private ITokenRateLimits GetTokenRateLimitsFromTwitter(IOAuthCredentials credentials) { if (_isRetrievingData) { return(null); } _isRetrievingData = true; var result = _credentialsAccessor.ExecuteOperationWithCredentials(credentials, () => { var twitterQuery = _twitterQueryFactory.Create(_helpQueryGenerator.GetCredentialsLimitsQuery(), HttpMethod.GET, credentials); string jsonResponse = _twitterRequester.ExecuteQuery(twitterQuery); return(_jsonObjectConverter.DeserializeObject <ITokenRateLimits>(jsonResponse)); }); _isRetrievingData = false; return(result); }