示例#1
0
        private string GetFormattedArticlesUri(string resourceUrl, ArticleSortingOptions options, ArticleSideLoadOptionsEnum sideloadOptions)
        {
            if (options != null)
            {
                if (string.IsNullOrEmpty(options.Locale))
                {
                    throw new ArgumentException("Locale is required to sort");
                }

                resourceUrl = options.GetSortingString(resourceUrl);
            }

            string sideLoads = sideloadOptions.ToString().ToLower().Replace(" ", "");

            if (sideloadOptions != ArticleSideLoadOptionsEnum.None)
            {
                resourceUrl += resourceUrl.Contains("?") ? "&include=" : "?include=";

                //Categories flag REQUIRES sections to be added as well, or nothing will be returned
                if (sideloadOptions.HasFlag(ArticleSideLoadOptionsEnum.Categories) && !sideloadOptions.HasFlag(ArticleSideLoadOptionsEnum.Sections))
                {
                    sideLoads += string.Format(",{0}", ArticleSideLoadOptionsEnum.Sections.ToString().ToLower());
                }

                resourceUrl += sideLoads;
            }
            return(resourceUrl);
        }
示例#2
0
        public GroupArticleResponse GetArticlesBySectionId(long sectionId, ArticleSideLoadOptionsEnum sideloadOptions = ArticleSideLoadOptionsEnum.None, ArticleSortingOptions options = null)
        {
            var uri = string.Format("help_center/sections/{0}/articles.json", sectionId);
            var resourceUrl = this.GetFormattedArticlesUri(uri, options, sideloadOptions);

            return GenericGet<GroupArticleResponse>(resourceUrl);
        }
示例#3
0
        public GroupArticleResponse GetArticlesBySectionId(long sectionId, ArticleSideLoadOptionsEnum sideloadOptions = ArticleSideLoadOptionsEnum.None, ArticleSortingOptions options = null)
        {
            var uri         = string.Format("help_center/sections/{0}/articles.json", sectionId);
            var resourceUrl = this.GetFormattedArticlesUri(uri, options, sideloadOptions);

            return(GenericGet <GroupArticleResponse>(resourceUrl));
        }
示例#4
0
        public GroupArticleResponse GetArticles(ArticleSideLoadOptionsEnum sideloadOptions = ArticleSideLoadOptionsEnum.None, ArticleSortingOptions options = null, int?perPage = null, int?page = null)
        {
            var resourceUrl = this.GetFormattedArticlesUri("help_center/articles.json", options, sideloadOptions);

            return(GenericPagedGet <GroupArticleResponse>(resourceUrl, perPage, page));
        }
示例#5
0
        public async Task <GroupArticleResponse> GetArticlesByCategoryIdAsync(long categoryId, ArticleSideLoadOptionsEnum sideloadOptions = ArticleSideLoadOptionsEnum.None, ArticleSortingOptions options = null)
        {
            var uri         = string.Format("help_center/categories/{0}/articles.json", categoryId);
            var resourceUrl = this.GetFormattedArticlesUri(uri, options, sideloadOptions);

            return(await GenericGetAsync <GroupArticleResponse>(resourceUrl));
        }
示例#6
0
        public GroupArticleResponse GetArticlesByCategoryId(long categoryId, ArticleSideLoadOptionsEnum sideloadOptions = ArticleSideLoadOptionsEnum.None, ArticleSortingOptions options = null)
        {
            var uri         = $"{urlPrefix}/categories/{categoryId}/articles.json";
            var resourceUrl = this.GetFormattedArticlesUri(uri, options, sideloadOptions);

            return(GenericGet <GroupArticleResponse>(resourceUrl));
        }
示例#7
0
        public async Task <GroupArticleResponse> GetArticlesBySectionIdAsync(long sectionId, ArticleSideLoadOptionsEnum sideloadOptions = ArticleSideLoadOptionsEnum.None, ArticleSortingOptions options = null)
        {
            var uri         = $"{urlPrefix}/sections/{sectionId}/articles.json";
            var resourceUrl = this.GetFormattedArticlesUri(uri, options, sideloadOptions);

            return(await GenericGetAsync <GroupArticleResponse>(resourceUrl));
        }
示例#8
0
        public async Task <GroupArticleResponse> GetArticlesAsync(ArticleSideLoadOptionsEnum sideloadOptions = ArticleSideLoadOptionsEnum.None, ArticleSortingOptions options = null, int?perPage = null, int?page = null)
        {
            var resourceUrl = this.GetFormattedArticlesUri($"{urlPrefix}/articles.json", options, sideloadOptions);

            return(await GenericPagedGetAsync <GroupArticleResponse>(resourceUrl, perPage, page));
        }
示例#9
0
        public GroupArticleResponse GetArticles(ArticleSideLoadOptionsEnum sideloadOptions = ArticleSideLoadOptionsEnum.None, ArticleSortingOptions options = null, int? perPage = null, int? page = null)
        {
            var resourceUrl = this.GetFormattedArticlesUri("help_center/articles.json", options, sideloadOptions);

            return GenericPagedGet<GroupArticleResponse>(resourceUrl, perPage, page);
        }
示例#10
0
        private string GetFormattedArticlesUri(string resourceUrl, ArticleSortingOptions options, ArticleSideLoadOptionsEnum sideloadOptions)
        {
            if (options != null)
            {
                if (string.IsNullOrEmpty(options.Locale))
                    throw new ArgumentException("Locale is required to sort");

                resourceUrl = options.GetSortingString(resourceUrl);
            }

            string sideLoads = sideloadOptions.ToString().ToLower().Replace(" ", "");
            if (sideloadOptions != ArticleSideLoadOptionsEnum.None)
            {
                resourceUrl += resourceUrl.Contains("?") ? "&include=" : "?include=";

                //Categories flag REQUIRES sections to be added as well, or nothing will be returned
                if (sideloadOptions.HasFlag(ArticleSideLoadOptionsEnum.Categories) && !sideloadOptions.HasFlag(ArticleSideLoadOptionsEnum.Sections))
                {
                    sideLoads += string.Format(",{0}", ArticleSideLoadOptionsEnum.Sections.ToString().ToLower());
                }

                resourceUrl += sideLoads;
            }
            return resourceUrl;
        }
示例#11
0
        public async Task<GroupArticleResponse> GetArticlesByCategoryIdAsync(long categoryId, ArticleSideLoadOptionsEnum sideloadOptions = ArticleSideLoadOptionsEnum.None, ArticleSortingOptions options = null)
        {
            var uri = string.Format("help_center/categories/{0}/articles.json", categoryId);
            var resourceUrl = this.GetFormattedArticlesUri(uri, options, sideloadOptions);

            return await GenericGetAsync<GroupArticleResponse>(resourceUrl);
        }
示例#12
0
        public async Task <GroupArticleResponse> GetArticlesAsync(ArticleSideLoadOptionsEnum sideloadOptions = ArticleSideLoadOptionsEnum.None, ArticleSortingOptions options = null)
        {
            var resourceUrl = this.GetFormattedArticlesUri("help_center/articles.json", options, sideloadOptions);

            return(await GenericGetAsync <GroupArticleResponse>(resourceUrl));
        }