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:) ⇒ Hash

Lists out specific historical information about the given hostname parameter with auto paging

Parameters:

  • hostname (String)
  • type (String)

    allowed values: a, aaaa, mx, ns, soa or txt

Returns:

  • (Hash)

See Also:



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

Parameters:

  • hostname (String)
  • type (String)

    allowed values: a, aaaa, mx, ns, soa or txt

  • page (Integer) (defaults to: 1)

    The page of the returned results

Returns:

  • (Hash)

Raises:

  • (ArgumentError)

See Also:



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

Parameters:

  • hostname (String)

Returns:

  • (Hash)

See Also:



58
59
60
# File 'lib/securitytrails/clients/history.rb', line 58

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