public void AddFixedPriceItem()
        {
            if (TestData.NewFixedPriceItem != null)
            {
                string outMsg;
                ItemHelper.EndItem(this.apiContext, TestData.NewFixedPriceItem, out outMsg);
                TestData.NewFixedPriceItem = null;
            }
            ItemType item = ItemHelper.BuildItem();

            item.ListingType = ListingTypeCodeType.FixedPriceItem;
            // Execute the API.
            FeeTypeCollection fees;
            // VerifyAddItem
            VerifyAddFixedPriceItemCall vi = new VerifyAddFixedPriceItemCall(this.apiContext);

            fees = vi.VerifyAddFixedPriceItem(item);
            Assert.IsNotNull(fees);
            // AddItem
            AddFixedPriceItemCall ai = new AddFixedPriceItemCall(this.apiContext);

            fees = ai.AddFixedPriceItem(item);
            Assert.IsNotNull(fees);
            // Save the result.
            TestData.NewFixedPriceItem = item;
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var context = NewApiContext(Settings.Default.eBayURI, Settings.Default.eBayToken);
            //var apiCall = new GeteBayOfficialTimeCall(context);
            var apiCall = new SetStoreCall(context);

            //var time = apiCall.GeteBayOfficialTime();
            //var options = apiCall.GetStoreOptions();
            var store = new StoreType()
            {
                Description       = "Test Store",
                Name              = "Test Store",
                SubscriptionLevel = StoreSubscriptionLevelCodeType.Basic,
                Theme             = new StoreThemeType()
                {
                    ThemeID = 1
                }
            };

            apiCall.SetStore(store);

            var addCall = new AddFixedPriceItemCall(context);


            addCall.AddFixedPriceItem(item);

            //Console.WriteLine(time);
            //Console.WriteLine(options);

            Console.ReadKey();
        }
Beispiel #3
0
 public EbayFacade()
 {
     InitializeContext();
     api2call       = new AddFixedPriceItemCall(Context);
     reviseItemCall = new ReviseFixedPriceItemCall(Context);
     deleteItemCall = new EndItemCall(Context);
 }
Beispiel #4
0
        // http://developer.ebay.com/DevZone/xml/docs/Reference/ebay/AddFixedPriceItem.html
        public AddFixedPriceItemCall AddFixedPriceItem(SiteCodeType siteid)
        {
            var call = new AddFixedPriceItemCall(api);

            call.Site = siteid;

            call.AddFixedPriceItem(item);

            return(call);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("+++++++++++++++++++++++++++++++++++++++");
                Console.WriteLine("+ Welcome to eBay SDK for .Net Sample +");
                Console.WriteLine("+ - ConsoleAddFixedPriceItem          +");
                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
                AddFixedPriceItemCall apiCall = new AddFixedPriceItemCall(apiContext);
                Console.WriteLine("Begin to call eBay API, please wait ...");
                FeeTypeCollection fees = apiCall.AddFixedPriceItem(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();
        }
Beispiel #6
0
        void AddItems()
        {
            try
            {
                ApiContext apiContext = GetApiContext();

                AddFixedPriceItemCall addApiCall  = new AddFixedPriceItemCall(apiContext);
                GetItemCall           getApiCall  = new GetItemCall(apiContext);
                GetSellerListCall     listApiCall = new GetSellerListCall(apiContext);
                EndItemsCall          endApiCall  = new EndItemsCall(apiContext);

                ModelDataContext context = new ModelDataContext();
                articles = (from current in context.Articles
                            orderby current.ArticleNumber
                            where current.AmountOnStock > 0
                            select current).Take(2);

                EndActiveAuctions(articles);

                System.Threading.Thread.Sleep(5000);

                foreach (Article article in articles)
                {
                    try
                    {
                        //create a new ItemType object corresponding to article-backend data with fix quantity of 99 pieces an add it
                        ItemType item = BuildItem(article);
                        addApiCall.AddFixedPriceItem(item);
                    }
                    catch (Exception ex)
                    {
                        Assert.Fail(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        public async Task <ItemType> AddItem(CommerceContext commerceContext, SellableItem sellableItem)
        {
            using (var activity = CommandActivity.Start(commerceContext, this))
            {
                var ebayItemComponent = sellableItem.GetComponent <EbayItemComponent>();

                try
                {
                    //Instantiate the call wrapper class
                    var apiCall = new AddFixedPriceItemCall(await GetEbayContext(commerceContext).ConfigureAwait(false));

                    var item = await PrepareItem(commerceContext, sellableItem).ConfigureAwait(false);

                    //Send the call to eBay and get the results
                    FeeTypeCollection feeTypeCollection = apiCall.AddFixedPriceItem(item);

                    foreach (var feeItem in feeTypeCollection)
                    {
                        var fee = feeItem as FeeType;
                        ebayItemComponent.Fees.Add(new AwardedAdjustment {
                            Adjustment = new Money(fee.Fee.currencyID.ToString(), System.Convert.ToDecimal(fee.Fee.Value)), AdjustmentType = "Fee", Name = fee.Name
                        });
                    }

                    ebayItemComponent.History.Add(new HistoryEntryModel {
                        EventMessage = "Listing Added", EventUser = commerceContext.CurrentCsrId()
                    });
                    ebayItemComponent.EbayId = item.ItemID;
                    ebayItemComponent.Status = "Listed";
                    sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Listed");
                    await commerceContext.AddMessage("Info", "EbayCommand.AddItem", new [] { item.ItemID }, $"Item Listed:{item.ItemID}").ConfigureAwait(false);

                    return(item);
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("It looks like this listing is for an item you already have on eBay"))
                    {
                        var existingId = ex.Message.Substring(ex.Message.IndexOf("(") + 1);
                        existingId = existingId.Substring(0, existingId.IndexOf(")"));
                        await commerceContext.AddMessage("Warn", "EbayCommand.AddItem", new [] { existingId }, $"ExistingId:{existingId}-ComponentId:{ebayItemComponent.EbayId}").ConfigureAwait(false);

                        ebayItemComponent.EbayId = existingId;
                        ebayItemComponent.Status = "Listed";
                        ebayItemComponent.History.Add(new HistoryEntryModel {
                            EventMessage = "Existing Listing Linked", EventUser = commerceContext.CurrentCsrId()
                        });
                        sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Listed");
                    }
                    else
                    {
                        commerceContext.Logger.LogError($"Ebay.AddItem.Exception: Message={ex.Message}");
                        await commerceContext.AddMessage("Error", "Ebay.AddItem.Exception", new [] { ex }, ex.Message).ConfigureAwait(false);

                        ebayItemComponent.History.Add(new HistoryEntryModel {
                            EventMessage = $"Error-{ex.Message}", EventUser = commerceContext.CurrentCsrId()
                        });
                    }
                }
                return(new ItemType());
            }
        }
        public async Task <ItemType> PrepareItem(CommerceContext commerceContext, SellableItem sellableItem)
        {
            using (var activity = CommandActivity.Start(commerceContext, this))
            {
                //Instantiate the call wrapper class
                var apiCall = new AddFixedPriceItemCall(await GetEbayContext(commerceContext).ConfigureAwait(false));

                var item = await this._commerceCommander.Pipeline <IPrepareEbayItemPipeline>().Run(sellableItem, commerceContext.PipelineContextOptions).ConfigureAwait(false);

                item.Description = sellableItem.Description;
                item.Title       = sellableItem.DisplayName;
                item.SubTitle    = "Test Item";

                var listPricingPolicy = sellableItem.GetPolicy <ListPricingPolicy>();
                var listPrice         = listPricingPolicy.Prices.FirstOrDefault();

                item.StartPrice = new AmountType {
                    currencyID = CurrencyCodeType.USD, Value = System.Convert.ToDouble(listPrice.Amount, System.Globalization.CultureInfo.InvariantCulture)
                };

                item.ConditionID = 1000;  //new

                item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
                item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PayPal);
                item.PaymentMethods.Add(BuyerPaymentMethodCodeType.VisaMC);
                item.PayPalEmailAddress = "*****@*****.**";
                item.PostalCode         = "98014";

                item.DispatchTimeMax = 3;
                item.ShippingDetails = new ShippingDetailsType();
                item.ShippingDetails.ShippingServiceOptions = new ShippingServiceOptionsTypeCollection();

                item.ShippingDetails.ShippingType = ShippingTypeCodeType.Flat;

                ShippingServiceOptionsType shipservice1 = new ShippingServiceOptionsType();
                shipservice1.ShippingService                = "USPSPriority";
                shipservice1.ShippingServicePriority        = 1;
                shipservice1.ShippingServiceCost            = new AmountType();
                shipservice1.ShippingServiceCost.currencyID = CurrencyCodeType.USD;
                shipservice1.ShippingServiceCost.Value      = 5.0;

                shipservice1.ShippingServiceAdditionalCost            = new AmountType();
                shipservice1.ShippingServiceAdditionalCost.currencyID = CurrencyCodeType.USD;
                shipservice1.ShippingServiceAdditionalCost.Value      = 1.0;

                item.ShippingDetails.ShippingServiceOptions.Add(shipservice1);


                //ShippingServiceOptionsType shipservice2 = new ShippingServiceOptionsType();
                //shipservice2.ShippingService = "US_Regular";
                //shipservice2.ShippingServicePriority = 2;
                //shipservice2.ShippingServiceCost = new AmountType();
                //shipservice2.ShippingServiceCost.currencyID = CurrencyCodeType.USD;
                //shipservice2.ShippingServiceCost.Value = 1.0;

                //shipservice2.ShippingServiceAdditionalCost = new AmountType();
                //shipservice2.ShippingServiceAdditionalCost.currencyID = CurrencyCodeType.USD;
                //shipservice2.ShippingServiceAdditionalCost.Value = 1.0;

                //item.ShippingDetails.ShippingServiceOptions.Add(shipservice2);

                //item.Variations.

                item.ReturnPolicy = new ReturnPolicyType {
                    ReturnsAcceptedOption = "ReturnsAccepted"
                };

                //Add pictures
                item.PictureDetails = new PictureDetailsType();

                //Specify GalleryType
                item.PictureDetails.GalleryType          = GalleryTypeCodeType.None;
                item.PictureDetails.GalleryTypeSpecified = true;

                return(item);
            }
        }
Beispiel #9
0
        public void AddFPItemCatalog()
        {
            //create the context
            ApiContext context = new ApiContext();

            //set the User token
            context.ApiCredential.eBayToken = "AgAAAA**AQAAAA**aAAAAA**imCbXA**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wFk4GkCZGKqQWdj6x9nY+seQ**UzUEAA**AAMAAA**MkSqad5luzLeJmNClKehjHdM+ldeDlfwYkDT4yV4I5vP2L19mrhH/FTgpJ007mmthRyAWTu9fwOAq8d7aCAVL+IQb+Aynt3NmgxJmHVruojV7fbOOkNjPCgLSUXeFIaTq+tlmr4ExLtiiArU2kFz60P2B8uVLREVDiyuYvLhZKdkNb1RADMSxGGjJBifrBCu2VgioR6tzoCKDn5FUm76FpTn6ghZ3LNgqpaNjLmXLaWFnDlGTmj2zVSfYDGVz3cFsrv8o+lA8FiqCc8v7ueSXeV0HoMt/k7+DAeeDGWpVstT91UjwgerZoPw/b2x9G7KfR6gfsgGBQ6f+YHqDeNy+4BOv++20BDiTPDD8Y7WsrmZBGY3ZCIIdBsfqVuwo6jyKHLAGnDwjGBEAsVZjCtW4Wn2j4LXzrAankErmPJn8rPmhg0MsyJ5nszkQO+JjZ5mR8BK2lYhXdhhTl/dB3+8ENZKiBnPYCV2+SZumof0j60NuFO3KoNy1bBic52aaR5XSYUIijKAXCXN2Q6sSu7TmLQ9KovV+kM8CDoIV4J0PoXQ/79HXK5POfefy+mJFzzMBCXiKHPYx7h0cwHbic2GgQXWcChf4mvLlLC5mPhHc3rAc3ujbSF1pFtRiXcrnWIshyYdC73GGk24cWmehvCwd6Edvv1BAZcNcbuHmXjlTbjRGkeC5ImlFgRH3CjbKhyByTGsc9PGrf99J1MqrfoEx/iHJMwL7Ka3inyK8dq4spOw8HWulvx5TOc7lsz+RLdc";
            //set the server url
            context.SoapApiServerUrl = "https://api.sandbox.ebay.com/wsapi";

            //enable logging
            context.ApiLogManager = new ApiLogManager();
            context.ApiLogManager.ApiLoggerList.Add(new FileLogger("log.txt", true, true, true));
            context.ApiLogManager.EnableLogging = true;

            //set the version
            context.Version = "1085";
            context.Site    = SiteCodeType.UK;

            string UPC   = "753759090913"; //Garmin nuvi 1350 GPS
            string Brand = "Garmin";
            string MPN   = "010-00782-20";

            //create the call object
            AddFixedPriceItemCall AddFPItemCall = new AddFixedPriceItemCall(context);

            AddFPItemCall.AutoSetItemUUID = true;

            //create an item object and set the properties
            ItemType item = new ItemType();

            //set the item condition depending on the value from GetCategoryFeatures
            item.ConditionID = 1000; //new

            //Basic properties of a listing
            item.Country  = CountryCodeType.GB;
            item.Currency = CurrencyCodeType.GBP;

            //Track item by SKU
            item.InventoryTrackingMethod = InventoryTrackingMethodCodeType.SKU;
            item.SKU = "PROD1234";

            item.Description     = "test - do not bid or buy";
            item.Title           = "test - do not bid or buy";
            item.SubTitle        = "Test Item";
            item.ListingDuration = "Days_7";

            item.PaymentMethods = new BuyerPaymentMethodCodeTypeCollection();
            item.PaymentMethods.Add(BuyerPaymentMethodCodeType.PayPal);
            item.PayPalEmailAddress = "*****@*****.**";
            item.PostalCode         = "2001";

            //Specify Shipping Services
            item.DispatchTimeMax = 3;
            item.ShippingDetails = new ShippingDetailsType();
            item.ShippingDetails.ShippingServiceOptions = new ShippingServiceOptionsTypeCollection();

            ShippingServiceOptionsType shipservice1 = new ShippingServiceOptionsType();

            shipservice1.ShippingService                = "UK_Parcelforce24";
            shipservice1.ShippingServicePriority        = 1;
            shipservice1.ShippingServiceCost            = new AmountType();
            shipservice1.ShippingServiceCost.currencyID = CurrencyCodeType.GBP;
            shipservice1.ShippingServiceCost.Value      = 1.0;

            shipservice1.ShippingServiceAdditionalCost            = new AmountType();
            shipservice1.ShippingServiceAdditionalCost.currencyID = CurrencyCodeType.GBP;
            shipservice1.ShippingServiceAdditionalCost.Value      = 1.0;

            item.ShippingDetails.ShippingServiceOptions.Add(shipservice1);

            ShippingServiceOptionsType shipservice2 = new ShippingServiceOptionsType();

            shipservice2.ShippingService                = "UK_Parcelforce48";
            shipservice2.ShippingServicePriority        = 2;
            shipservice2.ShippingServiceCost            = new AmountType();
            shipservice2.ShippingServiceCost.currencyID = CurrencyCodeType.GBP;
            shipservice2.ShippingServiceCost.Value      = 4.0;

            shipservice2.ShippingServiceAdditionalCost            = new AmountType();
            shipservice2.ShippingServiceAdditionalCost.currencyID = CurrencyCodeType.GBP;
            shipservice2.ShippingServiceAdditionalCost.Value      = 1.0;

            item.ShippingDetails.ShippingServiceOptions.Add(shipservice2);

            //Specify Return Policy
            item.ReturnPolicy = new ReturnPolicyType();
            item.ReturnPolicy.ReturnsAcceptedOption = "ReturnsAccepted";

            item.Quantity              = 10;
            item.StartPrice            = new AmountType();
            item.StartPrice.currencyID = CurrencyCodeType.GBP;
            item.StartPrice.Value      = 10;

            item.PrimaryCategory            = new CategoryType();
            item.PrimaryCategory.CategoryID = "184797";

            item.ProductListingDetails = new ProductListingDetailsType();

            //Specifying UPC as the product identifier. Other applicable product identifiers
            //include ISBN, EAN, Brand-MPN.

            item.ProductListingDetails.UPC = UPC;

            //If multiple product identifiers are specified, eBay uses the first one that
            //matches a product in eBay's catalog system.
            item.ProductListingDetails.BrandMPN       = new BrandMPNType();
            item.ProductListingDetails.BrandMPN.Brand = Brand;
            item.ProductListingDetails.BrandMPN.MPN   = MPN;

            //For listing to be pre-filled with product information from the catalog
            item.ProductListingDetails.IncludePrefilledItemInformation = true;

            //Include the eBay stock photo with the listing if available and use it as the gallery picture
            item.ProductListingDetails.IncludeStockPhotoURL               = true;
            item.ProductListingDetails.UseStockPhotoURLAsGallery          = true;
            item.ProductListingDetails.UseStockPhotoURLAsGallerySpecified = true;

            //If multiple prod matches found, list the item with the 1st product's information
            item.ProductListingDetails.UseFirstProduct = true;
            // List the item even if no product match found
            item.ProductListingDetails.ListIfNoProduct = true;

            //Add pictures
            item.PictureDetails = new PictureDetailsType();

            //Specify GalleryType
            item.PictureDetails.GalleryType          = GalleryTypeCodeType.None;
            item.PictureDetails.GalleryTypeSpecified = true;

            AddFPItemCall.Item = item;

            //set the item and make the call
            AddFPItemCall.Execute();

            Console.WriteLine(AddFPItemCall.ApiResponse.Ack + " " + AddFPItemCall.ApiResponse.ItemID);
        }