public static Uri CreateBreachedAccountUri(string emailAddress, HibpRequestOptions options = null) { if (string.IsNullOrEmpty(emailAddress)) { throw new ArgumentException("Email address was null or empty.", nameof(emailAddress)); } var uri = new Uri(BaseUrl + UriServicePath.BreachedAccount + "/" + WebUtility.UrlEncode(emailAddress)); if (options != null) { uri = uri.AddTruncateResponse(options.TruncateResponse); uri = uri.AddIncludeUnverified(options.IncludeUnverified); uri = uri.AddFilterByDomain(options.FilterByDomain); } return(uri); }
/// <summary> /// Get all breaches an account has been involved in. /// </summary> /// <param name="emailAddress">Email address for the account.</param> /// <param name="options">Search options.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>The task object representing the asynchronous operation with a result of the breaches.</returns> /// <exception cref="T:System.ArgumentException"><paramref name="emailAddress" /> is null or empty.</exception> /// <exception cref="T:ByteDev.Hibp.HibpClientException">Unhandled API error occured.</exception> public async Task <IEnumerable <HibpBreachResponse> > GetAccountBreachesAsync(string emailAddress, HibpRequestOptions options = null, CancellationToken cancellationToken = default) { var uri = HibpUriFactory.CreateBreachedAccountUri(emailAddress, options); var response = await _httpClient.ApiGetAsync(uri, _options, cancellationToken); return(await HibpResponseFactory.CreateBreachResponsesAsync(response)); }
private static Uri Act(string emailAddress, HibpRequestOptions options = null) { return(HibpUriFactory.CreateBreachedAccountUri(emailAddress, options)); }