Exemplo n.º 1
0
        /// <summary>
        /// Gets the tags on the site that only moderators can use.
        /// </summary>
        public static Task <Result <Tag[]> > GetModeratorOnlyAsync(QueryOptions options = null)
        {
            options = options.GetDefaultIfNull();

            var endpoint = $"{Constants.BaseApiUrl}/tags/moderator-only";

            return(ApiRequestScheduler.ScheduleRequestAsync <Tag[]>(endpoint, options));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the users who are active moderators who have also won a moderator election.
        /// </summary>
        public static Task <Result <User[]> > GetElectedModeratorsAsync(QueryOptions options = null)
        {
            options = options.GetDefaultIfNull();

            var endpoint = $"{Constants.BaseApiUrl}/users/moderators/elected";

            return(ApiRequestScheduler.ScheduleRequestAsync <User[]>(endpoint, options));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets all the suggested edits on a site.
        /// </summary>
        public static Task <Result <SuggestedEdit[]> > GetAllAsync(QueryOptions options = null)
        {
            options = options.GetDefaultIfNull();

            var endpoint = $"{Constants.BaseApiUrl}/suggested-edits";

            return(ApiRequestScheduler.ScheduleRequestAsync <SuggestedEdit[]>(endpoint, options));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the top tags (by score) a single user has posted in.
        /// </summary>
        public static Task <Result <TopTag[]> > GetAllAsync(int userId, QueryOptions options = null)
        {
            options = options.GetDefaultIfNull();

            var endpoint = $"{Constants.BaseApiUrl}/users/{userId}/top-tags";

            return(ApiRequestScheduler.ScheduleRequestAsync <TopTag[]>(endpoint, options));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets all the tag synonyms on a site.
        /// </summary>
        public static Task <Result <TagSynonym[]> > GetAllAsync(QueryOptions options = null)
        {
            options = options.GetDefaultIfNull();

            var endpoint = $"{Constants.BaseApiUrl}/tags/synonyms";

            return(ApiRequestScheduler.ScheduleRequestAsync <TagSynonym[]>(endpoint, options));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get all non-tagged-based badges in alphabetical order.
        /// </summary>
        public static Task <Result <Badge[]> > GetNamedAsync(QueryOptions options = null)
        {
            options = options.GetDefaultIfNull();

            var endpoint = $"{Constants.BaseApiUrl}/badges/name";

            return(ApiRequestScheduler.ScheduleRequestAsync <Badge[]>(endpoint, options));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the privileges the given user has on a site.
        /// </summary>
        public static Task <Result <Privilege[]> > GetByUserIdAsync(int userId, QueryOptions options = null)
        {
            options = options.GetDefaultIfNull();

            var endpoint = $"{Constants.BaseApiUrl}/users/{userId}/privileges";

            return(ApiRequestScheduler.ScheduleRequestAsync <Privilege[]>(endpoint, options));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Gets all questions on the site with no answers.
        /// </summary>
        public static Task <Result <Question[]> > GetAllNoAnswersAsync(QueryOptions options = null)
        {
            options = options.GetDefaultIfNull();

            var endpoint = $"{Constants.BaseApiUrl}/questions/no-answers";

            return(ApiRequestScheduler.ScheduleRequestAsync <Question[]>(endpoint, options));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets all questions on the site with active bounties.
        /// </summary>
        public static Task <Result <Question[]> > GetAllActiveBountiesAsync(QueryOptions options = null)
        {
            options = options.GetDefaultIfNull();

            var endpoint = $"{Constants.BaseApiUrl}/questions/featured";

            return(ApiRequestScheduler.ScheduleRequestAsync <Question[]>(endpoint, options));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets the suggested edits provided by users identified by a set of ids.
        /// </summary>
        public static Task <Result <SuggestedEdit[]> > GetByUserIdsAsync(IEnumerable <int> userIds, QueryOptions options = null)
        {
            options = options.GetDefaultIfNull();

            var idsStr   = userIds.ToDelimitedList();
            var endpoint = $"{Constants.BaseApiUrl}/users/{idsStr}/suggested-edits";

            return(ApiRequestScheduler.ScheduleRequestAsync <SuggestedEdit[]>(endpoint, options));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Gets the comments posted by a set of users in reply to another user.
        /// </summary>
        public static Task <Result <Comment[]> > GetRepliesByUserIdsAsync(IEnumerable <int> authorIds, int recipientUser, QueryOptions options = null)
        {
            authorIds.ThrowIfNullOrEmpty(nameof(authorIds));
            options = options.GetDefaultIfNull();

            var idsStr   = authorIds.ToDelimitedList();
            var endpoint = $"{Constants.BaseApiUrl}/users/{idsStr}/comments/{recipientUser}";

            return(ApiRequestScheduler.ScheduleRequestAsync <Comment[]>(endpoint, options));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Gets the users identified by a set of ids.
        /// </summary>
        public static Task <Result <User[]> > GetByIdsAsync(IEnumerable <int> userIds, QueryOptions options = null)
        {
            userIds.ThrowIfNullOrEmpty(nameof(userIds));
            options = options.GetDefaultIfNull();

            var idsStr   = userIds.ToDelimitedList();
            var endpoint = $"{Constants.BaseApiUrl}/users/{idsStr}";

            return(ApiRequestScheduler.ScheduleRequestAsync <User[]>(endpoint, options));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Returns recently awarded badges in the system, constrained
        /// to a set of badge IDs. As these badges have been awarded,
        /// they will have the <see cref="Badge.User"/> property set.
        ///
        /// Does not support the following <see cref="QueryOptions"/> properties:
        /// <see cref="QueryOptions.Sort"/>, <see cref="QueryOptions.Order"/>,
        /// <see cref="QueryOptions.Max"/>, <see cref="QueryOptions.Min"/>.
        /// </summary>
        public static Task <Result <Badge[]> > GetRecentByIdsAsync(IEnumerable <int> ids, QueryOptions options = null)
        {
            ids.ThrowIfNullOrEmpty(nameof(ids));
            options = options.GetDefaultIfNull();

            var idsStr   = ids.ToDelimitedList();
            var endpoint = $"{Constants.BaseApiUrl}/badges/{idsStr}/recipients";

            return(ApiRequestScheduler.ScheduleRequestAsync <Badge[]>(endpoint, options));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Gets the comments on the posts identified by a set of ids.
        /// </summary>
        public static Task <Result <Comment[]> > GetByPostIdsAsync(IEnumerable <int> postIds, QueryOptions options = null)
        {
            postIds.ThrowIfNullOrEmpty(nameof(postIds));
            options = options.GetDefaultIfNull();

            var idsStr   = postIds.ToDelimitedList();
            var endpoint = $"{Constants.BaseApiUrl}/posts/{idsStr}/comments";

            return(ApiRequestScheduler.ScheduleRequestAsync <Comment[]>(endpoint, options));
        }
Exemplo n.º 15
0
        /// <summary>
        /// Gets all revisions identified by a set of ids.
        /// </summary>
        public static Task <Result <Revision[]> > GetByRevisionGuidsAsync(IEnumerable <string> revGuids, QueryOptions options = null)
        {
            revGuids.ThrowIfNullOrEmpty(nameof(revGuids));
            options = options.GetDefaultIfNull();

            var idsStr   = revGuids.ToDelimitedList();
            var endpoint = $"{Constants.BaseApiUrl}/revisions/{idsStr}";

            return(ApiRequestScheduler.ScheduleRequestAsync <Revision[]>(endpoint, options));
        }
Exemplo n.º 16
0
        /// <summary>
        /// the top question askers in a specific tag, either in the last month or for all time.
        /// </summary>
        public static Task <Result <TagScore[]> > GetTopAskersAsync(string tag, Period period, QueryOptions options = null)
        {
            tag.ThrowIfNullOrEmpty(nameof(tag));
            options = options.GetDefaultIfNull();

            var t        = WebUtility.UrlEncode(tag);
            var p        = period.GetApiQueryValueAttributeValue();
            var endpoint = $"{Constants.BaseApiUrl}/tags/{t}/top-askers/{p}";

            return(ApiRequestScheduler.ScheduleRequestAsync <TagScore[]>(endpoint, options));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Gets the wiki entries for a set of tags.
        /// </summary>
        public static Task <Result <TagWiki[]> > GetByTagNamesAsync(IEnumerable <string> tagNames, QueryOptions options = null)
        {
            tagNames.ThrowIfNullOrEmpty(nameof(tagNames));
            options = options.GetDefaultIfNull();

            var tagList = tagNames
                          .Select(WebUtility.UrlEncode)
                          .ToDelimitedList();
            var endpoint = $"{Constants.BaseApiUrl}/tags/{tagList}/wikis";

            return(ApiRequestScheduler.ScheduleRequestAsync <TagWiki[]>(endpoint, options));
        }
Exemplo n.º 18
0
        /// <summary>
        /// Gets the top questions a user has posted with a set of tags.
        /// </summary>
        public static Task <Result <Question[]> > GetTopQuestionByUserIdByTagsAsync(int userId, IEnumerable <string> tags, QueryOptions options = null)
        {
            tags.ThrowIfNullOrEmpty(nameof(tags));
            options = options.GetDefaultIfNull();

            var tagList = tags
                          .Select(WebUtility.UrlEncode)
                          .ToDelimitedList();
            var endpoint = $"{Constants.BaseApiUrl}/users/{userId}/tags/{tagList}/top-questions";

            return(ApiRequestScheduler.ScheduleRequestAsync <Question[]>(endpoint, options));
        }
Exemplo n.º 19
0
        /// <summary>
        /// Gets the non-tagged-based badges whose name contains
        /// the specified search term, in alphabetical order.
        /// </summary>
        public static Task <Result <Badge[]> > GetNamedByNameAsync(string name, QueryOptions options = null)
        {
            name.ThrowIfNullOrEmpty(nameof(name));
            options = options.GetDefaultIfNull();

            options.Custom = new Dictionary <string, string>
            {
                ["inname"] = WebUtility.UrlEncode(name)
            };

            var endpoint = $"{Constants.BaseApiUrl}/badges/name";

            return(ApiRequestScheduler.ScheduleRequestAsync <Badge[]>(endpoint, options));
        }