Class: Copyleaks::CopyleaksFileOcrSubmissionModel

Inherits:
CopyleaksFileSubmissionModel show all
Defined in:
lib/copyleaks/models/submissions/file_ocr_submission_model.rb

Instance Attribute Summary

Attributes inherited from CopyleaksSubmissionModel

#properties

Instance Method Summary collapse

Constructor Details

#initialize(langCode, base64, filename, properties) ⇒ CopyleaksFileOcrSubmissionModel

Returns a new instance of CopyleaksFileOcrSubmissionModel.

Parameters:

  • langCode (String)

    The language code of your content. The selected language should be on the OCR supported languages list. api.copyleaks.com/documentation/v3/specifications/ocr-languages

  • base64 (String)

    A base64 data string of a file. If you would like to scan plain text, encode it as base64 and submit it.

  • filename (String)

    The name of the file as it will appear in the Copyleaks scan report Make sure to include the right extension for your filetype.

  • properties (SubmissionProperties)

    Check inner properties for more details.



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

def initialize(langCode, base64, filename, properties)
  unless langCode.instance_of?(String)
    raise 'Copyleaks::CopyleaksFileOcrSubmissionModel - langCode - langCode must be of type String'
  end
  unless base64.instance_of?(String)
    raise 'Copyleaks::CopyleaksFileOcrSubmissionModel - base64 - base64 must be of type String'
  end
  unless filename.instance_of?(String)
    raise 'Copyleaks::CopyleaksFileOcrSubmissionModel - filename - filename must be of type String'
  end
  unless properties.instance_of?(SubmissionProperties)
    raise 'Copyleaks::CopyleaksFileOcrSubmissionModel - properties - properties must be of type SubmissionProperties'
  end

  super(base64, filename, properties)
  @langCode = langCode
end

Instance Method Details

#as_json(*_args) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/copyleaks/models/submissions/file_ocr_submission_model.rb', line 48

def as_json(*_args)
  {
    langCode: @langCode,
    base64: @base64,
    filename: @filename,
    properties: @properties
  }.select { |_k, v| !v.nil? }
end

#to_json(*options) ⇒ Object



57
58
59
# File 'lib/copyleaks/models/submissions/file_ocr_submission_model.rb', line 57

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