Sha256: e535b650e80cb5b05ea135a69856b1969de82170a44fc07c704a90b4348c50b4

Contents?: true

Size: 834 Bytes

Versions: 14

Compression:

Stored size: 834 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Clients
    class UrlScan < Base
      #
      # @param [String] base_url
      # @param [String, nil] api_key
      # @param [Hash] headers
      #
      def initialize(base_url = "https://urlscan.io", api_key:, headers: {})
        raise(ArgumentError, "'api_key' argument is required") if api_key.nil?

        headers["api-key"] = api_key

        super(base_url, headers: headers)
      end

      #
      # @param [String] q
      # @param [Integer] size
      # @param [String, nil] search_after
      #
      # @return [Hash]
      #
      def search(q, size: 100, search_after: nil)
        params = { q: q, size: size, search_after: search_after }.compact
        res = get("/api/v1/search/", params: params)
        JSON.parse res.body.to_s
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mihari-5.4.2 lib/mihari/clients/urlscan.rb
mihari-5.4.1 lib/mihari/clients/urlscan.rb
mihari-5.4.0 lib/mihari/clients/urlscan.rb
mihari-5.3.2 lib/mihari/clients/urlscan.rb
mihari-5.3.1 lib/mihari/clients/urlscan.rb
mihari-5.3.0 lib/mihari/clients/urlscan.rb
mihari-5.2.4 lib/mihari/clients/urlscan.rb
mihari-5.2.3 lib/mihari/clients/urlscan.rb
mihari-5.2.2 lib/mihari/clients/urlscan.rb
mihari-5.2.1 lib/mihari/clients/urlscan.rb
mihari-5.2.0 lib/mihari/clients/urlscan.rb
mihari-5.1.4 lib/mihari/clients/urlscan.rb
mihari-5.1.3 lib/mihari/clients/urlscan.rb
mihari-5.1.2 lib/mihari/clients/urlscan.rb