Class: Copyleaks::CopyleaksStartRequestModel

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trigger, errorHandling = CopyleaksStartErrorHandlings::IGNORE) ⇒ CopyleaksStartRequestModel

Returns a new instance of CopyleaksStartRequestModel.

Parameters:

  • string[]

    trigger A list of scans that you submitted for a check-credits scan and that you would like to submit for a full scan.

  • CopyleaksStartErrorHandlings

    errorHandling When set to ignore (ignore = 1) the trigger scans will start running even if some of them are in error mode, when set to cancel (cancel = 0) the request will be cancelled if any error was found.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/copyleaks/models/start_request_model.rb', line 30

def initialize(trigger, errorHandling = CopyleaksStartErrorHandlings::IGNORE)
  trigger.each do |item|
    unless item.instance_of?(String)
      raise 'Copyleaks::CopyleaksStartRequestModel - trigger - entity must be of type String'
    end
  end

  unless [0, 1].include? errorHandling
    raise 'Copyleaks::CopyleaksStartRequestModel - errorHandling - errorHandling must be of type Copyleaks::CopyleaksStartErrorHandlings Consts'
  end

  @trigger = trigger
  @errorHandling = errorHandling
end

Instance Attribute Details

#errorHandlingObject (readonly)

Returns the value of attribute errorHandling.



26
27
28
# File 'lib/copyleaks/models/start_request_model.rb', line 26

def errorHandling
  @errorHandling
end

#triggerObject (readonly)

Returns the value of attribute trigger.



26
27
28
# File 'lib/copyleaks/models/start_request_model.rb', line 26

def trigger
  @trigger
end

Instance Method Details

#as_json(*_args) ⇒ Object



45
46
47
48
49
50
# File 'lib/copyleaks/models/start_request_model.rb', line 45

def as_json(*_args)
  {
    trigger: @trigger,
    errorHandling: @errorHandling
  }.select { |_k, v| !v.nil? }
end

#to_json(*options) ⇒ Object



52
53
54
# File 'lib/copyleaks/models/start_request_model.rb', line 52

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