Sha256: f444fb599ea75f598d6ea650ce43b27949221e3e3871c2c5a8ffa0471ce61dfd

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

module VirusTotal
  class API
    # @return [String] VirusTotal API key
    attr_reader :key

    #
    # @param [String] key VirusTotal API key
    #
    # @raise [ArgumentError] When given an empty key
    #
    def initialize(key: ENV["VIRUSTOTAL_API_KEY"])
      @key = key

      raise ArgumentError, "No API key has been found or provided! (setup your VIRUSTOTAL_API_KEY environment varialbe)" unless key
    end

    #
    # Analyses API endpoint client
    #
    # @return [VirusTotal::Client::Analysis]
    #
    def analysis
      @analysis ||= Client::Analysis.new(key: key)
    end

    #
    # Domains API endpoint client
    #
    # @return [VirusTotal::Client::Domain]
    #
    def domain
      @domain ||= Client::Domain.new(key: key)
    end

    #
    # Files API endpoint client
    #
    # @return [VirusTotal::Client::File]
    #
    def file
      @file ||= Client::File.new(key: key)
    end

    #
    # IP addresses API endpoint client
    #
    # @return [VirusTotal::Client::IPAddress]
    #
    def ip_address
      @ip_address ||= Client::IPAddress.new(key: key)
    end

    #
    # URLs API endpoint client
    #
    # @return [VirusTotal::Client::URL]
    #
    def url
      @url ||= Client::URL.new(key: key)
    end

    #
    # Graphs API endpoint client
    #
    # @return [VirusTotal::Client::Graph]
    #
    def graph
      @graph ||= Client::Graph.new(key: key)
    end

    #
    # Intelligence API endpoint client
    #
    # @return [VirusTotal::Client::Intelligence]
    #
    def intelligence
      @intelligence ||= Client::Intelligence.new(key: key)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
virustotalx-1.2.0 lib/virustotal/api.rb