Exemple #1
0
        /// <summary>
        /// revise an item
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="metrics"></param>
        public static void ReviseItem(ItemType item, CallMetricsTable metrics)
        {
            Debug.Assert(item != null);
            Debug.Assert(item.ItemID != null);
            Debug.Assert(item.ItemID.Length > 0);

            try
            {
                ApiContext ctx = GetContext();
                ctx.EnableMetrics    = true;
                ctx.CallMetricsTable = metrics;
                ReviseItemCall call = new ReviseItemCall(ctx);
                call.Site = SiteCodeType.US;
                ItemType itemToBeRevised = new ItemType();
                itemToBeRevised.ItemID = item.ItemID;
                call.Item = itemToBeRevised;
                itemToBeRevised.Description = "Item has been modified!";

                call.Execute();
            }
            catch (Exception e)
            {
                if (item == null)
                {
                    ShowException("ReviseItem(null)", e);
                }
                else
                {
                    ShowException("ReviseItem(" + item.ItemID + ")", e);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// get an item
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="metrics"></param>
        /// <returns></returns>
        public static ItemType GetItem(string itemId, CallMetricsTable metrics)
        {
            Debug.Assert(itemId != null);
            Debug.Assert(itemId.Length > 0);

            try
            {
                ApiContext ctx = GetContext();
                ctx.EnableMetrics    = true;
                ctx.CallMetricsTable = metrics;
                GetItemCall call = new GetItemCall(ctx);
                call.Site = SiteCodeType.US;

                ItemType item = call.GetItem(itemId);
                return(CheckForErrors("GetItem", call) ? item : null);
            }
            catch (Exception e) {
                ShowException("GetItem(" + itemId + ")", e);
                return(null);
            }
        }
Exemple #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);
            }
        }
Exemple #4
0
        public static ApiContext GetContext(SellerOrBuyer Who)
        {
            ApiContext apiContext = new ApiContext();

            apiContext.SoapApiServerUrl =
                ConfigurationManager.AppSettings["Environment.ApiServerUrl"];
            ApiCredential apiCredential = new ApiCredential();

            apiCredential.eBayToken =
                ConfigurationManager.AppSettings[
                    Who == SellerOrBuyer.typeSELLER ? "UserAccount.ApiToken_Seller" : "UserAccount.ApiToken_Buyer"];
            apiCredential.ApiAccount.Application = ConfigurationManager.AppSettings["AppID"];
            apiCredential.ApiAccount.Developer   = ConfigurationManager.AppSettings["DevID"];
            apiCredential.ApiAccount.Certificate = ConfigurationManager.AppSettings["CertID"];
            apiCredential.eBayAccount.UserName   = "";
            apiCredential.eBayAccount.Password   = "";

            apiContext.ApiCredential = apiCredential;

            apiContext.Site = global::eBay.Service.Core.Soap.SiteCodeType.US;

            Metrics = new CallMetricsTable();
            apiContext.EnableMetrics    = true;
            apiContext.CallMetricsTable = Metrics;

            LogManager = new ApiLogManager();
            LogManager.EnableLogging = true;

            LogManager.ApiLoggerList.Add(logger);
            LogManager.ApiLoggerList[0].LogApiMessages  = true;
            LogManager.ApiLoggerList[0].LogExceptions   = true;
            LogManager.ApiLoggerList[0].LogInformations = true;
            apiContext.ApiLogManager = LogManager;

            return(apiContext);
        }