Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public string AddFixedPriceItem(ItemType ebayItemToCreate)
        {
            var addFixedPriceDelegate = new Func <string>(() =>
            {
                api2call.PictureFileList = new StringCollection();
                api2call.AddFixedPriceItem(ebayItemToCreate);
                return(ebayItemToCreate.ItemID);
            });

            return(ExecuteWithExceptionHandling(addFixedPriceDelegate, ebayItemToCreate.ItemID));
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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());
            }
        }