Ejemplo n.º 1
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public virtual string BuildURL(Dictionary <string, string> parameters)
        {
            string url = null;

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", "Type");
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <BlockingType>(parameters["Type"]);

            switch (Type)
            {
            case BlockingType.Blocking:
                url = BuildBlockingUrl(parameters);
                break;

            case BlockingType.Exists:
                url = BuildBlockingExistsUrl(parameters);
                break;

            case BlockingType.IDS:
                url = BuildBlockingIDsUrl(parameters);
                break;

            default:
                throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified.");
            }

            return(url);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public string BuildURL(Dictionary <string, string> parameters)
        {
            string url = null;

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", "Type");
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <LegalType>(parameters["Type"]);

            switch (Type)
            {
            case LegalType.Privacy:
                url = BuildPrivacyUrl(parameters);
                break;

            case LegalType.TOS:
                url = BuildTosUrl(parameters);
                break;

            default:
                break;
            }

            return(url);
        }
Ejemplo n.º 3
0
        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>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public virtual Request BuildUrl(Dictionary <string, string> parameters)
        {
            const string TypeParam = "Type";

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", TypeParam);
            }

            Type = RequestProcessorHelper.ParseEnum <DirectMessageType>(parameters["Type"]);

            switch (Type)
            {
            case DirectMessageType.SentBy:
                return(BuildSentByUrl(parameters));

            case DirectMessageType.SentTo:
                return(BuildSentToUrl(parameters));

            case DirectMessageType.Show:
                return(BuildShowUrl(parameters));

            default:
                throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified.");
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public Request BuildUrl(Dictionary <string, string> parameters)
        {
            if (parameters.ContainsKey(nameof(Type)))
            {
                Type = RequestProcessorHelper.ParseEnum <TweetType>(parameters[nameof(Type)]);
            }
            else
            {
                throw new ArgumentException($"{nameof(Type)} is required", nameof(Type));
            }

            Type = RequestProcessorHelper.ParseEnum <TweetType>(parameters[nameof(Type)]);

            switch (Type)
            {
            case TweetType.Lookup:
                return(BuildLookupUrl(parameters));

            case TweetType.MentionsTimeline:
                return(BuildMentionsTimelineUrl(parameters));

            case TweetType.TweetsTimeline:
                return(BuildUserTimelineUrl(parameters));

            default:
                throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified.");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public string BuildURL(Dictionary <string, string> parameters)
        {
            string url = null;

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", "Type");
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <GeoType>(parameters["Type"]);

            switch (Type)
            {
            case GeoType.ID:
                url = BuildIDUrl(parameters);
                break;

            case GeoType.Reverse:
                url = BuildReverseUrl(parameters);
                break;

            case GeoType.Nearby:
                url = BuildNearbyPlacesUrl(parameters);
                break;

            default:
                throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified.");
            }

            return(url);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public string BuildURL(Dictionary <string, string> parameters)
        {
            string url = null;

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", "Type");
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <SocialGraphType>(parameters["Type"]);

            switch (Type)
            {
            case SocialGraphType.Followers:
                url = BuildSocialGraphFollowersUrl(parameters);
                break;

            case SocialGraphType.Friends:
                url = BuildSocialGraphFriendsUrl(parameters);
                break;

            default:
                throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified.");
            }

            return(url);
        }
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public virtual Request BuildUrl(Dictionary <string, string> parameters)
        {
            if (parameters == null || !parameters.ContainsKey(nameof(Type)))
            {
                throw new ArgumentException($"You must set {nameof(Type)}.", nameof(Type));
            }

            Type = RequestProcessorHelper.ParseEnum <WelcomeMessageType>(parameters[nameof(Type)]);

            switch (Type)
            {
            case WelcomeMessageType.ListMessages:
                return(BuildListMessagesUrl(parameters));

            case WelcomeMessageType.ListRules:
                return(BuildListRulesUrl(parameters));

            case WelcomeMessageType.ShowMessage:
                return(BuildShowMessagesUrl(parameters));

            case WelcomeMessageType.ShowRule:
                return(BuildShowRuleUrl(parameters));

            default:
                throw new InvalidOperationException(
                          $"Didn't recognize '{Type}' for {nameof(Type)} parameter in WelcomeMessageRequestProcessor.BuildUrl.");
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public virtual string BuildURL(Dictionary <string, string> parameters)
        {
            string url = null;

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", "Type");
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <DirectMessageType>(parameters["Type"]);

            switch (Type)
            {
            case DirectMessageType.SentBy:
                url = BuildSentByUrl(parameters);
                break;

            case DirectMessageType.SentTo:
                url = BuildSentToUrl(parameters);
                break;

            case DirectMessageType.Show:
                url = BuildShowUrl(parameters);
                break;

            default:
                throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified.");
            }

            return(url);
        }
        public Request BuildUrl(Dictionary <string, string> parameters)
        {
            const string TypeParam = "Type";

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", TypeParam);
            }

            Type = RequestProcessorHelper.ParseEnum <HelpType>(parameters["Type"]);

            switch (Type)
            {
            case HelpType.Configuration:
                return(new Request(BaseUrl + "help/configuration.json"));

            case HelpType.Languages:
                return(new Request(BaseUrl + "help/languages.json"));

            case HelpType.Privacy:
                return(new Request(BaseUrl + "help/privacy.json"));

            case HelpType.RateLimits:
                return(BuildRateLimitsUrl(parameters));

            case HelpType.Tos:
                return(new Request(BaseUrl + "help/tos.json"));

            default:
                throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified.");
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public virtual string BuildURL(Dictionary <string, string> parameters)
        {
            string url = null;

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", "Type");
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <AccountType>(parameters["Type"]);

            switch (Type)
            {
            case AccountType.VerifyCredentials:
                url = BaseUrl + "account/verify_credentials.xml";
                break;

            case AccountType.RateLimitStatus:
                url = BaseUrl + "account/rate_limit_status.xml";
                break;

            default:
                throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified.");
            }

            return(url);
        }
        Request BuildVerifyCredentialsUrl(Dictionary <string, string> parameters)
        {
            var req       = new Request(BaseUrl + "account/verify_credentials.json");
            var urlParams = req.RequestParameters;

            if (parameters.ContainsKey("SkipStatus") &&
                RequestProcessorHelper.FlagTrue(parameters, "SkipStatus"))
            {
                SkipStatus = true;
                urlParams.Add(new QueryParameter("skip_status", "true"));
            }

            if (parameters.ContainsKey("IncludeEntities"))
            {
                IncludeEntities = bool.Parse(parameters["IncludeEntities"]);
                urlParams.Add(new QueryParameter("include_entities", parameters["IncludeEntities"].ToLower()));
            }

            if (parameters.ContainsKey("IncludeEmail"))
            {
                IncludeEmail = bool.Parse(parameters["IncludeEmail"]);
                urlParams.Add(new QueryParameter("include_email", parameters["IncludeEmail"].ToLower()));
            }

            return(req);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public string BuildURL(Dictionary <string, string> parameters)
        {
            string url = null;

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", "Type");
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <UserStreamType>(parameters["Type"]);

            switch (Type)
            {
            case UserStreamType.User:
                url = BuildUserUrl(parameters);
                break;

            case UserStreamType.Site:
                url = BuildSiteUrl(parameters);
                break;

            default:
                throw new ArgumentException("Invalid UserStreamType", "UserStreamType");
            }

            return(url);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public virtual Request BuildUrl(Dictionary <string, string> parameters)
        {
            const string TypeParam = "Type";

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", TypeParam);
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <TrendType>(parameters["Type"]);

            switch (Type)
            {
            case TrendType.Available:
                return(BuildAvailableTrendsUrl());

            case TrendType.Closest:
                return(BuildClosestTrendsUrl(parameters));

            case TrendType.Place:
                return(BuildPlaceTrendsUrl(parameters));

            default:
                throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified.");
            }
        }
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public Request BuildUrl(Dictionary <string, string> parameters)
        {
            const string TypeParam = "Type";

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", TypeParam);
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <StreamingType>(parameters["Type"]);

            switch (Type)
            {
            case StreamingType.Filter:
                return(BuildFilterUrl(parameters));

            case StreamingType.Firehose:
                return(BuildFirehoseUrl(parameters));

            case StreamingType.Links:
                return(BuildLinksUrl(parameters));

            case StreamingType.Retweet:
                return(BuildRetweetUrl(parameters));

            case StreamingType.Sample:
                return(BuildSampleUrl(parameters));

            default:
                break;
            }

            return(null);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Builds url based on input parameters.
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public Request BuildUrl(Dictionary <string, string> parameters)
        {
            const string TypeParam = "Type";

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", TypeParam);
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <GeoType>(parameters["Type"]);

            switch (Type)
            {
            case GeoType.ID:
                return(BuildIDUrl(parameters));

            case GeoType.Reverse:
                return(BuildReverseUrl(parameters));

            case GeoType.Search:
                return(BuildSearchUrl(parameters));

            case GeoType.SimilarPlaces:
                return(BuildSimilarPlacesUrl(parameters));

            default:
                throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified.");
            }
        }
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public Request BuildUrl(Dictionary <string, string> parameters)
        {
            if (parameters.ContainsKey(nameof(Type)))
            {
                Type = RequestProcessorHelper.ParseEnum <StreamingType>(parameters["Type"]);
            }
            else
            {
                throw new ArgumentException($"{nameof(Type)} is required", nameof(Type));
            }

            string segment = Type == StreamingType.Filter ? "tweets/search/stream" : "tweets/sample/stream";

            bool isStreaming = true;

            if (Type == StreamingType.Rules)
            {
                segment     = "tweets/search/stream/rules";
                isStreaming = false;
            }

            var req = new Request(BaseUrl + segment)
            {
                IsStreaming = isStreaming
            };
            var urlParams = req.RequestParameters;

            BuildUrlParameters(parameters, urlParams);

            return(req);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public virtual string BuildURL(Dictionary <string, string> parameters)
        {
            string url = null;

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", "Type");
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <StatusType>(parameters["Type"]);

            switch (Type)
            {
            case StatusType.Friends:
                url = BuildFriendUrl(parameters);
                break;

            case StatusType.Home:
                url = BuildHomeUrl(parameters);
                break;

            case StatusType.Mentions:
                url = BuildMentionsUrl(parameters);
                break;

            case StatusType.Public:
                url = BuildPublicUrl();
                break;

            case StatusType.Retweets:
                url = BuildRetweetsUrl(parameters);
                break;

            case StatusType.RetweetedByMe:
                url = BuildRetweetedByMeUrl(parameters);
                break;

            case StatusType.RetweetedToMe:
                url = BuildRetweetedToMeUrl(parameters);
                break;

            case StatusType.RetweetsOfMe:
                url = BuildRetweetsOfMeUrl(parameters);
                break;

            case StatusType.Show:
                url = BuildShowUrl(parameters);
                break;

            case StatusType.User:
                url = BuildUserUrl(parameters);
                break;

            default:
                throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified.");
            }

            return(url);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public Request BuildUrl(Dictionary <string, string> parameters)
        {
            if (parameters.ContainsKey("Type"))
            {
                Type = RequestProcessorHelper.ParseEnum <SearchType>(parameters["Type"]);
            }
            else
            {
                throw new ArgumentException("Type is required", "Type");
            }

            return(BuildSearchUrlParameters(parameters, "search/tweets.json"));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public Request BuildUrl(Dictionary <string, string> parameters)
        {
            if (parameters.ContainsKey(nameof(Type)))
            {
                Type = RequestProcessorHelper.ParseEnum <TweetType>(parameters[nameof(Type)]);
            }
            else
            {
                throw new ArgumentException($"{nameof(Type)} is required", nameof(Type));
            }

            return(BuildUrlParameters(parameters, "tweets"));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public virtual string BuildURL(Dictionary <string, string> parameters)
        {
            string url = null;

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", "Type");
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <UserType>(parameters["Type"]);

            switch (Type)
            {
            case UserType.Followers:
                url = BuildFollowersUrl(parameters);
                break;

            case UserType.Friends:
                url = BuildFriendsUrl(parameters);
                break;

            case UserType.Show:
                url = BuildShowUrl(parameters);
                break;

            case UserType.Categories:
                url = BuildCategoriesUrl(parameters);
                break;

            case UserType.Category:
                url = BuildUsersInCategoryUrl(parameters);
                break;

            case UserType.CategoryStatus:
                url = BuildCategoryStatusUrl(parameters);
                break;

            case UserType.Lookup:
                url = BuildLookupUrl(parameters);
                break;

            case UserType.Search:
                url = BuildSearchUrl(parameters);
                break;

            default:
                throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified.");
            }

            return(url);
        }
Ejemplo n.º 22
0
        /// <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 = RequestProcessorHelper.ParseEnum <TweetMode>(parameters[nameof(TweetMode)]);
                urlParams.Add(new QueryParameter("tweet_mode", TweetMode.ToString().ToLower()));
            }

            return(req);
        }
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public virtual Request BuildUrl(Dictionary<string, string> parameters)
        {
            const string TypeParam = "Type";
            const string ParamsParam = "parameters";

            if (parameters == null)
                throw new ArgumentException("You must pass a \"parameters\" Dictionary<string, string> parameter.", ParamsParam);

            if (!parameters.ContainsKey("Type"))
                throw new ArgumentException("You must set Type.", TypeParam);

            Type = RequestProcessorHelper.ParseEnum<FavoritesType>(parameters["Type"]);

            return BuildFavoritesUrlParameters(parameters);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public virtual string BuildURL(Dictionary <string, string> parameters)
        {
            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", "Type");
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <FavoritesType>(parameters["Type"]);

            var url = BaseUrl + "favorites.xml";

            url = BuildFavoritesUrlParameters(parameters, url);

            return(url);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public string BuildURL(Dictionary <string, string> parameters)
        {
            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", "Type");
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <SearchType>(parameters["Type"]);

            var url = BaseUrl + "search.atom";

            url = BuildSearchUrlParameters(parameters, url);

            return(url);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public virtual Request BuildUrl(Dictionary <string, string> parameters)
        {
            const string TypeParam = "Type";

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", TypeParam);
            }

            Type = RequestProcessorHelper.ParseQueryEnumType <StatusType>(parameters["Type"]);

            switch (Type)
            {
            case StatusType.Conversation:
                return(BuildConversationUrl(parameters));

            case StatusType.Home:
                return(BuildHomeUrl(parameters));

            case StatusType.Lookup:
                return(BuildLookupUrl(parameters));

            case StatusType.Mentions:
                return(BuildMentionsUrl(parameters));

            case StatusType.Oembed:
                return(BuildOembedUrl(parameters));

            case StatusType.RetweetsOfMe:
                return(BuildRetweetsOfMeUrl(parameters));

            case StatusType.Retweets:
                return(BuildRetweets(parameters));

            case StatusType.Show:
                return(BuildShowUrl(parameters));

            case StatusType.User:
                return(BuildUserUrl(parameters));

            case StatusType.Retweeters:
                return(BuildRetweetersUrl(parameters));

            default:
                throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified.");
            }
        }
Ejemplo n.º 27
0
        /// <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);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public virtual Request BuildUrl(Dictionary <string, string> parameters)
        {
            const string TypeParam = "Type";

            if (parameters == null || !parameters.ContainsKey("Type"))
            {
                throw new ArgumentException("You must set Type.", TypeParam);
            }

            Type = RequestProcessorHelper.ParseEnum <AccountType>(parameters[TypeParam]);

            return(Type switch
            {
                AccountType.VerifyCredentials => BuildVerifyCredentialsUrl(parameters),
                AccountType.Settings => new Request(BaseUrl + "account/settings.json"),
                _ => throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified."),
            });
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public virtual Request BuildUrl(Dictionary <string, string> parameters)
        {
            if (parameters == null || !parameters.ContainsKey(nameof(Type)))
            {
                throw new ArgumentException($"You must set {nameof(Type)}.", nameof(Type));
            }

            Type = RequestProcessorHelper.ParseEnum <DirectMessageEventsType>(parameters[nameof(Type)]);

            return(Type switch
            {
                DirectMessageEventsType.List => BuildListUrl(parameters),
                DirectMessageEventsType.Show => BuildShowUrl(parameters),
                _ => throw new InvalidOperationException(
                    $"Didn't recognize '{Type}' for {nameof(Type)} parameter in " +
                    $"DirectMessageEventsRequestProcessor.BuildUrl."),
            });
Ejemplo n.º 30
0
        /// <summary>
        /// builds url based on input parameters
        /// </summary>
        /// <param name="parameters">criteria for url segments and parameters</param>
        /// <returns>URL conforming to Twitter API</returns>
        public Request BuildUrl(Dictionary <string, string> parameters)
        {
            if (parameters.ContainsKey(nameof(Type)))
            {
                Type = RequestProcessorHelper.ParseEnum <UserType>(parameters["Type"]);
            }
            else
            {
                throw new ArgumentException($"{nameof(Type)} is required", nameof(Type));
            }

            return(Type switch
            {
                UserType.IdLookup => BuildIdLookupUrl(parameters),
                UserType.UsernameLookup => BuildUsernameLookupUrl(parameters),
                _ => throw new InvalidOperationException("The default case of BuildUrl should never execute because a Type must be specified."),
            });