public static IServiceCollection AddHubSpotClient(this IServiceCollection services, Action <IHubSpotClientConfigurator> configuration = null)
        {
            _ = services ?? throw new ArgumentNullException(nameof(services));

            var configurator = new HubSpotClientConfigurator();

            configuration?.Invoke(configurator);

            services.AddHttpRestClient(HttpClientConfigurationName, builder =>
            {
                builder.ConfigureHttpClient(http =>
                {
                    http.BaseAddress = HttpHubSpotClient.DefaultApiEndpoint;
                });

                builder.ConfigureSerialization(HttpHubSpotClient.ConfigureJsonSerializer);

                configurator.ApplyHttpClientBuilderConfigurations(builder);
            });

            configurator.ApplyServiceConfigurations(services);

            services.AddTransient <IHubSpotClient, HttpHubSpotClient>();

            return(services);
        }
Exemple #2
0
        public void Registered_httpClientBuilder_actions_are_applied(HubSpotClientConfigurator sut, Action <IHttpClientBuilder> action, IHttpClientBuilder builder)
        {
            sut.AddHttpClientBuilderConfiguration(action);

            sut.ApplyHttpClientBuilderConfigurations(builder);

            Mock.Get(action).Verify(p => p(builder));
        }