Class: SecurityTrails::Clients::History
- Inherits:
-
SecurityTrails::Client
- Object
- SecurityTrails::Client
- SecurityTrails::Clients::History
- Defined in:
- lib/securitytrails/clients/history.rb
Constant Summary
Constants inherited from SecurityTrails::Client
SecurityTrails::Client::API_KEY_HEADER, SecurityTrails::Client::HOST, SecurityTrails::Client::URL, SecurityTrails::Client::VERSION
Instance Attribute Summary
Attributes inherited from SecurityTrails::Client
Instance Method Summary collapse
-
#get_all_dns_history(hostname, type:) ⇒ Hash
Lists out specific historical information about the given hostname parameter with auto paging.
-
#get_dns_history(hostname, type:, page: 1) ⇒ Hash
Lists out specific historical information about the given hostname parameter.
-
#get_whois_history(hostname) ⇒ Hash
Returns historical WHOIS information about the given domain.
Methods inherited from SecurityTrails::Client
Constructor Details
This class inherits a constructor from SecurityTrails::Client
Instance Method Details
#get_all_dns_history(hostname, type:) ⇒ Hash
Lists out specific historical information about the given hostname parameter with auto paging
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/securitytrails/clients/history.rb', line 33 def get_all_dns_history(hostname, type:) first_page = get_dns_history(hostname, type: type, page: 1) pages = first_page["pages"].to_i records = [] records << first_page["records"] (2..pages).each do |page_idx| next_page = get_dns_history(hostname, type: type, page: page_idx) records << next_page["records"] end first_page["records"] = records.flatten first_page end |
#get_dns_history(hostname, type:, page: 1) ⇒ Hash
Lists out specific historical information about the given hostname parameter
17 18 19 20 21 |
# File 'lib/securitytrails/clients/history.rb', line 17 def get_dns_history(hostname, type:, page: 1) raise ArgumentError, "The API currently supports a, aaaa, mx, ns, soa and txt records." unless valid_type?(type) get("/history/#{hostname}/dns/#{type.downcase}", page: page) { |json| json } end |
#get_whois_history(hostname) ⇒ Hash
Returns historical WHOIS information about the given domain
58 59 60 |
# File 'lib/securitytrails/clients/history.rb', line 58 def get_whois_history(hostname) get("/history/#{hostname}/whois/") { |json| json } end |