// Friends public string GetFriendIdsQuery(IUserIdDTO userDTO, int maxFriendsToRetrieve) { if (!_userQueryValidator.CanUserBeIdentified(userDTO)) { return(null); } string userIdentifierParameter = _userQueryParameterGenerator.GenerateIdOrScreenNameParameter(userDTO); return(GenerateGetFriendIdsQuery(userIdentifierParameter, maxFriendsToRetrieve)); }
public string GetMuteQuery(IUserIdentifier userIdentifier) { if (!_userQueryValidator.CanUserBeIdentified(userIdentifier)) { return(null); } string userIdParameter = _userQueryParameterGenerator.GenerateIdOrScreenNameParameter(userIdentifier); return(GenerateCreateMuteQuery(userIdParameter)); }
// Destroy Friendship public bool DestroyFriendshipWith(IUserIdentifier user) { if (!_userQueryValidator.CanUserBeIdentified(user)) { return(false); } string query = _friendshipQueryGenerator.GetDestroyFriendshipWithQuery(user); return(_twitterAccessor.TryExecutePOSTQuery(query)); }
// Create Friendship public string GetCreateFriendshipWithQuery(IUserIdentifier userDTO) { if (!_userQueryValidator.CanUserBeIdentified(userDTO)) { return(null); } var userIdentifierParameter = _userQueryParameterGenerator.GenerateIdOrScreenNameParameter(userDTO); return(GenerateCreateFriendshipQuery(userIdentifierParameter)); }
// Get Existing Relationship public string GetRelationshipDetailsQuery(IUserIdentifier sourceUserIdentifier, IUserIdentifier targetUserIdentifier) { if (!_userQueryValidator.CanUserBeIdentified(sourceUserIdentifier) || !_userQueryValidator.CanUserBeIdentified(targetUserIdentifier)) { return(null); } string sourceParameter = _userQueryParameterGenerator.GenerateIdOrScreenNameParameter(sourceUserIdentifier, "source_id", "source_screen_name"); string targetParameter = _userQueryParameterGenerator.GenerateIdOrScreenNameParameter(targetUserIdentifier, "target_id", "target_screen_name"); return(string.Format(Resources.Friendship_GetRelationship, sourceParameter, targetParameter)); }
// User Timeline public string GetUserTimelineQuery(IUserTimelineQueryParameters userTimelineQueryParameters) { if (userTimelineQueryParameters == null) { throw new ArgumentNullException("Timeline Query parameter cannot be null"); } var queryParameters = userTimelineQueryParameters.Parameters; var userIdentifier = userTimelineQueryParameters.UserIdentifier; if (queryParameters == null) { throw new ArgumentNullException("Timeline request parameter cannot be null"); } if (!_userQueryValidator.CanUserBeIdentified(userIdentifier)) { throw new ArgumentNullException("User identifier cannot be null"); } var userTimelineRequestParameter = GenerateUserTimelineRequestParameters(userTimelineQueryParameters); var includeContributorDetailsQueryParameter = GenerateIncludeContributorsDetailsParameter(queryParameters.IncludeContributorDetails); var timelineRequestParameter = GenerateTimelineRequestParameter(queryParameters); var requestParameters = String.Format("{0}{1}{2}", userTimelineRequestParameter, includeContributorDetailsQueryParameter, timelineRequestParameter); return(String.Format(Resources.Timeline_GetUserTimeline, requestParameters)); }
// Publish Message public string GetPublishMessageQuery(IMessageDTO messageDTO) { if (!_messageQueryValidator.CanMessageDTOBePublished(messageDTO)) { return(null); } if (_userQueryValidator.CanUserBeIdentified(messageDTO.Recipient)) { return(GetPublishMessageQuery(messageDTO.Text, messageDTO.Recipient)); } if (_userQueryValidator.IsUserIdValid(messageDTO.RecipientId)) { return(GetPublishMessageQuery(messageDTO.Text, messageDTO.RecipientId)); } return(GetPublishMessageQuery(messageDTO.Text, messageDTO.RecipientScreenName)); }
public string GetUserTimelineQuery(IUserIdDTO userDTO, int maximumTweets, bool excludeReplies) { if (!_userQueryValidator.CanUserBeIdentified(userDTO)) { return(null); } var userParameter = _userQueryParameterGenerator.GenerateIdOrScreenNameParameter(userDTO); return(GetUserTimelineBaseQuery(userParameter, maximumTweets, excludeReplies)); }
public string GetUserListsQuery(IUserIdentifier userIdentifier, bool getOwnedListsFirst) { if (!_userQueryValidator.CanUserBeIdentified(userIdentifier)) { return(null); } var userIdParameter = _userQueryParameterGenerator.GenerateIdOrScreenNameParameter(userIdentifier); return(GenerateUserListsQuery(userIdParameter, getOwnedListsFirst)); }
// Publish Message public string GetPublishMessageQuery(IMessagePublishParameters parameters) { var messageText = parameters.Text; var recipient = parameters.Recipient; if (!_messageQueryValidator.IsMessageTextValid(messageText) || !_userQueryValidator.CanUserBeIdentified(recipient)) { return(null); } string identifierParameter = _userQueryParameterGenerator.GenerateIdOrScreenNameParameter(recipient); return(GetPublishMessageFormattedQuery(messageText, identifierParameter)); }
// User Timeline public string GetUserTimelineQuery(IUserTimelineRequestParameters timelineRequestParameters) { if (timelineRequestParameters == null) { throw new ArgumentNullException("Timeline request parameter cannot be null"); } if (!_userQueryValidator.CanUserBeIdentified(timelineRequestParameters.UserIdentifier)) { throw new ArgumentNullException("User identifier cannot be null"); } var userTimelineRequestParameter = GenerateUserTimelineRequestParameters(timelineRequestParameters); var timelineRequestParameter = GenerateTimelineRequestParameter(timelineRequestParameters); var requestParameters = String.Format("{0}{1}", userTimelineRequestParameter, timelineRequestParameter); return(String.Format(Resources.Timeline_GetUserTimeline, requestParameters)); }
// Publish Message public string GetPublishMessageQuery(IPublishMessageParameters parameters) { var messageText = parameters.Text; var recipient = parameters.Recipient; if (!_messageQueryValidator.IsMessageTextValid(messageText) || !_userQueryValidator.CanUserBeIdentified(recipient)) { return(null); } var identifierParameter = _userQueryParameterGenerator.GenerateIdOrScreenNameParameter(recipient); var query = GetPublishMessageFormattedQuery(messageText, identifierParameter); query += _queryParameterGenerator.GenerateAdditionalRequestParameters(parameters.FormattedCustomQueryParameters); return(query); }
public bool CanMessageDTOBePublished(IMessageDTO messageDTO) { bool isMessageInValidState = messageDTO != null && !messageDTO.IsMessagePublished && !messageDTO.IsMessageDestroyed; if (!isMessageInValidState) { return(false); } bool isRecipientValid = _userQueryValidator.CanUserBeIdentified(messageDTO.Recipient) || _userQueryValidator.IsUserIdValid(messageDTO.RecipientId) || _userQueryValidator.IsScreenNameValid(messageDTO.RecipientScreenName); bool messageTextIsValid = IsMessageTextValid(messageDTO.Text); return(isRecipientValid && messageTextIsValid); }
public bool CanMessageBePublished(IMessagePublishParameters parameters) { var message = parameters.Message; var text = parameters.Text; bool messageTextIsValid = IsMessageTextValid(text); bool isRecipientValid = _userQueryValidator.CanUserBeIdentified(parameters.Recipient) || _userQueryValidator.IsUserIdValid(parameters.RecipientId) || _userQueryValidator.IsScreenNameValid(parameters.RecipientScreenName); bool isMessageInValidState = message == null || (!message.IsMessagePublished && !message.IsMessageDestroyed); if (!isMessageInValidState) { return(false); } return(isRecipientValid && messageTextIsValid); }
public string GenerateIdOrScreenNameParameter( IUserIdentifier userIdentifier, string idParameterName = "user_id", string screenNameParameterName = "screen_name") { if (userIdentifier == null) { throw new ArgumentException("Cannot extract id or name parameter from a null userIdentifier."); } if (!_userQueryValidator.CanUserBeIdentified(userIdentifier)) { throw new ArgumentException("Cannot extract either id or name parameter from the given userIdentifier."); } if (_userQueryValidator.IsUserIdValid(userIdentifier.Id)) { return(GenerateUserIdParameter(userIdentifier.Id, idParameterName)); } return(GenerateScreenNameParameter(userIdentifier.ScreenName, screenNameParameterName)); }
public IListIdentifier Create(ITweetListDTO tweetListDTO) { if (tweetListDTO == null) { return(null); } if (tweetListDTO.Id != TweetinviConstants.DEFAULT_ID) { return(Create(tweetListDTO.Id)); } if (!String.IsNullOrEmpty(tweetListDTO.Slug) && _userQueryValidator.CanUserBeIdentified(tweetListDTO.Creator)) { if (_userQueryValidator.IsUserIdValid(tweetListDTO.Creator.Id)) { return(Create(tweetListDTO.Slug, tweetListDTO.Creator.Id)); } return(Create(tweetListDTO.Slug, tweetListDTO.Creator.ScreenName)); } return(null); }