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); }
/// <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; }
/// <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; }
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); } }
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; }