コード例 #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
ファイル: Articles.cs プロジェクト: tofutim/ZendeskApi_v2
        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
ファイル: Articles.cs プロジェクト: seagulledge/ZendeskApi_v2
        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
ファイル: Articles.cs プロジェクト: seagulledge/ZendeskApi_v2
        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
ファイル: Articles.cs プロジェクト: seagulledge/ZendeskApi_v2
        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
ファイル: Articles.cs プロジェクト: tofutim/ZendeskApi_v2
        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
ファイル: Articles.cs プロジェクト: tofutim/ZendeskApi_v2
        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
ファイル: Articles.cs プロジェクト: tofutim/ZendeskApi_v2
        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));
        }