Class: HaveIBeenPwned::Client
- Inherits:
-
Object
- Object
- HaveIBeenPwned::Client
- Defined in:
- lib/haveibeenpwned/client.rb
Constant Summary collapse
- BASE_URL =
"https://haveibeenpwned.com/api/v3"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#user_agent ⇒ Object
readonly
Returns the value of attribute user_agent.
Instance Method Summary collapse
- #breach(name) ⇒ Object
-
#breached_account(account, truncate_response: true, domain: nil, include_unverified: true) ⇒ Object
Breaches.
- #breached_domain(domain) ⇒ Object
- #breaches(domain: nil, is_spam_list: nil) ⇒ Object
- #data_classes ⇒ Object
-
#initialize(api_key:, user_agent:) ⇒ Client
constructor
A new instance of Client.
- #latest_breach ⇒ Object
-
#pastes(account) ⇒ Object
Pastes.
-
#stealer_logs_by_email(email) ⇒ Object
Stealer Logs.
- #stealer_logs_by_email_domain(domain) ⇒ Object
- #stealer_logs_by_website_domain(domain) ⇒ Object
- #subscribed_domains ⇒ Object
-
#subscription_status ⇒ Object
Subscription.
Constructor Details
#initialize(api_key:, user_agent:) ⇒ Client
Returns a new instance of Client.
13 14 15 16 |
# File 'lib/haveibeenpwned/client.rb', line 13 def initialize(api_key:, user_agent:) @api_key = api_key @user_agent = user_agent end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
11 12 13 |
# File 'lib/haveibeenpwned/client.rb', line 11 def api_key @api_key end |
#user_agent ⇒ Object (readonly)
Returns the value of attribute user_agent.
11 12 13 |
# File 'lib/haveibeenpwned/client.rb', line 11 def user_agent @user_agent end |
Instance Method Details
#breach(name) ⇒ Object
46 47 48 |
# File 'lib/haveibeenpwned/client.rb', line 46 def breach(name) get("/breach/#{name}") end |
#breached_account(account, truncate_response: true, domain: nil, include_unverified: true) ⇒ Object
Breaches
20 21 22 23 24 25 26 27 28 |
# File 'lib/haveibeenpwned/client.rb', line 20 def breached_account(account, truncate_response: true, domain: nil, include_unverified: true) params = { truncateResponse: truncate_response, includeUnverified: include_unverified } params[:domain] = domain if domain get("/breachedaccount/#{url_encode(account)}", params) end |
#breached_domain(domain) ⇒ Object
30 31 32 |
# File 'lib/haveibeenpwned/client.rb', line 30 def breached_domain(domain) get("/breacheddomain/#{domain}") end |
#breaches(domain: nil, is_spam_list: nil) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/haveibeenpwned/client.rb', line 38 def breaches(domain: nil, is_spam_list: nil) params = {} params[:domain] = domain if domain params[:isSpamList] = is_spam_list unless is_spam_list.nil? get("/breaches", params) end |
#data_classes ⇒ Object
54 55 56 |
# File 'lib/haveibeenpwned/client.rb', line 54 def data_classes get("/dataclasses") end |
#latest_breach ⇒ Object
50 51 52 |
# File 'lib/haveibeenpwned/client.rb', line 50 def latest_breach get("/latestbreach") end |
#pastes(account) ⇒ Object
Pastes
74 75 76 |
# File 'lib/haveibeenpwned/client.rb', line 74 def pastes(account) get("/pasteaccount/#{url_encode(account)}") end |
#stealer_logs_by_email(email) ⇒ Object
Stealer Logs
60 61 62 |
# File 'lib/haveibeenpwned/client.rb', line 60 def stealer_logs_by_email(email) get("/stealerlogsbyemail/#{url_encode(email)}") end |
#stealer_logs_by_email_domain(domain) ⇒ Object
68 69 70 |
# File 'lib/haveibeenpwned/client.rb', line 68 def stealer_logs_by_email_domain(domain) get("/stealerlogsbyemaildomain/#{domain}") end |
#stealer_logs_by_website_domain(domain) ⇒ Object
64 65 66 |
# File 'lib/haveibeenpwned/client.rb', line 64 def stealer_logs_by_website_domain(domain) get("/stealerlogsbywebsitedomain/#{domain}") end |
#subscribed_domains ⇒ Object
34 35 36 |
# File 'lib/haveibeenpwned/client.rb', line 34 def subscribed_domains get("/subscribeddomains") end |
#subscription_status ⇒ Object
Subscription
80 81 82 |
# File 'lib/haveibeenpwned/client.rb', line 80 def subscription_status get("/subscription/status") end |