/// <summary> /// get some items which supports the ad format category, you can specify the number /// </summary> /// <param name="apiContext"></param> /// <param name="num"></param> /// <param name="categoryTypeCollection"></param> /// <param name="message"></param> /// <returns></returns> public static bool GetAdFormatCategory(ApiContext apiContext, int num, out CategoryTypeCollection categoryTypeCollection, out string message) { message = string.Empty; CategoryTypeCollection tmpCategories; categoryTypeCollection = null; num = (num <= 0)?1:num; GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(apiContext); setBasicInfo(ref api); //spcify category id if (!getAllCategories(apiContext, out tmpCategories, out message)) { message = message + ",203"; return(false); } FeatureIDCodeTypeCollection features = new FeatureIDCodeTypeCollection(); FeatureIDCodeType type = FeatureIDCodeType.AdFormatEnabled; features.Add(type); string categoryID = string.Empty; foreach (CategoryType category in tmpCategories) { if (category.LeafCategory == true) { categoryID = category.CategoryID; try { //call CategoryFeatureTypeCollection featureTypes = api.GetCategoryFeatures(categoryID, 10, true, features, true); if (featureTypes != null && featureTypes.Count > 0) { if (featureTypes[0].AdFormatEnabled == AdFormatEnabledCodeType.Enabled) { categoryTypeCollection.Add(category); } if (categoryTypeCollection.Count >= num) { break; } } } catch (Exception e) { message = e.Message + ",204"; return(false); } } } return(true); }
private void getCategoryFeatures() { GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(_apiContext); DetailLevelCodeTypeCollection detailLevels = new DetailLevelCodeTypeCollection(new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll }); api.DetailLevelList = detailLevels; // Make API call. api.GetCategoryFeatures(_categoryID, _levelLimit, _viewAllNodes, _featureIDs, _allFeaturesForCategory); _categoryFeatures = api.CategoryList; _categoryVersion = api.CategoryVersion; _siteDefaults = api.SiteDefaults; _siteFeatures = api.FeatureDefinitions; }
private ItemType addAdFormatItem() { ItemType item = ItemHelper.BuildItem(); GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(this.apiContext); DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll }; api.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels); api.LevelLimit = 10; api.ViewAllNodes = true; bool viewAllNodes = true; bool isSuccess; CategoryTypeCollection categories; string message; //get an item which supports the Ad-format isSuccess = CategoryHelper.GetAdFormatCategory(this.apiContext, 1, out categories, out message); Assert.IsTrue(isSuccess, message); Assert.IsNotNull(categories); Assert.Greater(categories.Count, 0); Assert.IsTrue(categories[0].CategoryID != string.Empty); item.PrimaryCategory.CategoryID = categories[0].CategoryID; // get the list duration value according to the category CategoryFeatureTypeCollection features = api.GetCategoryFeatures(item.PrimaryCategory.CategoryID, api.LevelLimit, viewAllNodes, null, true); Assert.IsNotNull(features); Assert.Greater(features.Count, 0); Assert.IsNotNull(features[0].ListingDuration); Assert.Greater(features[0].ListingDuration.Count, 0); //modify item property to adapt the AdFormatItem item.ListingType = ListingTypeCodeType.AdType; item.ListingDuration = features[0].ListingDuration[0].Value.ToString(); // Execute the API. FeeTypeCollection fees; // AddItem AddItemCall addItem = new AddItemCall(this.apiContext); fees = addItem.AddItem(item); Assert.IsNotNull(fees); // Save the result. return(item); }
private void SyncAllCategoriesFeatures() { if (!siteCategoriesFeaturesTable.ContainsKey(apiContext.Site)) { FeaturesDownloader downloader = new FeaturesDownloader(apiContext); GetCategoryFeaturesResponseType resp = downloader.GetCategoryFeatures(); CategoryFeatureTypeCollection cfCol = resp.Category; Hashtable cfsTable = new Hashtable(TABLE_SIZE); foreach (CategoryFeatureType cf in cfCol) { cfsTable.Add(cf.CategoryID, cf); } siteCategoriesFeaturesTable.Add(apiContext.Site, cfsTable); siteFeatureDefaultTable.Add(apiContext.Site, resp.SiteDefaults); siteFeatureDefinitionsTable.Add(apiContext.Site, resp.FeatureDefinitions); } }
public static void GetAllCategoriesFeatures(ApiContext context) { FeaturesDownloader downloader = new FeaturesDownloader(context); GetCategoryFeaturesResponseType resp = downloader.GetCategoryFeatures(); CategoryFeatureTypeCollection cfCol = resp.Category; //cache the features in hashtable foreach (CategoryFeatureType cf in cfCol) { cfsTable.Add(cf.CategoryID, cf); } //cache site defaults siteDefaults = resp.SiteDefaults; //cahce feature definitions featureDefinition = resp.FeatureDefinitions; }
public void GetCategoryFeatures() { GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(this.apiContext); DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll }; api.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels); api.LevelLimit = 1; api.ViewAllNodes = true; // Make API call. CategoryFeatureTypeCollection features = api.GetCategoryFeatures(); //check whether the call is success. Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success, "the call is failure!"); Assert.IsNotNull(features); Assert.IsTrue(features.Count > 0); Assert.IsNotNull(api.ApiResponse.CategoryVersion); // Testing GetCategoryFeaturesHelper this.apiContext.Site = SiteCodeType.Austria; GetCategoryFeaturesHelper helper = new GetCategoryFeaturesHelper(this.apiContext); Assert.IsTrue(helper.hasCategoryFeatures(SiteCodeType.Austria)); this.apiContext.Site = SiteCodeType.China; helper.loadCategoryFeatures(this.apiContext); Assert.IsTrue(helper.hasCategoryFeatures(SiteCodeType.Austria)); Assert.IsTrue(helper.hasCategoryFeatures(SiteCodeType.China)); this.apiContext.Site = SiteCodeType.US; helper.loadCategoryFeatures(this.apiContext); Assert.IsTrue(helper.hasCategoryFeatures(SiteCodeType.Austria)); Assert.IsTrue(helper.hasCategoryFeatures(SiteCodeType.China)); Assert.IsTrue(helper.hasCategoryFeatures(SiteCodeType.US)); // FeatureDefinitionsType USFeatures = helper.getSiteFeatures(SiteCodeType.US); Assert.IsNotNull(USFeatures); System.Console.WriteLine(USFeatures.ToString()); }
private void getCategoryFeatures() { GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(_apiContext); DetailLevelCodeTypeCollection detailLevels = new DetailLevelCodeTypeCollection( new DetailLevelCodeType[] {DetailLevelCodeType.ReturnAll}); api.DetailLevelList = detailLevels; // Make API call. api.GetCategoryFeatures(_categoryID, _levelLimit, _viewAllNodes, _featureIDs, _allFeaturesForCategory); _categoryFeatures = api.CategoryList; _categoryVersion = api.CategoryVersion; _siteDefaults = api.SiteDefaults; _siteFeatures = api.FeatureDefinitions; }
/// <summary> /// just support custom item specific. it would be enchance later. /// </summary> /// <param name="categoryID"></param> /// <param name="ids"></param> /// <returns></returns> private static bool isSupportFeature(int categoryID, FeatureIDCodeTypeCollection features, ApiContext apiContext, out bool isSupport, out string message) { isSupport = true; message = string.Empty; GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(apiContext); setBasicInfo(ref api); //spcify category id api.CategoryID = categoryID.ToString(); api.FeatureIDList = features; try { //call CategoryFeatureTypeCollection featureTypes = api.GetCategoryFeatures(); SiteDefaultsType siteDefaultsType = api.SiteDefaults; if (featureTypes != null && featureTypes.Count > 0) { foreach (FeatureIDCodeType feature in features) { if (feature.ToString() == "ItemSpecificsEnabled") { // Check if the specified category is ItemspecificEnabled, // Check for ItemspecificEnabled element in the features level // If the tag does not occur then fetch it from site defaults if (!featureTypes[0].ItemSpecificsEnabledSpecified) { if (siteDefaultsType.ItemSpecificsEnabledSpecified) { if (siteDefaultsType.ItemSpecificsEnabled != ItemSpecificsEnabledCodeType.Enabled) { isSupport = false; message = "ItemSpecificsEnabled is not supported!"; break; } } } else if (featureTypes[0].ItemSpecificsEnabled != ItemSpecificsEnabledCodeType.Enabled) { isSupport = false; message = "ItemSpecificsEnabled is not supported!"; break; } } if (feature.ToString() == "AdFormatEnabled") { if (featureTypes[0].AdFormatEnabled != AdFormatEnabledCodeType.Enabled) { isSupport = false; message = "AdFormatEnabled is not supported!"; break; } } } } } catch (Exception e) { message = e.Message; return(false); } return(true); }