Sha256: ea219f0e2dba71adb5503af06e14c05505e0ab684e1a088ccbf403d115e928eb
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
# frozen_string_literal: true module UrlScan module Clients class Pro < Base VERSION = 1 HOST = "pro.urlscan.com" # @return [Hash] def search(query: nil, filter: nil, size: 50) raise ArgumentError, "API key is required for this method." if key.nil? filter = build_filter(filter) params = { q: query, size: size }.compact uri_query = URI.encode_www_form(params) uri_query << "&filter=#{filter}" if filter get("/search?#{uri_query}") { |json| json } end # @return [Hash] def brands raise ArgumentError, "API key is required for this method." if key.nil? get("/brands") { |json| json } end # @return [Hash] def kits raise ArgumentError, "API key is required for this method." if key.nil? get("/kits") { |json| json } end # @return [Hash] def phishfeed(q: "result.task.time:>now-24h", format: "json") raise ArgumentError, "API key is required for this method." if key.nil? params = { q: q, format: format } query = URI.encode_www_form(params) get("/phishfeed?#{query}") { |json| json } end private def build_filter(filter) return nil unless filter filter.start_with?("$") ? filter : "$#{filter}" end def url @url ||= "https://#{self.class::HOST}/api/v#{self.class::VERSION}/pro" end def get(path, &block) get = Net::HTTP::Get.new(url_for(path), auth_header) request(get, &block) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
urlscan-0.5.0 | lib/urlscan/clients/pro.rb |