示例#1
0
        /// <summary>
        /// Get wiki settings for specified wiki page.
        /// </summary>
        /// <param name="name">wiki page</param>
        /// <returns></returns>
        public async Task <WikiPageSettings> GetPageSettingsAsync(string name)
        {
            var json = await WebAgent.Get(WikiPageSettingsUrl(name)).ConfigureAwait(false);

            return(new WikiPageSettings(WebAgent, json["data"]));
        }
示例#2
0
        /// <summary>
        /// Get a list of wiki page names for this subreddit.
        /// </summary>
        public async Task <IEnumerable <string> > GetPageNamesAsync()
        {
            var json = await WebAgent.Get(GetWikiPagesUrl).ConfigureAwait(false);

            return(json["data"].Values <string>());
        }
示例#3
0
        /// <summary>
        /// Get a wiki page
        /// </summary>
        /// <param name="page">wiki page name</param>
        /// <param name="version">page version</param>
        /// <returns></returns>
        public async Task <WikiPage> GetPageAsync(string page, string version = null)
        {
            var json = await WebAgent.Get(GetWikiPageUrl(page, version)).ConfigureAwait(false);

            return(new WikiPage(WebAgent, json["data"]));
        }
        /// <summary>
        /// Update the subreddit settings.
        /// </summary>
        public async Task UpdateSettings()
        {
            string link_type;
            string type;
            string wikimode;

            switch (ContentOptions)
            {
            case ContentOptions.All:
                link_type = "any";
                break;

            case ContentOptions.LinkOnly:
                link_type = "link";
                break;

            default:
                link_type = "self";
                break;
            }
            switch (SubredditType)
            {
            case SubredditType.Archived:
                type = "archived";
                break;

            case SubredditType.EmployeesOnly:
                type = "employees_only";
                break;

            case SubredditType.GoldOnly:
                type = "gold_only";
                break;

            case SubredditType.GoldRestricted:
                type = "gold_restricted";
                break;

            case SubredditType.Private:
                type = "private";
                break;

            case SubredditType.Public:
                type = "public";
                break;

            case SubredditType.Restricted:
                type = "restricted";
                break;

            case SubredditType.User:
                type = "user";
                break;

            default:
                type = "public";
                break;
            }
            switch (WikiEditMode)
            {
            case WikiEditMode.All:
                wikimode = "anyone";
                break;

            case WikiEditMode.Moderators:
                wikimode = "modonly";
                break;

            default:
                wikimode = "disabled";
                break;
            }
            await WebAgent.Post(SiteAdminUrl, new
            {
                allow_top    = AllowAsDefault,
                allow_images = AllowImages,
                description  = Sidebar,
                domain       = Domain,
                lang         = Language,
                link_type,
                over18             = NSFW,
                public_description = PublicDescription,
                show_media         = ShowThumbnails,
                sr    = Subreddit.FullName,
                title = Title,
                type,
                wiki_edit_age   = WikiEditAge,
                wiki_edit_karma = WikiEditKarma,
                wikimode,
                spam_links     = SpamFilter?.LinkPostStrength.ToString().ToLowerInvariant(),
                spam_selfposts = SpamFilter?.SelfPostStrength.ToString().ToLowerInvariant(),
                spam_comments  = SpamFilter?.CommentStrength.ToString().ToLowerInvariant(),
                api_type       = "json"
            }, "header-title", HeaderHoverText).ConfigureAwait(false);
        }