Sha256: ae48f00362b7e25ae5099e5bc8321f3e5e9244e0011b317d83eeab957edaac32

Contents?: true

Size: 1.17 KB

Versions: 8

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Mihari
  module Clients
    class PulseDive < Base
      # @return [String]
      attr_reader :api_key

      #
      # @param [String] base_url
      # @param [String, nil] api_key
      # @param [Hash] headers
      #
      def initialize(base_url = "https://pulsedive.com", api_key:, headers: {})
        super(base_url, headers: headers)

        @api_key = api_key

        raise(ArgumentError, "'api_key' argument is required") unless api_key
      end

      #
      # @param [String] indicator_id
      #
      # @return [Hash]
      #
      def get_indicator(ip_or_domain)
        _get "/api/info.php", params: { indicator: ip_or_domain }
      end

      #
      # @param [String] indicator_id
      #
      # @return [Hash]
      #
      def get_properties(indicator_id)
        _get "/api/info.php", params: { iid: indicator_id, get: "properties" }
      end

      private

      #
      # @param [String] path
      # @param [Hash] params
      #
      # @return [Hash]
      #
      def _get(path, params: {})
        params["key"] = api_key

        res = get(path, params: params)
        JSON.parse res.body.to_s
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mihari-5.6.0 lib/mihari/clients/publsedive.rb
mihari-5.5.0 lib/mihari/clients/publsedive.rb
mihari-5.4.9 lib/mihari/clients/publsedive.rb
mihari-5.4.8 lib/mihari/clients/publsedive.rb
mihari-5.4.7 lib/mihari/clients/publsedive.rb
mihari-5.4.6 lib/mihari/clients/publsedive.rb
mihari-5.4.5 lib/mihari/clients/publsedive.rb
mihari-5.4.4 lib/mihari/clients/publsedive.rb