private void BtnListingAnalyzer_Click(object sender, System.EventArgs e)
        {
            try
            {
                GetItemRecommendationsCall                       apicall = new GetItemRecommendationsCall(Context);
                GetRecommendationsRequestContainerType           req     = new GetRecommendationsRequestContainerType();
                GetRecommendationsRequestContainerTypeCollection reqc    = new GetRecommendationsRequestContainerTypeCollection();
                reqc.Add(req);
                req.RecommendationEngine = new RecommendationEngineCodeTypeCollection();
                req.RecommendationEngine.Add(RecommendationEngineCodeType.ListingAnalyzer);
                req.ListingFlow =
                    (ListingFlowCodeType)Enum.Parse(typeof(ListingFlowCodeType), CboListingFlow.SelectedItem.ToString());

                ItemType item = FillItem(RecommendationEngineCodeType.ListingAnalyzer);
                req.Item = item;
                if (req.ListingFlow == ListingFlowCodeType.AddItem)
                {
                    req.Item.ItemID = null;
                }
                else if (fetchedItem != null)
                {
                    req.Item.ItemID = fetchedItem.ItemID;
                }
                // Make API call
                apicall.GetItemRecommendations(reqc);
                GetRecommendationsResponseContainerTypeCollection resps           = apicall.ApiResponse.GetRecommendationsResponseContainer;
                ListingAnalyzerRecommendationsType listingAnalyzerRecommendations = resps[0].ListingAnalyzerRecommendations;
                LstTips.Items.Clear();
                if (listingAnalyzerRecommendations != null)
                {
                    ListingTipTypeCollection tips = listingAnalyzerRecommendations.ListingTipArray;
                    if (tips != null)
                    {
                        foreach (ListingTipType tip in tips)
                        {
                            string[] listparams = new string[8];
                            listparams[0] = tip.ListingTipID;
                            listparams[1] = tip.Field.ListingTipFieldID;
                            listparams[2] = tip.Priority.ToString();
                            listparams[3] = tip.Message.LongMessage;
                            listparams[4] = StripCDATA(tip.Field.FieldTip);
                            listparams[5] = StripCDATA(tip.Field.CurrentFieldText);
                            listparams[6] = StripCDATA(tip.Message.HelpURLPath);

                            ListViewItem vi = new ListViewItem(listparams);
                            LstTips.Items.Add(vi);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        public void GetItemRecommendationsFull()
        {
            bool   isTherePropertyNull;
            int    nullPropertyNums;
            string nullPropertyNames;

            Assert.IsNotNull(TestData.NewItem2, "Failed because no item available -- requires successful AddItem test");
            //
            GetItemRecommendationsCall                       api  = new GetItemRecommendationsCall(this.apiContext);
            GetRecommendationsRequestContainerType           req  = new GetRecommendationsRequestContainerType();
            GetRecommendationsRequestContainerTypeCollection reqc = new GetRecommendationsRequestContainerTypeCollection();

            reqc.Add(req);
            req.Item                 = TestData.NewItem2;
            req.ListingFlow          = ListingFlowCodeType.AddItem;
            req.RecommendationEngine = new RecommendationEngineCodeTypeCollection();
            req.RecommendationEngine.Add(RecommendationEngineCodeType.ListingAnalyzer);
            req.RecommendationEngine.Add(RecommendationEngineCodeType.SuggestedAttributes);
            req.RecommendationEngine.Add(RecommendationEngineCodeType.ProductPricing);
            req.Query = "shoe";
            GetRecommendationsResponseContainerTypeCollection resps = api.GetItemRecommendations(reqc);

            //check whether the call is success.
            Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning, "do not success!");
            Assert.IsNotNull(resps);
            Assert.IsTrue(resps.Count > 0);
            if (resps[0].AttributeRecommendations != null &&
                resps[0].AttributeRecommendations.AttributeSetArray != null &&
                resps[0].AttributeRecommendations.AttributeSetArray.Count > 0)
            {
                AttributeSetType attributeSet = resps[0].AttributeRecommendations.AttributeSetArray[0];

                isTherePropertyNull = ReflectHelper.IsProperteValueNotNull(attributeSet, out nullPropertyNums, out nullPropertyNames);
                Assert.IsTrue(isTherePropertyNull, "there are" + nullPropertyNums.ToString() + " properties value is null. (" + nullPropertyNames + ")");

                if (attributeSet.Attribute != null && attributeSet.Attribute.Count > 0)
                {
                    AttributeType attribute = attributeSet.Attribute[0];

                    isTherePropertyNull = ReflectHelper.IsProperteValueNotNull(attribute, out nullPropertyNums, out nullPropertyNames);
                    Assert.IsTrue(isTherePropertyNull, "there are" + nullPropertyNums.ToString() + " properties value is null. (" + nullPropertyNames + ")");
                }
            }
        }
        private void BtnProductPricing_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (TxtExternalProductID.Text.Length == 0)
                {
                    throw new Exception("Please specify the catalog product ID.");
                }
                TxtAverageSoldPrice.Text  = "";
                TxtAverageStartPrice.Text = "";
                TxtCatalogTitle.Text      = "";

                ItemType item = FillItem(RecommendationEngineCodeType.ProductPricing);
                GetItemRecommendationsCall             apicall = new GetItemRecommendationsCall(Context);
                GetRecommendationsRequestContainerType req     = new GetRecommendationsRequestContainerType();

                req.Item = item;
                req.Item.LookupAttributeArray = null;
                req.ListingFlow          = ListingFlowCodeType.AddItem;
                req.RecommendationEngine = new RecommendationEngineCodeTypeCollection();
                req.RecommendationEngine.Add(RecommendationEngineCodeType.ProductPricing);
                GetRecommendationsRequestContainerTypeCollection reqc = new GetRecommendationsRequestContainerTypeCollection();
                reqc.Add(req);

                // Make API call
                apicall.GetItemRecommendations(reqc);
                GetRecommendationsResponseContainerTypeCollection resps = apicall.ApiResponse.GetRecommendationsResponseContainer;
                PricingRecommendationsType pricingRecoms = resps[0].PricingRecommendations;

                if (pricingRecoms != null && pricingRecoms.ProductInfo != null)
                {
                    TxtCatalogTitle.Text = pricingRecoms.ProductInfo.Title;
                    AmountType avgSoldPrice = pricingRecoms.ProductInfo.AverageSoldPrice;
                    TxtAverageSoldPrice.Text = (avgSoldPrice != null)?avgSoldPrice.Value.ToString():"";
                    AmountType avgStartPrice = pricingRecoms.ProductInfo.AverageStartPrice;
                    TxtAverageStartPrice.Text = (avgStartPrice != null)?avgStartPrice.Value.ToString():"";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #4
0
        public void GetItemRecommendations()
        {
            Assert.IsNotNull(TestData.NewItem, "Failed because no item available -- requires successful AddItem test");
            //
            GetItemRecommendationsCall                       api  = new GetItemRecommendationsCall(this.apiContext);
            GetRecommendationsRequestContainerType           req  = new GetRecommendationsRequestContainerType();
            GetRecommendationsRequestContainerTypeCollection reqc = new GetRecommendationsRequestContainerTypeCollection();

            reqc.Add(req);
            req.Item = TestData.NewItem;
            req.Item.LookupAttributeArray = null;
            req.ListingFlow          = ListingFlowCodeType.ReviseItem;
            req.RecommendationEngine = new RecommendationEngineCodeTypeCollection();
            req.RecommendationEngine.Add(RecommendationEngineCodeType.ListingAnalyzer);
            // Make API call.
            api.GetItemRecommendations(reqc);
            GetRecommendationsResponseContainerTypeCollection resps = api.ApiResponse.GetRecommendationsResponseContainer;

            Assert.IsNotNull(resps);
            Assert.IsTrue(resps.Count > 0);
        }
        private void BtnSuggestedAttr_Click(object sender, System.EventArgs e)
        {
            try
            {
                ItemType item = FillItem(RecommendationEngineCodeType.SuggestedAttributes);
                GetItemRecommendationsCall             apicall = new GetItemRecommendationsCall(Context);
                GetRecommendationsRequestContainerType req     = new GetRecommendationsRequestContainerType();

                req.Item = item;
                req.Item.LookupAttributeArray = null;
                req.ListingFlow          = ListingFlowCodeType.AddItem;
                req.RecommendationEngine = new RecommendationEngineCodeTypeCollection();
                req.RecommendationEngine.Add(RecommendationEngineCodeType.SuggestedAttributes);
                if (TxtQuery.Text.Length > 0)
                {
                    req.Query = TxtQuery.Text;
                }

                GetRecommendationsRequestContainerTypeCollection reqc = new GetRecommendationsRequestContainerTypeCollection();
                reqc.Add(req);

                // Make API call
                apicall.GetItemRecommendations(reqc);
                GetRecommendationsResponseContainerTypeCollection resps = apicall.ApiResponse.GetRecommendationsResponseContainer;
                AttributeRecommendationsType attributes = resps[0].AttributeRecommendations;
                AttributeSetTypeCollection   attrSets   = null;
                if (attributes != null)
                {
                    attrSets = attributes.AttributeSetArray;
                }
                if (attrSets != null)
                {
                    foreach (AttributeSetType attribute in attrSets)
                    {
                        if (attribute != null)
                        {
                            string[] listparams = new string[3];
                            listparams[0] = attribute.attributeSetID.ToString();
                            listparams[1] = attribute.attributeSetVersion;
                            listparams[2] = attribute.Attribute.Count.ToString();

                            ListViewItem vi = new ListViewItem(listparams);
                            LstAttr.Items.Add(vi);
                        }
                    }
                }

                ProductInfoTypeCollection products = resps[0].ProductRecommendations;
                if (products != null)
                {
                    foreach (ProductInfoType product in products)
                    {
                        if (product != null)
                        {
                            string[] listparams = new string[4];
                            listparams[0] = product.Title;
                            listparams[1] = product.productInfoID;
                            if (product.AverageStartPrice != null)
                            {
                                listparams[2] = product.AverageStartPrice.Value.ToString();
                            }
                            if (product.AverageSoldPrice != null)
                            {
                                listparams[3] = product.AverageSoldPrice.Value.ToString();;
                            }
                            ListViewItem vi = new ListViewItem(listparams);
                            lstProduct.Items.Add(vi);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }