/// <summary> ///return leaf category objects of specific number /// </summary> /// <param name="number">how many leaf categories you wanna get.</param> /// <param name="category"></param> /// <param name="apiContext"></param> /// <param name="message"></param> /// <returns></returns> public static bool GetLeafCategory(int number,out CategoryTypeCollection categories,ApiContext apiContext,out string message) { CategoryTypeCollection categoryTypeCollection; categories=new CategoryTypeCollection(); if(number<=0) { number=1; } if(getAllCategories(apiContext,out categoryTypeCollection,out message)) { foreach(CategoryType category in categoryTypeCollection) { if(category.LeafCategory==true) { categories.Add(category); if(categories.Count==number) { break; } } } return true; } return false; }
/// <summary> /// /// </summary> /// <returns> API Context without user crendials /// </returns> private static ApiContext GetGenericApiContext() { ApiContext apiContext = new ApiContext(); apiContext.Version = System.Configuration.ConfigurationManager.AppSettings.Get(VERSION); apiContext.Timeout = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings.Get(TIME_OUT)); apiContext.SoapApiServerUrl = System.Configuration.ConfigurationManager.AppSettings.Get(API_SERVER_URL); apiContext.EPSServerUrl = System.Configuration.ConfigurationManager.AppSettings.Get(EPS_SERVER_URL); apiContext.SignInUrl = System.Configuration.ConfigurationManager.AppSettings.Get(SIGNIN_URL); ApiAccount apiAccount = new ApiAccount(); apiAccount.Developer = System.Configuration.ConfigurationManager.AppSettings.Get(DEV_ID); apiAccount.Application = System.Configuration.ConfigurationManager.AppSettings.Get(APP_ID); apiAccount.Certificate = System.Configuration.ConfigurationManager.AppSettings.Get(CERT_ID); ApiCredential apiCredential = new ApiCredential(); apiCredential.ApiAccount = apiAccount; apiContext.ApiCredential = apiCredential; apiContext.EnableMetrics = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings.Get(ENABLE_METRICS)); string site = System.Configuration.ConfigurationManager.AppSettings.Get(EBAY_USER_SITE_ID); if (site != null) { apiContext.Site = (SiteCodeType)Enum.Parse(typeof(SiteCodeType), site, false); } apiContext.RuleName = System.Configuration.ConfigurationManager.AppSettings.Get(RULE_NAME); return apiContext; }
private void APIAccount_Load(object sender, EventArgs e) { if (apiContext == null) { apiContext = AppSettingHelper.GetApiContext(); apiContext.ApiLogManager = new ApiLogManager(); LoggingProperties logProps = AppSettingHelper.GetLoggingProperties(); apiContext.ApiLogManager.ApiLoggerList.Add(new FileLogger(logProps.LogFileName, true, true, true)); apiContext.ApiLogManager.EnableLogging = true; apiContext.Site = SiteCodeType.US; } string[] sites = Enum.GetNames(typeof(SiteCodeType)); foreach (string site in sites) { if (site != "CustomCode") { CboSite.Items.Add(site); } } string[] langs = Enum.GetNames(typeof(ErrorLanguageCodeType)); foreach (string lang in langs) { if (lang != "CustomCode") { CboLanguage.Items.Add(lang); } } CboSite.SelectedIndex = 0; SetBindings(); }
/// <summary> /// Populate eBay SDK ApiContext object with data from application configuration file /// </summary> /// <returns>ApiContext</returns> static ApiContext GetApiContext() { //apiContext is a singleton, //to avoid duplicate configuration reading if (apiContext != null) { return apiContext; } else { apiContext = new ApiContext(); //set Api Server Url apiContext.SoapApiServerUrl = ConfigurationManager.AppSettings["Environment.ApiServerUrl"]; //set Api Token to access eBay Api Server ApiCredential apiCredential = new ApiCredential(); apiCredential.eBayToken = ConfigurationManager.AppSettings["UserAccount.ApiToken"]; apiContext.ApiCredential = apiCredential; //set eBay Site target to US apiContext.Site = SiteCodeType.US; return apiContext; } }
//get parameters from config file and create //ApiContext object static ApiContext GetApiContext() { ApiContext cxt = new ApiContext(); // set api server address cxt.SoapApiServerUrl = ConfigurationManager.AppSettings[KEY_API_URL]; // set token ApiCredential ac = new ApiCredential(); string token = ConfigurationManager.AppSettings[KEY_APITOKEN]; ac.eBayToken = token; cxt.ApiCredential = ac; // initialize log. ApiLogManager logManager = null; string logPath = ConfigurationManager.AppSettings[KEY_LOGFILE]; if (logPath.Length > 0) { logManager = new ApiLogManager(); logManager.EnableLogging = true; logManager.ApiLoggerList = new ApiLoggerCollection(); ApiLogger log = new FileLogger(logPath, true, true, true); logManager.ApiLoggerList.Add(log); } cxt.ApiLogManager = logManager; return cxt; }
public static ApiContext GetGenericApiContext(string site) { ApiContext apiContext = new ApiContext(); apiContext.Version = System.Configuration.ConfigurationManager.AppSettings.Get(VERSION); apiContext.Timeout = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings.Get(TIME_OUT)); apiContext.SoapApiServerUrl = System.Configuration.ConfigurationManager.AppSettings.Get(API_SERVER_URL); apiContext.EPSServerUrl = System.Configuration.ConfigurationManager.AppSettings.Get(EPS_SERVER_URL); apiContext.SignInUrl = System.Configuration.ConfigurationManager.AppSettings.Get(SIGNIN_URL); ApiAccount apiAccount = new ApiAccount(); apiAccount.Developer = System.Configuration.ConfigurationManager.AppSettings["Environment.DevId"]; apiAccount.Application = System.Configuration.ConfigurationManager.AppSettings["Environment.AppId"]; apiAccount.Certificate = System.Configuration.ConfigurationManager.AppSettings["Environment.CertId"]; ApiCredential apiCredential = new ApiCredential(); apiCredential.ApiAccount = apiAccount; apiContext.ApiCredential = apiCredential; apiContext.EnableMetrics = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings.Get(ENABLE_METRICS)); if (!string.IsNullOrEmpty(site)) { apiContext.Site = (SiteCodeType)Enum.Parse(typeof(SiteCodeType), site, true); } apiContext.RuleName = System.Configuration.ConfigurationManager.AppSettings["RuName"];// EBayPriceChanges.Config.RuName; apiContext.RuName = System.Configuration.ConfigurationManager.AppSettings["RuName"];// EBayPriceChanges.Config.RuName; return apiContext; }
protected void Page_Init() { //get eBayToken and ServerAddress from Web.config string tradingServerAddress = System.Configuration.ConfigurationManager.AppSettings["TradingServerAddress"]; string eBayToken = System.Configuration.ConfigurationManager.AppSettings["EBayToken"]; apiContext = new ApiContext(); //set Api Server Url apiContext.SoapApiServerUrl = tradingServerAddress; //set Api Token to access eBay Api Server ApiCredential apiCredential = new ApiCredential(); apiCredential.eBayToken = eBayToken; apiContext.ApiCredential = apiCredential; //set eBay Site target to US apiContext.Site = SiteCodeType.US; //set Api logging apiContext.ApiLogManager = new ApiLogManager(); apiContext.ApiLogManager.ApiLoggerList.Add( new FileLogger("trading_log.txt", true, true, true) ); apiContext.ApiLogManager.EnableLogging = true; }
private void BtnAccountSettings_Click(object sender, EventArgs e) { ApiAccount form = new ApiAccount(); form.apiContext = apiContext; if (form.ShowDialog() == DialogResult.OK) apiContext = form.apiContext; }
/// <summary> /// Populate eBay SDK ApiContext object with data from application configuration file /// </summary> /// <returns>ApiContext object</returns> static ApiContext GetApiContext() { //apiContext is a singleton, //to avoid duplicate configuration reading if (apiContext != null) { return apiContext; } else { apiContext = new ApiContext(); //set Api Server Url apiContext.SoapApiServerUrl = ConfigurationManager.AppSettings["Environment.ApiServerUrl"]; //set Api Token to access eBay Api Server ApiCredential apiCredential = new ApiCredential(); apiCredential.eBayToken = ConfigurationManager.AppSettings["UserAccount.ApiToken"]; apiContext.ApiCredential = apiCredential; //set eBay Site target to US apiContext.Site = SiteCodeType.US; //set Api logging apiContext.ApiLogManager = new ApiLogManager(); apiContext.ApiLogManager.ApiLoggerList.Add( new FileLogger("listing_log.txt", true, true, true) ); apiContext.ApiLogManager.EnableLogging = true; return apiContext; } }
/// <summary> /// Constructor /// </summary> /// <param name="context"></param> public CategoriesDownloader(ApiContext context) { this.context=context; //must initialize some super class fields this.filePrefix = "AllCategories"; this.fileSuffix = "cats"; this.objType = typeof(GetCategoriesResponseType); }
/// <summary> /// Constructor /// </summary> /// <param name="context"></param> public DetailsDownloader(ApiContext context) { this.context = context; //must initialize some super class fields this.filePrefix = "EBayDetails"; this.fileSuffix = "eds"; this.objType = typeof(GeteBayDetailsResponseType); }
//constructor public CategoryFacade(string catId, ApiContext apiContext,SiteFacade siteFacade) { this.catId = catId; this.apiContext = apiContext; this.siteFacade = siteFacade; this.SyncCategoryMetaData(); }
protected override void ExecuteInternal() { eBay.Service.Core.Sdk.ApiContext apiContext = this.ApiContext; eBay.Service.Call.GeteBayOfficialTimeCall apiCall = new eBay.Service.Call.GeteBayOfficialTimeCall(apiContext); apiCall.Execute(); this.EbayDateTime = apiCall.EBayTime; }
//constructor public CategoryFacade(string catId, ApiContext apiContext, AttributesMaster attrMaster, SiteFacade siteFacade) { this.catId = catId; this.apiContext = apiContext; this.attrMaster = attrMaster; this.siteFacade = siteFacade; this.SyncCategoryMetaData(); }
//get eBay Details public static GeteBayDetailsResponseType GetShippingServices(ApiContext apiContext) { GeteBayDetailsCall api = new GeteBayDetailsCall(apiContext); DetailNameCodeTypeCollection names=new DetailNameCodeTypeCollection(); names.Add(DetailNameCodeType.ShippingLocationDetails); names.Add(DetailNameCodeType.ShippingServiceDetails); api.GeteBayDetails(null); return api.ApiResponse; }
static void SetServiceContext() { eBayApiServiceUrl = Utility.GetApplicationSetting<string>(Constants.CONST_SETTINGS_EBAY_API_SERVER_URL, ""); eBayApiToken = Utility.GetApplicationSetting<string>(Constants.CONST_SETTINGS_EBAY_API_TOKEN, ""); _apiContext = new ApiContext(); _apiContext.SoapApiServerUrl = eBayApiServiceUrl; ApiCredential apiCredential = new ApiCredential(); apiCredential.eBayToken = eBayApiToken; _apiContext.ApiCredential = apiCredential; _apiContext.Site = SiteCodeType.UK; _apiContext.ApiLogManager = new ApiLogManager(); CallRetry retry = new CallRetry(); retry.DelayTime = 3000; retry.MaximumRetries = 5; retry.TriggerHttpStatusCodes.Add(500); retry.TriggerHttpStatusCodes.Add(502); _apiContext.CallRetry = retry; FileLogger loger = new FileLogger(); string path = Utility.GetApplicationSetting<string>("LogFilePath", @"D:\"); //string assemblyDir = Path.GetDirectoryName(path); string logFileDirectory = Path.Combine(path, @"LogFilePath"); if (!Directory.Exists(logFileDirectory)) { Directory.CreateDirectory(logFileDirectory); } string logFileName = string.Format(@"{0}\eBayLog_{1}.txt", logFileDirectory, DateTime.Now.Date.ToString("yyyyMMdd")); loger.FileName = logFileName; //loger.LogApiMessages = true; loger.LogExceptions = true; loger.LogInformations = false; _apiContext.ApiLogManager.ApiLoggerList.Add(loger); _apiContext.ApiLogManager.EnableLogging = true; }
/// <summary> /// get some items which supports the ad format category, you can specify the number /// </summary> /// <param name="apiContext"></param> /// <param name="num"></param> /// <param name="categoryTypeCollection"></param> /// <param name="message"></param> /// <returns></returns> public static bool GetAdFormatCategory(ApiContext apiContext,int num,out CategoryTypeCollection categoryTypeCollection,out string message) { message=string.Empty; CategoryTypeCollection tmpCategories; categoryTypeCollection = null; num=(num<=0)?1:num; GetCategoryFeaturesCall api = new GetCategoryFeaturesCall(apiContext); setBasicInfo(ref api); //spcify category id if(!getAllCategories(apiContext,out tmpCategories, out message)) { message=message+",203"; return false; } FeatureIDCodeTypeCollection features=new FeatureIDCodeTypeCollection(); FeatureIDCodeType type=FeatureIDCodeType.AdFormatEnabled; features.Add(type); string categoryID=string.Empty; foreach(CategoryType category in tmpCategories) { if(category.LeafCategory == true) { categoryID=category.CategoryID; try { //call CategoryFeatureTypeCollection featureTypes = api.GetCategoryFeatures(categoryID,10,true,features,true); if(featureTypes!=null&&featureTypes.Count>0) { if(featureTypes[0].AdFormatEnabled==AdFormatEnabledCodeType.Enabled) { categoryTypeCollection.Add(category); } if(categoryTypeCollection.Count>=num) { break; } } } catch(Exception e) { message=e.Message+",204"; return false; } } } return true; }
/// <summary> /// /// </summary> public GetCategoryFeaturesHelper(ApiContext ApiContext, string CategoryID, int LevelLimit, bool ViewAllNodes, FeatureIDCodeTypeCollection FeatureIDList, bool AllFeaturesForCategory) { _apiContext = ApiContext; _site = _apiContext.Site; _categoryID = CategoryID; _levelLimit = LevelLimit; _viewAllNodes = ViewAllNodes; _featureIDs = FeatureIDList; _allFeaturesForCategory = AllFeaturesForCategory; loadCategoryFeatures(_site); }
public EbayClient() { m_config = new ClientConfig(); m_config.ApplicationId = appID; m_config.EndPointAddress = findingServerAddress; m_client = FindingServiceClientFactory.getServiceClient(m_config); m_api = new ApiContext(); m_api = AppSettingHelper.GetApiContext(); m_cats = new tblCategory(); db = new DataClasses1DataContext(); m_log = new List<string> { }; }
private void APIMain_Load(object sender, EventArgs e) { apiContext = AppSettingHelper.GetApiContext(); apiContext.ApiLogManager = new ApiLogManager(); LoggingProperties logProps = AppSettingHelper.GetLoggingProperties(); apiContext.ApiLogManager.ApiLoggerList.Add(new FileLogger(logProps.LogFileName, true, true, true)); apiContext.ApiLogManager.EnableLogging = true; apiContext.ApiLogManager.MessageLoggingFilter = GetExceptionFilter(logProps); apiContext.Site = eBay.Service.Core.Soap.SiteCodeType.US; SetProxy(); }
//get all categories public static CategoryTypeCollection GetAllCategories(ApiContext apiContext) { CategoriesDownloader downloader = new CategoriesDownloader(apiContext); CategoryTypeCollection catsCol = downloader.GetAllCategories(); //cache the categories in hashtable foreach(CategoryType cat in catsCol) { catsTable.Add(cat.CategoryID, cat); } return catsCol; }
public static void GetAllCategoriesFeatures(ApiContext context) { FeaturesDownloader downloader = new FeaturesDownloader(context); GetCategoryFeaturesResponseType resp = downloader.GetCategoryFeatures(); CategoryFeatureTypeCollection cfCol = resp.Category; //cache the features in hashtable foreach(CategoryFeatureType cf in cfCol) { cfsTable.Add(cf.CategoryID, cf); } //cache site defaults siteDefaults = resp.SiteDefaults; //cahce feature definitions featureDefinition = resp.FeatureDefinitions; }
public static String FetchUserToken(String sessionId, out String userId) { userId = ""; if (sessionId == "") return ""; String token = ""; ApiAccount apiAccount = new ApiAccount(); apiAccount.Application = EbayAppId; apiAccount.Certificate = EbayCertId; apiAccount.Developer = EbayDevId; ApiContext localContext = new ApiContext(); localContext.ApiCredential = new eBay.Service.Core.Sdk.ApiCredential(); localContext.ApiCredential.ApiAccount = apiAccount; localContext.RuName = EbayRuName; localContext.SoapApiServerUrl = System.Configuration.ConfigurationManager.AppSettings.Get(AppSettingHelper.API_SERVER_URL); localContext.SignInUrl = System.Configuration.ConfigurationManager.AppSettings.Get(AppSettingHelper.SIGNIN_URL); ConfirmIdentityCall apiCall = new ConfirmIdentityCall(localContext); apiCall.SessionID = sessionId; try { apiCall.ConfirmIdentity(sessionId); userId = apiCall.UserID; } catch (System.Exception) { } FetchTokenCall fetchTokenApiCall = new FetchTokenCall(localContext); apiCall.SessionID = sessionId; try { fetchTokenApiCall.FetchToken(sessionId); token = fetchTokenApiCall.eBayToken; } catch (System.Exception) { } return token; }
/// <summary> /// Launches the sign in page for using the Authentication & Authorization feature. /// </summary> /// <param name="Context">The <see cref="ApiContext"/> which defines the SignInUrl and RuName.</param> /// <param name="SessionID">The SessionID which is used by <see cref="eBay.Service.Call.FetchTokenCall"/> to retrieve the token.</param> public static void LaunchSignInPage(ApiContext Context, string SessionID) { if(Context == null) throw new SdkException("Please specify the Context.", new System.ArgumentNullException()); if(Context.SignInUrl == null || Context.SignInUrl.ToString().Length == 0) throw new SdkException("Please specify the SignInUrl in the Context object.", new System.ArgumentNullException()); if (Context.RuName == null || Context.RuName.Length == 0) throw new SdkException("Please specify a RuName.", new System.ArgumentNullException()); // Go to the page. string finalUrl = Context.SignInUrl + "&runame=" + Context.RuName; if(SessionID != null && SessionID.Length > 0 ) finalUrl += "&sessid=" + SessionID; System.Diagnostics.Process.Start(finalUrl); }
public eBayWrapper() { this.changeStatus += new dChangeStatus(eBayLister.Program.mainForm.changeStatus); this.addLogStatus += new dChangeStatus(eBayLister.Program.mainForm.addLogStatus); this.reportProgress += new dChangeStatus(eBayLister.Program.mainForm.progressChanged); this.reportTotalItems += new dChangeStatus(eBayLister.Program.mainForm.totalItems); context = new ApiContext(); context.ApiCredential.eBayToken = eBayLister.UserSettings.Default.userToken; context.ApiCredential.ApiAccount.Application = eBayLister.UserSettings.Default.appId; context.ApiCredential.ApiAccount.Certificate = eBayLister.UserSettings.Default.certId; context.ApiCredential.ApiAccount.Developer = eBayLister.UserSettings.Default.devId; context.SoapApiServerUrl = eBayLister.UserSettings.Default.soapApiServerUrl; // 647 context.Version = eBayLister.UserSettings.Default.ApiVersion; context.Timeout = Int32.Parse(eBayLister.UserSettings.Default.Timeout); context.ApiLogManager = new ApiLogManager(); context.ApiLogManager.ApiLoggerList.Add(new FileLogger("Logs.txt", true, true, true)); context.ApiLogManager.EnableLogging = true; context.Site = (SiteCodeType)Enum.Parse(typeof(SiteCodeType),eBayLister.UserSettings.Default.Site,true); }
public static ApiContext LoadApiContext(string name) { ApiContext context = new ApiContext(); context.ApiCredential.ApiAccount.Application = LoadAppConfig(name+"appid"); context.ApiCredential.ApiAccount.Developer = LoadAppConfig(name+"devid"); context.ApiCredential.ApiAccount.Certificate = LoadAppConfig(name+"cert"); context.ApiCredential.eBayToken = LoadAppConfig(name+"token"); context.SoapApiServerUrl = LoadAppConfig("soapurl"); context.XmlApiServerUrl = LoadAppConfig("sdkurl"); context.EPSServerUrl = LoadAppConfig("epsurl"); string timeout = LoadAppConfig("timeout"); if (timeout != null && string.Empty != timeout) { context.Timeout = int.Parse(timeout); } ApiLogManager Logger = new ApiLogManager(); Logger.EnableLogging = true; string logfile = LoadAppConfig("logfile"); if (logfile != "" && logfile != null) Logger.ApiLoggerList.Add(new FileLogger(logfile)); else Logger.ApiLoggerList.Add(new ConsoleLogger()); if (LoadAppConfig("logexception").ToUpper() == "TRUE") Logger.ApiLoggerList[0].LogExceptions = true; if (LoadAppConfig("logmessages").ToUpper() == "TRUE") Logger.ApiLoggerList[0].LogApiMessages = true; Logger.ApiLoggerList[0].LogInformations = true; context.ApiLogManager = Logger; return context; }
/// <summary> /// get an item. /// </summary> /// <param name="itemGet"></param> /// <param name="apiContext"></param> /// <param name="message"></param> /// <param name="itemOut"></param> /// <returns></returns> public static bool GetItem(ItemType itemGet,ApiContext apiContext,out string message,out ItemType itemOut) { message=string.Empty; itemOut=null; bool includeCrossPromotion=true; bool includeItemSpecifics=true; bool includeTaxTable=true; bool includeWatchCount=true; try { GetItemCall api=new GetItemCall(apiContext); DetailLevelCodeType detaillevel= DetailLevelCodeType.ReturnAll; api.DetailLevelList=new DetailLevelCodeTypeCollection(new DetailLevelCodeType[]{detaillevel}); itemOut = api.GetItem(itemGet.ItemID,includeWatchCount,includeCrossPromotion,includeItemSpecifics,includeTaxTable,null, null, null, null, false); if(itemOut==null) { message="do not get the item"; } if(itemOut.ItemID!=itemGet.ItemID) { message="the item getted is not the same as item wanted"; } } catch(Exception e) { message=e.Message; return false; } return true; }
public static String getAuthenticateUrl(out String sessionId) { sessionId = ""; ApiAccount apiAccount = new ApiAccount(); apiAccount.Application = EbayAppId; apiAccount.Certificate = EbayCertId; apiAccount.Developer = EbayDevId; ApiContext localContext = new ApiContext(); localContext.ApiCredential = new eBay.Service.Core.Sdk.ApiCredential(); localContext.ApiCredential.ApiAccount = apiAccount; localContext.RuName = EbayRuName; localContext.SoapApiServerUrl = System.Configuration.ConfigurationManager.AppSettings.Get(AppSettingHelper.API_SERVER_URL); localContext.SignInUrl = System.Configuration.ConfigurationManager.AppSettings.Get(AppSettingHelper.SIGNIN_URL); GetSessionIDCall apiCall = new GetSessionIDCall(localContext); apiCall.RuName = EbayRuName; apiCall.Execute(); sessionId = apiCall.SessionID; String authUrl = String.Format("{0}&RuName={1}&SessID={2}", localContext.SignInUrl, EbayRuName, sessionId); return authUrl; }
/// <summary> /// /// </summary> /// <param name="ApiContext">The <see cref="ApiCall.ApiContext"/> for this API Call of type <see cref="ApiContext"/>.</param> public AddMemberMessagesAAQToBidderCall(ApiContext ApiContext) { ApiRequest = new AddMemberMessagesAAQToBidderRequestType(); this.ApiContext = ApiContext; }
/// <summary> /// /// </summary> /// <param name="ApiContext">The <see cref="ApiCall.ApiContext"/> for this API Call of type <see cref="ApiContext"/>.</param> public GetItemCall(ApiContext ApiContext) { ApiRequest = new GetItemRequestType(); this.ApiContext = ApiContext; }
/// <summary> /// /// </summary> /// <param name="ApiContext">The <see cref="ApiCall.ApiContext"/> for this API Call of type <see cref="ApiContext"/>.</param> public GetShippingDiscountProfilesCall(ApiContext ApiContext) { ApiRequest = new GetShippingDiscountProfilesRequestType(); this.ApiContext = ApiContext; }