public DefaultRequestExecutor(
            IHttpClient httpClient,
            IClientApiKey apiKey,
            AuthenticationScheme authenticationScheme,
            ILogger logger,
            IBackoffStrategy defaultBackoffStrategy,
            IBackoffStrategy throttlingBackoffStrategy)
        {
            if (!apiKey.IsValid())
            {
                throw new ApplicationException("API Key is invalid.");
            }

            this.httpClient = httpClient;
            this.syncHttpClient = httpClient as ISynchronousHttpClient;
            this.asyncHttpClient = httpClient as IAsynchronousHttpClient;

            this.apiKey = apiKey;
            this.authenticationScheme = authenticationScheme;

            IRequestAuthenticatorFactory requestAuthenticatorFactory = new DefaultRequestAuthenticatorFactory();
            this.requestAuthenticator = requestAuthenticatorFactory.Create(authenticationScheme);

            this.logger = logger;
            this.defaultBackoffStrategy = defaultBackoffStrategy;
            this.throttlingBackoffStrategy = throttlingBackoffStrategy;
        }
 public DefaultRequestExecutor(
     IHttpClient httpClient,
     IClientApiKey apiKey,
     AuthenticationScheme authenticationScheme,
     ILogger logger)
     : this(httpClient, apiKey, authenticationScheme, logger, new DefaultBackoffStrategy(MaxBackoffMilliseconds), new ThrottlingBackoffStrategy(MaxBackoffMilliseconds))
 {
 }
        IRequestAuthenticator IRequestAuthenticatorFactory.Create(AuthenticationScheme scheme)
        {
            if (scheme == null ||
                scheme == AuthenticationScheme.SAuthc1)
            {
                return new SAuthc1RequestAuthenticator();
            }

            if (scheme == AuthenticationScheme.Basic)
            {
                return new BasicRequestAuthenticator();
            }

            throw new RequestAuthenticationException("Unknown authentication scheme.");
        }
        public DefaultClient(
            IClientApiKey apiKey,
            string baseUrl,
            AuthenticationScheme authenticationScheme,
            int connectionTimeout,
            IWebProxy proxy,
            IHttpClient httpClient,
            IJsonSerializer serializer,
            ICacheProvider cacheProvider,
            IUserAgentBuilder userAgentBuilder,
            ILogger logger,
            TimeSpan identityMapExpiration)
        {
            if (apiKey == null || !apiKey.IsValid())
            {
                throw new ArgumentException("API Key is not valid.");
            }

            if (string.IsNullOrEmpty(baseUrl))
            {
                throw new ArgumentNullException("Base URL cannot be empty.");
            }

            if (connectionTimeout < 0)
            {
                throw new ArgumentException("Timeout cannot be negative.");
            }

            this.logger = logger;
            this.apiKey = apiKey;
            this.baseUrl = baseUrl;
            this.connectionTimeout = connectionTimeout;
            this.proxy = proxy;
            this.cacheProvider = cacheProvider;
            this.authenticationScheme = authenticationScheme;
            this.serializer = serializer;
            this.httpClient = httpClient;

            var requestExecutor = new DefaultRequestExecutor(httpClient, apiKey, authenticationScheme, this.logger);

            this.dataStore = new DefaultDataStore(this as IClient, requestExecutor, baseUrl, this.serializer, this.logger, userAgentBuilder, cacheProvider, identityMapExpiration);
            this.dataStoreAsync = this.dataStore as IInternalAsyncDataStore;
            this.dataStoreSync = this.dataStore as IInternalSyncDataStore;
        }