Exemple #1
0
        /// <summary>
        /// Gets the top categories.
        /// </summary>
        /// <returns>The top categories</returns>
        public async Task <IEnumerable <CategoryModel> > GetTopCategories()
        {
            CategoryWrapperModel categories = await this.GetAsync <CategoryWrapperModel>("categorys/top");

            if (categories != null)
            {
                return(categories.category_info);
            }
            return(null);
        }
        /// <summary>
        /// Searches for categories matching the specified query.
        /// </summary>
        /// <param name="query">The query to search for</param>
        /// <param name="maxResults">The maximum number of results. Will be either that amount or slightly more</param>
        /// <returns>The matching categories</returns>
        public async Task <IEnumerable <CategoryModel> > SearchCategories(string query, int maxResults = 1)
        {
            Validator.ValidateString(query, "query");

            CategoryWrapperModel categories = await this.GetAsync <CategoryWrapperModel>($"categorys/searchcategory?query={query}&limit={maxResults}");

            if (categories != null)
            {
                return(categories.category_info);
            }
            return(null);
        }
Exemple #3
0
        /// <summary>
        /// Searches for categories matching the specified query.
        /// </summary>
        /// <param name="query">The query to search for</param>
        /// <param name="maxResults">The maximum number of results. Will be either that amount or slightly more</param>
        /// <returns>The matching categories</returns>
        public async Task <IEnumerable <CategoryModel> > SearchCategories(string query, int maxResults = 1)
        {
            Validator.ValidateString(query, "query");

            JObject jobj = new JObject();

            jobj["query"] = query;
            jobj["limit"] = maxResults;

            CategoryWrapperModel categories = await this.PostAsync <CategoryWrapperModel>("searchcategory", AdvancedHttpClient.CreateContentFromObject(jobj));

            if (categories != null)
            {
                return(categories.category_info);
            }
            return(null);
        }