/// <summary> /// Builds an url for getting all results from the Twitter stream. /// </summary> /// <param name="parameters">parameter list</param> /// <returns>base url + show segment</returns> Request BuildFirehoseUrl(Dictionary <string, string> parameters) { var req = new Request(BaseUrl + "statuses/firehose.json"); var urlParams = req.RequestParameters; if (parameters.ContainsKey("Count")) { urlParams.Add(new QueryParameter("count", parameters["Count"])); } if (parameters.ContainsKey("Delimited")) { urlParams.Add(new QueryParameter("delimited", parameters["Delimited"])); } if (parameters.ContainsKey("Language")) { urlParams.Add(new QueryParameter("language", parameters["Language"].Replace(" ", ""))); } if (parameters.ContainsKey("StallWarnings")) { urlParams.Add(new QueryParameter("stall_warnings", parameters["StallWarnings"].ToLower())); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = (TweetMode)int.Parse(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }
/// <summary> /// Builds an url for getting random sample tweets from the stream. /// </summary> /// <param name="parameters">parameter list</param> /// <returns>base url + show segment</returns> Request BuildSampleUrl(Dictionary <string, string> parameters) { if (parameters.ContainsKey("Count")) { throw new ArgumentException("Count is forbidden in Sample streams.", "Count"); } var req = new Request(BaseUrl + "statuses/sample.json"); var urlParams = req.RequestParameters; if (parameters.ContainsKey("Delimited")) { urlParams.Add(new QueryParameter("delimited", parameters["Delimited"])); } if (parameters.ContainsKey("Language")) { urlParams.Add(new QueryParameter("language", parameters["Language"].Replace(" ", ""))); } if (parameters.ContainsKey("StallWarnings")) { urlParams.Add(new QueryParameter("stall_warnings", parameters["StallWarnings"].ToLower())); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = (TweetMode)int.Parse(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }
Request BuildRetweetersUrl(Dictionary <string, string> parameters) { if (!parameters.ContainsKey("ID")) { throw new ArgumentException("ID is required.", "ID"); } var url = BaseUrl + "statuses/retweeters/ids.json"; var req = new Request(url); var urlParams = req.RequestParameters; ID = ulong.Parse(parameters["ID"]); urlParams.Add(new QueryParameter("id", parameters["ID"])); if (parameters.ContainsKey("Cursor")) { Cursor = long.Parse(parameters["Cursor"]); urlParams.Add(new QueryParameter("cursor", parameters["Cursor"])); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = RequestProcessorHelper.ParseEnum <TweetMode>(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }
/// <summary> /// Sends a status update. /// </summary> /// <param name="tweetID">ID (aka StatusID) of tweet to reply to. Sent via ReplyAsync overloads.</param> /// <param name="status">Status text.</param> /// <param name="latitude">Latitude coordinate of where tweet occurred.</param> /// <param name="longitude">Longitude coordinate of where tweet occurred.</param> /// <param name="placeID">ID of place (found via Geo Reverse lookup query).</param> /// <param name="displayCoordinates">Allow or prevent display of coordinates for this tweet.</param> /// <param name="trimUser">Remove user entity from response</param> /// <param name="mediaIds">Collection of ids of media to include in tweet.</param> /// <param name="autoPopulateReplyMetadata">Enables extended tweet mode where mentions don't count towards tweet length.</param> /// <param name="excludeReplyUserIds">Comma-separated list of @mentions to exclude from extended tweet prefix list.</param> /// <param name="attachmentUrl">Tweet link or DM deep link for extended tweet suffix that doesn't count towards tweet length.</param> /// <param name="tweetMode">Set to Extended for 280 characters (Text is blank and FullText contains tweet.</param> /// <param name="cancelToken">Async cancellation token.</param> /// <returns>Tweeted status.</returns> internal virtual async Task <Status> TweetOrReplyAsync(ulong tweetID, string status, decimal latitude, decimal longitude, string placeID, bool displayCoordinates, bool trimUser, IEnumerable <ulong> mediaIds, bool autoPopulateReplyMetadata, IEnumerable <ulong> excludeReplyUserIds, string attachmentUrl, TweetMode tweetMode = TweetMode.Compat, CancellationToken cancelToken = default(CancellationToken)) { if (string.IsNullOrWhiteSpace(status) && (mediaIds == null || !mediaIds.Any())) { throw new ArgumentException("status is a required parameter.", "status"); } var updateUrl = BaseUrl + "statuses/update.json"; RawResult = await TwitterExecutor.PostFormUrlEncodedToTwitterAsync <Status>( HttpMethod.Post.ToString(), updateUrl, new Dictionary <string, string> { { "status", status }, { "in_reply_to_status_id", tweetID == NoReply ? null : tweetID.ToString() }, { "lat", latitude == NoCoordinate ? null : latitude.ToString(Culture.US) }, { "long", longitude == NoCoordinate ? null : longitude.ToString(Culture.US) }, { "place_id", placeID == NoInputParam ? null : placeID }, { "display_coordinates", displayCoordinates ? displayCoordinates.ToString().ToLower() : null }, { "trim_user", trimUser ? trimUser.ToString().ToLower() : null }, { "media_ids", mediaIds == null || !mediaIds.Any() ? null : string.Join(",", mediaIds) }, { "auto_populate_reply_metadata", autoPopulateReplyMetadata ? autoPopulateReplyMetadata.ToString().ToLower() : null }, { "exclude_reply_user_ids", excludeReplyUserIds == null || !excludeReplyUserIds.Any() ? null : string.Join(",", excludeReplyUserIds) }, { "attachment_url", attachmentUrl }, { "tweet_mode", tweetMode == TweetMode.Compat ? null : tweetMode.ToString().ToLower() } }, cancelToken) .ConfigureAwait(false); return(new StatusRequestProcessor <Status>() .ProcessActionResult(RawResult, StatusAction.SingleStatus)); }
/// <summary> /// Builds an url for getting user info from stream. /// </summary> /// <param name="parameters">parameter list</param> /// <returns>base url + show segment</returns> Request BuildUserUrl(Dictionary <string, string> parameters) { var req = new Request(UserStreamUrl + "user.json"); var urlParams = req.RequestParameters; if (parameters.ContainsKey("Delimited")) { Delimited = parameters["Delimited"]; urlParams.Add(new QueryParameter("delimited", Delimited.ToLower())); } if (parameters.ContainsKey("Language")) { Language = parameters["Language"].Replace(" ", ""); urlParams.Add(new QueryParameter("language", Language)); } if (parameters.ContainsKey("Track")) { Track = parameters["Track"]; urlParams.Add(new QueryParameter("track", Track)); } if (parameters.ContainsKey("With")) { With = parameters["With"]; urlParams.Add(new QueryParameter("with", With.ToLower())); } if (parameters.ContainsKey("AllReplies")) { AllReplies = bool.Parse(parameters["AllReplies"]); if (AllReplies) { urlParams.Add(new QueryParameter("replies", "all")); } } if (parameters.ContainsKey("StallWarnings")) { StallWarnings = bool.Parse(parameters["StallWarnings"]); urlParams.Add(new QueryParameter("stall_warnings", parameters["StallWarnings"].ToLower())); } if (parameters.ContainsKey("Locations")) { Locations = parameters["Locations"]; urlParams.Add(new QueryParameter("locations", Locations)); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = (TweetMode)int.Parse(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }
public void AppendTweetModeParameter(StringBuilder query, TweetMode?tweetMode) { if (tweetMode == TweetMode.None) { return; } query.AddParameterToQuery("tweet_mode", tweetMode?.ToString().ToLowerInvariant()); }
public override string ToString() { if (_tweetMode == TweetMode.None) { return(null); } return(_tweetMode?.ToString().ToLowerInvariant()); }
/// <summary> /// Builds an url for filtering stream. /// </summary> /// <param name="parameters">parameter list</param> /// <returns>base url + show segment</returns> Request BuildFilterUrl(Dictionary <string, string> parameters) { if (!parameters.ContainsKey("Follow") && !parameters.ContainsKey("Locations") && !parameters.ContainsKey("Track")) { throw new ArgumentException("You must specify at least one of the parameters Follow, Locations, or Track.", "FollowOrLocationsOrTrack"); } var req = new Request(BaseUrl + "statuses/filter.json"); var urlParams = req.RequestParameters; if (parameters.ContainsKey("Count")) { urlParams.Add(new QueryParameter("count", parameters["Count"])); } if (parameters.ContainsKey("Delimited")) { urlParams.Add(new QueryParameter("delimited", parameters["Delimited"])); } if (parameters.ContainsKey("Follow")) { urlParams.Add(new QueryParameter("follow", parameters["Follow"])); } if (parameters.ContainsKey("Locations")) { urlParams.Add(new QueryParameter("locations", parameters["Locations"])); } if (parameters.ContainsKey("Track")) { urlParams.Add(new QueryParameter("track", parameters["Track"])); } if (parameters.ContainsKey("StallWarnings")) { urlParams.Add(new QueryParameter("stall_warnings", parameters["StallWarnings"].ToLower())); } if (parameters.ContainsKey("Language")) { urlParams.Add(new QueryParameter("language", parameters["Language"].Replace(" ", ""))); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = (TweetMode)int.Parse(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }
/// <summary> /// appends parameters for Favorites request /// </summary> /// <param name="parameters">list of parameters from expression tree</param> /// <param name="url">base url</param> /// <returns>base url + parameters</returns> Request BuildFavoritesUrlParameters(Dictionary <string, string> parameters) { var req = new Request(BaseUrl + "favorites/list.json"); var urlParams = req.RequestParameters; if (parameters.ContainsKey("UserID")) { UserID = ulong.Parse(parameters["UserID"]); urlParams.Add(new QueryParameter("user_id", parameters["UserID"])); } if (parameters.ContainsKey("ScreenName")) { ScreenName = parameters["ScreenName"]; urlParams.Add(new QueryParameter("screen_name", parameters["ScreenName"])); } if (parameters.ContainsKey("Count")) { Count = int.Parse(parameters["Count"]); urlParams.Add(new QueryParameter("count", parameters["Count"])); } if (parameters.ContainsKey("SinceID")) { SinceID = ulong.Parse(parameters["SinceID"]); urlParams.Add(new QueryParameter("since_id", parameters["SinceID"])); } if (parameters.ContainsKey("MaxID")) { MaxID = ulong.Parse(parameters["MaxID"]); urlParams.Add(new QueryParameter("max_id", parameters["MaxID"])); } if (parameters.ContainsKey("IncludeEntities")) { IncludeEntities = bool.Parse(parameters["IncludeEntities"]); urlParams.Add(new QueryParameter("include_entities", parameters["IncludeEntities"].ToLower())); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = (TweetMode)int.Parse(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }
/// <summary> /// builds a url to show user info /// </summary> /// <param name="parameters">url parameters</param> /// <returns>new url for request</returns> Request BuildShowUrl(Dictionary <string, string> parameters) { if (!parameters.ContainsKey("UserID") && !parameters.ContainsKey("ScreenName")) { throw new ArgumentException("Parameters must include either UserID or ScreenName.", ScreenNameOrUserID); } if (parameters.ContainsKey("UserID") && string.IsNullOrWhiteSpace(parameters["UserID"])) { throw new ArgumentNullException("UserID", "If specified, UserID can't be null or an empty string."); } if (parameters.ContainsKey("ScreenName") && string.IsNullOrWhiteSpace(parameters["ScreenName"])) { throw new ArgumentNullException("ScreenName", "If specified, ScreenName can't be null or an empty string."); } var req = new Request(BaseUrl + "users/show.json"); var urlParams = req.RequestParameters; if (parameters.ContainsKey("UserID")) { UserID = ulong.Parse(parameters["UserID"]); urlParams.Add(new QueryParameter("user_id", parameters["UserID"])); } if (parameters.ContainsKey("ScreenName")) { ScreenName = parameters["ScreenName"]; urlParams.Add(new QueryParameter("screen_name", parameters["ScreenName"])); } if (parameters.ContainsKey("IncludeEntities")) { IncludeEntities = bool.Parse(parameters["IncludeEntities"]); urlParams.Add(new QueryParameter("include_entities", parameters["IncludeEntities"].ToLower())); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = RequestProcessorHelper.ParseEnum <TweetMode>(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }
Request BuildLookupUrl(Dictionary <string, string> parameters) { if (!parameters.ContainsKey("TweetIDs") || string.IsNullOrWhiteSpace(parameters["TweetIDs"])) { throw new ArgumentNullException("TweetIDs", "TweetIDs is required"); } var req = new Request(BaseUrl + "statuses/lookup.json"); var urlParams = req.RequestParameters; TweetIDs = parameters["TweetIDs"].Replace(" ", ""); urlParams.Add(new QueryParameter("id", TweetIDs)); if (parameters.ContainsKey("IncludeEntities")) { IncludeEntities = bool.Parse(parameters["IncludeEntities"]); urlParams.Add(new QueryParameter("include_entities", parameters["IncludeEntities"].ToLower())); } if (parameters.ContainsKey("Map")) { Map = bool.Parse(parameters["Map"]); urlParams.Add(new QueryParameter("map", parameters["Map"].ToLower())); } if (parameters.ContainsKey("TrimUser")) { TrimUser = bool.Parse(parameters["TrimUser"]); urlParams.Add(new QueryParameter("trim_user", parameters["TrimUser"].ToLower())); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = RequestProcessorHelper.ParseEnum <TweetMode>(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } if (parameters.ContainsKey(nameof(IncludeAltText))) { IncludeAltText = bool.Parse(parameters[nameof(IncludeAltText)]); urlParams.Add(new QueryParameter("include_ext_alt_text", parameters[nameof(IncludeAltText)].ToLower())); } return(req); }
/// <summary> /// Builds a URL to perform a user search /// </summary> /// <param name="parameters">Query, Page, and Count</param> /// <returns>URL for performing user search</returns> Request BuildSearchUrl(Dictionary <string, string> parameters) { const string QueryParam = "Query"; if (!parameters.ContainsKey("Query")) { throw new ArgumentException("Query parameter is required.", QueryParam); } var req = new Request(BaseUrl + "users/search.json"); var urlParams = req.RequestParameters; if (parameters.ContainsKey("Query")) { Query = parameters["Query"]; urlParams.Add(new QueryParameter("q", parameters["Query"])); } if (parameters.ContainsKey("Page")) { Page = int.Parse(parameters["Page"]); urlParams.Add(new QueryParameter("page", parameters["Page"])); } if (parameters.ContainsKey("Count")) { Count = int.Parse(parameters["Count"]); urlParams.Add(new QueryParameter("count", parameters["Count"])); } if (parameters.ContainsKey("IncludeEntities")) { IncludeEntities = bool.Parse(parameters["IncludeEntities"]); urlParams.Add(new QueryParameter("include_entities", parameters["IncludeEntities"].ToLower())); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = RequestProcessorHelper.ParseEnum <TweetMode>(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }
Request BuildContributeesUrl(Dictionary <string, string> parameters) { if (!(parameters.ContainsKey("ScreenName") || parameters.ContainsKey("UserID")) || (parameters.ContainsKey("ScreenName") && parameters.ContainsKey("UserID"))) { throw new ArgumentException("Query must contain one of either ScreenName or UserID parameters, but not both.", ScreenNameOrUserID); } var req = new Request(BaseUrl + "users/contributees.json"); var urlParams = req.RequestParameters; if (parameters.ContainsKey("UserID")) { UserID = ulong.Parse(parameters["UserID"]); urlParams.Add(new QueryParameter("user_id", parameters["UserID"])); } if (parameters.ContainsKey("ScreenName")) { ScreenName = parameters["ScreenName"]; urlParams.Add(new QueryParameter("screen_name", parameters["ScreenName"])); } if (parameters.ContainsKey("IncludeEntities")) { IncludeEntities = bool.Parse(parameters["IncludeEntities"]); urlParams.Add(new QueryParameter("include_entities", parameters["IncludeEntities"].ToLower())); } if (parameters.ContainsKey("SkipStatus")) { SkipStatus = bool.Parse(parameters["SkipStatus"]); urlParams.Add(new QueryParameter("skip_status", parameters["SkipStatus"].ToLower())); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = RequestProcessorHelper.ParseEnum <TweetMode>(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }
Request BuildConversationUrl(Dictionary <string, string> parameters) { if (!parameters.ContainsKey("ID") || string.IsNullOrWhiteSpace(parameters["ID"])) { throw new ArgumentNullException("ID", "ID is required"); } var req = new Request(BaseUrl + "conversation/show.json"); var urlParams = req.RequestParameters; ID = ulong.Parse(parameters["ID"]); urlParams.Add(new QueryParameter("id", parameters["ID"])); if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = RequestProcessorHelper.ParseEnum <TweetMode>(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }
/// <summary> /// Builds a url for performing lookups /// </summary> /// <param name="parameters">Either UserID or ScreenName</param> /// <returns>URL for performing lookups</returns> Request BuildLookupUrl(Dictionary <string, string> parameters) { if (!(parameters.ContainsKey("ScreenNameList") || parameters.ContainsKey("UserIdList")) || (parameters.ContainsKey("ScreenNameList") && parameters.ContainsKey("UserIdList"))) { throw new ArgumentException("Query must contain one of either ScreenNameList or UserIdList parameters, but not both.", ScreenNameListOrUserIdList); } var req = new Request(BaseUrl + "users/lookup.json"); var urlParams = req.RequestParameters; if (parameters.ContainsKey("ScreenNameList")) { ScreenNameList = parameters["ScreenNameList"]; urlParams.Add(new QueryParameter("screen_name", parameters["ScreenNameList"])); } if (parameters.ContainsKey("UserIdList")) { UserIdList = parameters["UserIdList"]; urlParams.Add(new QueryParameter("user_id", parameters["UserIdList"].Replace(" ", ""))); } if (parameters.ContainsKey("IncludeEntities")) { IncludeEntities = bool.Parse(parameters["IncludeEntities"]); urlParams.Add(new QueryParameter("include_entities", parameters["IncludeEntities"].ToLower())); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = RequestProcessorHelper.ParseEnum <TweetMode>(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }
/// <summary> /// appends parameters for Search request /// </summary> /// <param name="parameters">list of parameters from expression tree</param> /// <param name="url">base url</param> /// <returns>base url + parameters</returns> private Request BuildSearchUrlParameters(Dictionary <string, string> parameters, string url) { var req = new Request(BaseUrl + url); var urlParams = req.RequestParameters; if (parameters.ContainsKey("Query") && !string.IsNullOrWhiteSpace(parameters["Query"])) { Query = parameters["Query"]; urlParams.Add(new QueryParameter("q", Query)); } else { throw new ArgumentNullException("Query", "Query filter in where clause is required."); } if (parameters.ContainsKey("GeoCode")) { GeoCode = parameters["GeoCode"]; urlParams.Add(new QueryParameter("geocode", GeoCode)); } if (parameters.ContainsKey("SearchLanguage")) { SearchLanguage = parameters["SearchLanguage"]; urlParams.Add(new QueryParameter("lang", SearchLanguage)); } if (parameters.ContainsKey("Locale")) { Locale = parameters["Locale"]; urlParams.Add(new QueryParameter("locale", Locale)); } if (parameters.ContainsKey("Count")) { Count = int.Parse(parameters["Count"]); urlParams.Add(new QueryParameter("count", Count.ToString(CultureInfo.InvariantCulture))); } if (parameters.ContainsKey("Until")) { Until = DateTime.Parse(parameters["Until"]).Date; urlParams.Add(new QueryParameter("until", Until.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture))); } if (parameters.ContainsKey("SinceID")) { SinceID = ulong.Parse(parameters["SinceID"]); urlParams.Add(new QueryParameter("since_id", SinceID.ToString(CultureInfo.InvariantCulture))); } if (parameters.ContainsKey("MaxID")) { MaxID = ulong.Parse(parameters["MaxID"]); urlParams.Add(new QueryParameter("max_id", MaxID.ToString(CultureInfo.InvariantCulture))); } if (parameters.ContainsKey("ResultType")) { ResultType = RequestProcessorHelper.ParseEnum <ResultType>(parameters["ResultType"]); urlParams.Add(new QueryParameter("result_type", ResultType.ToString().ToLower())); } if (parameters.ContainsKey("IncludeEntities")) { IncludeEntities = bool.Parse(parameters["IncludeEntities"]); urlParams.Add(new QueryParameter("include_entities", parameters["IncludeEntities"].ToLower())); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = RequestProcessorHelper.ParseEnum <TweetMode>(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }
/// <summary> /// construct an oembed url /// </summary> /// <param name="parameters">input parameters</param> /// <returns>base url + url segment</returns> Request BuildOembedUrl(Dictionary <string, string> parameters) { var req = new Request(BaseUrl + "statuses/oembed.json"); var urlParams = req.RequestParameters; if (parameters.ContainsKey("ID")) { ID = ulong.Parse(parameters["ID"]); urlParams.Add(new QueryParameter("id", parameters["ID"])); } if (parameters.ContainsKey("OEmbedUrl")) { OEmbedUrl = parameters["OEmbedUrl"]; urlParams.Add(new QueryParameter("url", parameters["OEmbedUrl"])); } if (parameters.ContainsKey("OEmbedMaxWidth")) { OEmbedMaxWidth = int.Parse(parameters["OEmbedMaxWidth"]); urlParams.Add(new QueryParameter("maxwidth", parameters["OEmbedMaxWidth"])); } if (parameters.ContainsKey("OEmbedHideMedia")) { OEmbedHideMedia = bool.Parse(parameters["OEmbedHideMedia"]); urlParams.Add(new QueryParameter("hide_media", parameters["OEmbedHideMedia"].ToLower())); } if (parameters.ContainsKey("OEmbedHideThread")) { OEmbedHideThread = bool.Parse(parameters["OEmbedHideThread"]); urlParams.Add(new QueryParameter("hide_thread", parameters["OEmbedHideThread"].ToLower())); } if (parameters.ContainsKey("OEmbedOmitScript")) { OEmbedOmitScript = bool.Parse(parameters["OEmbedOmitScript"]); urlParams.Add(new QueryParameter("omit_script", parameters["OEmbedOmitScript"].ToLower())); } if (parameters.ContainsKey("OEmbedAlign")) { OEmbedAlign = RequestProcessorHelper.ParseEnum <EmbeddedStatusAlignment>(parameters["OEmbedAlign"]); urlParams.Add(new QueryParameter("align", OEmbedAlign.ToString().ToLower())); } if (parameters.ContainsKey("OEmbedRelated")) { OEmbedRelated = parameters["OEmbedRelated"]; urlParams.Add(new QueryParameter("related", parameters["OEmbedRelated"].Replace(" ", ""))); } if (parameters.ContainsKey("OEmbedLanguage")) { OEmbedLanguage = parameters["OEmbedLanguage"]; urlParams.Add(new QueryParameter("lang", parameters["OEmbedLanguage"].ToLower())); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = RequestProcessorHelper.ParseEnum <TweetMode>(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }
/// <summary> /// appends parameters that are common to both friend and user queries /// </summary> /// <param name="parameters">list of parameters from expression tree</param> /// <param name="url">base url</param> /// <returns>base url + parameters</returns> Request BuildUrlParameters(Dictionary <string, string> parameters, string url) { var req = new Request(BaseUrl + url); var urlParams = req.RequestParameters; if (parameters.ContainsKey("ID")) { ID = ulong.Parse(parameters["ID"]); urlParams.Add(new QueryParameter("id", parameters["ID"])); } if (parameters.ContainsKey("UserID")) { UserID = ulong.Parse(parameters["UserID"]); urlParams.Add(new QueryParameter("user_id", parameters["UserID"])); } if (parameters.ContainsKey("ScreenName")) { ScreenName = parameters["ScreenName"]; urlParams.Add(new QueryParameter("screen_name", parameters["ScreenName"])); } if (parameters.ContainsKey("SinceID")) { SinceID = ulong.Parse(parameters["SinceID"]); urlParams.Add(new QueryParameter("since_id", parameters["SinceID"])); } if (parameters.ContainsKey("MaxID")) { MaxID = ulong.Parse(parameters["MaxID"]); urlParams.Add(new QueryParameter("max_id", parameters["MaxID"])); } if (parameters.ContainsKey("Count")) { Count = int.Parse(parameters["Count"]); urlParams.Add(new QueryParameter("count", parameters["Count"])); } if (parameters.ContainsKey("IncludeRetweets")) { IncludeRetweets = bool.Parse(parameters["IncludeRetweets"]); urlParams.Add(new QueryParameter("include_rts", parameters["IncludeRetweets"].ToLower())); } if (parameters.ContainsKey("ExcludeReplies")) { ExcludeReplies = bool.Parse(parameters["ExcludeReplies"]); urlParams.Add(new QueryParameter("exclude_replies", parameters["ExcludeReplies"].ToLower())); } if (parameters.ContainsKey("IncludeMyRetweet")) { IncludeMyRetweet = bool.Parse(parameters["IncludeMyRetweet"]); urlParams.Add(new QueryParameter("include_my_retweet", parameters["IncludeMyRetweet"].ToLower())); } if (parameters.ContainsKey("IncludeEntities")) { IncludeEntities = bool.Parse(parameters["IncludeEntities"]); urlParams.Add(new QueryParameter("include_entities", parameters["IncludeEntities"].ToLower())); } if (parameters.ContainsKey("IncludeUserEntities")) { IncludeUserEntities = bool.Parse(parameters["IncludeUserEntities"]); urlParams.Add(new QueryParameter("include_user_entities", parameters["IncludeUserEntities"].ToLower())); } if (parameters.ContainsKey("TrimUser")) { TrimUser = bool.Parse(parameters["TrimUser"]); urlParams.Add(new QueryParameter("trim_user", parameters["TrimUser"].ToLower())); } if (parameters.ContainsKey("IncludeContributorDetails")) { IncludeContributorDetails = bool.Parse(parameters["IncludeContributorDetails"]); urlParams.Add(new QueryParameter("contributor_details", parameters["IncludeContributorDetails"].ToLower())); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = RequestProcessorHelper.ParseEnum <TweetMode>(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } if (parameters.ContainsKey(nameof(IncludeAltText))) { IncludeAltText = bool.Parse(parameters[nameof(IncludeAltText)]); urlParams.Add(new QueryParameter("include_ext_alt_text", parameters[nameof(IncludeAltText)].ToLower())); } return(req); }
public string GenerateTweetModeParameter(TweetMode? tweetMode) { var tweetModeParameter = string.Empty; if (tweetMode != null) { tweetModeParameter = tweetMode.ToString().ToLowerInvariant(); } return tweetModeParameter; }
/// <summary> /// Builds an url for getting info for multiple users from stream. /// </summary> /// <param name="parameters">parameter list</param> /// <returns>base url + show segment</returns> Request BuildSiteUrl(Dictionary <string, string> parameters) { if (!parameters.ContainsKey("Follow")) { throw new ArgumentNullException("Follow", "Follow is required."); } var req = new Request(SiteStreamUrl + "site.json"); var urlParams = req.RequestParameters; if (parameters.ContainsKey("Delimited")) { Delimited = parameters["Delimited"]; urlParams.Add(new QueryParameter("delimited", Delimited.ToLower())); } if (parameters.ContainsKey("Language")) { Language = parameters["Language"].Replace(" ", ""); urlParams.Add(new QueryParameter("language", Language)); } if (parameters.ContainsKey("Follow")) { Follow = parameters["Follow"].Replace(" ", ""); urlParams.Add(new QueryParameter("follow", Follow.ToLower())); } if (parameters.ContainsKey("Track")) { throw new ArgumentException("Track is not supported for Site Streams.", "Track"); } if (parameters.ContainsKey("With")) { With = parameters["With"]; urlParams.Add(new QueryParameter("with", With.ToLower())); } if (parameters.ContainsKey("AllReplies")) { AllReplies = bool.Parse(parameters["AllReplies"]); if (AllReplies) { urlParams.Add(new QueryParameter("replies", "all")); } } if (parameters.ContainsKey("StallWarnings")) { StallWarnings = bool.Parse(parameters["StallWarnings"]); urlParams.Add(new QueryParameter("stall_warnings", parameters["StallWarnings"].ToLower())); } if (parameters.ContainsKey(nameof(TweetMode))) { TweetMode = (TweetMode)int.Parse(parameters[nameof(TweetMode)]); urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower())); } return(req); }