private async Task <ReverbProduct> CollectProductsFromAllPagesAsync(string state)
        {
            ReverbProduct data = new ReverbProduct();

            data.listings = new List <ReverbProductItem>();

            ReverbProduct listingItem = null;

            Int32 pageIndex = 1;

            do
            {
                await ActionPolicies.GetAsync.Do(async() =>
                {
                    listingItem = await CollectProductsFromSinglePageAsync(state, pageIndex, Int32.MaxValue);

                    //API requirement
                    await this.CreateApiDelay();

                    if (listingItem.listings != null)
                    {
                        data.listings.AddRange(listingItem.listings);
                    }

                    pageIndex++;
                });
            } while (listingItem._links != null && listingItem._links.next != null);

            return(data);
        }
        public async Task <IEnumerable <ReverbProductEntity> > GetProductsAsync()
        {
            ReverbProduct data = await GetCommonProductsAsync("all", null, null);

            return(data.listings.Select(x => new ReverbProductEntity()
            {
                Sku = !String.IsNullOrEmpty(x.sku) ? x.sku : String.Empty,
                Slug = !String.IsNullOrEmpty(x.unique_id) ? x.unique_id : String.Empty,
                Inventory = x.inventory,
                HasInventory = x.inventory != 0
            })
                   .ToList());
        }
        private async Task <ReverbProduct> CollectProductsDraftsAsync(string endpoint)
        {
            ReverbProduct data = null;

            await ActionPolicies.GetAsync.Do(async() =>
            {
                data = await this._webRequestServices.GetResponseAsync <ReverbProduct>(ReverbCommand.GetProductsDrafts, endpoint);

                //API requirement
                await this.CreateApiDelay();
            });

            return(data);
        }
        private ReverbProduct CollectProductsDrafts(string endpoint)
        {
            ReverbProduct data = null;

            ActionPolicies.Get.Do(() =>
            {
                data = this._webRequestServices.GetResponse <ReverbProduct>(ReverbCommand.GetProductsDrafts, endpoint);

                //API requirement
                this.CreateApiDelay().Wait();
            });

            return(data);
        }
        private async Task <ReverbProduct> CollectProductsFromSinglePageAsync(string state, Int32 page, Int32 per_page)
        {
            ReverbProduct data = null;

            var endpoint = ParamsBuilder.CreateProductsParams(state, page, per_page);

            await ActionPolicies.GetAsync.Do(async() =>
            {
                data = await this._webRequestServices.GetResponseAsync <ReverbProduct>(ReverbCommand.GetProducts, endpoint);

                //API requirement
                await this.CreateApiDelay();
            });

            return(data);
        }
        private ReverbProduct CollectProductsFromSinglePage(string state, Int32 page, Int32 per_page)
        {
            ReverbProduct data = null;

            var endpoint = ParamsBuilder.CreateProductsParams(state, page, per_page);

            ActionPolicies.Get.Do(() =>
            {
                data = this._webRequestServices.GetResponse <ReverbProduct>(ReverbCommand.GetProducts, endpoint);

                //API requirement
                this.CreateApiDelay().Wait();
            });

            return(data);
        }