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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Build url for getting list memberships.
        /// </summary>
        /// <param name="parameters">NoChange required</param>
        /// <returns>URL for memberships query</returns>
        Request BuildMembershipsUrl(Dictionary <string, string> parameters)
        {
            if (!(parameters.ContainsKey("UserID") && !string.IsNullOrWhiteSpace(parameters["UserID"])) &&
                !(parameters.ContainsKey("ScreenName") && !string.IsNullOrWhiteSpace(parameters["ScreenName"])))
            {
                throw new ArgumentException("Either UserID or ScreenName are required.", UserIdOrScreenName);
            }

            var req       = new Request(BaseUrl + "lists/memberships.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("Cursor"))
            {
                Cursor = long.Parse(parameters["Cursor"]);
                urlParams.Add(new QueryParameter("cursor", parameters["Cursor"]));
            }

            if (parameters.ContainsKey("FilterToOwnedLists"))
            {
                if (RequestProcessorHelper.FlagTrue(parameters, "FilterToOwnedLists"))
                {
                    FilterToOwnedLists = true;
                    urlParams.Add(new QueryParameter("filter_to_owned_lists", "true"));
                }
            }

            return(req);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Build URL to see if user is subscribed to a list.
        /// </summary>
        /// <param name="parameters">Should contain ID and ListID</param>
        /// <returns>URL for IsSubscriber query</returns>
        Request BuildIsSubcribedUrl(Dictionary <string, string> parameters)
        {
            if ((!parameters.ContainsKey("UserID") || string.IsNullOrWhiteSpace(parameters["UserID"])) &&
                (!parameters.ContainsKey("ScreenName") || string.IsNullOrWhiteSpace(parameters["ScreenName"])))
            {
                throw new ArgumentException("You must specify either UserID or ScreenName of the user you're checking.", UserIdOrScreenName);
            }

            if ((!parameters.ContainsKey("ListID") || string.IsNullOrWhiteSpace(parameters["ListID"])) &&
                (!parameters.ContainsKey("Slug") || string.IsNullOrWhiteSpace(parameters["Slug"])))
            {
                throw new ArgumentException("You must specify either ListID or Slug.", ListIdOrSlugParam);
            }

            if (parameters.ContainsKey("Slug") &&
                !(parameters.ContainsKey("OwnerID") && !string.IsNullOrWhiteSpace(parameters["OwnerID"])) &&
                !(parameters.ContainsKey("OwnerScreenName") && !string.IsNullOrWhiteSpace(parameters["OwnerScreenName"])))
            {
                throw new ArgumentException("If you specify a Slug, you must also specify either OwnerID or OwnerScreenName.", OwnerIdOrOwnerScreenName);
            }

            var req       = new Request(BaseUrl + "lists/subscribers/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("Slug"))
            {
                Slug = parameters["Slug"];
                urlParams.Add(new QueryParameter("slug", parameters["Slug"]));
            }

            if (parameters.ContainsKey("OwnerID"))
            {
                OwnerID = ulong.Parse(parameters["OwnerID"]);
                urlParams.Add(new QueryParameter("owner_id", parameters["OwnerID"]));
            }

            if (parameters.ContainsKey("OwnerScreenName"))
            {
                OwnerScreenName = parameters["OwnerScreenName"];
                urlParams.Add(new QueryParameter("owner_screen_name", parameters["OwnerScreenName"]));
            }

            if (parameters.ContainsKey("ListID"))
            {
                ListID = ulong.Parse(parameters["ListID"]);
                urlParams.Add(new QueryParameter("list_id", parameters["ListID"]));
            }

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

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

            return(req);
        }