Sha256: f4bd1537ed11c92e871bf611fb4d903955a153389ade6a0dc2983ce5cc1358c7

Contents?: true

Size: 919 Bytes

Versions: 3

Compression:

Stored size: 919 Bytes

Contents

# frozen_string_literal: true

module UrlScan
  module Clients
    class Community < Base
      # @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]
      def result(uuid)
        get("/result/#{uuid}") { |json| json }
      end

      # @return [String]
      def dom(uuid)
        get("/dom/#{uuid}/") { |dom| dom }
      end

      def screenshot(uuid)
        get("/screenshots/#{uuid}.png") { |png| png }
      end

      # @return [Hash]
      def search(q, size: 100, offset: 0, sort: "_score")
        params = { q: q, size: size, offset: offset, sort: sort }
        query = URI.encode_www_form(params)
        get("/search/?#{query}") { |json| json }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
urlscan-0.5.0 lib/urlscan/clients/community.rb
urlscan-0.4.1 lib/urlscan/clients/community.rb
urlscan-0.4.0 lib/urlscan/clients/community.rb