Class: Intrinsic::DetectionsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/intrinsic/detections/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ DetectionsClient

Parameters:



13
14
15
16
# File 'lib/intrinsic/detections/client.rb', line 13

def initialize(request_client:)
  # @type [RequestClient]
  @request_client = request_client
end

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



9
10
11
# File 'lib/intrinsic/detections/client.rb', line 9

def request_client
  @request_client
end

Instance Method Details

#get_detection(id:, request_options: nil) ⇒ DetectionObject

Parameters:

  • id (String)

    Detection ID

  • request_options (RequestOptions) (defaults to: nil)

Returns:



21
22
23
24
25
26
27
28
# File 'lib/intrinsic/detections/client.rb', line 21

def get_detection(id:, request_options: nil)
  response = @request_client.conn.get("/api/v2/detections/#{id}") do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["X-API-Key"] = request_options.api_key unless request_options&.api_key.nil?
    req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
  end
  DetectionObject.from_json(json_object: response.body)
end