public ITwitterPageIterator <IFilteredTwitterResult <UserDTO[]>, int?> GetSearchUsersIterator(ISearchUsersParameters parameters, ITwitterRequest request) { var pageNumber = parameters.Page ?? 1; var previousResultIds = new HashSet <long>(); return(new TwitterPageIterator <IFilteredTwitterResult <UserDTO[]>, int?>( parameters.Page, async cursor => { var cursoredParameters = new SearchUsersParameters(parameters) { Page = cursor }; var page = await _searchQueryExecutor.SearchUsersAsync(cursoredParameters, new TwitterRequest(request)).ConfigureAwait(false); return new FilteredTwitterResult <UserDTO[]>(page) { FilteredDTO = page.Model.Where(x => !previousResultIds.Contains(x.Id)).ToArray() }; }, page => { if (page.Model.Length == 0) { return null; } return ++pageNumber; }, page => { var requestUserIds = page.Model.Select(x => x.Id).ToArray(); var newItemIds = requestUserIds.Except(previousResultIds).ToArray(); foreach (var newItemId in newItemIds) { previousResultIds.Add(newItemId); } return newItemIds.Length == 0 || page.Model.Length == 0; })); }
public Task <ITwitterResult <IWebhookDTO[]> > GetAccountActivityEnvironmentWebhooksAsync(IGetAccountActivityEnvironmentWebhooksParameters parameters, ITwitterRequest request) { var consumerCredentials = new ConsumerCredentials(request.Query.TwitterCredentials); request.Query.Url = _accountActivityQueryGenerator.GetAccountActivityEnvironmentWebhooksQuery(parameters); request.Query.HttpMethod = HttpMethod.GET; request.Query.TwitterCredentials = new TwitterCredentials(consumerCredentials); return(_twitterAccessor.ExecuteRequestAsync <IWebhookDTO[]>(request)); }
public Task <ITwitterResult> TriggerAccountActivityWebhookCRCAsync(ITriggerAccountActivityWebhookCRCParameters parameters, ITwitterRequest request) { request.Query.Url = _accountActivityQueryGenerator.GetTriggerAccountActivityWebhookCRCQuery(parameters); request.Query.HttpMethod = HttpMethod.PUT; return(_twitterAccessor.ExecuteRequestAsync(request)); }
public Task <ITwitterResult <ITweetDTO[]> > GetTweetsFromListAsync(IGetTweetsFromListParameters parameters, ITwitterRequest request) { request.Query.Url = _listsQueryGenerator.GetTweetsFromListQuery(parameters, request.ExecutionContext.TweetMode); request.Query.HttpMethod = HttpMethod.GET; return(_twitterAccessor.ExecuteRequestAsync <ITweetDTO[]>(request)); }
public Task <ITwitterResult <ITwitterListDTO> > AddMemberToListAsync(IAddMemberToListParameters parameters, ITwitterRequest request) { request.Query.Url = _listsQueryGenerator.GetAddMemberToListQuery(parameters); request.Query.HttpMethod = HttpMethod.POST; return(_twitterAccessor.ExecuteRequestAsync <ITwitterListDTO>(request)); }
public Task <ITwitterResult <IGetMessageDTO> > GetMessage(IGetMessageParameters parameters, ITwitterRequest request) { return(_messageQueryExecutor.GetMessage(parameters, request)); }
public ComputedTweetMode(ITweetModeParameter parameter, ITwitterRequest request) { _tweetMode = parameter?.TweetMode ?? request.ExecutionContext.TweetMode; }
Task <ITwitterResult <ITwitterListDTO> > ITwitterListController.DestroyListAsync(IDestroyListParameters parameters, ITwitterRequest request) { return(_twitterListQueryExecutor.DestroyListAsync(parameters, request)); }
public Task <ITwitterResult <ITwitterListDTO> > AddMembersToListAsync(IAddMembersToListParameters parameters, ITwitterRequest request) { return(_twitterListQueryExecutor.AddMembersToListAsync(parameters, request)); }
public Task <ITwitterResult <ITwitterListDTO[]> > GetListsSubscribedByUserAsync(IGetListsSubscribedByUserParameters parameters, ITwitterRequest request) { return(_twitterListQueryExecutor.GetListsSubscribedByUserAsync(parameters, request)); }
public Task <ITwitterResult <ITwitterListDTO> > UpdateListAsync(IUpdateListParameters parameters, ITwitterRequest request) { return(_twitterListQueryExecutor.UpdateListAsync(parameters, request)); }
public ITwitterPageIterator <ITwitterResult <ITweetDTO[]>, long?> GetTweetsFromListIterator(IGetTweetsFromListParameters parameters, ITwitterRequest request) { return(_pageCursorIteratorFactories.Create(parameters, cursor => { var cursoredParameters = new GetTweetsFromListParameters(parameters) { MaxId = cursor }; return _twitterListQueryExecutor.GetTweetsFromListAsync(cursoredParameters, new TwitterRequest(request)); })); }
public Task <ITwitterResult <ITwitterListDTO> > UnsubscribeFromListAsync(IUnsubscribeFromListParameters parameters, ITwitterRequest request) { return(_twitterListQueryExecutor.UnsubscribeFromListAsync(parameters, request)); }
public Task <ITwitterResult <ITwitterListDTO> > RemoveMembersFromListAsync(IRemoveMembersFromListParameters parameters, ITwitterRequest request) { return(_twitterListQueryExecutor.RemoveMembersFromListAsync(parameters, request)); }
public Task <ITwitterResult <ICreateMessageDTO> > PublishMessage(IPublishMessageParameters parameters, ITwitterRequest request) { return(_messageQueryExecutor.PublishMessage(parameters, request)); }
public ITwitterPageIterator <ITwitterResult <IUserCursorQueryResultDTO> > GetMembersOfListIterator(IGetMembersOfListParameters parameters, ITwitterRequest request) { return(_pageCursorIteratorFactories.Create(parameters, cursor => { var cursoredParameters = new GetMembersOfListParameters(parameters) { Cursor = cursor }; return _twitterListQueryExecutor.GetMembersOfListAsync(cursoredParameters, new TwitterRequest(request)); })); }
public Task <ITwitterResult> DestroyMessage(IDeleteMessageParameters parameters, ITwitterRequest request) { return(_messageQueryExecutor.DestroyMessage(parameters, request)); }
public Task <ITwitterResult <ITwitterListDTO> > CheckIfUserIsAListMemberAsync(ICheckIfUserIsMemberOfListParameters parameters, ITwitterRequest request) { return(_twitterListQueryExecutor.CheckIfUserIsAListMemberAsync(parameters, request)); }
public ITwitterPageIterator <ITwitterResult <IMessageCursorQueryResultDTO> > GetMessagesIterator(IGetMessagesParameters parameters, ITwitterRequest request) { return(new TwitterPageIterator <ITwitterResult <IMessageCursorQueryResultDTO> >( parameters.Cursor, cursor => { var cursoredParameters = new GetMessagesParameters(parameters) { Cursor = cursor }; return _messageQueryExecutor.GetMessages(cursoredParameters, new TwitterRequest(request)); }, page => page.DataTransferObject.NextCursorStr, page => { return page.DataTransferObject.NextCursorStr == "0" || string.IsNullOrEmpty(page.DataTransferObject.NextCursorStr); })); }
public Task <ITwitterResult> RequestAuthUrl(RequestAuthUrlInternalParameters parameters, ITwitterRequest request) { var oAuthWebRequestGenerator = _oAuthWebRequestGeneratorFactory.Create(); var callbackParameter = oAuthWebRequestGenerator.GenerateParameter("oauth_callback", parameters.CallbackUrl, true, true, false); request.Query.Url = _queryGenerator.GetRequestAuthUrlQuery(parameters); request.Query.HttpMethod = HttpMethod.POST; request.TwitterClientHandler = new AuthHttpHandler(callbackParameter, parameters.AuthRequest, oAuthWebRequestGenerator); return(_twitterAccessor.ExecuteRequest(request)); }
public Task <ITwitterResult <ITwitterListDTO> > CheckIfUserIsSubscriberOfListAsync(ICheckIfUserIsSubscriberOfListParameters parameters, ITwitterRequest request) { request.Query.Url = _listsQueryGenerator.GetCheckIfUserIsSubscriberOfListQuery(parameters); request.Query.HttpMethod = HttpMethod.GET; return(_twitterAccessor.ExecuteRequestAsync <ITwitterListDTO>(request)); }
public Task <ITwitterResult> RequestCredentials(IRequestCredentialsParameters parameters, ITwitterRequest request) { var oAuthWebRequestGenerator = _oAuthWebRequestGeneratorFactory.Create(); var callbackParameter = oAuthWebRequestGenerator.GenerateParameter("oauth_verifier", parameters.VerifierCode, true, true, false); request.Query.Url = _queryGenerator.GetRequestCredentialsQuery(parameters); request.Query.HttpMethod = HttpMethod.POST; request.Query.TwitterCredentials = new TwitterCredentials(parameters.AuthRequest.ConsumerKey, parameters.AuthRequest.ConsumerSecret); request.TwitterClientHandler = new AuthHttpHandler(callbackParameter, parameters.AuthRequest, oAuthWebRequestGenerator); return(_twitterAccessor.ExecuteRequest(request)); }
public Task <ITwitterResult <ITwitterListCursorQueryResultDTO> > GetListsOwnedByUserAsync(IGetListsOwnedByUserParameters parameters, ITwitterRequest request) { request.Query.Url = _listsQueryGenerator.GetListsOwnedByUserQuery(parameters); request.Query.HttpMethod = HttpMethod.GET; return(_twitterAccessor.ExecuteRequestAsync <ITwitterListCursorQueryResultDTO>(request)); }
public Task <ITwitterResult <InvalidateTokenResponse> > InvalidateBearerToken(IInvalidateBearerTokenParameters parameters, ITwitterRequest request) { var oAuthWebRequestGenerator = _oAuthWebRequestGeneratorFactory.Create(); request.Query.Url = _queryGenerator.GetInvalidateBearerTokenQuery(parameters); request.Query.HttpMethod = HttpMethod.POST; request.TwitterClientHandler = new InvalidateTokenHttpHandler(oAuthWebRequestGenerator); return(_twitterAccessor.ExecuteRequest <InvalidateTokenResponse>(request)); }
public Task <ITwitterResult <IWebhookDTO> > CreateAccountActivityWebhookAsync(ICreateAccountActivityWebhookParameters parameters, ITwitterRequest request) { request.Query.Url = _accountActivityQueryGenerator.GetCreateAccountActivityWebhookQuery(parameters); request.Query.HttpMethod = HttpMethod.POST; return(_twitterAccessor.ExecuteRequestAsync <IWebhookDTO>(request)); }
public Task <ITwitterResult <InvalidateTokenResponse> > InvalidateAccessToken(IInvalidateAccessTokenParameters parameters, ITwitterRequest request) { request.Query.Url = _queryGenerator.GetInvalidateAccessTokenQuery(parameters); request.Query.HttpMethod = HttpMethod.POST; return(_twitterAccessor.ExecuteRequest <InvalidateTokenResponse>(request)); }
public Task <ITwitterResult> DeleteAccountActivityWebhookAsync(IDeleteAccountActivityWebhookParameters parameters, ITwitterRequest request) { request.Query.Url = _accountActivityQueryGenerator.GetDeleteAccountActivityWebhookQuery(parameters); request.Query.HttpMethod = HttpMethod.DELETE; return(_twitterAccessor.ExecuteRequestAsync(request)); }
public Task <ITwitterResult <UsersV2Response> > GetUsersAsync(IGetUsersByNameV2Parameters parameters, ITwitterRequest request) { request.Query.Url = _tweetQueryGenerator.GetUsersQuery(parameters); return(_twitterAccessor.ExecuteRequestAsync <UsersV2Response>(request)); }
public Task <ITwitterResult> SubscribeToAccountActivityAsync(ISubscribeToAccountActivityParameters parameters, ITwitterRequest request) { request.Query.Url = _accountActivityQueryGenerator.GetSubscribeToAccountActivityQuery(parameters); request.Query.HttpMethod = HttpMethod.POST; return(_twitterAccessor.ExecuteRequestAsync(request)); }
public ITwitterPageIterator <ITwitterResult <ISearchResultsDTO>, long?> GetSearchTweetsIterator(ISearchTweetsParameters parameters, ITwitterRequest request) { long lastCursor = -1; long?getNextCursor(ITwitterResult <ISearchResultsDTO> page) { if (page?.Model?.SearchMetadata?.NextResults == null) { return(null); } return(page.Model.TweetDTOs.Min(x => x.Id) - 1); } return(new TwitterPageIterator <ITwitterResult <ISearchResultsDTO>, long?>( parameters.MaxId, cursor => { var cursoredParameters = new SearchTweetsParameters(parameters) { MaxId = cursor }; return _searchQueryExecutor.SearchTweetsAsync(cursoredParameters, new TwitterRequest(request)); }, getNextCursor, page => { var nextCursor = getNextCursor(page); if (nextCursor == null) { return true; } if (lastCursor == nextCursor) { return true; } lastCursor = nextCursor.Value; return false; })); }