示例#1
0
文件: eBayApi.cs 项目: fudder/cs493
        /// <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;
            }
        }
示例#2
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);
				}
			}
		}
示例#3
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;
			}
		}