Sha256: 5bc4a8f1f0ce6e0cf61c0317c76ff04332753bebeabba6d045ef1cf05ddf476f

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 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
      # @param [Integer, nil] timeout
      #
      def initialize(base_url = "https://pulsedive.com", api_key:, headers: {}, timeout: nil)
        raise(ArgumentError, "api_key is required") unless api_key

        @api_key = api_key

        super(base_url, headers: headers, timeout: timeout)
      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

2 entries across 2 versions & 1 rubygems

Version Path
mihari-5.6.2 lib/mihari/clients/publsedive.rb
mihari-5.6.1 lib/mihari/clients/publsedive.rb