/// <summary>
        /// get all attributes from the charactersic with which the specific category is mapping
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="apiContext"></param>
        /// <returns></returns>
        //private static AttributeSetTypeCollection GetAttributeSetCol(int categoryId,ApiContext apiContext)
        //{
        //    IAttributesMaster attributesMaster=new AttributesMaster();
        //    AttributeSetTypeCollection attributeSTC=new AttributeSetTypeCollection();

        //    attributesMaster.CategoryCSProvider=new CategoryCSDownloader(apiContext);
        //    attributesMaster.XmlProvider=new AttributesXmlDownloader(apiContext);
        //    //get the characteristic set id of the specified category
        //    IAttributeSetCollection attributeSetCol=attributesMaster.GetItemSpecificAttributeSetsForCategories(new Int32Collection(new int[]{categoryId}));

        //    Assert.IsNotNull(attributeSetCol);

        //    IAttributesXmlProvider iaxp=attributesMaster.XmlProvider;
        //    //download all attributes from ebay
        //    XmlDocument document=iaxp.DownloadXml();
        //    //write the memory xml to disk
        //    WriteXMLToDisk(document);
        //    AttributeSetTypeCollection attributeSetTypeCol=new AttributeSetTypeCollection();
        //    //get Required Item specifics by call getAttributesCS
        //    foreach(AttributeSet attributeSet in attributeSetCol)
        //    {
        //        AttributeSetType attributeST=new AttributeSetType();
        //        attributeST.attributeSetID=attributeSet.attributeSetID;
        //        String xpath="//Characteristics/CharacteristicsSet[@id='"+attributeSet.attributeSetID.ToString()+"']//CharacteristicsList//Initial//Attribute";
        //        XmlNodeList nodeList;
        //        XmlNode root = document.DocumentElement;
        //        nodeList=root.SelectNodes(xpath);
        //        AttributeTypeCollection attributeTypeCol=new AttributeTypeCollection();
        //        foreach (XmlNode node in nodeList)
        //        {
        //            AttributeType attributeT=new AttributeType();
        //            XmlAttributeCollection attributes=node.Attributes;
        //            Assert.IsNotNull(attributes);
        //            XmlNode idNode = attributes.GetNamedItem("id");
        //            attributeT.attributeID=int.Parse(idNode.Value);
        //            ValTypeCollection valTypeCol=getValue(node);
        //            if(valTypeCol==null)
        //            {
        //                System.Console.WriteLine("can not find any specific value!");
        //            }
        //            attributeT.Value=valTypeCol;
        //            attributeTypeCol.Add(attributeT);
        //        }

        //        attributeST.Attribute=attributeTypeCol;
        //        attributeSTC.Add(attributeST);
        //    }
        //    return attributeSTC;
        //}


        /// <summary>
        /// get all id value of the valuelist in the xml document
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <returns></returns>
        private static ValTypeCollection getValue(XmlNode xmlNode)
        {
            string            xpath      = "ValueList/Value";
            XmlNodeList       nodeList   = xmlNode.SelectNodes(xpath);
            ValTypeCollection valTypeCol = new ValTypeCollection();

            foreach (XmlNode node in nodeList)
            {
                XmlAttributeCollection attribute = node.Attributes;
                XmlNode idNode  = attribute.GetNamedItem("id");
                int     valueId = int.Parse(idNode.Value);
                if (valueId > 0)
                {
                    ValType valType = new ValType();
                    valType.ValueID = valueId;
                    valTypeCol.Add(valType);
                    break;
                }
            }

            if (valTypeCol.Count == 0)
            {
                return(null);
            }

            return(valTypeCol);
        }
Example #2
0
        private static ValTypeCollection ConvertValTypeCollection(ValTypeCollection fromVals)
        {
            ValTypeCollection toVals = new ValTypeCollection();

            foreach (ValType fromVal in fromVals)
            {
                ValType newVal = new ValType();

                newVal.Any = fromVal.Any;
                newVal.SuggestedValueLiteral = fromVal.SuggestedValueLiteral;
                newVal.ValueID          = fromVal.ValueID;
                newVal.ValueIDSpecified = fromVal.ValueIDSpecified;
                newVal.ValueLiteral     = fromVal.ValueLiteral;

                toVals.Add(newVal);
            }

            return(toVals);
        }
Example #3
0
        /// <summary>
        /// get all id value of the valuelist in the xml document
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <returns></returns>
        private static ValTypeCollection getValue(XmlNode xmlNode)
        {
            string xpath="ValueList/Value";
            XmlNodeList nodeList=xmlNode.SelectNodes(xpath);
            ValTypeCollection valTypeCol=new ValTypeCollection();

            foreach(XmlNode node in nodeList)
            {
                XmlAttributeCollection attribute=node.Attributes;
                XmlNode idNode=attribute.GetNamedItem("id");
                int valueId=int.Parse(idNode.Value);
                if(valueId>0)
                {
                    ValType valType=new ValType();
                    valType.ValueID=valueId;
                    valTypeCol.Add(valType);
                    break;
                }
            }

            if(valTypeCol.Count==0)
            {
                return null;
            }

            return valTypeCol;
        }
Example #4
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);
        }
		private static ValTypeCollection ConvertValTypeCollection(ValTypeCollection fromVals)
		{
			ValTypeCollection toVals = new ValTypeCollection();

			foreach(ValType fromVal in fromVals)
			{
				ValType newVal = new ValType();

				newVal.Any = fromVal.Any;
				newVal.SuggestedValueLiteral = fromVal.SuggestedValueLiteral;
				newVal.ValueID = fromVal.ValueID;
				newVal.ValueIDSpecified = fromVal.ValueIDSpecified;
				newVal.ValueLiteral = fromVal.ValueLiteral;

				toVals.Add(newVal);
			}

			return toVals;
		}
Example #6
0
        private string addItem(MySQLWrapper.eBayItem ebayItem)
        {
            string        listedItemId    = "-1";
            StringBuilder htmlDescription = new StringBuilder();
            TextReader    tr = new StreamReader("template.txt");

            htmlDescription.Insert(0, tr.ReadToEnd());
            tr.Close();
            htmlDescription.Replace("{0}", ebayItem.Title);
            htmlDescription.Replace("{1}", ebayItem.Author);
            htmlDescription.Replace("{2}", ebayItem.Publisher);
            htmlDescription.Replace("{3}", ebayItem.publishDate);
            htmlDescription.Replace("{4}", ebayItem.Binding);
            htmlDescription.Replace("{5}", ebayItem.ISBN);
            if (ebayItem.UPC != "")
            {
                htmlDescription.Replace("{6}", "<b>UPC : </b>" + ebayItem.UPC + "</br>");
            }
            else
            {
                htmlDescription.Replace("{6}", "");
            }
            htmlDescription.Replace("{7}", ebayItem.Weight.ToString());
            htmlDescription.Replace("{8}", ebayItem.Notes);
            htmlDescription.Replace("{9}", ebayItem.Description);

            ItemType item = new ItemType();


            item.InventoryTrackingMethod = InventoryTrackingMethodCodeType.SKU;
            item.SKU = ebayItem.SKU;

            // Title max length 55 chars
            if (ebayItem.Title.Length > 55)
            {
                item.Title = ebayItem.Title.Substring(0, 54);
            }
            else
            {
                item.Title = ebayItem.Title;
            }

            if (ebayItem.Image != "")
            {
                item.PictureDetails = new PictureDetailsType();
                item.PictureDetails.PictureURL.Add(ebayItem.Image);
            }

            item.Description     = htmlDescription.ToString();
            item.Currency        = CurrencyCodeType.INR;
            item.ListingType     = ListingTypeCodeType.FixedPriceItem;
            item.Quantity        = ebayItem.Quantity;
            item.PostalCode      = eBayLister.UserSettings.Default.itemPincode;
            item.Location        = eBayLister.UserSettings.Default.itemCityState;
            item.Country         = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), eBayLister.UserSettings.Default.itemCountry, true);
            item.ListingDuration = getListingDuration();
            item.PrimaryCategory = new CategoryType();
            if (eBayLister.UserSettings.Default.ListInCategory.Equals("Other Books"))
            {
                item.PrimaryCategory.CategoryID = "268";
            }
            else
            {
                item.PrimaryCategory.CategoryID = "37558";
            }
            item.StartPrice            = new AmountType();
            item.StartPrice.currencyID = CurrencyCodeType.INR;
            item.StartPrice.Value      = ebayItem.Price *
                                         Convert.ToDouble(eBayLister.UserSettings.Default.ConversionRate);
            item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
            item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PaisaPayAccepted);
            item.ShippingDetails = this.getShippingDetails();
            item.ReturnPolicy    = this.getReturnPolicy();
            string handlingTime = eBayLister.UserSettings.Default.handlingTime;

            handlingTime         = handlingTime.Remove(handlingTime.IndexOf(' '));
            item.DispatchTimeMax = Convert.ToInt32(handlingTime);

            AttributeType conditionAttribute = new AttributeType();

            conditionAttribute.attributeLabel = "Condition";
            ValTypeCollection valueCollection = new ValTypeCollection();
            ValType           valueType       = new ValType();

            if (ebayItem.bookCondition.Contains("Used"))
            {
                valueType.ValueLiteral = "Used";
            }
            else
            {
                valueType.ValueLiteral = "New";
            }
            valueCollection.Add(valueType);
            conditionAttribute.Value = valueCollection;
            item.AttributeArray      = new AttributeTypeCollection();
            item.AttributeArray.Add(conditionAttribute);
            AddItemCall apiCall = new AddItemCall(context);


            FeeTypeCollection fees = apiCall.AddItem(item);

            foreach (FeeType fee in fees)
            {
                if (fee.Name == "ListingFee")
                {
                    addLogStatus("Success!     Listing Fee : " + Convert.ToString(fee.Fee.Value));
                }
            }

            listedItemId = apiCall.ItemID;
            return(listedItemId);
        }
Example #7
0
        private bool verifyAddItem(MySQLWrapper.eBayItem ebayItem)
        {
            bool          itemListing     = false;
            TextReader    tr              = new StreamReader("template.txt");
            StringBuilder htmlDescription = new StringBuilder();

            htmlDescription.Insert(0, tr.ReadToEnd());
            tr.Close();
            htmlDescription.Replace("{0}", ebayItem.Title);
            htmlDescription.Replace("{1}", ebayItem.Author);
            htmlDescription.Replace("{2}", ebayItem.Publisher);
            htmlDescription.Replace("{3}", ebayItem.publishDate);
            htmlDescription.Replace("{4}", ebayItem.Binding);
            htmlDescription.Replace("{5}", ebayItem.ISBN);
            if (ebayItem.UPC != "")
            {
                htmlDescription.Replace("{6}", "<b>UPC : </b>" + ebayItem.UPC + "</br>");
            }
            else
            {
                htmlDescription.Replace("{6}", "");
            }
            htmlDescription.Replace("{7}", ebayItem.Weight.ToString());
            htmlDescription.Replace("{8}", ebayItem.Notes);
            htmlDescription.Replace("{9}", ebayItem.Description);

            ItemType item = new ItemType();

            item.SKU             = ebayItem.SKU;
            item.Title           = ebayItem.Title;
            item.Description     = htmlDescription.ToString();
            item.Currency        = CurrencyCodeType.INR;
            item.Country         = CountryCodeType.IN;
            item.ListingType     = ListingTypeCodeType.FixedPriceItem;
            item.Quantity        = ebayItem.Quantity;
            item.Location        = eBayLister.UserSettings.Default.itemCityState;
            item.ListingDuration = getListingDuration();
            item.PrimaryCategory = new CategoryType();
            if (eBayLister.UserSettings.Default.ListInCategory.Equals("Other Books"))
            {
                item.PrimaryCategory.CategoryID = "268";
            }
            else
            {
                item.PrimaryCategory.CategoryID = "37558";
            }
            item.StartPrice            = new AmountType();
            item.StartPrice.currencyID = CurrencyCodeType.INR;
            item.StartPrice.Value      = ebayItem.Price *
                                         Convert.ToDouble(eBayLister.UserSettings.Default.ConversionRate);

            item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
            item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PaisaPayAccepted);
            item.ShippingDetails = this.getShippingDetails();
            item.ReturnPolicy    = this.getReturnPolicy();

            string handlingTime = eBayLister.UserSettings.Default.handlingTime;

            handlingTime         = handlingTime.Remove(handlingTime.IndexOf(' '));
            item.DispatchTimeMax = Convert.ToInt32(handlingTime);

            AttributeType conditionAttribute = new AttributeType();

            conditionAttribute.attributeLabel = "Condition";
            ValTypeCollection valueCollection = new ValTypeCollection();
            ValType           valueType       = new ValType();

            if (ebayItem.bookCondition.Contains("Used"))
            {
                valueType.ValueLiteral = "Used";
            }
            else
            {
                valueType.ValueLiteral = "New";
            }
            valueCollection.Add(valueType);
            conditionAttribute.Value = valueCollection;
            item.AttributeArray      = new AttributeTypeCollection();
            item.AttributeArray.Add(conditionAttribute);

            VerifyAddItemCall apiCall = new VerifyAddItemCall(context);

            try
            {
                FeeTypeCollection fees = apiCall.VerifyAddItem(item);
                foreach (FeeType fee in fees)
                {
                    if (fee.Name == "ListingFee")
                    {
                        addLogStatus("Success!     Listing Fee : " + Convert.ToString(fee.Fee.Value));
                    }
                }
                itemListing = true;
            }
            catch (ApiException ex)
            {
                itemListing = false;
                MessageBox.Show(ex.Message);
                Console.WriteLine(ex.Message);
            }
            return(itemListing);
        }
Example #8
0
        private bool verifyAddItem(MySQLWrapper.eBayItem ebayItem)
        {
            bool itemListing = false;
            TextReader tr = new StreamReader("template.txt");
            StringBuilder htmlDescription = new StringBuilder();
            htmlDescription.Insert(0,tr.ReadToEnd());
            tr.Close();
            htmlDescription.Replace("{0}", ebayItem.Title);
            htmlDescription.Replace("{1}", ebayItem.Author);
            htmlDescription.Replace("{2}", ebayItem.Publisher);
            htmlDescription.Replace("{3}", ebayItem.publishDate);
            htmlDescription.Replace("{4}", ebayItem.Binding);
            htmlDescription.Replace("{5}", ebayItem.ISBN);
            if (ebayItem.UPC != "")
                htmlDescription.Replace("{6}", "<b>UPC : </b>" + ebayItem.UPC + "</br>");
            else
                htmlDescription.Replace("{6}", "");
            htmlDescription.Replace("{7}", ebayItem.Weight.ToString());
            htmlDescription.Replace("{8}", ebayItem.Notes);
            htmlDescription.Replace("{9}", ebayItem.Description);

            ItemType item = new ItemType();
            item.SKU = ebayItem.SKU;
            item.Title = ebayItem.Title;
            item.Description = htmlDescription.ToString();
            item.Currency = CurrencyCodeType.INR;
            item.Country = CountryCodeType.IN;
            item.ListingType = ListingTypeCodeType.FixedPriceItem;
            item.Quantity = ebayItem.Quantity;
            item.Location = eBayLister.UserSettings.Default.itemCityState;
            item.ListingDuration = getListingDuration();
            item.PrimaryCategory = new CategoryType();
            if (eBayLister.UserSettings.Default.ListInCategory.Equals("Other Books"))
            {
                item.PrimaryCategory.CategoryID = "268";
            }
            else {
                item.PrimaryCategory.CategoryID = "37558";
            }
            item.StartPrice = new AmountType();
            item.StartPrice.currencyID = CurrencyCodeType.INR;
            item.StartPrice.Value = ebayItem.Price *
                Convert.ToDouble(eBayLister.UserSettings.Default.ConversionRate);

            item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
            item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PaisaPayAccepted);
            item.ShippingDetails = this.getShippingDetails();
            item.ReturnPolicy = this.getReturnPolicy();

            string handlingTime = eBayLister.UserSettings.Default.handlingTime;
            handlingTime = handlingTime.Remove(handlingTime.IndexOf(' '));
            item.DispatchTimeMax = Convert.ToInt32(handlingTime);

            AttributeType conditionAttribute = new AttributeType();
            conditionAttribute.attributeLabel = "Condition";
            ValTypeCollection valueCollection = new ValTypeCollection();
            ValType valueType = new ValType();
            if(ebayItem.bookCondition.Contains("Used"))
                valueType.ValueLiteral = "Used";
            else
                valueType.ValueLiteral = "New";
            valueCollection.Add(valueType);
            conditionAttribute.Value = valueCollection;
            item.AttributeArray = new AttributeTypeCollection();
            item.AttributeArray.Add(conditionAttribute);

            VerifyAddItemCall apiCall = new VerifyAddItemCall(context);

            try
            {
                FeeTypeCollection fees = apiCall.VerifyAddItem(item);
                foreach (FeeType fee in fees)
                {
                    if (fee.Name == "ListingFee")
                        addLogStatus("Success!     Listing Fee : " + Convert.ToString(fee.Fee.Value));
                }
                itemListing = true;
            }
            catch (ApiException ex)
            {
                itemListing = false;
                MessageBox.Show(ex.Message);
                Console.WriteLine(ex.Message);
            }
            return itemListing;
        }
Example #9
0
        private string addItem(MySQLWrapper.eBayItem ebayItem)
        {
            string listedItemId = "-1";
            StringBuilder htmlDescription = new StringBuilder();
            TextReader tr = new StreamReader("template.txt");
            htmlDescription.Insert(0, tr.ReadToEnd());
            tr.Close();
            htmlDescription.Replace("{0}", ebayItem.Title);
            htmlDescription.Replace("{1}", ebayItem.Author);
            htmlDescription.Replace("{2}", ebayItem.Publisher);
            htmlDescription.Replace("{3}", ebayItem.publishDate);
            htmlDescription.Replace("{4}", ebayItem.Binding);
            htmlDescription.Replace("{5}", ebayItem.ISBN);
            if (ebayItem.UPC != "")
                htmlDescription.Replace("{6}", "<b>UPC : </b>" + ebayItem.UPC + "</br>");
            else
                htmlDescription.Replace("{6}", "");
            htmlDescription.Replace("{7}", ebayItem.Weight.ToString());
            htmlDescription.Replace("{8}", ebayItem.Notes);
            htmlDescription.Replace("{9}", ebayItem.Description);

            ItemType item = new ItemType();

            item.InventoryTrackingMethod = InventoryTrackingMethodCodeType.SKU;
            item.SKU = ebayItem.SKU;

            // Title max length 55 chars
            if (ebayItem.Title.Length > 55)
                item.Title = ebayItem.Title.Substring(0, 54);
            else
                item.Title = ebayItem.Title;

            if (ebayItem.Image != "") {
                item.PictureDetails = new PictureDetailsType();
                item.PictureDetails.PictureURL.Add(ebayItem.Image);
            }

            item.Description = htmlDescription.ToString();
            item.Currency = CurrencyCodeType.INR;
            item.ListingType = ListingTypeCodeType.FixedPriceItem;
            item.Quantity = ebayItem.Quantity;
            item.PostalCode = eBayLister.UserSettings.Default.itemPincode;
            item.Location = eBayLister.UserSettings.Default.itemCityState;
            item.Country = (CountryCodeType)Enum.Parse(typeof(CountryCodeType), eBayLister.UserSettings.Default.itemCountry, true);
            item.ListingDuration = getListingDuration();
            item.PrimaryCategory = new CategoryType();
            if (eBayLister.UserSettings.Default.ListInCategory.Equals("Other Books"))
            {
                item.PrimaryCategory.CategoryID = "268";
            }
            else
            {
                item.PrimaryCategory.CategoryID = "37558";
            }
            item.StartPrice = new AmountType();
            item.StartPrice.currencyID = CurrencyCodeType.INR;
            item.StartPrice.Value = ebayItem.Price *
                Convert.ToDouble(eBayLister.UserSettings.Default.ConversionRate);
            item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
            item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PaisaPayAccepted);
            item.ShippingDetails = this.getShippingDetails();
            item.ReturnPolicy = this.getReturnPolicy();
            string handlingTime = eBayLister.UserSettings.Default.handlingTime;
            handlingTime = handlingTime.Remove(handlingTime.IndexOf(' '));
            item.DispatchTimeMax = Convert.ToInt32(handlingTime);

            AttributeType conditionAttribute = new AttributeType();
            conditionAttribute.attributeLabel = "Condition";
            ValTypeCollection valueCollection = new ValTypeCollection();
            ValType valueType = new ValType();
            if (ebayItem.bookCondition.Contains("Used"))
                valueType.ValueLiteral = "Used";
            else
                valueType.ValueLiteral = "New";
            valueCollection.Add(valueType);
            conditionAttribute.Value = valueCollection;
            item.AttributeArray = new AttributeTypeCollection();
            item.AttributeArray.Add(conditionAttribute);
            AddItemCall apiCall = new AddItemCall(context);

            FeeTypeCollection fees = apiCall.AddItem(item);
            foreach (FeeType fee in fees)
            {

                if (fee.Name == "ListingFee")
                    addLogStatus("Success!     Listing Fee : " + Convert.ToString(fee.Fee.Value));
            }

            listedItemId = apiCall.ItemID;
            return listedItemId;
        }
        public void GetProductSearchResultsFull()
        {
            bool isbnExisting=false;
            Int32Collection attributes=new Int32Collection();

            Assert.IsNotNull(TestData.ProductSearchPages2);
            Assert.Greater(TestData.ProductSearchPages2.Count,0);
            Assert.Greater(TestData.ProductSearchPages2[0].SearchCharacteristicsSet.Characteristics.Count,0);

            //check whether the call is success.
            Assert.AreEqual(string.Compare(TestData.Category2CS2.CategoryID,PSPACATEGORYID,true),0);
            CharacteristicsSetTypeCollection characteristics = TestData.Category2CS2.CharacteristicsSets;

            //confirm that the category was in the mapping category.
            Assert.IsNotNull(characteristics);
            Assert.Greater(characteristics.Count,0);

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

            //check the isbn-13 attribute id exists and its value has not been changed.
            CharacteristicTypeCollection chs = TestData.ProductSearchPages2[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);
            TestData.ProductSearchResults2 = searchResultsCall.ApiResponse.ProductSearchResult;
        }