/// <summary>
        /// Gets a count of all of the custom collections
        /// </summary>
        /// <returns>The count of all collects for the shop.</returns>
        public virtual async Task <int> CountAsync(CustomCollectionFilter options = null)
        {
            var req = PrepareRequest("custom_collections/count.json");

            if (options != null)
            {
                req.Url.QueryParams.AddRange(options.ToParameters());
            }

            return(await ExecuteRequestAsync <int>(req, HttpMethod.Get, rootElement : "count"));
        }
        /// <summary>
        /// default: 50
        /// Gets a list of up to 250 custom collections for the corresponding productId
        /// </summary>
        /// <param name="filter">The <see cref="CustomCollection"/>. used to filter results</param>
        /// <returns></returns>
        public virtual async Task <IEnumerable <CustomCollection> > ListAsync(CustomCollectionFilter filter = null)
        {
            var req = PrepareRequest("custom_collections.json");

            //Add optional parameters to request
            if (filter != null)
            {
                req.Url.QueryParams.AddRange(filter.ToParameters());
            }

            return(await ExecuteRequestAsync <List <CustomCollection> >(req, HttpMethod.Get, rootElement : "custom_collections"));
        }
Пример #3
0
        static async public Task <List <CustomCollection> > GetCollections()
        {
            List <CustomCollection> list = new List <CustomCollection>();
            int count = await CustomCollectionService.CountAsync().ConfigureAwait(false);

            int pages = (count / 250) + 1;

            for (int page = 1; page <= pages; page++)
            {
                CustomCollectionFilter filter = new CustomCollectionFilter
                {
                    Limit = 250,
                    Page  = page
                };
                list.AddRange(await CustomCollectionService.ListAsync(filter));
            }
            return(list);
        }