Class: Copyleaks::CopyleaksDeleteRequestModel

Inherits:
Object
  • Object
show all
Defined in:
lib/copyleaks/models/delete_request_model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scans, purge = false, completionWebhook = '') ⇒ CopyleaksDeleteRequestModel

Returns a new instance of CopyleaksDeleteRequestModel.

Parameters:

  • scans (Array)

    The list of scans to delete

  • purge (Boolean) (defaults to: false)

    Delete all trace of the scan from Copyleaks server, including from internal database. A purged process will not be available as a result for previous scans.

  • completionWebhook (String) (defaults to: '')

    Allows you to register to a webhook that will be fired once the removal has been completed. Make sure that your endpoint is listening to a POST method (no body parameters were supplied).



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/copyleaks/models/delete_request_model.rb', line 32

def initialize(scans, purge = false, completionWebhook = '')
  scans.each do |object_id|
    unless object_id.instance_of?(IdObject)
      raise 'Copyleaks::CopyleaksDeleteRequestModel - scans - entity must be of type Copyleaks::IdObject'
    end
  end

  unless [true, false].include? purge
    raise 'Copyleaks::CopyleaksDeleteRequestModel - purge - purge must be of type Boolean'
  end

  unless completionWebhook.instance_of?(String)
    raise 'Copyleaks::CopyleaksDeleteRequestModel - completionWebhook - completionWebhook must be of type String'
  end

  @scans = scans
  @purge = purge
  @completionWebhook = completionWebhook
end

Instance Attribute Details

#completionWebhookObject (readonly)

Returns the value of attribute completionWebhook.



27
28
29
# File 'lib/copyleaks/models/delete_request_model.rb', line 27

def completionWebhook
  @completionWebhook
end

#purgeObject (readonly)

Returns the value of attribute purge.



27
28
29
# File 'lib/copyleaks/models/delete_request_model.rb', line 27

def purge
  @purge
end

#scansObject (readonly)

Returns the value of attribute scans.



27
28
29
# File 'lib/copyleaks/models/delete_request_model.rb', line 27

def scans
  @scans
end

Instance Method Details

#as_json(*_args) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/copyleaks/models/delete_request_model.rb', line 52

def as_json(*_args)
  {
    scans: @scans.map { |object_id| object_id.as_json },
    purge: @purge,
    completionWebhook: @completionWebhook
  }.select { |_k, v| !v.nil? }
end

#to_json(*options) ⇒ Object



60
61
62
# File 'lib/copyleaks/models/delete_request_model.rb', line 60

def to_json(*options)
  as_json(*options).to_json(*options)
end