lib/urlscan/api.rb in urlscan-0.2.0 vs lib/urlscan/api.rb in urlscan-0.2.1
- old
+ new
@@ -12,17 +12,17 @@
URL = "https://#{HOST}/api/v#{VERSION}"
attr_reader :key
def initialize(key = ENV["URLSCAN_API_KEY"])
- raise ArgumentError, "`key` argument required" if key.nil?
-
@key = key
end
# @return [Hash]
def submit(url, is_public = true)
+ raise ArgumentError, "API key is required for this method." if key.nil?
+
params = { url: url, public: is_public ? "on" : "off" }
post("/scan/", params) { |json| json }
end
# @return [Hash]
@@ -85,10 +85,10 @@
def auth_header
{ "API-KEY": key }
end
def get(path, &block)
- get = Net::HTTP::Get.new(url_for(path), auth_header)
+ get = Net::HTTP::Get.new(url_for(path))
request(get, &block)
end
def post(path, json, &block)
post = Net::HTTP::Post.new(url_for(path), auth_header)