示例#1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ApiContext">The <see cref="ApiCall.ApiContext"/> for this API Call of type <see cref="ApiContext"/>.</param>
 public PlaceOfferCall(ApiContext ApiContext)
 {
     ApiRequest      = new PlaceOfferRequestType();
     this.ApiContext = ApiContext;
 }
示例#2
0
 /// <summary>
 ///
 /// </summary>
 public PlaceOfferCall()
 {
     ApiRequest = new PlaceOfferRequestType();
 }
		/// <summary>
		/// 
		/// </summary>
		public PlaceOfferCall()
		{
			ApiRequest = new PlaceOfferRequestType();
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="ApiContext">The <see cref="ApiCall.ApiContext"/> for this API Call of type <see cref="ApiContext"/>.</param>
		public PlaceOfferCall(ApiContext ApiContext)
		{
			ApiRequest = new PlaceOfferRequestType();
			this.ApiContext = ApiContext;
		}
示例#5
0
        private void SetSnipe(Snipe snipe, int nbRetry)
        {
            Logger.CreateLog("Beginning__SetSnipe", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO);

            string callname = "PlaceOffer";

            try
            {

                this.BuildService(callname);

                PlaceOfferRequestType request = new PlaceOfferRequestType();
                request.Version = _version;

                request.ItemID = snipe.ItemID.ToString();

                request.Offer = new OfferType();
                request.Offer.Action = BidActionCodeType.Bid;
                request.Offer.ActionSpecified = true;

                request.Offer.MaxBid = new AmountType();

                if (snipe.SnipeStyle == EnumSnipeStyle.Snipe || snipe.SnipeStyle == EnumSnipeStyle.Manual)
                {
                    request.Offer.MaxBid.currencyID = (UltimateSniper_Services.eBayPublic.CurrencyCodeType)snipe.SnipeBidCurrency;
                    request.Offer.MaxBid.Value = snipe.SnipeBidInFinalCurrency;
                }
                if (snipe.SnipeStyle == EnumSnipeStyle.BidOptimizer)
                {
                    // Creating an object to the BestMatchService class
                    UltimateSniper_Services.ebayShopping.Shopping shoppingService = new UltimateSniper_Services.ebayShopping.Shopping();

                    int siteID = 1;
                    if (this._user != null) siteID = (int)this._user.EBayRegistrationSiteID;

                    string requestURL = _shoppingServerUrl + "?callname=GetSingleItem&siteid=" + siteID.ToString()
                    + "&appid=" + _eBayKeyHandler.GetEBayKeySet().AppID + "&version=" + _version + "&routing=default";
                    shoppingService.Url = requestURL;

                    UltimateSniper_Services.ebayShopping.GetSingleItemRequestType itemRequest = new UltimateSniper_Services.ebayShopping.GetSingleItemRequestType();

                    itemRequest.ItemID = snipe.ItemID.ToString();
                    itemRequest.IncludeSelector = "Details";

                    UltimateSniper_Services.ebayShopping.GetSingleItemResponseType shoppingResponse = shoppingService.GetSingleItem(itemRequest);

                    if (shoppingResponse.Ack == UltimateSniper_Services.ebayShopping.AckCodeType.Success)
                    {
                        if (shoppingResponse.Item.MinimumToBid != null && shoppingResponse.Item.ListingStatus == UltimateSniper_Services.ebayShopping.ListingStatusCodeType.Active)
                        {
                            if (shoppingResponse.Item.MinimumToBid.Value > snipe.SnipeBidInFinalCurrency)
                            {
                                List<UserMessage> errorList = new List<UserMessage>();

                                errorList.Add(new UserMessage(EnumSeverity.Error, EnumMessageCode.SnipeBidOptimizerMaxBidReached));

                                ControlObjectException ex = new ControlObjectException(errorList);
                                throw ex;
                            }

                            request.Offer.MaxBid.currencyID = (UltimateSniper_Services.eBayPublic.CurrencyCodeType)shoppingResponse.Item.MinimumToBid.currencyID;
                            request.Offer.MaxBid.Value = shoppingResponse.Item.MinimumToBid.Value;
                        }
                        else
                            throw new Exception("This item isn't valid anymore.");
                    }
                    else
                    {
                        string error = "";

                        foreach (UltimateSniper_Services.ebayShopping.ErrorType err in shoppingResponse.Errors) error += err.LongMessage + Environment.NewLine;

                        throw new Exception(error);
                    }
                }

                request.Offer.Quantity = 1;
                request.Offer.QuantitySpecified = true;
                request.EndUserIP = User.UserIPAddress;

                PlaceOfferResponseType response = this.service.PlaceOffer(request);

                if (response.BotBlock != null)
                {
                    this._eBayKeyHandler.GetNextEBayKeySet();

                    throw new Exception("BotBlock detected.");
                }

                if (response.Ack != AckCodeType.Success)
                {
            #warning implement retry if type = bidoptimizer

                    string error = "";

                    foreach (ErrorType err in response.Errors) error += err.LongMessage + Environment.NewLine;

                    throw new Exception(error);
                }

            }
            catch (Exception ex)
            {
                if (nbRetry < ServiceParametersHelper.nbAPIRetry())
                    this.SetSnipe(snipe, nbRetry + 1);
                else
                {
                    Logger.CreateLog("Error__SetSnipe", snipe.SnipeID.ToString(), ex, EnumLogLevel.ERROR);
                    throw ex;
                }
            }

            Logger.CreateLog("Ending__SetSnipe", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO);
        }