// Publish Tweet
        public string GetPublishTweetQuery(IPublishTweetParameters parameters, ComputedTweetMode tweetMode)
        {
            var text = parameters.Text;
            var useExtendedTweetMode = tweetMode == null || tweetMode == TweetMode.Extended;

            var quotedTweetUrl = GetQuotedTweetUrl(parameters);
            var attachmentUrl  = parameters.QuotedTweetUrl;

            if (quotedTweetUrl != null)
            {
                // if there is a quoted tweet we need to pass the url in the text or attachment url
                // attachment_url is only available under tweetMode
                if (useExtendedTweetMode && attachmentUrl == null)
                {
                    attachmentUrl = quotedTweetUrl;
                }
                else
                {
                    text = text.TrimEnd() + " " + quotedTweetUrl;
                }
            }

            var query = new StringBuilder(Resources.Tweet_Publish);

            query.AddParameterToQuery("status", text);
            query.AddParameterToQuery("auto_populate_reply_metadata", parameters.AutoPopulateReplyMetadata);
            query.AddParameterToQuery("attachment_url", attachmentUrl);
            query.AddParameterToQuery("card_uri", parameters.CardUri);
            query.AddParameterToQuery("display_coordinates", parameters.DisplayExactCoordinates);

            if (parameters.ExcludeReplyUserIds != null)
            {
                query.AddParameterToQuery("exclude_reply_user_ids", string.Join(",", parameters.ExcludeReplyUserIds));
            }

            query.AddParameterToQuery("in_reply_to_status_id", GetTweetId(parameters.InReplyToTweet));
            query.AddParameterToQuery("lat", parameters.Coordinates?.Latitude.ToString(CultureInfo.InvariantCulture));
            query.AddParameterToQuery("long", parameters.Coordinates?.Longitude.ToString(CultureInfo.InvariantCulture));

            if (parameters.MediaIds.Count > 0)
            {
                var mediaIdsParameter = string.Join(",", parameters.MediaIds.Select(x => x.ToString(CultureInfo.InvariantCulture)));
                query.AddParameterToQuery("media_ids", mediaIdsParameter);
            }

            query.AddParameterToQuery("place_id", parameters.PlaceId);
            query.AddParameterToQuery("possibly_sensitive", parameters.PossiblySensitive);
            query.AddParameterToQuery("trim_user", parameters.TrimUser);
            query.AddParameterToQuery("tweet_mode", tweetMode);

            query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters);

            return(query.ToString());
        }
        public string GetDestroyTweetQuery(IDestroyTweetParameters parameters, ComputedTweetMode tweetMode)
        {
            var query = new StringBuilder(string.Format(Resources.Tweet_Destroy, _queryParameterGenerator.GenerateTweetIdentifier(parameters.Tweet)));

            query.AddParameterToQuery("trim_user", parameters.TrimUser);
            query.AddParameterToQuery("tweet_mode", tweetMode);

            query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters);

            return(query.ToString());
        }
        // Home Timeline
        public string GetHomeTimelineQuery(IGetHomeTimelineParameters parameters, ComputedTweetMode tweetMode)
        {
            var query = new StringBuilder(Resources.Timeline_GetHomeTimeline);

            _queryParameterGenerator.AddTimelineParameters(query, parameters, tweetMode);

            query.AddParameterToQuery("exclude_replies", parameters.ExcludeReplies);
            query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters);

            return(query.ToString());
        }
        public string GetDestroyRetweetQuery(IDestroyRetweetParameters parameters, ComputedTweetMode tweetMode)
        {
            var tweetId = GetTweetId(parameters.Tweet);
            var query   = new StringBuilder(string.Format(Resources.Tweet_DestroyRetweet, tweetId));

            query.AddParameterToQuery("trim_user", parameters.TrimUser);
            query.AddParameterToQuery("tweet_mode", tweetMode);

            query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters);

            return(query.ToString());
        }
        public string GetRetweetsQuery(IGetRetweetsParameters parameters, ComputedTweetMode tweetMode)
        {
            var tweetId = GetTweetId(parameters.Tweet);
            var query   = new StringBuilder(string.Format(Resources.Tweet_Retweet_GetRetweets, tweetId));

            query.AddParameterToQuery("count", parameters.PageSize);
            query.AddParameterToQuery("trim_user", parameters.TrimUser);

            query.AddParameterToQuery("tweet_mode", tweetMode);
            query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters);

            return(query.ToString());
        }
        // User Timeline
        public string GetUserTimelineQuery(IGetUserTimelineParameters parameters, ComputedTweetMode tweetMode)
        {
            var query = new StringBuilder(Resources.Timeline_GetUserTimeline);

            query.AddFormattedParameterToQuery(_userQueryParameterGenerator.GenerateIdOrScreenNameParameter(parameters.User));

            _queryParameterGenerator.AddTimelineParameters(query, parameters, tweetMode);

            query.AddParameterToQuery("exclude_replies", parameters.ExcludeReplies);
            query.AddParameterToQuery("include_rts", parameters.IncludeRetweets);
            query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters);

            return(query.ToString());
        }
        // Get Tweet
        public string GetTweetQuery(IGetTweetParameters parameters, ComputedTweetMode tweetMode)
        {
            var query = new StringBuilder(Resources.Tweet_Get);

            query.AddParameterToQuery("id", parameters.Tweet?.Id.ToString() ?? parameters.Tweet?.IdStr);
            query.AddParameterToQuery("include_card_uri", parameters.IncludeCardUri);
            query.AddParameterToQuery("include_entities", parameters.IncludeEntities);
            query.AddParameterToQuery("include_ext_alt_text", parameters.IncludeExtAltText);
            query.AddParameterToQuery("include_my_retweet", parameters.IncludeMyRetweet);
            query.AddParameterToQuery("trim_user", parameters.TrimUser);
            query.AddParameterToQuery("tweet_mode", tweetMode);

            query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters);

            return(query.ToString());
        }
        public string GetTweetsQuery(IGetTweetsParameters parameters, ComputedTweetMode tweetMode)
        {
            var query = new StringBuilder(Resources.Tweet_Lookup);

            var validTweetIdentifiers = parameters.Tweets.Where(x => GetTweetId(x) != null);
            var tweetIds = validTweetIdentifiers.Select(GetTweetId);

            query.AddParameterToQuery("id", string.Join(",", tweetIds));
            query.AddParameterToQuery("include_card_uri", parameters.IncludeCardUri);
            query.AddParameterToQuery("include_entities", parameters.IncludeEntities);
            query.AddParameterToQuery("include_ext_alt_text", parameters.IncludeExtAltText);
            query.AddParameterToQuery("trim_user", parameters.TrimUser);
            query.AddParameterToQuery("tweet_mode", tweetMode);

            query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters);

            return(query.ToString());
        }
Example #9
0
        public string GetSearchTweetsQuery(ISearchTweetsParameters parameters, ComputedTweetMode tweetMode)
        {
            var query = new StringBuilder(Resources.Search_SearchTweets);

            query.AddParameterToQuery("q", GenerateQueryParameter(parameters.Query, parameters.Filters));
            query.AddParameterToQuery("geocode", _searchQueryParameterGenerator.GenerateGeoCodeParameter(parameters.GeoCode));

            query.AddParameterToQuery("lang", parameters.Lang?.GetLanguageCode());
            query.AddParameterToQuery("locale", parameters.Locale);
            query.AddParameterToQuery("result_type", parameters.SearchType?.ToString().ToLowerInvariant());

            _queryParameterGenerator.AddMinMaxQueryParameters(query, parameters);

            query.AddFormattedParameterToQuery(_searchQueryParameterGenerator.GenerateSinceParameter(parameters.Since));
            query.AddFormattedParameterToQuery(_searchQueryParameterGenerator.GenerateUntilParameter(parameters.Until));
            query.AddParameterToQuery("include_entities", parameters.IncludeEntities);
            query.AddParameterToQuery("tweet_mode", tweetMode);

            query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters);

            return(query.ToString());
        }
        public string GetFavoriteTweetsQuery(IGetUserFavoriteTweetsParameters parameters, ComputedTweetMode tweetMode)
        {
            var userParameter = _userQueryParameterGenerator.GenerateIdOrScreenNameParameter(parameters.User);
            var query         = new StringBuilder(Resources.User_GetFavorites + userParameter);

            query.AddParameterToQuery("include_entities", parameters.IncludeEntities);
            _queryParameterGenerator.AddMinMaxQueryParameters(query, parameters);

            query.AddParameterToQuery("tweet_mode", tweetMode);
            query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters);

            return(query.ToString());
        }
Example #11
0
 public void AddTimelineParameters(StringBuilder query, ITimelineRequestParameters parameters, ComputedTweetMode tweetMode)
 {
     AddMinMaxQueryParameters(query, parameters);
     query.AddParameterToQuery("include_entities", parameters.IncludeEntities);
     query.AddParameterToQuery("trim_user", parameters.TrimUser);
     query.AddParameterToQuery("tweet_mode", tweetMode);
 }
Example #12
0
        // TWEETS
        public string GetTweetsFromListQuery(IGetTweetsFromListParameters parameters, ComputedTweetMode tweetMode)
        {
            var query = new StringBuilder(Resources.List_GetTweetsFromList);

            _twitterListQueryParameterGenerator.AppendListIdentifierParameter(query, parameters.List);
            _queryParameterGenerator.AddTimelineParameters(query, parameters, tweetMode);

            query.AddParameterToQuery("include_rts", parameters.IncludeRetweets);
            query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters);

            return(query.ToString());
        }
        // Retweets of Me Timeline
        public string GetRetweetsOfMeTimelineQuery(IGetRetweetsOfMeTimelineParameters parameters, ComputedTweetMode tweetMode)
        {
            var query = new StringBuilder(Resources.Timeline_GetRetweetsOfMeTimeline);

            _queryParameterGenerator.AddTimelineParameters(query, parameters, tweetMode);

            query.AddParameterToQuery("include_user_entities", parameters.IncludeUserEntities);
            query.AddFormattedParameterToQuery(parameters.FormattedCustomQueryParameters);

            return(query.ToString());
        }