copyleaks 5.0.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 (157) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/CHANGELOG.md +102 -0
  4. data/Gemfile +5 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +487 -0
  7. data/Rakefile +13 -0
  8. data/bin/console +11 -0
  9. data/bin/setup +8 -0
  10. data/lib/copyleaks/ai_detection_client.rb +27 -0
  11. data/lib/copyleaks/ai_image_detection_client.rb +35 -0
  12. data/lib/copyleaks/ai_video_detection_client.rb +20 -0
  13. data/lib/copyleaks/api.rb +247 -0
  14. data/lib/copyleaks/app.config.rb +36 -0
  15. data/lib/copyleaks/image_plagiarism_client.rb +19 -0
  16. data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionExplainModel.rb +26 -0
  17. data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionMatchModel.rb +33 -0
  18. data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionMatchTextModel.rb +31 -0
  19. data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionPatternMatchModel.rb +32 -0
  20. data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionPatternStatisticsModel.rb +46 -0
  21. data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionPatternsModel.rb +38 -0
  22. data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionPositionsModel.rb +39 -0
  23. data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionResponseModel.rb +68 -0
  24. data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionResultModel.rb +41 -0
  25. data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionScannedDocumentModel.rb +21 -0
  26. data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionSummaryModel.rb +34 -0
  27. data/lib/copyleaks/models/auth_token.rb +46 -0
  28. data/lib/copyleaks/models/constants/CopyleaksAiImageDetectionModels.rb +5 -0
  29. data/lib/copyleaks/models/constants/CopyleaksAiImageMaskTypes.rb +11 -0
  30. data/lib/copyleaks/models/constants/CopyleaksAiVideoDetectionModels.rb +5 -0
  31. data/lib/copyleaks/models/constants/CopyleaksAlertCodes.rb +7 -0
  32. data/lib/copyleaks/models/constants/CopyleaksTextModerationConstants.rb +15 -0
  33. data/lib/copyleaks/models/constants/CopyleaksTextModerationLanguages.rb +6 -0
  34. data/lib/copyleaks/models/constants/index.rb +10 -0
  35. data/lib/copyleaks/models/delete_request_model.rb +50 -0
  36. data/lib/copyleaks/models/exceptions/auth_expired_exception.rb +7 -0
  37. data/lib/copyleaks/models/exceptions/command_exception.rb +13 -0
  38. data/lib/copyleaks/models/exceptions/copyleaks_api_exception.rb +18 -0
  39. data/lib/copyleaks/models/exceptions/index.rb +8 -0
  40. data/lib/copyleaks/models/exceptions/rate_limit_exception.rb +8 -0
  41. data/lib/copyleaks/models/exceptions/under_maintenance_exception.rb +8 -0
  42. data/lib/copyleaks/models/exports/export_crawled_version.rb +6 -0
  43. data/lib/copyleaks/models/exports/export_model.rb +87 -0
  44. data/lib/copyleaks/models/exports/export_pdf_report.rb +6 -0
  45. data/lib/copyleaks/models/exports/export_results.rb +30 -0
  46. data/lib/copyleaks/models/exports/export_target.rb +42 -0
  47. data/lib/copyleaks/models/exports/index.rb +8 -0
  48. data/lib/copyleaks/models/id_object.rb +22 -0
  49. data/lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionAsyncRequestModel.rb +63 -0
  50. data/lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb +135 -0
  51. data/lib/copyleaks/models/imageDetection/requests/CopyleaksAsyncWebhooksModel.rb +37 -0
  52. data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectedObjectModel.rb +31 -0
  53. data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionImageInfoModel.rb +31 -0
  54. data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResponseModel.rb +79 -0
  55. data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResultModel.rb +40 -0
  56. data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionScannedDocumentModel.rb +46 -0
  57. data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionSummaryModel.rb +33 -0
  58. data/lib/copyleaks/models/imageDetection/responses/CopyleaksImageMetadataModel.rb +45 -0
  59. data/lib/copyleaks/models/imageDetection/responses/CopyleaksImageShapeModel.rb +31 -0
  60. data/lib/copyleaks/models/imagePlagiarism/requests/CopyleaksImagePlagiarismRequestModel.rb +51 -0
  61. data/lib/copyleaks/models/imagePlagiarism/responses/CopyleaksImagePlagiarismResponseModel.rb +187 -0
  62. data/lib/copyleaks/models/index.rb +51 -0
  63. data/lib/copyleaks/models/start_request_model.rb +40 -0
  64. data/lib/copyleaks/models/submissions/ai_detection/ai_detection_submission_model.rb +25 -0
  65. data/lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb +41 -0
  66. data/lib/copyleaks/models/submissions/file_ocr_submission_model.rb +36 -0
  67. data/lib/copyleaks/models/submissions/file_submission_model.rb +35 -0
  68. data/lib/copyleaks/models/submissions/index.rb +16 -0
  69. data/lib/copyleaks/models/submissions/properties/actions.rb +10 -0
  70. data/lib/copyleaks/models/submissions/properties/ai_generated_text.rb +40 -0
  71. data/lib/copyleaks/models/submissions/properties/ai_generated_text_explain.rb +6 -0
  72. data/lib/copyleaks/models/submissions/properties/ai_source_match.rb +6 -0
  73. data/lib/copyleaks/models/submissions/properties/assignment.rb +6 -0
  74. data/lib/copyleaks/models/submissions/properties/author.rb +18 -0
  75. data/lib/copyleaks/models/submissions/properties/copyleaks_db.rb +22 -0
  76. data/lib/copyleaks/models/submissions/properties/course.rb +6 -0
  77. data/lib/copyleaks/models/submissions/properties/cross_languages.rb +21 -0
  78. data/lib/copyleaks/models/submissions/properties/custom_metadata.rb +19 -0
  79. data/lib/copyleaks/models/submissions/properties/domains_mode.rb +8 -0
  80. data/lib/copyleaks/models/submissions/properties/enable_flag.rb +26 -0
  81. data/lib/copyleaks/models/submissions/properties/exclude.rb +57 -0
  82. data/lib/copyleaks/models/submissions/properties/exclude_code.rb +19 -0
  83. data/lib/copyleaks/models/submissions/properties/filter.rb +49 -0
  84. data/lib/copyleaks/models/submissions/properties/index.rb +43 -0
  85. data/lib/copyleaks/models/submissions/properties/indexing.rb +25 -0
  86. data/lib/copyleaks/models/submissions/properties/indexing_repository.rb +26 -0
  87. data/lib/copyleaks/models/submissions/properties/institution.rb +6 -0
  88. data/lib/copyleaks/models/submissions/properties/internal_ai_source_match.rb +7 -0
  89. data/lib/copyleaks/models/submissions/properties/language.rb +18 -0
  90. data/lib/copyleaks/models/submissions/properties/masking_policy.rb +11 -0
  91. data/lib/copyleaks/models/submissions/properties/overview.rb +42 -0
  92. data/lib/copyleaks/models/submissions/properties/pdf_colors.rb +48 -0
  93. data/lib/copyleaks/models/submissions/properties/pdf_properties.rb +51 -0
  94. data/lib/copyleaks/models/submissions/properties/pdf_report_version.rb +9 -0
  95. data/lib/copyleaks/models/submissions/properties/pdf_version.rb +10 -0
  96. data/lib/copyleaks/models/submissions/properties/references.rb +26 -0
  97. data/lib/copyleaks/models/submissions/properties/repository.rb +18 -0
  98. data/lib/copyleaks/models/submissions/properties/scan_method_algorithm.rb +8 -0
  99. data/lib/copyleaks/models/submissions/properties/scanning.rb +44 -0
  100. data/lib/copyleaks/models/submissions/properties/scanning_exclude.rb +47 -0
  101. data/lib/copyleaks/models/submissions/properties/scanning_include.rb +25 -0
  102. data/lib/copyleaks/models/submissions/properties/scanning_repository.rb +23 -0
  103. data/lib/copyleaks/models/submissions/properties/sensitive_data_protection.rb +42 -0
  104. data/lib/copyleaks/models/submissions/properties/submission_properties.rb +179 -0
  105. data/lib/copyleaks/models/submissions/properties/webhooks.rb +42 -0
  106. data/lib/copyleaks/models/submissions/properties/writing_feedback.rb +30 -0
  107. data/lib/copyleaks/models/submissions/submission_model.rb +24 -0
  108. data/lib/copyleaks/models/submissions/url_submission_model.rb +41 -0
  109. data/lib/copyleaks/models/submissions/webhooks/CompletedWebhook.rb +67 -0
  110. data/lib/copyleaks/models/submissions/webhooks/CreditsCheckedWebhook.rb +24 -0
  111. data/lib/copyleaks/models/submissions/webhooks/ErrorWebhook.rb +22 -0
  112. data/lib/copyleaks/models/submissions/webhooks/ExportCompletedWebhook.rb +25 -0
  113. data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/Metadata.rb +61 -0
  114. data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/StatusWebhook.rb +23 -0
  115. data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/Webhook.rb +25 -0
  116. data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Notifications.rb +24 -0
  117. data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb +54 -0
  118. data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/ScannedDocument.rb +36 -0
  119. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ErrorModels/Error.rb +49 -0
  120. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ExportModels/Task.rb +29 -0
  121. data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultScore.rb +22 -0
  122. data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultsInternet.rb +37 -0
  123. data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultsRepositories.rb +28 -0
  124. data/lib/copyleaks/models/submissions/webhooks/HelperModels/NotificationsModels/Alerts.rb +91 -0
  125. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Batch.rb +26 -0
  126. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Database.rb +26 -0
  127. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Internet.rb +23 -0
  128. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Repositories.rb +36 -0
  129. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/RepositoryMetadata.rb +11 -0
  130. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Score.rb +20 -0
  131. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/SharedResultsModel.rb +22 -0
  132. data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Tags.rb +12 -0
  133. data/lib/copyleaks/models/submissions/webhooks/IndexedWebhook.rb +9 -0
  134. data/lib/copyleaks/models/submissions/webhooks/NewResultWebhook.rb +32 -0
  135. data/lib/copyleaks/models/submissions/webhooks/index.rb +34 -0
  136. data/lib/copyleaks/models/submissions/writing_assistant/score_weights.rb +26 -0
  137. data/lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb +32 -0
  138. data/lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationLabel.rb +21 -0
  139. data/lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb +45 -0
  140. data/lib/copyleaks/models/textModeration/responses/CopyleaksTextModerationResponseModel.rb +55 -0
  141. data/lib/copyleaks/models/textModeration/responses/submodules/ModerationsModel.rb +27 -0
  142. data/lib/copyleaks/models/textModeration/responses/submodules/Text.rb +27 -0
  143. data/lib/copyleaks/models/textModeration/responses/submodules/TextModerationChars.rb +32 -0
  144. data/lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb +55 -0
  145. data/lib/copyleaks/models/textModeration/responses/submodules/TextModerationsLegend.rb +29 -0
  146. data/lib/copyleaks/models/videoDetection/requests/CopyleaksAiVideoDetectionRequestModel.rb +61 -0
  147. data/lib/copyleaks/models/videoDetection/responses/CopyleaksAiVideoDetectionResponseModel.rb +177 -0
  148. data/lib/copyleaks/text_moderation_client.rb +18 -0
  149. data/lib/copyleaks/utils/copyleaks_client.utils.rb +101 -0
  150. data/lib/copyleaks/utils/http_client.rb +164 -0
  151. data/lib/copyleaks/utils/multipart.rb +86 -0
  152. data/lib/copyleaks/utils/status-code.utils.rb +23 -0
  153. data/lib/copyleaks/version.rb +3 -0
  154. data/lib/copyleaks/writing_assistant_client.rb +26 -0
  155. data/lib/copyleaks.rb +11 -0
  156. data/lib/index.rb +4 -0
  157. metadata +248 -0
@@ -0,0 +1,187 @@
1
+ module Copyleaks
2
+ # Metadata about the submitted image and the scan.
3
+ class CopyleaksImagePlagiarismScannedImageModel
4
+ attr_accessor :scan_id, :expected_credits, :actual_credits, :creation_time, :width, :height, :filename
5
+
6
+ def initialize(scan_id: nil, expected_credits: nil, actual_credits: nil, creation_time: nil, width: nil,
7
+ height: nil, filename: nil)
8
+ @scan_id = scan_id
9
+ @expected_credits = expected_credits
10
+ @actual_credits = actual_credits
11
+ @creation_time = creation_time
12
+ @width = width
13
+ @height = height
14
+ @filename = filename
15
+ end
16
+
17
+ def self.from_json(json_hash)
18
+ return nil unless json_hash.is_a?(Hash)
19
+
20
+ new(
21
+ scan_id: json_hash['scanId'],
22
+ expected_credits: json_hash['expectedCredits'],
23
+ actual_credits: json_hash['actualCredits'],
24
+ creation_time: json_hash['creationTime'],
25
+ width: json_hash['width'],
26
+ height: json_hash['height'],
27
+ filename: json_hash['filename']
28
+ )
29
+ end
30
+
31
+ def as_json(*_args)
32
+ {
33
+ 'scanId' => @scan_id,
34
+ 'expectedCredits' => @expected_credits,
35
+ 'actualCredits' => @actual_credits,
36
+ 'creationTime' => @creation_time,
37
+ 'width' => @width,
38
+ 'height' => @height,
39
+ 'filename' => @filename
40
+ }.reject { |_k, v| v.nil? }
41
+ end
42
+
43
+ def to_json(*args)
44
+ as_json.to_json(*args)
45
+ end
46
+ end
47
+
48
+ # One image found on the web.
49
+ class CopyleaksImagePlagiarismInternetMatchModel
50
+ # matchType values
51
+ FULL = 0
52
+ PARTIAL = 1
53
+
54
+ # @return [String] The URL of the matching image.
55
+ attr_accessor :url
56
+ # @return [Integer] 0 (full: exact or near-exact copy) or 1 (partial: cropped, resized or modified).
57
+ attr_accessor :match_type
58
+ # @return [Array<String>, nil] URLs of the web pages where the image was found. nil when none were found.
59
+ attr_accessor :web_pages
60
+
61
+ def initialize(url: nil, match_type: nil, web_pages: nil)
62
+ @url = url
63
+ @match_type = match_type
64
+ @web_pages = web_pages
65
+ end
66
+
67
+ def self.from_json(json_hash)
68
+ return nil unless json_hash.is_a?(Hash)
69
+
70
+ pages = json_hash['webPages']
71
+ new(
72
+ url: json_hash['url'],
73
+ match_type: json_hash['matchType'],
74
+ web_pages: pages.is_a?(Array) ? pages.map { |page| page.is_a?(Hash) ? page['url'] : page } : nil
75
+ )
76
+ end
77
+
78
+ def as_json(*_args)
79
+ {
80
+ 'url' => @url,
81
+ 'matchType' => @match_type,
82
+ 'webPages' => @web_pages&.map { |page_url| { 'url' => page_url } }
83
+ }.reject { |_k, v| v.nil? }
84
+ end
85
+
86
+ def to_json(*args)
87
+ as_json.to_json(*args)
88
+ end
89
+ end
90
+
91
+ # Match counts.
92
+ class CopyleaksImagePlagiarismScoreModel
93
+ attr_accessor :total_matches, :full_matches, :partial_matches
94
+
95
+ def initialize(total_matches: nil, full_matches: nil, partial_matches: nil)
96
+ @total_matches = total_matches
97
+ @full_matches = full_matches
98
+ @partial_matches = partial_matches
99
+ end
100
+
101
+ def self.from_json(json_hash)
102
+ return nil unless json_hash.is_a?(Hash)
103
+
104
+ new(
105
+ total_matches: json_hash['totalMatches'],
106
+ full_matches: json_hash['fullMatches'],
107
+ partial_matches: json_hash['partialMatches']
108
+ )
109
+ end
110
+
111
+ def as_json(*_args)
112
+ {
113
+ 'totalMatches' => @total_matches,
114
+ 'fullMatches' => @full_matches,
115
+ 'partialMatches' => @partial_matches
116
+ }.reject { |_k, v| v.nil? }
117
+ end
118
+
119
+ def to_json(*args)
120
+ as_json.to_json(*args)
121
+ end
122
+ end
123
+
124
+ # The detection results.
125
+ class CopyleaksImagePlagiarismMatchesModel
126
+ attr_accessor :internet, :score
127
+
128
+ def initialize(internet: nil, score: nil)
129
+ @internet = internet
130
+ @score = score
131
+ end
132
+
133
+ def self.from_json(json_hash)
134
+ return nil unless json_hash.is_a?(Hash)
135
+
136
+ internet = json_hash['internet']
137
+ new(
138
+ internet: internet.is_a?(Array) ? internet.map { |m| CopyleaksImagePlagiarismInternetMatchModel.from_json(m) } : nil,
139
+ score: CopyleaksImagePlagiarismScoreModel.from_json(json_hash['score'])
140
+ )
141
+ end
142
+
143
+ def as_json(*_args)
144
+ {
145
+ 'internet' => @internet&.map(&:as_json),
146
+ 'score' => @score&.as_json
147
+ }.reject { |_k, v| v.nil? }
148
+ end
149
+
150
+ def to_json(*args)
151
+ as_json.to_json(*args)
152
+ end
153
+ end
154
+
155
+ # Image Plagiarism Detector response.
156
+ class CopyleaksImagePlagiarismResponseModel
157
+ attr_accessor :developer_payload, :scanned_image, :matches
158
+
159
+ def initialize(developer_payload: nil, scanned_image: nil, matches: nil)
160
+ @developer_payload = developer_payload
161
+ @scanned_image = scanned_image
162
+ @matches = matches
163
+ end
164
+
165
+ def self.from_json(json_hash)
166
+ return nil unless json_hash.is_a?(Hash)
167
+
168
+ new(
169
+ developer_payload: json_hash['developerPayload'],
170
+ scanned_image: CopyleaksImagePlagiarismScannedImageModel.from_json(json_hash['scannedImage']),
171
+ matches: CopyleaksImagePlagiarismMatchesModel.from_json(json_hash['matches'])
172
+ )
173
+ end
174
+
175
+ def as_json(*_args)
176
+ {
177
+ 'developerPayload' => @developer_payload,
178
+ 'scannedImage' => @scanned_image&.as_json,
179
+ 'matches' => @matches&.as_json
180
+ }.reject { |_k, v| v.nil? }
181
+ end
182
+
183
+ def to_json(*args)
184
+ as_json.to_json(*args)
185
+ end
186
+ end
187
+ end
@@ -0,0 +1,51 @@
1
+ require_relative 'constants/index.rb'
2
+ require_relative 'exceptions/index.rb'
3
+ require_relative 'exports/index.rb'
4
+ require_relative 'submissions/index.rb'
5
+ require_relative 'auth_token.rb'
6
+
7
+ require_relative 'id_object.rb'
8
+ require_relative 'delete_request_model.rb'
9
+ require_relative 'start_request_model.rb'
10
+
11
+ require_relative 'textModeration/requests/CopyleaksTextModerationRequestModel.rb'
12
+ require_relative 'textModeration/requests/CopyleaksTextModerationLabel.rb'
13
+ require_relative 'textModeration/responses/submodules/ModerationsModel.rb'
14
+ require_relative 'textModeration/responses/submodules/Text.rb'
15
+ require_relative 'textModeration/responses/submodules/TextModerationChars.rb'
16
+ require_relative 'textModeration/responses/submodules/TextModerationScannedDocument.rb'
17
+ require_relative 'textModeration/responses/submodules/TextModerationsLegend.rb'
18
+ require_relative 'textModeration/responses/CopyleaksTextModerationResponseModel.rb'
19
+
20
+ require_relative 'imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb'
21
+ require_relative 'imageDetection/requests/CopyleaksAsyncWebhooksModel.rb'
22
+ require_relative 'imageDetection/requests/CopyleaksAiImageDetectionAsyncRequestModel.rb'
23
+ require_relative 'imageDetection/responses/CopyleaksAiImageDetectionResponseModel.rb'
24
+ require_relative 'imageDetection/responses/CopyleaksAiImageDetectionResultModel.rb'
25
+ require_relative 'imageDetection/responses/CopyleaksAiImageDetectionImageInfoModel.rb'
26
+ require_relative 'imageDetection/responses/CopyleaksAiImageDetectionScannedDocumentModel.rb'
27
+ require_relative 'imageDetection/responses/CopyleaksAiImageDetectionSummaryModel.rb'
28
+ require_relative 'imageDetection/responses/CopyleaksImageMetadataModel.rb'
29
+ require_relative 'imageDetection/responses/CopyleaksImageShapeModel.rb'
30
+ require_relative 'imageDetection/responses/CopyleaksAiImageDetectedObjectModel.rb'
31
+
32
+ require_relative 'videoDetection/requests/CopyleaksAiVideoDetectionRequestModel.rb'
33
+ require_relative 'videoDetection/responses/CopyleaksAiVideoDetectionResponseModel.rb'
34
+
35
+ require_relative 'imagePlagiarism/requests/CopyleaksImagePlagiarismRequestModel.rb'
36
+ require_relative 'imagePlagiarism/responses/CopyleaksImagePlagiarismResponseModel.rb'
37
+
38
+ require_relative 'aiDetection/responses/CopyleaksAiTextDetectionResponseModel.rb'
39
+ require_relative 'aiDetection/responses/CopyleaksAiTextDetectionResultModel.rb'
40
+ require_relative 'aiDetection/responses/CopyleaksAiTextDetectionMatchModel.rb'
41
+ require_relative 'aiDetection/responses/CopyleaksAiTextDetectionMatchTextModel.rb'
42
+ require_relative 'aiDetection/responses/CopyleaksAiTextDetectionPositionsModel.rb'
43
+ require_relative 'aiDetection/responses/CopyleaksAiTextDetectionSummaryModel.rb'
44
+ require_relative 'aiDetection/responses/CopyleaksAiTextDetectionExplainModel.rb'
45
+ require_relative 'aiDetection/responses/CopyleaksAiTextDetectionPatternsModel.rb'
46
+ require_relative 'aiDetection/responses/CopyleaksAiTextDetectionPatternStatisticsModel.rb'
47
+ require_relative 'aiDetection/responses/CopyleaksAiTextDetectionPatternMatchModel.rb'
48
+ require_relative 'aiDetection/responses/CopyleaksAiTextDetectionScannedDocumentModel.rb'
49
+
50
+ module Copyleaks
51
+ end
@@ -0,0 +1,40 @@
1
+ module Copyleaks
2
+ class CopyleaksStartRequestModel
3
+ attr_reader :trigger, :errorHandling
4
+
5
+ # @param [Array<String>] trigger Ids of scans submitted for a credits check, to run as full scans.
6
+ # @param [Integer] errorHandling See CopyleaksStartErrorHandlings.
7
+ def initialize(trigger, errorHandling = CopyleaksStartErrorHandlings::IGNORE)
8
+ trigger.each do |item|
9
+ unless item.instance_of?(String)
10
+ raise 'Copyleaks::CopyleaksStartRequestModel - trigger - entity must be of type String'
11
+ end
12
+ end
13
+
14
+ unless [0, 1].include? errorHandling
15
+ raise 'Copyleaks::CopyleaksStartRequestModel - errorHandling - errorHandling must be of type Copyleaks::CopyleaksStartErrorHandlings Consts'
16
+ end
17
+
18
+ @trigger = trigger
19
+ @errorHandling = errorHandling
20
+ end
21
+
22
+ def as_json(*_args)
23
+ {
24
+ trigger: @trigger,
25
+ errorHandling: @errorHandling
26
+ }.select { |_k, v| !v.nil? }
27
+ end
28
+
29
+ def to_json(*options)
30
+ as_json(*options).to_json(*options)
31
+ end
32
+ end
33
+
34
+ class CopyleaksStartErrorHandlings
35
+ # Cancel the request if any scan has an error.
36
+ CANCEL = 0
37
+ # Start the trigger scans even if some of them have errors.
38
+ IGNORE = 1
39
+ end
40
+ end
@@ -0,0 +1,25 @@
1
+ module Copyleaks
2
+ class AIDetectionSubmissionModel
3
+ attr_accessor :text, :sandbox
4
+
5
+ # @param [Boolean] sandbox Free test mode. nil omits the field (server default: false).
6
+ def initialize(text, sandbox = nil)
7
+ unless text.instance_of?(String)
8
+ raise 'Copyleaks::AIDetectionSubmissionModel - text - text must be of type String'
9
+ end
10
+ @text = text
11
+ @sandbox = sandbox
12
+ end
13
+
14
+ def as_json(*_args)
15
+ {
16
+ 'text' => @text,
17
+ 'sandbox' => @sandbox
18
+ }.reject { |_, v| v.nil? }
19
+ end
20
+
21
+ def to_json(*options)
22
+ as_json(*options).to_json(*options)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,41 @@
1
+ module Copyleaks
2
+ class NaturalLanguageSubmissionModel < AIDetectionSubmissionModel
3
+ attr_accessor :language, :explain, :sensitivity
4
+
5
+ # Arguments left nil are not sent, so the server default applies.
6
+ # @param [String] text 255 to 100,000 characters.
7
+ # @param [String] language Language code; auto-detected when nil.
8
+ # @param [Boolean] sandbox Free test mode (server default: false).
9
+ # @param [Boolean] explain AI Logic: the response includes explain, the patterns behind the result. Default false.
10
+ # @param [Integer] sensitivity 1 to 3, default 2: 1 finds unedited AI text, 3 also heavily edited AI text.
11
+ def initialize(text, language = nil, sandbox = nil, explain: nil, sensitivity: nil)
12
+ unless text.instance_of?(String)
13
+ raise 'Copyleaks::NaturalLanguageSubmissionModel - text - text must be of type String'
14
+ end
15
+ if !explain.nil? && ![true, false].include?(explain)
16
+ raise 'Copyleaks::NaturalLanguageSubmissionModel - explain - explain must be of type Boolean'
17
+ end
18
+ if !sensitivity.nil? && !(sensitivity.is_a?(Integer) && sensitivity.between?(1, 3))
19
+ raise 'Copyleaks::NaturalLanguageSubmissionModel - sensitivity - sensitivity must be an Integer from 1 to 3'
20
+ end
21
+ super(text, sandbox)
22
+ @language = language
23
+ @explain = explain
24
+ @sensitivity = sensitivity
25
+ end
26
+
27
+ def as_json(*_args)
28
+ {
29
+ text: @text,
30
+ sandbox: @sandbox,
31
+ language: @language,
32
+ explain: @explain,
33
+ sensitivity: @sensitivity
34
+ }.select { |_k, v| !v.nil? }
35
+ end
36
+
37
+ def to_json(*options)
38
+ as_json(*options).to_json(*options)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,36 @@
1
+ module Copyleaks
2
+ class CopyleaksFileOcrSubmissionModel < CopyleaksFileSubmissionModel
3
+ # Same as CopyleaksFileSubmissionModel, plus the content language.
4
+ # @param [String] langCode One of API#get_ocr_supported_languages.
5
+ def initialize(langCode, base64, filename, properties)
6
+ unless langCode.instance_of?(String)
7
+ raise 'Copyleaks::CopyleaksFileOcrSubmissionModel - langCode - langCode must be of type String'
8
+ end
9
+ unless base64.instance_of?(String)
10
+ raise 'Copyleaks::CopyleaksFileOcrSubmissionModel - base64 - base64 must be of type String'
11
+ end
12
+ unless filename.instance_of?(String)
13
+ raise 'Copyleaks::CopyleaksFileOcrSubmissionModel - filename - filename must be of type String'
14
+ end
15
+ unless properties.instance_of?(SubmissionProperties)
16
+ raise 'Copyleaks::CopyleaksFileOcrSubmissionModel - properties - properties must be of type SubmissionProperties'
17
+ end
18
+
19
+ super(base64, filename, properties)
20
+ @langCode = langCode
21
+ end
22
+
23
+ def as_json(*_args)
24
+ {
25
+ langCode: @langCode,
26
+ base64: @base64,
27
+ filename: @filename,
28
+ properties: @properties
29
+ }.select { |_k, v| !v.nil? }
30
+ end
31
+
32
+ def to_json(*options)
33
+ as_json(*options).to_json(*options)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,35 @@
1
+ module Copyleaks
2
+ class CopyleaksFileSubmissionModel < CopyleaksSubmissionModel
3
+ attr_reader :base64, :filename, :properties
4
+
5
+ # @param [String] base64 The file, base64-encoded. To scan plain text, base64-encode it.
6
+ # @param [String] filename Shown in the scan report; include the right extension.
7
+ def initialize(base64, filename, properties)
8
+ unless base64.instance_of?(String)
9
+ raise 'Copyleaks::CopyleaksFileSubmissionModel - base64 - base64 must be of type String'
10
+ end
11
+ unless filename.instance_of?(String)
12
+ raise 'Copyleaks::CopyleaksFileSubmissionModel - filename - filename must be of type String'
13
+ end
14
+ unless properties.instance_of?(SubmissionProperties)
15
+ raise 'Copyleaks::CopyleaksFileSubmissionModel - properties - properties must be of type SubmissionProperties'
16
+ end
17
+
18
+ super(properties)
19
+ @base64 = base64
20
+ @filename = filename
21
+ end
22
+
23
+ def as_json(*_args)
24
+ {
25
+ base64: @base64,
26
+ filename: @filename,
27
+ properties: @properties
28
+ }.select { |_k, v| !v.nil? }
29
+ end
30
+
31
+ def to_json(*options)
32
+ as_json(*options).to_json(*options)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'properties/index.rb'
2
+
3
+ require_relative 'submission_model.rb'
4
+ require_relative 'file_submission_model.rb'
5
+ require_relative 'file_ocr_submission_model.rb'
6
+ require_relative 'url_submission_model.rb'
7
+
8
+ require_relative 'ai_detection/ai_detection_submission_model.rb'
9
+ require_relative 'ai_detection/natural_language_submission_model.rb'
10
+ require_relative 'webhooks/index.rb'
11
+
12
+ require_relative 'writing_assistant/score_weights.rb'
13
+ require_relative 'writing_assistant/writing_assistant_submission_model.rb'
14
+
15
+ module Copyleaks
16
+ end
@@ -0,0 +1,10 @@
1
+ module Copyleaks
2
+ class SubmissionActions
3
+ # Start the scan immediately.
4
+ SCAN = 0
5
+ # Only report how many credits the scan would use.
6
+ CHECKCREDITS = 1
7
+ # Only index the file in the Copyleaks internal database; uses no credits.
8
+ INDEXONLY = 2
9
+ end
10
+ end
@@ -0,0 +1,40 @@
1
+ module Copyleaks
2
+ class SubmissionAiGeneratedText
3
+ attr_reader :detect, :sensitivity, :explain
4
+
5
+ # Fields left nil are not sent, so the server default applies.
6
+ # @param [Boolean] detect Detect AI-written text (server default: false).
7
+ # @param [Integer] sensitivity 1 to 3, default 2: 1 finds unedited AI text, 3 also heavily edited AI text.
8
+ # @param [SubmissionAiGeneratedTextExplain, Boolean] explain AI Logic explanations.
9
+ # true is the same as SubmissionAiGeneratedTextExplain.new(true).
10
+ def initialize(detect = nil, sensitivity: nil, explain: nil)
11
+ if !detect.nil? && ![true, false].include?(detect)
12
+ raise 'Copyleaks::SubmissionAiGeneratedText - detect - detect must be of type Boolean'
13
+ end
14
+ if !sensitivity.nil? && !(sensitivity.is_a?(Integer) && sensitivity.between?(1, 3))
15
+ raise 'Copyleaks::SubmissionAiGeneratedText - sensitivity - sensitivity must be an Integer from 1 to 3'
16
+ end
17
+
18
+ explain = SubmissionAiGeneratedTextExplain.new(explain) if [true, false].include?(explain)
19
+ if !explain.nil? && !explain.instance_of?(SubmissionAiGeneratedTextExplain)
20
+ raise 'Copyleaks::SubmissionAiGeneratedText - explain - explain must be of type SubmissionAiGeneratedTextExplain'
21
+ end
22
+
23
+ @detect = detect
24
+ @sensitivity = sensitivity
25
+ @explain = explain
26
+ end
27
+
28
+ def as_json(*_args)
29
+ {
30
+ detect: @detect,
31
+ sensitivity: @sensitivity,
32
+ explain: @explain
33
+ }.select { |_k, v| !v.nil? }
34
+ end
35
+
36
+ def to_json(*options)
37
+ as_json(*options).to_json(*options)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,6 @@
1
+ require_relative 'enable_flag.rb'
2
+
3
+ module Copyleaks
4
+ # AI Logic settings for AI-generated text detection in a scan.
5
+ class SubmissionAiGeneratedTextExplain < SubmissionEnableFlag; end
6
+ end
@@ -0,0 +1,6 @@
1
+ require_relative 'enable_flag.rb'
2
+
3
+ module Copyleaks
4
+ # Find online sources suspected of containing AI-generated text. English documents only.
5
+ class SubmissionAiSourceMatch < SubmissionEnableFlag; end
6
+ end
@@ -0,0 +1,6 @@
1
+ require_relative '../../id_object.rb'
2
+
3
+ module Copyleaks
4
+ # The assignment of the submission, for analytics. new(id) takes a unique assignment id String.
5
+ class SubmissionAssignment < IdObject; end
6
+ end
@@ -0,0 +1,18 @@
1
+ module Copyleaks
2
+ class SubmissionAuthor
3
+ # @param [String] id Unique author id. Reuse it for the same author so Copyleaks learns their writing patterns.
4
+ def initialize(id)
5
+ @id = id
6
+ end
7
+
8
+ def as_json(*_args)
9
+ {
10
+ id: @id
11
+ }.select { |_k, v| !v.nil? }
12
+ end
13
+
14
+ def to_json(*options)
15
+ as_json(*options).to_json(*options)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ module Copyleaks
2
+ class SubmissionScanningCopyleaksDB
3
+ # Arguments left nil are not sent. Either flag set to true also indexes the scan in the internal database.
4
+ # @param [Boolean] includeMySubmissions Also compare against content YOU uploaded to the internal database.
5
+ # @param [Boolean] includeOthersSubmissions Also compare against content OTHERS uploaded to the internal database.
6
+ def initialize(includeMySubmissions = nil, includeOthersSubmissions = nil)
7
+ @includeMySubmissions = includeMySubmissions
8
+ @includeOthersSubmissions = includeOthersSubmissions
9
+ end
10
+
11
+ def as_json(*_args)
12
+ {
13
+ includeMySubmissions: @includeMySubmissions,
14
+ includeOthersSubmissions: @includeOthersSubmissions
15
+ }.select { |_k, v| !v.nil? }
16
+ end
17
+
18
+ def to_json(*options)
19
+ as_json(*options).to_json(*options)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,6 @@
1
+ require_relative '../../id_object.rb'
2
+
3
+ module Copyleaks
4
+ # The course of the submission, for analytics. new(id) takes a unique course id String.
5
+ class SubmissionCourse < IdObject; end
6
+ end
@@ -0,0 +1,21 @@
1
+ module Copyleaks
2
+ class SubmissionCrossLanguages
3
+ # @param [Language[]] languages - Languages to scan your content against.
4
+ def initialize(languages = nil)
5
+ if !languages.nil? && !(languages.is_a?(Array) && languages.all? { |element| element.is_a?(SubmissionLanguage) })
6
+ raise 'Copyleaks::SubmissionCrossLanguages - languages - languages must be of type SubmissionLanguage[]'
7
+ end
8
+ @languages = languages
9
+ end
10
+
11
+ def as_json(*_args)
12
+ {
13
+ languages: @languages,
14
+ }.select { |_k, v| !v.nil? }
15
+ end
16
+
17
+ def to_json(*options)
18
+ as_json(*options).to_json(*options)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ module Copyleaks
2
+ class SubmissionCustomMetadata
3
+ def initialize(key, value)
4
+ @key = key
5
+ @value = value
6
+ end
7
+
8
+ def as_json(*_args)
9
+ {
10
+ key: @key,
11
+ value: @value
12
+ }.select { |_k, v| !v.nil? }
13
+ end
14
+
15
+ def to_json(*options)
16
+ as_json(*options).to_json(*options)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ module Copyleaks
2
+ class SubmissionFilterDomainsMode
3
+ # Only results from the properties.filters.domains list.
4
+ INCLUDE = 0
5
+ # Only results outside the properties.filters.domains list.
6
+ EXCLUDE = 1
7
+ end
8
+ end
@@ -0,0 +1,26 @@
1
+ module Copyleaks
2
+ # A property with a single enable flag. Base of SubmissionAiSourceMatch, SubmissionInternalAiSourceMatch and
3
+ # SubmissionAiGeneratedTextExplain.
4
+ class SubmissionEnableFlag
5
+ attr_reader :enable
6
+
7
+ # @param [Boolean] enable nil omits the field (server default: false).
8
+ def initialize(enable = nil)
9
+ if !enable.nil? && ![true, false].include?(enable)
10
+ raise "Copyleaks::#{self.class.name.split('::').last} - enable - enable must be of type Boolean"
11
+ end
12
+
13
+ @enable = enable
14
+ end
15
+
16
+ def as_json(*_args)
17
+ {
18
+ enable: @enable
19
+ }.select { |_k, v| !v.nil? }
20
+ end
21
+
22
+ def to_json(*options)
23
+ as_json(*options).to_json(*options)
24
+ end
25
+ end
26
+ end