Exemplo n.º 1
0
        public void SetUserPreferences()
        {
            if (TestData.UserPreferencesResponse == null)
            {
                return;
            }
            SetUserPreferencesCall api = new SetUserPreferencesCall(this.apiContext);

            api.BidderNoticePreferences = TestData.UserPreferencesResponse.BidderNoticePreferences;
            //		api.CombinedPaymentPreferences = TestData.UserPreferencesResponse.CombinedPaymentPreferences;
            api.CrossPromotionPreferences     = TestData.UserPreferencesResponse.CrossPromotionPreferences;
            api.EndOfAuctionEmailPreferences  = TestData.UserPreferencesResponse.EndOfAuctionEmailPreferences;
            api.SellerFavoriteItemPreferences = TestData.UserPreferencesResponse.SellerFavoriteItemPreferences;
            api.SellerPaymentPreferences      = TestData.UserPreferencesResponse.SellerPaymentPreferences;
            // Make API call.
            ApiException gotException = null;

            try
            {
                api.Execute();
            }
            catch (ApiException e)
            {
                gotException = e;
            }
            Assert.IsTrue(gotException == null || gotException.containsErrorCode("249"));
        }
Exemplo n.º 2
0
        public bool SetMarketplaceUserPreference(UserPreferenceFeed preference)
        {
            // create and init the API Context
            var context = new ApiContext();

            context.ApiCredential    = RequestHelper.ApiCredential;
            context.SoapApiServerUrl = RequestHelper.ServiceUrl;

            try
            {
                // create the preference feed
                var preferenceType = new SetUserPreferencesRequestType
                {
                    OutOfStockControlPreference          = preference.OutOfStockControlPreference,
                    OutOfStockControlPreferenceSpecified = preference.isOutOfStockControlPreference,
                };

                var apiCall  = new SetUserPreferencesCall(context);
                var response = apiCall.ExecuteRequest(preferenceType);

                if (response.Ack == AckCodeType.Success)
                {
                    return(true);
                }

                // log the error
                _logger.LogError(LogEntryType.eBayProductProvider,
                                 string.Format("{0} - Error in sending user preference - Message: {1}", ChannelName, response.Errors[0].LongMessage),
                                 string.Join(",", response.Errors[0].ErrorParameters));
                return(false);
            }
            catch (Exception ex)
            {
                _logger.LogError(LogEntryType.eBayProductProvider,
                                 string.Format("Unexpected error in sending user preference\". Err Message: {0}", EisHelper.GetExceptionMessage(ex)),
                                 ex.StackTrace);
                return(false);
            }
        }