Exemple #1
0
        /// <summary>
        /// Get all breached sites in the system. Requires that a client API key be provided.
        /// </summary>
        /// <param name="domain">Optional. Filters the result set to only breaches against the domain specified. It is possible that one site (and consequently domain), is compromised on multiple occasions.</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:ByteDev.Hibp.HibpClientException">Unhandled API error occured.</exception>
        public async Task <IEnumerable <HibpBreachResponse> > GetBreachedSitesAsync(string domain = null, CancellationToken cancellationToken = default)
        {
            var uri = HibpUriFactory.CreateBreachedSiteUri(domain);

            var response = await _httpClient.ApiGetAsync(uri, _options, cancellationToken);

            return(await HibpResponseFactory.CreateBreachResponsesAsync(response));
        }
Exemple #2
0
        /// <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));
        }