Esempio n. 1
0
        public static Pathoschild.Http.Client.IClient GetFluentClient(MockHttpMessageHandler httpMessageHandler)
        {
            var httpClient = httpMessageHandler.ToHttpClient();
            var client     = new FluentClient(SENDGRID_API_BASE_URI, httpClient);

            client.SetRequestCoordinator(new SendGridRetryStrategy());
            client.Filters.Remove <DefaultErrorFilter>();
            client.Filters.Add(new SendGridErrorHandler());
            return(client);
        }
Esempio n. 2
0
        public static Pathoschild.Http.Client.IClient GetFluentClient(MockHttpMessageHandler httpMessageHandler)
        {
            var httpClient = httpMessageHandler.ToHttpClient();
            var client     = new FluentClient(new Uri(ZOOM_V2_BASE_URI), httpClient);

            client.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), null));
            client.Filters.Remove <DefaultErrorFilter>();
            client.Filters.Add(new DiagnosticHandler(LogLevel.Debug, LogLevel.Error));
            client.Filters.Add(new ZoomErrorHandler());

            return(client);
        }
Esempio n. 3
0
        public static FluentClient Create()
        {
            var client = new FluentClient(BaseUri);

            client.SetOptions(new FluentClientOptions()
            {
                IgnoreHttpErrors = true, IgnoreNullArguments = true
            });
            client.SetRequestCoordinator(
                maxRetries: 5,
                shouldRetry: req => req.StatusCode != HttpStatusCode.OK,
                getDelay: (attempt, response) => TimeSpan.FromSeconds(attempt));
            return(client);
        }
Esempio n. 4
0
        public static Pathoschild.Http.Client.IClient GetFluentClient(MockHttpMessageHandler httpMessageHandler)
        {
            var httpClient = httpMessageHandler.ToHttpClient();
            var client     = new FluentClient(new Uri(SENDGRID_API_BASE_URI), httpClient);

            client.SetRequestCoordinator(new SendGridRetryStrategy());
            client.Filters.Remove <DefaultErrorFilter>();

            // Remove all the built-in formatters and replace them with our custom JSON formatter
            client.Formatters.Clear();
            client.Formatters.Add(new JsonFormatter());

            // Order is important: DiagnosticHandler must be first.
            // Also, the list of filters must be kept in sync with the filters in BaseClient in the StrongGrid project.
            client.Filters.Add(new DiagnosticHandler(LogLevel.Debug, LogLevel.Error));
            client.Filters.Add(new SendGridErrorHandler());
            return(client);
        }