public async Task <JsonResult> AmazonSignedUrl([FromQuery] string query)
        {
            AmazonProductService service = new AmazonProductService(new AmazonService(httpService, config));
            var result = await service.Search(query);

            return(new JsonResult(result));
        }
Esempio n. 2
0
        public int AddPro(CreateProductInput input)
        {
            AmazonProductService service = new AmazonProductService();
            var product = service.GetProduct(input.Url);

            product.Cashback = new Cashback()
            {
                SalesPrice = 18
            };

            var id = _productRepository.InsertOrUpdateAndGetId(product);

            return(id);
        }
Esempio n. 3
0
        public void AmazonProductService_ParseReturnResult_ReturnsProduct()
        {
            // Load xml from the file
            string     path         = @"C:\Users\atrifono\Documents\Personal\Opinions\BestFor\BestFor.Services\AffiliateProgram\Amazon\";
            FileStream myFileStream = new FileStream(path + "myxml.xml", FileMode.Open);
            var        xmlDoc       = new XmlDocument();

            xmlDoc.Load(myFileStream);
            // Ask service to parse it.
            var appSettings = new IOptionsImplementation()
            {
                AppSettings = new Common.AppSettings()
            };
            var cache = new Mock <ICacheManager>().Object;

            var service = new AmazonProductService(appSettings, cache);
            var product = service.ReadXml(xmlDoc);

            Assert.True(product.DetailPageURL.StartsWith("http://www.amazon.com/Total-Fishing-Manual-Field-Stream/dp/1616284870%3FSubscriptionId%3DAKIAI5A2QWLR7ECMOCWA%26tag%3Dbestfor03"));
            Assert.Equal(product.MerchantProductId, "1616284870");
            Assert.Equal(product.Title, "The Total Fishing Manual (Field & Stream): 317 Essential Fishing Skills (Field and Stream)");
        }
Esempio n. 4
0
        public void AmazonProductService_FindProduct_FindsProduct()
        {
            // Uncomment this to actually run.
            var t = 5; if (t > 1)
            {
                return;
            }

            var cacheMock = new Mock <ICacheManager>();
            var cache     = cacheMock.Object;
            var service   = new AmazonProductService(Common.AppSettings.ReadSettings(), cache);
            var product   = service.FindProduct(new ProductSearchParameters()
            {
                Keyword = "fishing"
            });

            // Amazon may return a different product on search every time, no point in checking the exact values.
            Assert.NotNull(product);
            Assert.NotNull(product.MerchantProductId);
            Assert.NotNull(product.Title);
            Assert.NotNull(product.DetailPageURL);
        }