Ejemplo n.º 1
0
        /// <summary>
        ///     This method initializes the NeverBounceSDK
        /// </summary>
        /// <param name="ApiKey">The api key to use to make the requests</param>
        /// <param name="Host">Specify a different host to make the request to. Leave null to use 'https://api.neverbounce.com'</param>
        /// <param name="Client">An instance of IHttpClient to use; useful for mocking HTTP requests</param>
        public NeverBounceSdk(string ApiKey, string Host = null, IHttpClient Client = null)
        {
            _apiKey = ApiKey;

            // Accept debug host
            if (Host != null)
            {
                _host = Host;
            }

            // Check for mocked IHttpClient, if none exists create default
            if (Client == null)
            {
                _client = new HttpClientWrapper();
            }
            else
            {
                _client = Client;
            }

            Account = new AccountService(_client, _apiKey, _host);
            Jobs    = new JobsService(_client, _apiKey, _host);
            POE     = new POEService(_client, _apiKey, _host);
            Single  = new SingleService(_client, _apiKey, _host);
        }
        /// <summary>
        ///     This method initializes the NeverBounceSDK
        /// </summary>
        /// <param name="ApiKey">The api key to use to make the requests</param>
        /// <param name="Version">The api version to make this request on</param>
        /// <param name="Host">Specify a different host to make the request to. Leave null to use 'https://api.neverbounce.com'</param>
        /// <param name="Client">An instance of IHttpClient to use; useful for mocking HTTP requests</param>
        public NeverBounceSdk(string ApiKey, string Version = "v4.2", string Host = null, IHttpClient Client = null)
        {
            _apiKey  = ApiKey;
            _version = Version;

            // Check for mocked IHttpClient, if none exists create default
            _client = Client ?? new HttpClientWrapper();

            var url = $"{Host ?? _host}/{_version}";

            Account = new AccountService(_client, _apiKey, url);
            Jobs    = new JobsService(_client, _apiKey, url);
            POE     = new POEService(_client, _apiKey, url);
            Single  = new SingleService(_client, _apiKey, url);
        }