Ejemplo n.º 1
0
 public TrmHandler(
     IHttpClientFactory httpClientFactory,
     HttpClientPoliciesSettings httpClientPoliciesSettings,
     IOptionsMonitor <CurrencySettings> serviceSettings,
     ISlackHooksService slackHooksService,
     ILogger <CurrencyHandler> logger) : base(httpClientFactory, httpClientPoliciesSettings, serviceSettings.Get("TrmService"), slackHooksService, logger)
 {
 }
Ejemplo n.º 2
0
 public BnaHandler(
     IHttpClientFactory httpClientFactory,
     HttpClientPoliciesSettings bnaClientPoliciesSettings,
     IOptionsMonitor <CurrencySettings> bnaSettings,
     ISlackHooksService slackHooksService,
     ILogger <CurrencyHandler> logger) : base(httpClientFactory, bnaClientPoliciesSettings,
                                              bnaSettings.Get("BnaService"), slackHooksService, logger)
 {
 }
Ejemplo n.º 3
0
 public BnaService(IHttpClientFactory httpClientFactory,
                   HttpClientPoliciesSettings bnaClientPoliciesSettings,
                   BnaSettings bnaSettings,
                   ISlackHooksService slackHooksService)
 {
     _httpClient        = httpClientFactory.CreateClient(bnaClientPoliciesSettings.ClientName);
     _bnaSettings       = bnaSettings;
     _slackHooksService = slackHooksService;
 }
Ejemplo n.º 4
0
 public DofHandler(
     IHttpClientFactory httpClientFactory,
     HttpClientPoliciesSettings dofClientPoliciesSettings,
     IOptionsMonitor <CurrencySettings> dofSettings,
     ISlackHooksService slackHooksService,
     ILogger <CurrencyHandler> logger) : base(httpClientFactory, dofClientPoliciesSettings, dofSettings.Get("DofService"),
                                              slackHooksService, logger)
 {
 }
Ejemplo n.º 5
0
 protected CurrencyHandler(
     IHttpClientFactory httpClientFactory,
     HttpClientPoliciesSettings httpClientPoliciesSettings,
     CurrencySettings serviceSettings,
     ISlackHooksService slackHooksService,
     ILogger <CurrencyHandler> logger)
 {
     HttpClientFactory          = httpClientFactory;
     HttpClientPoliciesSettings = httpClientPoliciesSettings;
     ServiceSettings            = serviceSettings;
     SlackHooksService          = slackHooksService;
     Logger = logger;
 }
Ejemplo n.º 6
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddHangfire(x =>
            {
                x.UseSQLiteStorage();
            });

            var httpClientPolicies = new HttpClientPoliciesSettings();

            Configuration.GetSection("HttpClient:Client").Bind(httpClientPolicies);
            services.AddSingleton(httpClientPolicies);

            var handlerHttpClient = new HttpClientHandler
            {
                ClientCertificateOptions = ClientCertificateOption.Automatic,
                SslProtocols             = SslProtocols.Tls12
            };

            services.AddHttpClient(httpClientPolicies.ClientName, c => { })
            .ConfigurePrimaryHttpMessageHandler(() => handlerHttpClient)
            .AddTransientHttpErrorPolicy(builder => GetRetryPolicy(httpClientPolicies.Policies.RetryAttemps));

            services.Configure <DopplerCurrencyServiceSettings>(Configuration.GetSection(nameof(DopplerCurrencyServiceSettings)));

            var jobsConfig = new TimeZoneJobConfigurations
            {
                TimeZoneJobs = TimeZoneHelper.GetTimeZoneByOperativeSystem(Configuration["TimeZoneJobs"])
            };

            services.AddSingleton(jobsConfig);
            services.AddTransient <IDopplerCurrencyService, DopplerCurrencyService>();

            services.Configure <DopplerSapConfiguration>(Configuration.GetSection(nameof(DopplerSapConfiguration)));
            services.AddTransient <IDopplerSapService, DopplerSapService>();

            services.AddTransient <IDbConnectionFactory, DbConnectionFactory>();
            services.Configure <DopplerBillingJobSettings>(Configuration.GetSection("Jobs:DopplerBillingJobSettings"));
            services.Configure <DopplerBillingUsJobSettings>(Configuration.GetSection("Jobs:DopplerBillingUsJobSettings"));
            services.AddTransient <IDopplerRepository, DopplerRepository>();

            ConfigureJobsScheduler();

            services.AddTransient <JwtSecurityTokenHandler>();
            services.Configure <JwtOptions>(Configuration.GetSection(nameof(JwtOptions)));
            services.AddJwtToken();
            services.AddSingleton <IJwtTokenGenerator, JwtTokenGenerator>();
        }
Ejemplo n.º 7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            var httpClientPolicies = new HttpClientPoliciesSettings();

            Configuration.GetSection("HttpClient:BnaClient").Bind(httpClientPolicies);
            services.AddSingleton(httpClientPolicies);

            services.AddHttpClient(httpClientPolicies.ClientName, c => { })
            .SetHandlerLifetime(TimeSpan.FromMinutes(5))
            .AddPolicyHandler(GetRetryPolicy(httpClientPolicies.Policies.RetryAttemps));

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "BNA API",
                    Version     = "v1",
                    Description = "API for BNA"
                });
            });

            services.AddTransient <IBnaService, BnaService>();
            services.AddTransient <ISlackHooksService, SlackHooksService>();

            var slackHookSettings = new SlackHookSettings();

            Configuration.GetSection("SlackHook").Bind(slackHookSettings);
            services.AddSingleton(slackHookSettings);

            var bnaSettings = new BnaSettings();

            Configuration.GetSection("BnaService").Bind(bnaSettings);
            services.AddSingleton(bnaSettings);
        }
Ejemplo n.º 8
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers()
            .AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; });

            var httpClientPolicies = new HttpClientPoliciesSettings();

            Configuration.GetSection("HttpClient:Client").Bind(httpClientPolicies);
            services.AddSingleton(httpClientPolicies);

            var handlerHttpClient = new HttpClientHandler
            {
                ClientCertificateOptions = ClientCertificateOption.Automatic,
                SslProtocols             = SslProtocols.Tls12
            };

            services.AddHttpClient(httpClientPolicies.ClientName, c => { })
            .ConfigurePrimaryHttpMessageHandler(() => handlerHttpClient)
            .AddTransientHttpErrorPolicy(builder => GetRetryPolicy(httpClientPolicies.Policies.RetryAttemps));

            services.Configure <CurrencySettings>("BnaService", Configuration.GetSection("CurrencyCode:BnaService"));
            services.Configure <CurrencySettings>("DofService", Configuration.GetSection("CurrencyCode:DofService"));
            services.Configure <CurrencySettings>("TrmService", Configuration.GetSection("CurrencyCode:TrmService"));

            services.AddTransient <BnaHandler>();
            services.AddTransient <DofHandler>();
            services.AddTransient <TrmHandler>();

            services.AddTransient <ICurrencyService, CurrencyService>();
            services.AddTransient <ICurrencyFactory, CurrencyFactory>();


            services.AddSwaggerGen(c =>
            {
                c.EnableAnnotations();
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "Doppler Currency API",
                    Version     = "v1",
                    Description = "API for Doppler Currency"
                });

                c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    Description = "JWT Authorization header using the Bearer scheme (Example: 'Bearer 12345abcdef')",
                    Name        = "Authorization",
                    In          = ParameterLocation.Header,
                    Type        = SecuritySchemeType.ApiKey,
                    Scheme      = "Bearer"
                });

                c.AddSecurityRequirement(new OpenApiSecurityRequirement
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "Bearer"
                            }
                        },
                        Array.Empty <string>()
                    }
                });
            });

            services.AddSlackHook();


            services.AddDopplerSecurity();
            services.AddCors();
        }