Class: SecurityTrails::Clients::History

Inherits:
SecurityTrails::Client show all
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

#api_key

Instance Method Summary collapse

Methods inherited from SecurityTrails::Client

#initialize

Constructor Details

This class inherits a constructor from SecurityTrails::Client

Instance Method Details

#get_all_dns_history(hostname, type) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/securitytrails/clients/history.rb', line 12

def get_all_dns_history(hostname, type)
  first_page = get_dns_history(hostname, type, 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, page_idx)
    records << next_page["records"]
  end

  first_page["records"] = records.flatten
  first_page
end

#get_dns_history(hostname, type, page = 1) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
# File 'lib/securitytrails/clients/history.rb', line 6

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) ⇒ Object



28
29
30
# File 'lib/securitytrails/clients/history.rb', line 28

def get_whois_history(hostname)
  get("/history/#{hostname}/whois/") { |json| json }
end