/// <summary>Instantiates new MangoPayApi object.</summary> public MangoPayApi() { // default config setup Config = new Configuration(); OAuthTokenManager = new AuthorizationTokenManager(this); // API managers initialization AuthenticationManager = new ApiOAuth(this); Clients = new ApiClients(this); Users = new ApiUsers(this); Wallets = new ApiWallets(this); PayIns = new ApiPayIns(this); PayOuts = new ApiPayOuts(this); Refunds = new ApiRefunds(this); Transfers = new ApiTransfers(this); CardRegistrations = new ApiCardRegistrations(this); Cards = new ApiCards(this); Events = new ApiEvents(this); CardPreAuthorizations = new ApiCardPreAuthorizations(this); Hooks = new ApiHooks(this); Kyc = new ApiKyc(this); Disputes = new ApiDisputes(this); Idempotency = new ApiIdempotency(this); Mandates = new ApiMandates(this); Reports = new ApiReports(this); SingleSignOns = new ApiSingleSignOns(this); PermissionGroups = new ApiPermissionGroups(this); BankingAlias = new ApiBankingAliases(this); UboDeclarations = new ApiUboDeclarations(this); }
private IApiClient GetOrAddApiClient(ServerInfo server, ConnectionMode connectionMode) { IApiClient apiClient; if (!ApiClients.TryGetValue(server.Id, out apiClient)) { var address = server.GetAddress(connectionMode); apiClient = new ApiClient(_logger, address, ApplicationName, Device, ApplicationVersion, _cryptographyProvider, _localAssetManager) { JsonSerializer = JsonSerializer, OnAuthenticated = ApiClientOnAuthenticated }; ApiClients[server.Id] = apiClient; } if (string.IsNullOrEmpty(server.AccessToken)) { apiClient.ClearAuthenticationInfo(); } else { apiClient.SetAuthenticationInfo(server.AccessToken, server.UserId); } return(apiClient); }
public static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.RootComponents.Add <App>("app"); //builder.AddApiClients(typeof(RgbApiClient)); builder.Services.TryAddTransient <RgbApiClient>(); builder.Services.TryAddTransient <WeatherApiClient>(); var apiClients = new ApiClients(); builder.Configuration.Bind("ApiClients", apiClients); builder.Services.Configure <ApiClients>(builder.Configuration.GetSection("ApiClients")); builder.Services.AddTransient <ConfigurableAuthorizationMessageHandler <RgbApiClient> >(); builder.Services.AddTransient <WeatherApiAuthorizationMessageHandler>(); builder.Services.AddHttpClient <RgbApiClient>(client => client.BaseAddress = new Uri("https://localhost:44341/")) .AddHttpMessageHandler <ConfigurableAuthorizationMessageHandler <RgbApiClient> >(); //builder.Services.AddHttpClient(nameof(RgbApiClient), client => client.BaseAddress = new Uri("https://localhost:44341/")) // .AddHttpMessageHandler<ConfigurableAuthorizationMessageHandler<RgbApiClient>>(); builder.Services.AddAuthorizationCore(); builder.Services.AddOidcAuthentication(options => { // see https://aka.ms/blazor-standalone-auth builder.Configuration.Bind("Oidc:ProviderOptions", options.ProviderOptions); builder.Configuration.Bind("Oidc:UserOptions", options.UserOptions); }); builder.Services.AddHttpClient <WeatherApiClient>(client => client.BaseAddress = new Uri("https://localhost:44305/")) .AddHttpMessageHandler <WeatherApiAuthorizationMessageHandler>(); await builder.Build().RunAsync(); }
private IApiClient GetOrAddApiClient(ServerInfo server) { if (!ApiClients.TryGetValue(server.Id, out IApiClient apiClient)) { var address = server.Address; apiClient = new ApiClient(_logger, address, ApplicationName, Device, ApplicationVersion) { JsonSerializer = JsonSerializer, }; apiClient.Authenticated += ApiClientOnAuthenticated; ApiClients[server.Id] = apiClient; } if (string.IsNullOrEmpty(server.AccessToken)) { apiClient.ClearAuthenticationInfo(); } else { apiClient.SetAuthenticationInfo(server.AccessToken, server.UserId); } return(apiClient); }
public ListFactsTask( Object basePath, Object token, Parameters parameters, Object debugInfo ) { basePath_casted = Utils.castParamString(basePath, "basePath", false, "http://secxbrl.28.io/v1/_queries/public"); api = ApiClients.getDataApiClient(basePath_casted); token_casted = Utils.castParamString(token, "token", true); eid_casted = Utils.castParamString(parameters.getParamValue("eid"), "eid", false); ticker_casted = Utils.castParamString(parameters.getParamValue("ticker"), "ticker", false); tag_casted = Utils.castParamString(parameters.getParamValue("tag"), "tag", false); aid_casted = Utils.castParamString(parameters.getParamValue("aid"), "aid", false); fiscalYear_casted = Utils.castParamString(parameters.getParamValue("fiscalYear"), "fiscalYear", false); concept_casted = Utils.castParamString(parameters.getParamValue("concept"), "concept", false); fiscalPeriod_casted = Utils.castParamString(parameters.getParamValue("fiscalPeriod"), "fiscalPeriod", false); fiscalPeriodType_casted = Utils.castParamString(parameters.getParamValue("fiscalPeriodType"), "fiscalPeriodType", false); report_casted = Utils.castParamString(parameters.getParamValue("report"), "report", false); additionalRules_casted = Utils.castParamString(parameters.getParamValue("additionalRules"), "additionalRules", false); open_casted = Utils.castParamBool(parameters.getParamValue("open"), "open", false); aggregationFunction_casted = Utils.castParamString(parameters.getParamValue("aggregation-function"), "aggregationFunction", false); profileName_casted = Utils.castParamString(parameters.getParamValue("profile-name"), "profileName", false); dimensions_casted = parameters.getDimensionsValues(); dimensionDefaults_casted = parameters.getDimensionDefaultsValues(); dimensionTypes_casted = parameters.getDimensionTypesValues(); dimensionAggregation_casted = parameters.getDimensionAggregationsValues(); count_casted = Utils.castParamBool(parameters.getParamValue("count"), "count", false); top_casted = Utils.castParamInt(parameters.getParamValue("top"), "top", 100); //skip_casted = Utils.castParamInt(skip, "skip", 0); debugInfo_casted = Utils.castParamBool(debugInfo, "debugInfo", false); if (!(Utils.hasEntityFilter(eid_casted, ticker_casted, tag_casted, dimensions_casted) && Utils.hasConceptFilter(concept_casted, dimensions_casted) && Utils.hasAdditionalFilter(fiscalYear_casted, fiscalPeriod_casted, dimensions_casted))) { throw new Exception("Too generic filter."); } //Utils.log("Created Task " + ToString()); }
/// <summary>Instantiates new MangoPayApi object.</summary> public MangoPayApi() { // default config setup Config = new Configuration(); OAuthTokenManager = new AuthorizationTokenManager(this); // API managers initialization AuthenticationManager = new ApiOAuth(this); Clients = new ApiClients(this); Users = new ApiUsers(this); Wallets = new ApiWallets(this); PayIns = new ApiPayIns(this); PayOuts = new ApiPayOuts(this); Refunds = new ApiRefunds(this); Transfers = new ApiTransfers(this); CardRegistrations = new ApiCardRegistrations(this); Cards = new ApiCards(this); Events = new ApiEvents(this); CardPreAuthorizations = new ApiCardPreAuthorizations(this); Hooks = new ApiHooks(this); }
protected override void OnInitialize() { ApiClients.AddRange(apiClientFactory.GetAll()); SelectedApiClient = apiClientFactory.Get <TwitchApiClient>(); base.OnInitialize(); }
public string SendMessage(string id) { var res = ""; bool callbackWatson = false; string userInput = id; //string wccontext = Session["wccontext"]; WCMessageResponse watsonResponse = (WCMessageResponse)Session["watsonResponse"]; watsonResponse.input.text = userInput; watsonResponse = WatsonConversationClient.ConverseWatson(watsonResponse); res += "<section class=\"post\"><header class=\"post-header-watson\">" + "<img width = \"48\" height=\"48\" alt=\"img\" class=\"pre-avatar-w\"" + "src=\"/Content/img/avatar-user.png\"><h2 class=\"post-title-user\">@Usuario</h2>" + "</header><div class=\"post-description-user\">" + userInput + "</div></section>"; if (watsonResponse.context.ban_accion != null) { switch (watsonResponse.context.ban_accion) { case "redirect_pago": return("redirect_pago"); //"window.location='https://escritorio.aspel.com.mx/webapps/CotizadorSist.exe/Cotizador'"; case "valida_rfc": callbackWatson = true; watsonResponse.context.ban_accion = null; watsonResponse.context.rfc_valido = ApiClients.ValidateRFC(watsonResponse.context.rfc); break; case "consulta_precios": var product = watsonResponse.context.producto; var productType = watsonResponse.context.tipo_producto; int usuarios = int.Parse(watsonResponse.context.cantidad_usuarios); var precio = ApiClients.GetProductPrice(product, usuarios, productType); watsonResponse.context.ban_accion = null; watsonResponse.context.precio_producto = "$" + precio; break; } } foreach (var text in watsonResponse.output.text) { res += "<section class=\"post\"><header class=\"post-header-watson\">" + "<img width = \"48\" height=\"48\" alt=\"img\" class=\"post-avatar-w\"" + "src=\"/Content/img/avatar-watson.png\"><h2 class=\"post-title-watson\">@IBM Watson</h2>" + "</header><div class=\"post-description-watson\">" + text + "</div></section>"; } if (callbackWatson) { watsonResponse = WatsonConversationClient.ConverseWatson(watsonResponse); foreach (var text in watsonResponse.output.text) { res += "<section class=\"post\"><header class=\"post-header-watson\">" + "<img width = \"48\" height=\"48\" alt=\"img\" class=\"post-avatar-w\"" + "src=\"/Content/img/avatar-watson.png\"><h2 class=\"post-title-watson\">@IBM Watson</h2>" + "</header><div class=\"post-description-watson\">" + text + "</div></section>"; } } Session["watsonResponse"] = watsonResponse; return(res); }
/// <summary> /// Register an API client /// </summary> /// <param name="apiClient">The client</param> protected T AddApiClient <T>(T apiClient) where T : BaseApiClient { log.Write(LogLevel.Trace, $" {apiClient.GetType().Name} configuration: {apiClient.Options}"); ApiClients.Add(apiClient); return(apiClient); }
protected override void OnInitialize() { ApiClients.AddRange(apiClientFactory.GetAll().Where(x => x.HasVodViewerSupport)); base.OnInitialize(); }
/// <summary> /// Adds ApiClients (each with HttpClient and configured HttpMethodHandler), /// using settings from Configuration ("ApiClients" section) /// Calls AddAuthorizationCore() and AddOidcAuthentication, /// using OIDC settings from Configuration sections (Oidc:ProviderOptions, Oidc:UserOptions) /// </summary> /// <param name="builder"></param> /// <param name="apiClientTypes"></param> public static void AddApiClients(this WebAssemblyHostBuilder builder, params Type[] apiClientTypes) { var apiClients = new ApiClients(); builder.Configuration.Bind("ApiClients", apiClients); builder.Services.Configure <ApiClients>(builder.Configuration.GetSection("ApiClients")); var addTransientMethod = typeof(ServiceCollectionServiceExtensions) .GetMethods(BindingFlags.Public | BindingFlags.Static) .FirstOrDefault(mi => mi.Name == nameof(ServiceCollectionServiceExtensions.AddTransient) && mi.GetGenericArguments().Count() == 1 && mi.GetParameters().Count() == 1 ); var addHttpMessageHandlerMethod = typeof(HttpClientBuilderExtensions) .GetMethods(BindingFlags.Public | BindingFlags.Static) .FirstOrDefault(mi => mi.Name == nameof(HttpClientBuilderExtensions.AddHttpMessageHandler) && mi.GetGenericArguments().Count() == 1 && mi.GetParameters().Count() == 1 ); foreach (var apiClientType in apiClientTypes) { var d1 = typeof(ConfigurableAuthorizationMessageHandler <>); Type[] typeArgs = { apiClientType }; var configurableAuthorizationMethodHandlerGenericType = d1.MakeGenericType(typeArgs); //AddTransient<...> var addTransientGenericMethod = addTransientMethod .MakeGenericMethod(configurableAuthorizationMethodHandlerGenericType); addTransientGenericMethod.Invoke(builder.Services, new object[] { builder.Services }); //Get ApiClient settings from Configuration. Throw exception if key not found if (!apiClients.TryGetValue(apiClientType.Name, out ApiClient apiClient)) { throw new Exception($"{apiClientType.Name} cannot be found in ApiClients section of Configuration"); } //AddHttpClient() var httpClientBuilder = builder.Services .AddHttpClient(apiClientType.Name, client => client.BaseAddress = new Uri(apiClient.TargetUrl)); //register Api Client Type in DI var addTransientApiClientMethod = addTransientMethod .MakeGenericMethod(apiClientType); addTransientGenericMethod.Invoke(builder.Services, new object[] { builder.Services }); //AddHttpMessageHandler<ConfigurableAuthorizationMethodHandler<>> var addHttpMessageHandlerGenericMethod = addHttpMessageHandlerMethod .MakeGenericMethod(configurableAuthorizationMethodHandlerGenericType); addHttpMessageHandlerGenericMethod.Invoke(httpClientBuilder, new object[] { httpClientBuilder }); } builder.Services.AddAuthorizationCore(); builder.Services.AddOidcAuthentication(options => { // see https://aka.ms/blazor-standalone-auth builder.Configuration.Bind("Oidc:ProviderOptions", options.ProviderOptions); builder.Configuration.Bind("Oidc:UserOptions", options.UserOptions); }); }