lib/censys/api.rb in censu-0.1.2 vs lib/censys/api.rb in censu-0.1.3

- old
+ new

@@ -2,10 +2,11 @@ require 'censys/search' require 'censys/report' require 'censys/ipv4' require 'censys/website' require 'censys/certificate' +require 'censys/data' require 'net/https' require 'json' module Censys @@ -163,9 +164,28 @@ raise(ArgumentError, "must specify the :query param") unless params[:query] raise(ArgumentError, "must specify the :field param") unless params[:field] post("/report/#{resource}", params) do |response| Report::Response.new(response) + end + end + + def data(params = {}) + series = params[:series] + result = params[:result] + type, path = + if series && result.nil? then [:series, "/data/#{series}"] + elsif series && result then [:result, "/data/#{series}/#{result}"] + else + [:series_list, "/data"] + end + get(path) do |response| + case type + when :series then Data::Series.new(response) + when :result then Data::Result.new(response) + else + Data::SeriesList.new(response) + end end end private