Exemplo n.º 1
0
 /// <summary>
 /// set basic info for GetCategoryFeaturesCall
 /// </summary>
 /// <param name="api"></param>
 private static void setBasicInfo(ref GetCategoryFeaturesCall api)
 {
     DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
         DetailLevelCodeType.ReturnAll
     };
     api.Site            = SiteCodeType.US;
     api.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
 }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        public void GetCategoryFeaturesFull()
        {
            GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(this.apiContext);

            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
                DetailLevelCodeType.ReturnSummary
            };
            api.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
            api.Execute();
            //check whether the call is success.
            Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning, "the call is failure!");
            Assert.IsNotNull(api.ApiResponse.FeatureDefinitions);
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        /// <summary>
        /// get last update time from site
        /// </summary>
        /// <returns>string</returns>
        protected override string getLastUpdateTime()
        {
            GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(context);

            //set output selector
            api.ApiRequest.OutputSelector = new StringCollection(new String[] { "CategoryVersion" });
            //api.ApiRequest.OutputSelector = new StringCollection(new String[]{"UpdateTime"});
            //execute call
            api.GetCategoryFeatures();

            //workaround, for GetCategoryFeaturesCall, we just use CategoryVersion as last update time
            return(api.ApiResponse.CategoryVersion);
            //DateTime updateTime = api.ApiResponse.UpdateTime;

            //return updateTime.ToString("yyyy-MM-dd-hh-mm-ss");
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        // http://developer.ebay.com/DevZone/xml/docs/Reference/ebay/GetCategoryFeatures.html#Response.Category.ReturnPolicyEnabled
        public GetCategoryFeaturesCall GetCategoryFeatures(int categoryid, SiteCodeType siteid)
        {
            //create the call object for GetCategoryFeatures
            var call = new GetCategoryFeaturesCall(api);

            call.Site = siteid;

            //set the CategoryID
            call.CategoryID = categoryid.ToString();

            //view all the nodes and get all the details
            call.ViewAllNodes = true;
            call.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);

            //execute the request
            call.GetCategoryFeatures();
            return(call);
        }
Exemplo n.º 8
0
        public void GetCategoryFeaturesFull2()
        {
            GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(this.apiContext);

            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
                DetailLevelCodeType.ReturnAll
            };
            api.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);
            FeatureIDCodeTypeCollection features = new FeatureIDCodeTypeCollection();
            FeatureIDCodeType           feature  = FeatureIDCodeType.BestOfferEnabled;

            features.Add(feature);
            api.FeatureIDList = features;
            api.CategoryID    = COOKBOOKSCATEGORYID;
            api.Execute();
            //check whether the call is success.
            Assert.IsTrue(api.ApiResponse.Ack == AckCodeType.Success || api.ApiResponse.Ack == AckCodeType.Warning, "the call is failure!");
            Assert.IsNotNull(api.ApiResponse.FeatureDefinitions);
            Assert.AreEqual(api.ApiResponse.Category[0].CategoryID, COOKBOOKSCATEGORYID);
        }
Exemplo n.º 9
0
        /// <summary>
        /// call GetCategories to get all categories for a given site
        /// </summary>
        /// <returns>generic object</returns>
        protected override object callApi()
        {
            GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(context);

            //set detail level
            api.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);
            api.ViewAllNodes = true;
            FeatureIDCodeTypeCollection featureCol = new FeatureIDCodeTypeCollection();

            featureCol.Add(FeatureIDCodeType.ListingDurations);
            featureCol.Add(FeatureIDCodeType.ItemSpecificsEnabled);
            featureCol.Add(FeatureIDCodeType.ReturnPolicyEnabled);
            featureCol.Add(FeatureIDCodeType.PaymentMethods);
            featureCol.Add(FeatureIDCodeType.ConditionEnabled);
            featureCol.Add(FeatureIDCodeType.ConditionValues);
            //execute call
            api.FeatureIDList = featureCol;
            api.GetCategoryFeatures();

            return(api.ApiResponse);
        }
Exemplo n.º 10
0
        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());
        }
Exemplo n.º 11
0
        /// <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);
        }