/// <summary> /// Read API information from appSettings.json file. /// </summary> /// <returns>IXeroCoreApi instance</returns> private static IXeroCoreApi InitializeAPI() { var settings = new XeroApiSettings(); //AppType is mandatory. Hence the validation. This is the main entry point bool isAppTypeAvailable = !string.IsNullOrEmpty(settings.AppType) ? true : false; if (!isAppTypeAvailable) { Console.WriteLine("Please provide the mandatory AppType information in appSettings.json and restart the application"); Log.Information("Please provide the mandatory AppType information in appSettings.json and restart the application "); System.Environment.Exit(0); } //Convert string to Enum and ignore the case sensitivity Enum.TryParse(settings.AppType, true, out AppTypes appType); switch (appType) { case AppTypes.@public: return(PublicApp()); case AppTypes.@private: throw new NotImplementedException("AppType: private is not implemented."); case AppTypes.partner: throw new NotImplementedException("AppType: partner is not implemented."); default: throw new ApplicationException("AppType did not match one of: private, public, partner"); } }
public static IMvcAuthenticator MvcAuthenticator(XeroApiSettings applicationSettings) { if (_authenticator != null) { return(_authenticator); } // Set up some token stores to hold request and access tokens var accessTokenStore = new MemoryTokenStore(); var requestTokenStore = new MemoryTokenStore(); // Set the application settings with an authenticator relevant to your app type switch (applicationSettings.AppType) { case XeroApiAppType.Public: _authenticator = new PublicMvcAuthenticator(requestTokenStore, accessTokenStore); break; case XeroApiAppType.Partner: _authenticator = new PartnerMvcAuthenticator(requestTokenStore, accessTokenStore); break; case XeroApiAppType.Private: throw new ApplicationException("MVC cannot be used with private applications."); default: throw new ApplicationException("Unknown app type."); } return(_authenticator); }
public static IMvcAuthenticator MvcAuthenticator(XeroApiSettings applicationSettings) { if (_authenticator != null) { return(_authenticator); } // Set up some token stores to hold request and access tokens var accessTokenStore = new MemoryTokenStore(); var requestTokenStore = new MemoryTokenStore(); // Set the application settings with an authenticator relevant to your app type switch (applicationSettings.AppType.ToLower()) { case "public": _authenticator = new PublicMvcAuthenticator(requestTokenStore, accessTokenStore); break; case "partner": _authenticator = new PartnerMvcAuthenticator(requestTokenStore, accessTokenStore); break; case "private": throw new ApplicationException("MVC cannot be used with private applications"); case "default": throw new ApplicationException("AppType did not match one of: public, partner"); } return(_authenticator); }
public static IMvcAuthenticator MvcAuthenticator(XeroApiSettings applicationSettings) { // Set up some token stores to hold request and access tokens var accessTokenStore = new MemoryTokenStore(); var requestTokenStore = new MemoryTokenStore(); // Set the application settings with an authenticator relevant to your app type if (applicationSettings.IsPartnerApp) { Authenticator = new PartnerMvcAuthenticator(requestTokenStore, accessTokenStore); } else { Authenticator = new PublicMvcAuthenticator(requestTokenStore, accessTokenStore); } return(Authenticator); }
private static IXeroCoreApi Initialise() { var settings = new XeroApiSettings(); switch (settings.AppType.ToLower()) { case "private": return(PrivateApp()); case "public": return(PublicApp()); case "partner": return(PartnerApp()); default: throw new ApplicationException("AppType did not match one of: private, public, partner"); } }
public Core(bool includeRateLimiter = false, XeroApiSettings ApplicationSettings = null) : this(ApplicationSettings, new PrivateAuthenticator(ApplicationSettings.SigningCertificatePath, ApplicationSettings.SigningCertificatePassword), includeRateLimiter) { }
public Core(XeroApiSettings ApplicationSettings, IAuthenticator authenticator, bool includeRateLimiter = false) : base(authenticator, ApplicationSettings, rateLimiter: includeRateLimiter ? new RateLimiter.RateLimiter() : null) { }
public static IXeroCoreApi CoreApi(XeroApiSettings applicationSettings) { return(new XeroCoreApi(Authenticator as IAuthenticator, applicationSettings, User())); }
public HomeSettingController(IOptions <XeroApiSettings> applicationSettings) { _user = XeroApiHelper.User(); _applicationSettings = applicationSettings.Value; _authenticator = XeroApiHelper.MvcAuthenticator(_applicationSettings); }