Esempio n. 1
0
        /// <summary>
        /// Converts ProductCallSize enum integer value
        /// to string.
        /// </summary>
        /// <returns>True of operation was success</returns>
        private bool CallSizeToString(ProductCallSize callSize, out string count)
        {
            bool callAll = callSize == ProductCallSize.All;

            count = callAll ? ((int)ProductCallSize.Max).ToString() : ((int)callSize).ToString();
            return(callAll);
        }
Esempio n. 2
0
        /// <summary>
        /// Sends GET request for any kinds of products in Steam store.
        /// Request can be cancelled by providing cancellation token.
        /// </summary>
        /// <param name="products">What products to include</param>
        /// <param name="callSize">Call size</param>
        /// <param name="cToken">Cancellation token</param>
        /// <returns>SteamProductResponse object</returns>
        public async Task <SteamProductsResponse> GetSteamProductsAsync(IncludeProducts products,
                                                                        ProductCallSize callSize = ProductCallSize.Default, CToken cToken = default)
        {
            if (products.Equals(IncludeProducts.None))
            {
                return(new SteamProductsResponse()
                {
                    Successful = false
                });
            }
            else
            {
                bool callAll = CallSizeToString(callSize, out string size);
                CreateProductUrl(products, size);

                string originalUrl              = UrlBuilder.GetEncodedUrl();
                SteamProductsResponse result    = null;
                Exception             exception = null;

                if (callAll)
                {
                    (result, exception) = await GetAllProducts(result, exception, cToken);
                }
                else
                {
                    (result, exception) = await GetProducts(result, exception, cToken);
                }
                return(WrapResponse(result, originalUrl, exception));
            }
        }
        public void CallSizeDefined_ReturnsCorrectAmountOfProducs(ProductCallSize callSize)
        {
            var response = SteamApiClient.GetSteamProductsAsync(IncludeProducts.Games, callSize: callSize)
                           .Result;

            SleepAfterSendingRequest();

            Assert.True((int)callSize >= response.Contents.Count);
        }