/// <summary> /// Default constructor to create a new <see cref="EmailRepClient"/>. /// </summary> /// <param name="httpClient">A <see cref="HttpClient"/> instance. This can be provided manually or through dependency injection.</param> /// <param name="settings">An instance of the settings is .</param> public EmailRepClient(HttpClient httpClient, EmailRepClientSettings settings = default) { _httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); // make sure the http client is in a fit state to continue _httpClient.SetBaseAddress(settings); _httpClient.SetUserAgent(settings); _httpClient.SetApiHeader(settings); _httpClient.Validate(); }
static async Task Main(string[] args) { var client = new HttpClient(); var settings = new EmailRep.NET.EmailRepClientSettings(); settings.UserAgent = "consoleapp/test"; settings.ApiKey = "**** insert api key here ****"; var emailRepClient = new EmailRep.NET.EmailRepClient(client, settings); try { var response = await emailRepClient.QueryEmailAsync("*****@*****.**"); Console.WriteLine($"Name: {response.Email} ({response.Reputation})."); } catch (EmailRepException e) { Console.WriteLine(e); } }