private ItemType FillItem(RecommendationEngineCodeType engine)
        {
            ItemType item = new ItemType();

            if (TxtTitle.Text.Length > 0)
            {
                item.Title = TxtTitle.Text;
            }

            CurrencyCodeType currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);

            item.Currency = currencyID;
            if (TxtStartPrice.Text.Length > 0)
            {
                item.StartPrice            = new AmountType();
                item.StartPrice.Value      = Convert.ToDouble(TxtStartPrice.Text);
                item.StartPrice.currencyID = currencyID;
            }

            if (TxtReservePrice.Text.Length > 0)
            {
                item.ReservePrice            = new AmountType();
                item.ReservePrice.Value      = Convert.ToDouble(TxtReservePrice.Text);
                item.ReservePrice.currencyID = currencyID;
            }
            ;

            if (TxtBuyItNowPrice.Text.Length > 0)
            {
                item.BuyItNowPrice            = new AmountType();
                item.BuyItNowPrice.Value      = Convert.ToDouble(TxtBuyItNowPrice.Text);
                item.BuyItNowPrice.currencyID = currencyID;
            }

            if (TxtPrimaryCategory.Text.Length > 0)
            {
                item.PrimaryCategory            = new CategoryType();
                item.PrimaryCategory.CategoryID = TxtPrimaryCategory.Text;
            }

            if (TxtSecondaryCategory.Text.Length > 0)
            {
                item.SecondaryCategory            = new CategoryType();
                item.SecondaryCategory.CategoryID = TxtSecondaryCategory.Text;
            }

            if (TxtItemID.Visible)
            {
                item.ItemID = TxtItemID.Text;
            }
            if (engine == RecommendationEngineCodeType.ProductPricing)
            {
                string s = TxtExternalProductID.Text;
                if (s.Length > 0)
                {
                    ProductListingDetailsType pld = new ProductListingDetailsType();
                    pld.ProductID = s;
                    item.ProductListingDetails = pld;
                }
            }

            return(item);
        }
示例#2
0
        public void AddItemFull3()
        {
            bool isSucess,isProductSearchPageAvailable;
            bool existing=false,isbnExisting=false;
            string message;
            Int32Collection attributes=new Int32Collection();
            CategoryTypeCollection categories=null;
            CharacteristicsSetTypeCollection characteristics=null;

            ItemType item= ItemHelper.BuildItem();
            //check whether the category is catalog enabled.
            isSucess=CategoryHelper.IsCatagoryEnabled(this.apiContext,PSPACATEGORYID.ToString(),CategoryEnableCodeType.ProductSearchPageAvailable,out isProductSearchPageAvailable,out message);
            Assert.IsTrue(isSucess,message);
            Assert.IsTrue(isProductSearchPageAvailable,message);
            isSucess=CategoryHelper.IsCatagoryEnabled(this.apiContext,PSPACATEGORYID.ToString(),CategoryEnableCodeType.CatalogEnabled,out isProductSearchPageAvailable,out message);
            Assert.IsTrue(isSucess,message);
            Assert.IsTrue(isProductSearchPageAvailable,message);
            //modify item information approporiately.
            item.PrimaryCategory.CategoryID=PSPACATEGORYID.ToString();
            item.Description = "check whether the item can be added by GetProductSearchPage method way,This is a test item created by eBay SDK SanityTest.";

            //get characters information using GetCategory2CSCall
            GetCategory2CSCall csCall=new GetCategory2CSCall(this.apiContext);

            DetailLevelCodeTypeCollection levels=new DetailLevelCodeTypeCollection();
            DetailLevelCodeType level=new DetailLevelCodeType();
            level=DetailLevelCodeType.ReturnAll;
            levels.Add(level);
            csCall.DetailLevelList=levels;
            csCall.CategoryID=PSPACATEGORYID.ToString();
            csCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(csCall.AbstractResponse.Ack==AckCodeType.Success || csCall.AbstractResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.IsNotNull(csCall.ApiResponse.MappedCategoryArray);
            Assert.Greater(csCall.ApiResponse.MappedCategoryArray.Count,0);
            categories=csCall.ApiResponse.MappedCategoryArray;

            foreach(CategoryType category in categories)
            {
                if(string.Compare(category.CategoryID,PSPACATEGORYID)==0)
                {
                    characteristics=category.CharacteristicsSets;
                    existing= true;
                    break;
                }
            }

            //confirm that the category was in the mapping category.
            Assert.IsTrue(existing,PSPACATEGORYID+" do not exist in the mapping category");
            Assert.IsNotNull(characteristics);
            Assert.Greater(characteristics.Count,0);

            foreach(CharacteristicsSetType characteristic in characteristics)
            {
                attributes.Add(characteristic.AttributeSetID);
            }

            //confirm that there is real attributeset in the mapping category.
            Assert.AreEqual(attributes.Count,1);//there is only one AttributeSetID in the category 279.

            GetProductSearchPageCall searchPageCall=new GetProductSearchPageCall(this.apiContext);
            searchPageCall.AttributeSetIDList=attributes;
            DetailLevelCodeTypeCollection levels2=new DetailLevelCodeTypeCollection();
            DetailLevelCodeType level2=new DetailLevelCodeType();
            level2=DetailLevelCodeType.ReturnAll;
            levels2.Add(level2);
            searchPageCall.DetailLevelList=levels2;
            searchPageCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(searchPageCall.ApiResponse.Ack==AckCodeType.Success || searchPageCall.ApiResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.AreEqual(searchPageCall.ApiResponse.ProductSearchPage.Count,1);//for the input attributeset id is only one.
            Assert.IsNotNull(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet);//for the input attributeset id is only one.
            Assert.IsNotNull(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics);
            Assert.Greater(searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics.Count,0);

            //check the isbn-13 attribute id exists and its value has not been changed.
            CharacteristicTypeCollection chs = searchPageCall.ApiResponse.ProductSearchPage[0].SearchCharacteristicsSet.Characteristics;
            foreach(CharacteristicType charactersic in chs)
            {
                //check whether the isbn attribute can be used
                if(charactersic.AttributeID==ISBN13ATTRIBUTEID && (string.Compare(charactersic.Label.Name,"ISBN-13",true)==0))
                {
                    isbnExisting=true;
                    break;
                }
            }

            Assert.IsTrue(isbnExisting,"the isbn attribute id is not existing or has been changed!");
            //using GetProductSearchResults call to find products.
            ProductSearchType productSearch=new ProductSearchType();
            productSearch.AttributeSetID=attributes[0];
            SearchAttributesTypeCollection searchAttributes=new SearchAttributesTypeCollection();
            SearchAttributesType searchAttribute=new SearchAttributesType();
            searchAttribute.AttributeID=ISBN13ATTRIBUTEID;
            ValTypeCollection vals=new ValTypeCollection();
            ValType val=new ValType();
            val.ValueLiteral=ISBN;
            vals.Add(val);
            searchAttribute.ValueList=vals;
            searchAttributes.Add(searchAttribute);
            productSearch.SearchAttributes=searchAttributes;
            GetProductSearchResultsCall searchResultsCall=new GetProductSearchResultsCall(this.apiContext);
            searchResultsCall.ProductSearchList=new ProductSearchTypeCollection(new ProductSearchType[]{productSearch});
            searchResultsCall.Execute();
            //check whether the call is success.
            Assert.IsTrue(searchResultsCall.ApiResponse.Ack==AckCodeType.Success || searchResultsCall.ApiResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult.Count,0);
            Assert.AreEqual(int.Parse(searchResultsCall.ApiResponse.ProductSearchResult[0].NumProducts),1);
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet.Count,0);
            Assert.Greater(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies.Count,0);
            Assert.IsFalse(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].hasMoreChildren);
            Assert.IsNotNull(searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].ParentProduct.productID);

            string productID=searchResultsCall.ApiResponse.ProductSearchResult[0].AttributeSet[0].ProductFamilies[0].ParentProduct.productID;
            ProductListingDetailsType plist=new ProductListingDetailsType();
            plist.ProductID=productID;
            plist.IncludePrefilledItemInformation=true;
            plist.IncludeStockPhotoURL=true;
            item.ProductListingDetails=plist;

            FeeTypeCollection fees;

            VerifyAddItemCall vi = new VerifyAddItemCall(apiContext);
            fees = vi.VerifyAddItem(item);
            Assert.IsNotNull(fees);

            AddItemCall addItemCall = new AddItemCall(apiContext);;
            fees = addItemCall.AddItem(item);
            //check whether the call is success.
            Assert.IsTrue(addItemCall.AbstractResponse.Ack==AckCodeType.Success || addItemCall.AbstractResponse.Ack==AckCodeType.Warning,"do not success!");
            Assert.IsTrue(item.ItemID!=string.Empty);
            Assert.IsNotNull(fees);

            //caution check
            ItemType itemOut;
            isSucess=ItemHelper.GetItem(item,this.apiContext,out message, out itemOut);
            Assert.IsTrue(isSucess,message);
            Assert.IsNotNull(itemOut,"Item is null");
            Assert.Greater(itemOut.AttributeSetArray.Count,0);
            Assert.Greater(itemOut.AttributeSetArray[0].Attribute.Count,0);
            Assert.Greater(itemOut.AttributeSetArray[0].Attribute[0].Value.Count,0);
        }
示例#3
0
        private ItemType FillItem(RecommendationEngineCodeType engine)
        {
            ItemType item = new ItemType();
            if (TxtTitle.Text.Length > 0)
                item.Title = TxtTitle.Text;

            CurrencyCodeType currencyID = CurrencyUtility.GetDefaultCurrencyCodeType(Context.Site);

            item.Currency = currencyID;
            if (TxtStartPrice.Text.Length > 0)
            {
                item.StartPrice = new AmountType();
                item.StartPrice.Value = Convert.ToDouble(TxtStartPrice.Text);
                item.StartPrice.currencyID = currencyID;
            }

            if (TxtReservePrice.Text.Length > 0)
            {
                item.ReservePrice = new AmountType();
                item.ReservePrice.Value = Convert.ToDouble(TxtReservePrice.Text);
                item.ReservePrice.currencyID = currencyID;
            };

            if (TxtBuyItNowPrice.Text.Length > 0)
            {
                item.BuyItNowPrice = new AmountType();
                item.BuyItNowPrice.Value = Convert.ToDouble(TxtBuyItNowPrice.Text);
                item.BuyItNowPrice.currencyID = currencyID;
            }

            if (TxtPrimaryCategory.Text.Length > 0)
            {
                item.PrimaryCategory = new CategoryType();
                item.PrimaryCategory.CategoryID = TxtPrimaryCategory.Text;
            }

            if (TxtSecondaryCategory.Text.Length > 0)
            {
                item.SecondaryCategory = new CategoryType();
                item.SecondaryCategory.CategoryID= TxtSecondaryCategory.Text;
            }

            if (TxtItemID.Visible)
            {
                item.ItemID = TxtItemID.Text;
            }
            if( engine == RecommendationEngineCodeType.ProductPricing )
            {
                string s = TxtExternalProductID.Text;
                if (s.Length > 0)
                {
                    ProductListingDetailsType pld = new ProductListingDetailsType();
                    pld.ProductID = s;
                    item.ProductListingDetails = pld;
                }
            }

            return item;
        }