private ItemType  AddItem()
		{
			ItemType item = ItemHelper.BuildItem();
			// Execute the API.
			FeeTypeCollection fees;
			// AddItem
			AddItemCall addItem = new AddItemCall(this.apiContext);
			fees = addItem.AddItem(item);
			Assert.IsNotNull(fees);
			// Save the result.
			return item;
		}
Example #2
0
        static void Main(string[] args)
        {

            try {
                Console.WriteLine("+++++++++++++++++++++++++++++++++++++++");
                Console.WriteLine("+ Welcome to eBay SDK for .Net Sample +");
                Console.WriteLine("+ - ConsoleAddItem                    +");
                Console.WriteLine("+++++++++++++++++++++++++++++++++++++++");

                //[Step 1] Initialize eBay ApiContext object
                ApiContext apiContext = GetApiContext();

                //[Step 2] Create a new ItemType object
                ItemType item = BuildItem();


                //[Step 3] Create Call object and execute the Call
                AddItemCall apiCall = new AddItemCall(apiContext);
                Console.WriteLine("Begin to call eBay API, please wait ...");
                FeeTypeCollection fees = apiCall.AddItem(item);
                Console.WriteLine("End to call eBay API, show call result ...");
                Console.WriteLine();

                //[Step 4] Handle the result returned
                Console.WriteLine("The item was listed successfully!");
                double listingFee = 0.0;
                foreach (FeeType fee in fees)
                {
                    if (fee.Name == "ListingFee")
                    {
                        listingFee = fee.Fee.Value;
                    }
                }
                Console.WriteLine(String.Format("Listing fee is: {0}", listingFee));
                Console.WriteLine(String.Format("Listed Item ID: {0}", item.ItemID));
            } 
            catch (Exception ex)
            {
                Console.WriteLine("Fail to list the item : " + ex.Message);
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to close the program.");
            Console.ReadKey();

        }
Example #3
0
        /// <summary>
        /// add an item
        /// </summary>
        /// <returns></returns>
        public static string AddItem(CallMetricsTable metrics)
        {
            try
            {
                ApiContext ctx = GetContext();
                ctx.EnableMetrics = true;
                ctx.CallMetricsTable = metrics;
                AddItemCall call = new AddItemCall(ctx);
                call.Site = SiteCodeType.US;
                call.Item=ItemHelper.BuildItem();
                call.Execute();

                return CheckForErrors("AddItem", call) ?
                call.ApiResponse.ItemID : null;
            }
            catch (Exception e)
            {
                ShowException("AddItem()", e);
                return null;
            }
        }
		public void AddItem()
		{
			if(TestData.NewItem != null )
			{
				(new T_120_EndItemLibrary()).EndItem();
				TestData.NewItem = null;
			}
			ItemType item = ItemHelper.BuildItem();
			// Execute the API.
			FeeTypeCollection fees;
			// VerifyAddItem
			VerifyAddItemCall vi = new VerifyAddItemCall(this.apiContext);
			fees = vi.VerifyAddItem(item);
			Assert.IsNotNull(fees);
			// AddItem
			AddItemCall addItem = new AddItemCall(this.apiContext);
			fees = addItem.AddItem(item);
			Assert.IsNotNull(fees);
			// Save the result.
			TestData.NewItem = item;
		}
Example #5
0
		private void BtnAddItem_Click(object sender, System.EventArgs e)
		{
			try 
			{
				TxtItemId.Text = "";
				TxtListingFee.Text = "";

				ItemType item = FillItem();
				AddItemCall apicall = new AddItemCall(Context);

				if (ListPictures.Items.Count > 0)
				{
					apicall.PictureFileList = new StringCollection();
					item.PictureDetails = new PictureDetailsType();
					item.PictureDetails.PhotoDisplay = (PhotoDisplayCodeType) Enum.Parse(typeof(PhotoDisplayCodeType), CboPicDisplay.SelectedItem.ToString());
				}

				foreach (string pic in ListPictures.Items)
				{
					apicall.PictureFileList.Add(pic);
				}

				FeeTypeCollection fees = apicall.AddItem(item);
	
				TxtItemId.Text = item.ItemID;

				BtnGetItem.Visible = true;
				
				foreach (FeeType fee in fees)
				{
					if (fee.Name == "ListingFee")
					{
						TxtListingFee.Text = fee.Fee.Value.ToString();
						break;
					}
				}

			} 
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
Example #6
0
        /// <summary>
        /// add an item of chinese category.
        /// </summary>
        /// <returns></returns>
        private ItemType addChineseAuctionItem()
        {
            ItemType item = ItemHelper.BuildItem();

            //modify the property to adapt the Chinese Type Item
            item.ListingType = ListingTypeCodeType.Chinese;
            item.Quantity=1;

            // Execute the API.
            FeeTypeCollection fees;
            // AddItem
            AddItemCall addItem = new AddItemCall(this.apiContext);
            fees = addItem.AddItem(item);
            Assert.IsNotNull(fees);
            // Save the result.
            return item;
        }
Example #7
0
 public void AddItemProPay()
 {
     ItemType item = ItemHelper.BuildItem();
     item.PaymentMethods=new BuyerPaymentMethodCodeTypeCollection(new BuyerPaymentMethodCodeType[]{BuyerPaymentMethodCodeType.ProPay,BuyerPaymentMethodCodeType.PayPal});
     // Execute the API.
     FeeTypeCollection fees;
     // VerifyAddItem
     VerifyAddItemCall vi = new VerifyAddItemCall(this.apiContext);
     fees = vi.VerifyAddItem(item);
     Assert.IsNotNull(fees);
     // AddItem
     AddItemCall addItem = new AddItemCall(this.apiContext);
     fees = addItem.AddItem(item);
     Assert.IsNotNull(fees);
 }
Example #8
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);
        }
Example #9
0
        public void AddItemFull2()
        {
            bool isSucess,isCatalogEnabled;
            string message;
            ItemType item= ItemHelper.BuildItem();
            //check whether the category is catalog enabled.
            isSucess=CategoryHelper.IsCatagoryEnabled(this.apiContext,MEDIACATEGORYID.ToString(),CategoryEnableCodeType.CatalogEnabled,out isCatalogEnabled,out message);
            Assert.IsTrue(isSucess,message);
            Assert.IsTrue(isCatalogEnabled,message);
            //modify item information approporiately.
            item.PrimaryCategory.CategoryID=MEDIACATEGORYID.ToString();
            item.Description = "check media category like books whether can be added by specifing ISBN,This is a test item created by eBay SDK SanityTest.";
            ExternalProductIDType isbn=new ExternalProductIDType();
            isbn.Type=ExternalProductCodeType.ISBN;
            isbn.Value=ISBN;
            item.ExternalProductID=isbn;

            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);
        }
Example #10
0
        public void AddItemFull()
        {
            if( TestData.NewItem2 != null )
            {
                (new T_120_EndItemLibrary()).EndItemFull();
                TestData.NewItem2 = null;
            }

            bool isSucess,isSupport;
            string message;
            ItemType item= ItemHelper.BuildItem();
            item.PrimaryCategory.CategoryID=CATEGORYID.ToString();
            //add Item AttributeSetArray
            AttributeSetTypeCollection attributeSAT=GetAttributeSetCol(CATEGORYID,apiContext);
            item.AttributeSetArray=attributeSAT;

            //check this category is custom specifics support
            FeatureIDCodeTypeCollection features=new FeatureIDCodeTypeCollection();
            FeatureIDCodeType feature=FeatureIDCodeType.ItemSpecificsEnabled;
            features.Add(feature);
            isSucess=UnitTests.Helper.CategoryHelper.IsSupportFeature(CATEGORYID,features,apiContext,out isSupport,out message);
            Assert.IsTrue(isSucess,"there are some errors during checkging the CategoryFeatures");
            Assert.IsTrue(isSupport,"this category 50253 do not support the custom item specified any more!");
            //add CIS
            item.ItemSpecifics = getCIS();

            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.IsNotNull(fees);
            // Save the result.
            TestData.NewItem2 = item;
        }
Example #11
0
        protected void BtnAddItem_Click(object sender, System.EventArgs e)
        {
            try
            {
                AttributesMaster attrMaster = (AttributesMaster)Session[Global.ATTRIBUTES_MASTER];

                //
                ApiContext asn = (ApiContext)Session[Global.APISESSION];
                AddItemCall api = new AddItemCall(asn);

                // Create the item
                ItemType item = new ItemType();

                item.Site = (SiteCodeType)Session[Global.SITE];
                item.Country = CountryCodeType.US;

                item.ListingType = (ListingTypeCodeType)Enum.Parse(typeof(ListingTypeCodeType),this.ddlListingType.SelectedValue.ToString());
                if(item.ListingType.Equals(ListingTypeCodeType.LeadGeneration))
                {
                    item.ListingSubtype2=ListingSubtypeCodeType.ClassifiedAd;
                }
                item.Title = this.ItemTitle.Text;
                item.Description = this.Description.Text;
                item.Currency = Global.GetCurrencyType(item.Site);

                if(this.StartPrice.Text!=string.Empty)
                {
                    item.StartPrice = new AmountType();
                    item.StartPrice.currencyID = item.Currency;
                    item.StartPrice.Value = Convert.ToDouble(this.StartPrice.Text);
                }

                if(this.BuyItNowPrice.Text!=string.Empty)
                {
                    item.BuyItNowPrice = new AmountType();
                    item.BuyItNowPrice.currencyID = item.Currency;
                    item.BuyItNowPrice.Value = Convert.ToDouble(this.BuyItNowPrice.Text);
                }

                item.Quantity = Int32.Parse(this.Quantity.Text);

                item.Location = this.ItemLocation.Text;
                item.ListingDuration = this.ItemDuration.SelectedItem.Value;

                ListingEnhancementsCodeTypeCollection enhancements = new ListingEnhancementsCodeTypeCollection();
                enhancements.Add(ListingEnhancementsCodeType.BoldTitle);
                item.ListingEnhancement = enhancements;

                // Set Attributes property.
                int catID = (int)Session["CategoryId"];
                item.PrimaryCategory = new CategoryType();
                item.PrimaryCategory.CategoryID = catID.ToString();

                catID = (int)Session["Category2Id"];
                if( catID != 0 )
                {
                    item.SecondaryCategory = new CategoryType();
                    item.SecondaryCategory.CategoryID = catID.ToString();
                }

                IAttributeSetCollection itemAttributes=null;
                if(Session[Global.ITEM_ATTR_SETS]!=null)
                {
                    itemAttributes = (IAttributeSetCollection)Session[Global.ITEM_ATTR_SETS];
                    item.AttributeSetArray = attrMaster.ConvertAttributeSetArray(itemAttributes);
                }
                if (Session[Global.CUSTOME_ITEM_SPECIFIC]!=null)
                {
                    item.ItemSpecifics=(NameValueListTypeCollection)Session[Global.CUSTOME_ITEM_SPECIFIC];
                }

                // Motor
                if( this.MotorSubtitle.Text.Length > 0 )
                {
                    MotorAttributeHelper mh = new MotorAttributeHelper(item.AttributeSetArray[0]);
                    mh.Subtitle = this.MotorSubtitle.Text;
                    if( this.MotorDepositAmount.Text.Length > 0 )
                        mh.DepositAmount = Decimal.Parse(this.MotorDepositAmount.Text);
                }

                if(ddlShippingServiceDetails.SelectedItem.Value != "None")
                {
                    //add shipping information
                    item.ShippingDetails=getShippingDetails(ddlShippingServiceDetails.SelectedItem.Value);
                }
                //add handling time
                item.DispatchTimeMax=1;
                //add return policy
                if(ltlReturnPolicyEnalbed.Text!=string.Empty&&ltlReturnPolicyEnalbed.Text==RETURN_POLICY_ENABLE)
                {
                    item.ReturnPolicy=getReturnPolicy();
                }

                //get shipping locations
                item.ShipToLocations=getShppingLocations();
                //set payments
                setPaymentMethods(item);

                FeeTypeCollection fees = api.AddItem(item);

                viewItemInfo(item);
            }
            catch(Exception ex)
            {
                this.StatusText.Text = ex.Message;
                this.StatusText.Visible = true;
            }
        }
Example #12
0
        private void btnAddItem_Click(object sender, System.EventArgs e)
        {
            this.txteBayTime.Text = "";
            this.txtError.Text = "In progress...";
            this.txtItemId.Text = "";

            AddItemCall api = null;

            try
            {
                ItemType item = GetItem();

                SetItemDetails(item);
                SetItemShipToLocations(item);
                this.SetShippingServiceOptions(item);

                //set insurance and tax for both flat and calculated type
                //SetInsuranceOptions(item);
                SetSalesTaxInfo(item);
                if (this.rbtnCalculatedShippingRates.Checked)
                {
                    SetCalculatedShippingDetails(item);
                }

                api = new AddItemCall(this.apiContext);
                api.AddItem(item);

                if (api.HasError)
                {
                    this.txtError.Text = api.ApiException.Message.ToString();
                }
                else
                {
                    this.txtItemId.Text = api.Item.ItemID;
                    this.txtError.Text = api.ApiResponse.Ack.ToString();
                }

            }
            catch (Exception ex)
            {
                if (api != null)
                {
                    this.txtError.Text = api.ApiException.Message.ToString();
                }
                else
                {
                    this.txtError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                if (api != null && api.ApiResponse != null)
                {
                    this.txteBayTime.Text = api.ApiResponse.Timestamp.ToString();
                }
            }
        }
		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;
		}
Example #14
0
        //list to eBay
        private void addItem()
        {

            try
            {
                //
                ApiContext apiContext = this.controller.ApiContext;
                AddItemCall api = new AddItemCall(apiContext);

                // Create the item
                ItemType item = new ItemType();

                item.Site = apiContext.Site;
                item.Country = CountryCodeType.US;

                item.ListingType = (ListingTypeCodeType)Enum.Parse(typeof(ListingTypeCodeType), (this.listingTypeComboBox.SelectedItem as ListItem).Value);
                if (item.ListingType.Equals(ListingTypeCodeType.LeadGeneration))
                {
                    item.ListingSubtype2 = ListingSubtypeCodeType.ClassifiedAd;
                }
                item.Title = this.titleTextBox.Text;
                item.Description = this.descriptionTextBox.Text;
                item.Currency = this.getCurrencyType(item.Site);

                if (this.startPriceTextBox.Text != string.Empty)
                {
                    item.StartPrice = new AmountType();
                    item.StartPrice.currencyID = item.Currency;
                    item.StartPrice.Value = Convert.ToDouble(this.startPriceTextBox.Text);
                }

                if (this.binTextBox.Text != string.Empty)
                {
                    item.BuyItNowPrice = new AmountType();
                    item.BuyItNowPrice.currencyID = item.Currency;
                    item.BuyItNowPrice.Value = Convert.ToDouble(this.binTextBox.Text);
                }

                item.Quantity = Int32.Parse(this.quantityTextBox.Text);

                item.Location = this.locationTextBox.Text;
                item.ListingDuration = (this.durationComboBox.SelectedItem as ListItem).Value;

                ListingEnhancementsCodeTypeCollection enhancements = new ListingEnhancementsCodeTypeCollection();
                enhancements.Add(ListingEnhancementsCodeType.BoldTitle);
                item.ListingEnhancement = enhancements;


                // Set Item Condtion
                ConditionEnabledCodeType condition = this.controller.CategoryFacade.ConditionEnabled;
                if (condition == ConditionEnabledCodeType.Enabled ||
                    condition == ConditionEnabledCodeType.Required)
                {
                    ListItem li = this.conditionComboBox.SelectedItem as ListItem;
                    int conditionId = int.Parse(li.Value);
                    item.ConditionID = conditionId;
                }

                // Set Attributes property.
                item.PrimaryCategory = new CategoryType();
                item.PrimaryCategory.CategoryID = this.controller.CategoryFacade.CategoryID;
                
                if (this.controller.CategoryFacade.ItemSpecificEnabled == ItemSpecificsEnabledCodeType.Enabled &&
                    this.controller.CategoryFacade.ItemSpecificsCache != null)
                {
                    item.ItemSpecifics = this.controller.CategoryFacade.ItemSpecificsCache;
                }

                // Motor
                if (this.controller.ApiContext.Site == SiteCodeType.eBayMotors &&
                    this.subTitleTextBox.Text.Length > 0)
                {
                    MotorAttributeHelper mh = new MotorAttributeHelper(item.AttributeSetArray[0]);
                    mh.Subtitle = this.subTitleTextBox.Text;
                    if (this.depositAmountTextBox.Text.Length > 0)
                        mh.DepositAmount = Decimal.Parse(this.depositAmountTextBox.Text);
                }

                if ((this.shippingServiceComboBox.SelectedItem as ListItem).Value != "None")
                {
                    //add shipping information
                    item.ShippingDetails = getShippingDetails((this.shippingServiceComboBox.SelectedItem as ListItem).Value);
                }

                //add handling time
                item.DispatchTimeMax = 1;

                SellerProfilesType sellerProfile = new SellerProfilesType();
                //add return policy
                if (this.controller.CategoryFacade.ReturnPolicyEnabled)
                {
                    if (this.controller.CategoryFacade.ReturnPolicyProfileCache != null)
                    {
                        sellerProfile.SellerReturnProfile = this.controller.CategoryFacade.ReturnPolicyProfileCache;
                    }
                    else if (this.controller.CategoryFacade.ReturnPolicyCache != null)
                    {
                        item.ReturnPolicy = this.controller.CategoryFacade.ReturnPolicyCache;
                    }
                }
                if (paymentProfileIdTextBox.Text != "" || paymentProfileNameTextBox.Text != "")
                {
                    sellerProfile.SellerPaymentProfile = new SellerPaymentProfileType();
                    if (this.paymentProfileIdTextBox.Text != "")
                    {
                        sellerProfile.SellerPaymentProfile.PaymentProfileID = Int64.Parse(paymentProfileIdTextBox.Text);
                        sellerProfile.SellerPaymentProfile.PaymentProfileIDSpecified = true;
                    }
                    sellerProfile.SellerPaymentProfile.PaymentProfileName = paymentProfileNameTextBox.Text;
                }
                if (shippingProfileIdTextBox.Text != "" || shippingProfileNameTextBox.Text != "")
                {
                    sellerProfile.SellerShippingProfile = new SellerShippingProfileType();
                    if (this.shippingProfileIdTextBox.Text != "")
                    {
                        sellerProfile.SellerShippingProfile.ShippingProfileID = Int64.Parse(shippingProfileIdTextBox.Text);
                        sellerProfile.SellerShippingProfile.ShippingProfileIDSpecified = true;
                    }
                    sellerProfile.SellerShippingProfile.ShippingProfileName = shippingProfileNameTextBox.Text;
                }

                //get shipping locations
                item.ShipToLocations = getShppingLocations();
                //set payments
                setPaymentMethods(item);
                // set seller profiles
                item.SellerProfiles = sellerProfile;

                FeeTypeCollection fees = api.AddItem(item);

                viewItemInfo(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

        }
Example #15
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;
        }