Пример #1
0
        public void GetCategory2CS()
        {
            GetCategory2CSCall api = new GetCategory2CSCall(this.apiContext);
            // Return version only
            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
            DetailLevelCodeType.ReturnAll
            };
            api.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
            api.CategoryID = "279";   //Children's Book

            //api.CategoryID = "64355";   //Cell Phones
            api.Timeout = 300000;

            string message=string.Empty;

            // Make API call.
            CategoryTypeCollection cats = api.GetCategory2CS();

            Assert.IsNotNull(cats);
            Assert.IsNotNull(api.AttributeSystemVersionResponse);
            int ver = Int32.Parse(api.AttributeSystemVersionResponse);
            Assert.IsTrue(ver > 0);
            Assert.IsNotNull(api.SiteWideCharacteristicList);
            TestData.Category2CS = cats;

            IAttributesMaster attrMaster = new AttributesMaster();
            ICategoryCSProvider catCSDownLoader = new CategoryCSDownloader(apiContext);
            attrMaster.CategoryCSProvider = catCSDownLoader;
            int[] catIds = catCSDownLoader.GetSiteWideCharSetsAttrIds("48514");
            Assert.IsNotNull(catIds);
        }
Пример #2
0
        public void GetCategory2CSFull()
        {
            //pls do not change this category id. It may have some negative effects on GetProductFinderCall
            string mediaCategory="279";//this is children's book whick blongs to Media category and is catalog-enabled.
            CategoryType categoryTmp=null;
            bool isValid,isSuccess;
            string message;

            //check whether the category is valid.
            isSuccess=CategoryHelper.IsValidCategory(this.apiContext,ref mediaCategory,out isValid,out message);
            Assert.IsTrue(isSuccess,message);
            Assert.IsTrue(isValid,"this category is not valid");

            GetCategory2CSCall api = new GetCategory2CSCall(this.apiContext);
            // Return all message.
            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
            DetailLevelCodeType.ReturnAll
            };
            api.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
            api.CategoryID = mediaCategory.ToString();

            // Make API call.
            CategoryTypeCollection categories = api.GetCategory2CS();
            //check whether the call is success.
            Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning,"the call is failure!");
            Assert.IsNotNull(categories);
            Assert.Greater(categories.Count,0);
            foreach(CategoryType category in categories)
            {
                if(string.Compare(category.CategoryID,mediaCategory,true)==0)
                {
                    categoryTmp=category;
                    break;
                }
            }

            //the media category should be catalog-enabled and contains attributeset id accordingly.
            Assert.IsNotNull(categoryTmp);
            Assert.IsTrue(categoryTmp.CatalogEnabled);
            Assert.IsTrue(categoryTmp.ProductSearchPageAvailable);
            Assert.IsNotNull(categoryTmp.CharacteristicsSets);
            Assert.Greater(categoryTmp.CharacteristicsSets.Count,0);
            Assert.Greater(categoryTmp.CharacteristicsSets[0].AttributeSetID,0);

            TestData.Category2CS2=categoryTmp;
        }
Пример #3
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);
        }
		/// <summary>
		/// Get CategoryCS data by calling eBay API. Special version for fast example usage.
		/// </summary>
		/// <param name="asn">The <c>ApiContext</c> object to make API call.</param>
		/// <param name="categoryId">A specific category ID for which to download CategoryCS data.</param>
		public CategoryTypeCollection DownloadCategoryCS(ApiContext asn, string categoryId)
		{
			GetCategory2CSCall	api = new GetCategory2CSCall(asn);
			//api.ErrorLevel = ErrorLevelEnum.BothShortAndLongErrorStrings;
			if (categoryId != null) 
			{
				api.CategoryID = categoryId;
			}
			api.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);	//.DetailLevel = 1;
			api.Timeout = 480000;
			mCats = api.GetCategory2CS();
			mSiteWideCharacteristicSets = api.SiteWideCharacteristicList;

			return mCats;
		}
		private string getCurrentAttributeSystemVersion() 
		{
			GetCategory2CSCall api = new GetCategory2CSCall(apiContext);
			api.DetailLevelList.Add(DetailLevelCodeType.ReturnSummary);
		    
			return api.GetCategory2CSVersion();  
		}
Пример #6
0
        /// <summary>
        /// check an category whether it is catalog-enabled.
        /// </summary>
        /// <param name="apiContext"></param>
        /// <param name="categorid"></param>
        /// <param name="isCatalogEnable"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        private static bool isCatagoryEnabled(ApiContext apiContext,string categorid,CategoryEnableCodeType enableType,out bool isEnable,out string message)
        {
            CategoryTypeCollection categories;
            isEnable=false;
            message=string.Empty;

            GetCategory2CSCall api =new GetCategory2CSCall(apiContext);
            DetailLevelCodeType detaillevel= DetailLevelCodeType.ReturnAll;
            api.DetailLevelList=new DetailLevelCodeTypeCollection(new DetailLevelCodeType[]{detaillevel});
            api.CategoryID=categorid;
            try
            {
                categories = api.GetCategory2CS();
                foreach(CategoryType category in categories)
                {
                    if(string.Compare(category.CategoryID,categorid,false)==0)
                    {
                        if(enableType==CategoryEnableCodeType.CatalogEnabled)
                        {
                            isEnable=category.CatalogEnabled;
                            break;
                        }
                        else if(enableType==CategoryEnableCodeType.ProductSearchPageAvailable)
                        {
                            isEnable=category.ProductSearchPageAvailable;
                            break;
                        }
                    }
                }
            }
            catch(Exception e)
            {
                message=e.Message;
                return false;
            }

            return true;
        }
Пример #7
0
        private void BtnGetCategory2CS_Click(object sender, System.EventArgs e)
        {
            try
            {
                LstCategories.Items.Clear();

                GetCategory2CSCall apicall = new GetCategory2CSCall(Context);
                apicall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
                if (TxtCategory.Text.Length > 0)
                    apicall.CategoryID = TxtCategory.Text;
                CategoryTypeCollection	cats = apicall.GetCategory2CS();
                int numCats = cats.Count;
                lblShowNumCats.Text = numCats.ToString();
                int catCount = 0;
                foreach (CategoryType category in cats)
                {
                    bool hasProdFinder = category.ProductFinderIDs.Count > 0;
                    if(category.CatalogEnabled || hasProdFinder
                        || category.ProductSearchPageAvailable
                        || category.ProductSearchPageAvailableSpecified)
                    {
                        string[] listparams = new string[8];
                        listparams[0] = category.CategoryID;
                        listparams[1] = category.CharacteristicsSets[0].Name;
                        listparams[2] = category.CharacteristicsSets[0].AttributeSetID.ToString();
                        listparams[3] = category.CatalogEnabled.ToString();
                        listparams[4] = hasProdFinder.ToString();
                        listparams[5] = category.ProductSearchPageAvailable.ToString();
                        listparams[6] = category.ProductSearchPageAvailableSpecified.ToString();
                        ListViewItem vi = new ListViewItem(listparams);
                        this.LstCategories.Items.Add(vi);
                        catCount++;
                    }
                }
                lblShowNumCats.Text = catCount.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }