public IDialogFlowClient CreateDialogFlowClient(DialogFlowConfig dialogFlowConfig)
        {
            var httpClient    = BuildAuthenticatingHttpClientFrom(dialogFlowConfig);
            var dialogFlowApi = RestService.For <IDialogFlowApi>(httpClient);

            return(new DialogFlowClient(dialogFlowApi));
        }
 private static HttpClient BuildAuthenticatingHttpClientFrom(DialogFlowConfig dialogFlowConfig)
 {
     return(new HttpClient(new AuthenticatingHttpClientHandler(dialogFlowConfig.ApiKey))
     {
         BaseAddress = new Uri(dialogFlowConfig.BaseApiUrl)
     });
 }
Ejemplo n.º 3
0
        private static IDialogFlowClient BuildDialogFlowClientFrom(Configuration config)
        {
            var dialogFlowConfig = new DialogFlowConfig
            {
                ApiKey = config.DialogFlowApiKey
            };

            return(new DialogFlowClientFactory().CreateDialogFlowClient(dialogFlowConfig));
        }
        public DialogFlowAgentFixture()
        {
            var builder = new ConfigurationBuilder()
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables();
            var config = builder.Build();

            var services = new ServiceCollection();

            services.AddOptions();
            services.Configure <DialogFlowConfig>(config.GetSection(nameof(DialogFlowConfig)));

            var sp = services.BuildServiceProvider();

            DialogFlowConfig = sp.GetRequiredService <IOptions <DialogFlowConfig> >().Value;
        }