plagiarism-checker 3.3.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -0
  3. data/Gemfile +0 -0
  4. data/LICENSE.txt +0 -0
  5. data/README.md +0 -0
  6. data/Rakefile +0 -0
  7. data/bin/console +0 -0
  8. data/bin/setup +0 -0
  9. data/lib/copyleaks/ai_detection_client.rb +98 -98
  10. data/lib/copyleaks/api.rb +4 -21
  11. data/lib/copyleaks/app.config.rb +0 -0
  12. data/lib/copyleaks/models/auth_token.rb +0 -0
  13. data/lib/copyleaks/models/delete_request_model.rb +0 -0
  14. data/lib/copyleaks/models/exceptions/{auth_exipred_exception.rb → auth_expired_exception.rb} +2 -4
  15. data/lib/copyleaks/models/exceptions/command_exception.rb +11 -4
  16. data/lib/copyleaks/models/exceptions/index.rb +1 -1
  17. data/lib/copyleaks/models/exceptions/rate_limit_exception.rb +2 -4
  18. data/lib/copyleaks/models/exceptions/under_maintenance_exception.rb +2 -4
  19. data/lib/copyleaks/models/exports/export_crawled_version.rb +0 -0
  20. data/lib/copyleaks/models/exports/export_model.rb +0 -0
  21. data/lib/copyleaks/models/exports/export_pdf_report.rb +0 -0
  22. data/lib/copyleaks/models/exports/export_results.rb +0 -0
  23. data/lib/copyleaks/models/exports/index.rb +0 -0
  24. data/lib/copyleaks/models/id_object.rb +0 -0
  25. data/lib/copyleaks/models/index.rb +0 -0
  26. data/lib/copyleaks/models/start_request_model.rb +0 -0
  27. data/lib/copyleaks/models/submissions/ai_detection/ai_detection_submission_model.rb +50 -50
  28. data/lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb +52 -52
  29. data/lib/copyleaks/models/submissions/ai_detection/source_code_submission_model.rb +55 -55
  30. data/lib/copyleaks/models/submissions/file_ocr_submission_model.rb +0 -0
  31. data/lib/copyleaks/models/submissions/file_submission_model.rb +0 -0
  32. data/lib/copyleaks/models/submissions/index.rb +1 -0
  33. data/lib/copyleaks/models/submissions/properties/actions.rb +0 -0
  34. data/lib/copyleaks/models/submissions/properties/ai_generated_text.rb +0 -0
  35. data/lib/copyleaks/models/submissions/properties/author.rb +0 -0
  36. data/lib/copyleaks/models/submissions/properties/copyleaks_db.rb +0 -0
  37. data/lib/copyleaks/models/submissions/properties/cross_languages.rb +0 -0
  38. data/lib/copyleaks/models/submissions/properties/custom_metadata.rb +0 -0
  39. data/lib/copyleaks/models/submissions/properties/domains_mode.rb +0 -0
  40. data/lib/copyleaks/models/submissions/properties/exclude.rb +0 -0
  41. data/lib/copyleaks/models/submissions/properties/exclude_code.rb +0 -0
  42. data/lib/copyleaks/models/submissions/properties/filter.rb +0 -0
  43. data/lib/copyleaks/models/submissions/properties/index.rb +1 -0
  44. data/lib/copyleaks/models/submissions/properties/indexing.rb +0 -0
  45. data/lib/copyleaks/models/submissions/properties/indexing_repository.rb +0 -0
  46. data/lib/copyleaks/models/submissions/properties/language.rb +0 -0
  47. data/lib/copyleaks/models/submissions/properties/masking_policy.rb +0 -0
  48. data/lib/copyleaks/models/submissions/properties/pdf_colors.rb +0 -0
  49. data/lib/copyleaks/models/submissions/properties/pdf_properties.rb +0 -0
  50. data/lib/copyleaks/models/submissions/properties/pdf_version.rb +0 -0
  51. data/lib/copyleaks/models/submissions/properties/repository.rb +0 -0
  52. data/lib/copyleaks/models/submissions/properties/scan_method_algorithm.rb +0 -0
  53. data/lib/copyleaks/models/submissions/properties/scanning.rb +0 -0
  54. data/lib/copyleaks/models/submissions/properties/scanning_exclude.rb +0 -0
  55. data/lib/copyleaks/models/submissions/properties/scanning_repository.rb +0 -0
  56. data/lib/copyleaks/models/submissions/properties/sensitive_data_protection.rb +0 -0
  57. data/lib/copyleaks/models/submissions/properties/submission_properties.rb +9 -3
  58. data/lib/copyleaks/models/submissions/properties/webhooks.rb +0 -0
  59. data/lib/copyleaks/models/submissions/properties/writing_feedback.rb +53 -0
  60. data/lib/copyleaks/models/submissions/submission_model.rb +0 -0
  61. data/lib/copyleaks/models/submissions/url_submission_model.rb +0 -0
  62. data/lib/copyleaks/models/submissions/webhooks/CompletedWebhook.rb +46 -0
  63. data/lib/copyleaks/models/submissions/webhooks/CreditsCheckedWebhook.rb +43 -0
  64. data/lib/copyleaks/models/submissions/webhooks/ErrorWebhook.rb +41 -0
  65. data/lib/copyleaks/models/submissions/webhooks/ExportCompletedWebhook.rb +44 -0
  66. data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/Metadata.rb +89 -0
  67. data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/StatusWebhook.rb +41 -0
  68. data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/Webhook.rb +43 -0
  69. data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Notifications.rb +43 -0
  70. data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb +68 -0
  71. data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/ScannedDocument.rb +61 -0
  72. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ErrorModels/Error.rb +46 -0
  73. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ExportModels/Task.rb +49 -0
  74. data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultScore.rb +42 -0
  75. data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultsInternet.rb +60 -0
  76. data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultsRepositories.rb +49 -0
  77. data/lib/copyleaks/models/submissions/webhooks/HelperModels/NotificationsModels/Alerts.rb +65 -0
  78. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Batch.rb +46 -0
  79. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Database.rb +46 -0
  80. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Internet.rb +42 -0
  81. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Repositories.rb +57 -0
  82. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/RepositoryMetadata.rb +30 -0
  83. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Score.rb +40 -0
  84. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/SharedResultsModel.rb +46 -0
  85. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Tags.rb +33 -0
  86. data/lib/copyleaks/models/submissions/webhooks/IndexedWebhook.rb +29 -0
  87. data/lib/copyleaks/models/submissions/webhooks/NewResultWebhook.rb +46 -0
  88. data/lib/copyleaks/models/submissions/webhooks/index.rb +34 -0
  89. data/lib/copyleaks/models/submissions/writing_assistant/score_weights.rb +54 -54
  90. data/lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb +56 -56
  91. data/lib/copyleaks/utils/copyleaks_client.utils.rb +56 -64
  92. data/lib/copyleaks/utils/status-code.utils.rb +0 -0
  93. data/lib/copyleaks/version.rb +1 -1
  94. data/lib/copyleaks/writing_assistant_client.rb +81 -81
  95. data/lib/copyleaks.rb +0 -0
  96. data/lib/index.rb +0 -0
  97. metadata +36 -7
@@ -1,55 +1,55 @@
1
- #
2
- # The MIT License(MIT)
3
- #
4
- # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in all
14
- # copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- # SOFTWARE.
23
- # =
24
-
25
- module Copyleaks
26
- class SourceCodeSubmissionModel < AIDetectionSubmissionModel
27
- attr_accessor :filename
28
-
29
- # @param [String] A text string.
30
- # @param [String] The name of the file. Make sure to include the right extension for your file type.
31
- # @param [Boolean] Use sandbox mode to test your integration with the Copyleaks API for free.
32
- def initialize(text, filename, sandbox = false)
33
- unless text.instance_of?(String)
34
- raise 'Copyleaks::SourceCodeSubmissionModel - text - text must be of type String'
35
- end
36
- unless filename.instance_of?(String)
37
- raise 'Copyleaks::SourceCodeSubmissionModel - filename - filename must be of type String'
38
- end
39
- super(text, sandbox)
40
- @filename = filename
41
- end
42
-
43
- def as_json(*_args)
44
- {
45
- text: @text,
46
- sandbox: @sandbox,
47
- filename: @filename
48
- }.select { |_k, v| !v.nil? }
49
- end
50
-
51
- def to_json(*options)
52
- as_json(*options).to_json(*options)
53
- end
54
- end
55
- end
1
+ #
2
+ # The MIT License(MIT)
3
+ #
4
+ # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+ # =
24
+
25
+ module Copyleaks
26
+ class SourceCodeSubmissionModel < AIDetectionSubmissionModel
27
+ attr_accessor :filename
28
+
29
+ # @param [String] A text string.
30
+ # @param [String] The name of the file. Make sure to include the right extension for your file type.
31
+ # @param [Boolean] Use sandbox mode to test your integration with the Copyleaks API for free.
32
+ def initialize(text, filename, sandbox = false)
33
+ unless text.instance_of?(String)
34
+ raise 'Copyleaks::SourceCodeSubmissionModel - text - text must be of type String'
35
+ end
36
+ unless filename.instance_of?(String)
37
+ raise 'Copyleaks::SourceCodeSubmissionModel - filename - filename must be of type String'
38
+ end
39
+ super(text, sandbox)
40
+ @filename = filename
41
+ end
42
+
43
+ def as_json(*_args)
44
+ {
45
+ text: @text,
46
+ sandbox: @sandbox,
47
+ filename: @filename
48
+ }.select { |_k, v| !v.nil? }
49
+ end
50
+
51
+ def to_json(*options)
52
+ as_json(*options).to_json(*options)
53
+ end
54
+ end
55
+ end
@@ -31,6 +31,7 @@ require_relative 'url_submission_model.rb'
31
31
  require_relative 'ai_detection/ai_detection_submission_model.rb'
32
32
  require_relative 'ai_detection/natural_language_submission_model.rb'
33
33
  require_relative 'ai_detection/source_code_submission_model.rb'
34
+ require_relative 'Webhooks/index.rb'
34
35
 
35
36
  require_relative 'writing_assistant/score_weights.rb'
36
37
  require_relative 'writing_assistant/writing_assistant_submission_model.rb'
@@ -48,6 +48,7 @@ require_relative 'scanning_repository.rb'
48
48
  require_relative 'sensitive_data_protection.rb'
49
49
  require_relative 'submission_properties.rb'
50
50
  require_relative 'webhooks.rb'
51
+ require_relative 'writing_feedback.rb'
51
52
 
52
53
 
53
54
 
@@ -25,7 +25,7 @@ module Copyleaks
25
25
  class SubmissionProperties
26
26
  attr_reader :webhooks, :includeHtml, :developerPayload, :sandbox, :expiration, :sensitivityLevel, :cheatDetection,
27
27
  :action, :author, :filters, :scanning, :indexing, :exclude, :pdf, :sensitiveDataProtection, :scanMethodAlgorithm,
28
- :aiGeneratedText, :customMetadata
28
+ :aiGeneratedText, :customMetadata, :writingFeedback
29
29
 
30
30
  # @param [SubmissionWebhooks] webhooks - Check inner properties for more details.
31
31
  # @param [Boolean] includeHtml - By default, Copyleaks will present the report in text format. If set to true, Copyleaks will also include html format.
@@ -45,11 +45,12 @@ module Copyleaks
45
45
  # @param [SubmissionScanMethodAlgorithm] scanMethodAlgorithm - Check inner properties for more details.
46
46
  # @param [SubmissionAiGeneratedText] aiGeneratedText - Check inner properties for more details.
47
47
  # @param [SubmissionCustomMetadata] customMetadata - Add custom properties that will be attached to your document in a Copyleaks repository.
48
+ # @param [SubmissionWritingFeedback] writingFeedback - Check inner properties for more details.
48
49
  def initialize(
49
50
  webhooks, includeHtml = nil, developerPayload = nil, sandbox = nil, expiration = nil,
50
51
  sensitivityLevel = nil, cheatDetection = nil, action = nil, author = nil, filters = nil,
51
52
  scanning = nil, indexing = nil, exclude = nil, pdf = nil, sensitiveDataProtection = nil,
52
- scanMethodAlgorithm = nil, aiGeneratedText = nil, customMetadata = nil
53
+ scanMethodAlgorithm = nil, aiGeneratedText = nil, customMetadata = nil, writingFeedback = nil
53
54
  )
54
55
  unless webhooks.instance_of?(SubmissionWebhooks)
55
56
  raise 'Copyleaks::SubmissionProperties - webhooks - webhooks must be of type SubmissionWebhooks'
@@ -105,6 +106,9 @@ module Copyleaks
105
106
  if !customMetadata.nil? && !(customMetadata.is_a?(Array) && customMetadata.all? { |element| element.is_a?(SubmissionCustomMetadata) })
106
107
  raise 'Copyleaks::SubmissionProperties - customMetadata - customMetadata must be of type SubmissionCustomMetadata[]'
107
108
  end
109
+ if !writingFeedback.nil? && !writingFeedback.instance_of?(SubmissionWritingFeedback)
110
+ raise 'Copyleaks::SubmissionProperties - writingFeedback - writingFeedback must be of type SubmissionWritingFeedback'
111
+ end
108
112
 
109
113
  @webhooks = webhooks
110
114
  @includeHtml = includeHtml
@@ -124,6 +128,7 @@ module Copyleaks
124
128
  @sensitiveDataProtection = sensitiveDataProtection
125
129
  @scanMethodAlgorithm = scanMethodAlgorithm
126
130
  @customMetadata = customMetadata
131
+ @writingFeedback = writingFeedback
127
132
  end
128
133
 
129
134
  def as_json(*_args)
@@ -145,7 +150,8 @@ module Copyleaks
145
150
  pdf: @pdf,
146
151
  sensitiveDataProtection: @sensitiveDataProtection,
147
152
  scanMethodAlgorithm: @scanMethodAlgorithm,
148
- customMetadata: @customMetadata
153
+ customMetadata: @customMetadata,
154
+ writingFeedback: @writingFeedback
149
155
  }.select { |_k, v| !v.nil? }
150
156
  end
151
157
 
@@ -0,0 +1,53 @@
1
+ #
2
+ # The MIT License(MIT)
3
+ #
4
+ # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+ # =
24
+
25
+ module Copyleaks
26
+ class SubmissionWritingFeedback
27
+ attr_accessor :enable, :score
28
+ # @param [Boolean] Enable automated Writing Assistant . This feature includes grammar checking, spell checking and sentence structure corrections.
29
+ # @param [ScoreWeights] an object containing the score weights for different writing aspects (e.g., grammar, mechanics). Optional.
30
+ def initialize(enable = false, score = nil)
31
+ unless [true, false].include?(enable)
32
+ raise 'Copyleaks::SubmissionWritingFeedback - enable - enable must be of type Boolean'
33
+ end
34
+ unless score.nil? || score.is_a?(ScoreWeights)
35
+ raise 'Copyleaks::SubmissionWritingFeedback - score - score must be of type ScoreWeights'
36
+ end
37
+
38
+ @enable = enable
39
+ @score = score
40
+ end
41
+
42
+ def as_json(*_args)
43
+ {
44
+ enable: @enable,
45
+ score: @score
46
+ }.reject { |_k, v| v.nil? }
47
+ end
48
+
49
+ def to_json(*options)
50
+ as_json(*options).to_json(*options)
51
+ end
52
+ end
53
+ end
File without changes
@@ -0,0 +1,46 @@
1
+ #The MIT License(MIT)
2
+ #Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
3
+ #Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ #of this software and associated documentation files (the "Software"), to deal
5
+ #in the Software without restriction, including without limitation the rights
6
+ #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ #copies of the Software, and to permit persons to whom the Software is
8
+ #furnished to do so, subject to the following conditions:
9
+ #The above copyright notice and this permission notice shall be included in all
10
+ #copies or substantial portions of the Software.
11
+ #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ #FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
14
+ #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ #SOFTWARE.
18
+ #=
19
+
20
+ module Copyleaks
21
+ class CompletedWebhook < StatusWebhook
22
+ attr_reader :results, :notifications, :scannedDocument
23
+
24
+ def initialize(results: nil, notifications: nil, scannedDocument: nil, **args)
25
+ super(**args)
26
+ @results = results
27
+ @notifications = notifications
28
+ @scannedDocument = scannedDocument
29
+ @extra_fields = args # Store any additional fields here
30
+ end
31
+
32
+ def as_json(*_args)
33
+ super.merge(
34
+ {
35
+ results: @results.respond_to?(:as_json) ? @results.as_json : @results,
36
+ notifications: @notifications.respond_to?(:as_json) ? @notifications.as_json : @notifications,
37
+ scannedDocument: @scannedDocument.respond_to?(:as_json) ? @scannedDocument.as_json : @scannedDocument
38
+ }
39
+ ).merge(@extra_fields)
40
+ end
41
+
42
+ def to_json(*options)
43
+ as_json.to_json(*options)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,43 @@
1
+ #The MIT License(MIT)
2
+ #Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
3
+ #Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ #of this software and associated documentation files (the "Software"), to deal
5
+ #in the Software without restriction, including without limitation the rights
6
+ #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ #copies of the Software, and to permit persons to whom the Software is
8
+ #furnished to do so, subject to the following conditions:
9
+ #The above copyright notice and this permission notice shall be included in all
10
+ #copies or substantial portions of the Software.
11
+ #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ #FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
14
+ #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ #SOFTWARE.
18
+ #=
19
+
20
+ module Copyleaks
21
+ class CreditsCheckedWebhook < StatusWebhook
22
+ attr_reader :credits, :scannedDocument
23
+
24
+ def initialize(credits: nil, scannedDocument: nil, **args)
25
+ super(**args)
26
+ @credits = credits
27
+ @scannedDocument = scannedDocument
28
+ end
29
+
30
+ def as_json(*_args)
31
+ super.merge(
32
+ {
33
+ credits: @credits,
34
+ scannedDocument: @scannedDocument.respond_to?(:as_json) ? @scannedDocument.as_json : @scannedDocument
35
+ }
36
+ )
37
+ end
38
+
39
+ def to_json(*options)
40
+ as_json.to_json(*options)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,41 @@
1
+ #The MIT License(MIT)
2
+ #Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
3
+ #Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ #of this software and associated documentation files (the "Software"), to deal
5
+ #in the Software without restriction, including without limitation the rights
6
+ #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ #copies of the Software, and to permit persons to whom the Software is
8
+ #furnished to do so, subject to the following conditions:
9
+ #The above copyright notice and this permission notice shall be included in all
10
+ #copies or substantial portions of the Software.
11
+ #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ #FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
14
+ #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ #SOFTWARE.
18
+ #=
19
+
20
+ module Copyleaks
21
+ class ErrorWebhook < StatusWebhook
22
+ attr_reader :error
23
+
24
+ def initialize(error: nil, **args)
25
+ super(**args)
26
+ @error = error
27
+ end
28
+
29
+ def as_json(*_args)
30
+ super.merge(
31
+ {
32
+ error: @error.respond_to?(:as_json) ? @error.as_json : @error
33
+ }
34
+ )
35
+ end
36
+
37
+ def to_json(*options)
38
+ as_json.to_json(*options)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,44 @@
1
+ #The MIT License(MIT)
2
+ #Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
3
+ #Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ #of this software and associated documentation files (the "Software"), to deal
5
+ #in the Software without restriction, including without limitation the rights
6
+ #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ #copies of the Software, and to permit persons to whom the Software is
8
+ #furnished to do so, subject to the following conditions:
9
+ #The above copyright notice and this permission notice shall be included in all
10
+ #copies or substantial portions of the Software.
11
+ #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ #FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
14
+ #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ #SOFTWARE.
18
+ #=
19
+
20
+ module Copyleaks
21
+ class ExportCompletedWebhook < Webhook
22
+ attr_reader :completed, :tasks
23
+
24
+ def initialize(completed: nil, tasks: nil, **args)
25
+ super(**args)
26
+ @completed = completed
27
+ @tasks = tasks
28
+ end
29
+
30
+ def as_json(*_args)
31
+ super.merge(
32
+ {
33
+ completed: @completed,
34
+ tasks: @tasks.respond_to?(:map) ? @tasks.map { |t| t.respond_to?(:as_json) ? t.as_json : t } : @tasks
35
+ }
36
+ )
37
+ end
38
+
39
+ def to_json(*options)
40
+ as_json.to_json(*options)
41
+ end
42
+ end
43
+ end
44
+
@@ -0,0 +1,89 @@
1
+
2
+ #The MIT License(MIT)
3
+ #Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
4
+ #Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ #of this software and associated documentation files (the "Software"), to deal
6
+ #in the Software without restriction, including without limitation the rights
7
+ #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ #copies of the Software, and to permit persons to whom the Software is
9
+ #furnished to do so, subject to the following conditions:
10
+ #The above copyright notice and this permission notice shall be included in all
11
+ #copies or substantial portions of the Software.
12
+ #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ #FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
15
+ #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ #SOFTWARE.
19
+ #=
20
+
21
+ module Copyleaks
22
+ class Metadata
23
+ attr_reader :finalUrl, :canonicalUrl, :publishDate, :creationDate,
24
+ :lastModificationDate, :author, :organization, :filename
25
+
26
+ # @param [String] finalUrl - The final URL of the document.
27
+ # @param [String] canonicalUrl - The canonical URL if available.
28
+ # @param [String] publishDate - The date the content was published.
29
+ # @param [String] creationDate - The date the content was created.
30
+ # @param [String] lastModificationDate - The last time the content was modified.
31
+ # @param [String] author - The author of the content.
32
+ # @param [String] organization - The organization associated with the content.
33
+ # @param [String] filename - The original filename of the content.
34
+ def initialize(finalUrl: nil, canonicalUrl: nil, publishDate: nil, creationDate: nil,
35
+ lastModificationDate: nil, author: nil, organization: nil, filename: nil)
36
+
37
+ if !finalUrl.nil? && !finalUrl.is_a?(String)
38
+ raise 'Copyleaks::Metadata - finalUrl must be a String'
39
+ end
40
+ if !canonicalUrl.nil? && !canonicalUrl.is_a?(String)
41
+ raise 'Copyleaks::Metadata - canonicalUrl must be a String'
42
+ end
43
+ if !publishDate.nil? && !publishDate.is_a?(String)
44
+ raise 'Copyleaks::Metadata - publishDate must be a String'
45
+ end
46
+ if !creationDate.nil? && !creationDate.is_a?(String)
47
+ raise 'Copyleaks::Metadata - creationDate must be a String'
48
+ end
49
+ if !lastModificationDate.nil? && !lastModificationDate.is_a?(String)
50
+ raise 'Copyleaks::Metadata - lastModificationDate must be a String'
51
+ end
52
+ if !author.nil? && !author.is_a?(String)
53
+ raise 'Copyleaks::Metadata - author must be a String'
54
+ end
55
+ if !organization.nil? && !organization.is_a?(String)
56
+ raise 'Copyleaks::Metadata - organization must be a String'
57
+ end
58
+ if !filename.nil? && !filename.is_a?(String)
59
+ raise 'Copyleaks::Metadata - filename must be a String'
60
+ end
61
+
62
+ @finalUrl = finalUrl
63
+ @canonicalUrl = canonicalUrl
64
+ @publishDate = publishDate
65
+ @creationDate = creationDate
66
+ @lastModificationDate = lastModificationDate
67
+ @author = author
68
+ @organization = organization
69
+ @filename = filename
70
+ end
71
+
72
+ def as_json(*_args)
73
+ {
74
+ finalUrl: @finalUrl,
75
+ canonicalUrl: @canonicalUrl,
76
+ publishDate: @publishDate,
77
+ creationDate: @creationDate,
78
+ lastModificationDate: @lastModificationDate,
79
+ author: @author,
80
+ organization: @organization,
81
+ filename: @filename
82
+ }.select { |_k, v| !v.nil? }
83
+ end
84
+
85
+ def to_json(*options)
86
+ as_json(*options).to_json(*options)
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,41 @@
1
+ #The MIT License(MIT)
2
+ #Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
3
+ #Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ #of this software and associated documentation files (the "Software"), to deal
5
+ #in the Software without restriction, including without limitation the rights
6
+ #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ #copies of the Software, and to permit persons to whom the Software is
8
+ #furnished to do so, subject to the following conditions:
9
+ #The above copyright notice and this permission notice shall be included in all
10
+ #copies or substantial portions of the Software.
11
+ #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ #FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
14
+ #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ #SOFTWARE.
18
+ #=
19
+ module Copyleaks
20
+ class StatusWebhook < Webhook
21
+ attr_reader :status
22
+
23
+ def initialize(status:, **args)
24
+ unless status.is_a?(Integer)
25
+ raise 'Copyleaks::StatusWebhook - status must be an Integer'
26
+ end
27
+ super(**args)
28
+ @status = status
29
+ end
30
+
31
+ def as_json(*_args)
32
+ {
33
+ status: @status
34
+ }.merge(super)
35
+ end
36
+
37
+ def to_json(*options)
38
+ as_json.to_json(*options)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,43 @@
1
+ #The MIT License(MIT)
2
+ #Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
3
+ #Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ #of this software and associated documentation files (the "Software"), to deal
5
+ #in the Software without restriction, including without limitation the rights
6
+ #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ #copies of the Software, and to permit persons to whom the Software is
8
+ #furnished to do so, subject to the following conditions:
9
+ #The above copyright notice and this permission notice shall be included in all
10
+ #copies or substantial portions of the Software.
11
+ #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ #FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
14
+ #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ #SOFTWARE.
18
+ #=
19
+ module Copyleaks
20
+ class Webhook
21
+
22
+ # @param [String] developerPayload - The developer payload that was provided in the submit method.
23
+ attr_reader :developerPayload
24
+
25
+ def initialize(developerPayload: nil,**args)
26
+ if !developerPayload.nil? && !developerPayload.is_a?(String)
27
+ raise 'Copyleaks::Webhook - developerPayload must be a String'
28
+ end
29
+ @developerPayload = developerPayload
30
+ @extra_fields = args
31
+ end
32
+
33
+ def as_json(*_args)
34
+ {
35
+ developerPayload: @developerPayload
36
+ }.compact
37
+ end
38
+
39
+ def to_json(*options)
40
+ as_json.to_json(*options)
41
+ end
42
+ end
43
+ end