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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/CHANGELOG.md +102 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +487 -0
- data/Rakefile +13 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/copyleaks/ai_detection_client.rb +27 -0
- data/lib/copyleaks/ai_image_detection_client.rb +35 -0
- data/lib/copyleaks/ai_video_detection_client.rb +20 -0
- data/lib/copyleaks/api.rb +247 -0
- data/lib/copyleaks/app.config.rb +36 -0
- data/lib/copyleaks/image_plagiarism_client.rb +19 -0
- data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionExplainModel.rb +26 -0
- data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionMatchModel.rb +33 -0
- data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionMatchTextModel.rb +31 -0
- data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionPatternMatchModel.rb +32 -0
- data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionPatternStatisticsModel.rb +46 -0
- data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionPatternsModel.rb +38 -0
- data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionPositionsModel.rb +39 -0
- data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionResponseModel.rb +68 -0
- data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionResultModel.rb +41 -0
- data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionScannedDocumentModel.rb +21 -0
- data/lib/copyleaks/models/aiDetection/responses/CopyleaksAiTextDetectionSummaryModel.rb +34 -0
- data/lib/copyleaks/models/auth_token.rb +46 -0
- data/lib/copyleaks/models/constants/CopyleaksAiImageDetectionModels.rb +5 -0
- data/lib/copyleaks/models/constants/CopyleaksAiImageMaskTypes.rb +11 -0
- data/lib/copyleaks/models/constants/CopyleaksAiVideoDetectionModels.rb +5 -0
- data/lib/copyleaks/models/constants/CopyleaksAlertCodes.rb +7 -0
- data/lib/copyleaks/models/constants/CopyleaksTextModerationConstants.rb +15 -0
- data/lib/copyleaks/models/constants/CopyleaksTextModerationLanguages.rb +6 -0
- data/lib/copyleaks/models/constants/index.rb +10 -0
- data/lib/copyleaks/models/delete_request_model.rb +50 -0
- data/lib/copyleaks/models/exceptions/auth_expired_exception.rb +7 -0
- data/lib/copyleaks/models/exceptions/command_exception.rb +13 -0
- data/lib/copyleaks/models/exceptions/copyleaks_api_exception.rb +18 -0
- data/lib/copyleaks/models/exceptions/index.rb +8 -0
- data/lib/copyleaks/models/exceptions/rate_limit_exception.rb +8 -0
- data/lib/copyleaks/models/exceptions/under_maintenance_exception.rb +8 -0
- data/lib/copyleaks/models/exports/export_crawled_version.rb +6 -0
- data/lib/copyleaks/models/exports/export_model.rb +87 -0
- data/lib/copyleaks/models/exports/export_pdf_report.rb +6 -0
- data/lib/copyleaks/models/exports/export_results.rb +30 -0
- data/lib/copyleaks/models/exports/export_target.rb +42 -0
- data/lib/copyleaks/models/exports/index.rb +8 -0
- data/lib/copyleaks/models/id_object.rb +22 -0
- data/lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionAsyncRequestModel.rb +63 -0
- data/lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb +135 -0
- data/lib/copyleaks/models/imageDetection/requests/CopyleaksAsyncWebhooksModel.rb +37 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectedObjectModel.rb +31 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionImageInfoModel.rb +31 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResponseModel.rb +79 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResultModel.rb +40 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionScannedDocumentModel.rb +46 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionSummaryModel.rb +33 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksImageMetadataModel.rb +45 -0
- data/lib/copyleaks/models/imageDetection/responses/CopyleaksImageShapeModel.rb +31 -0
- data/lib/copyleaks/models/imagePlagiarism/requests/CopyleaksImagePlagiarismRequestModel.rb +51 -0
- data/lib/copyleaks/models/imagePlagiarism/responses/CopyleaksImagePlagiarismResponseModel.rb +187 -0
- data/lib/copyleaks/models/index.rb +51 -0
- data/lib/copyleaks/models/start_request_model.rb +40 -0
- data/lib/copyleaks/models/submissions/ai_detection/ai_detection_submission_model.rb +25 -0
- data/lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb +41 -0
- data/lib/copyleaks/models/submissions/file_ocr_submission_model.rb +36 -0
- data/lib/copyleaks/models/submissions/file_submission_model.rb +35 -0
- data/lib/copyleaks/models/submissions/index.rb +16 -0
- data/lib/copyleaks/models/submissions/properties/actions.rb +10 -0
- data/lib/copyleaks/models/submissions/properties/ai_generated_text.rb +40 -0
- data/lib/copyleaks/models/submissions/properties/ai_generated_text_explain.rb +6 -0
- data/lib/copyleaks/models/submissions/properties/ai_source_match.rb +6 -0
- data/lib/copyleaks/models/submissions/properties/assignment.rb +6 -0
- data/lib/copyleaks/models/submissions/properties/author.rb +18 -0
- data/lib/copyleaks/models/submissions/properties/copyleaks_db.rb +22 -0
- data/lib/copyleaks/models/submissions/properties/course.rb +6 -0
- data/lib/copyleaks/models/submissions/properties/cross_languages.rb +21 -0
- data/lib/copyleaks/models/submissions/properties/custom_metadata.rb +19 -0
- data/lib/copyleaks/models/submissions/properties/domains_mode.rb +8 -0
- data/lib/copyleaks/models/submissions/properties/enable_flag.rb +26 -0
- data/lib/copyleaks/models/submissions/properties/exclude.rb +57 -0
- data/lib/copyleaks/models/submissions/properties/exclude_code.rb +19 -0
- data/lib/copyleaks/models/submissions/properties/filter.rb +49 -0
- data/lib/copyleaks/models/submissions/properties/index.rb +43 -0
- data/lib/copyleaks/models/submissions/properties/indexing.rb +25 -0
- data/lib/copyleaks/models/submissions/properties/indexing_repository.rb +26 -0
- data/lib/copyleaks/models/submissions/properties/institution.rb +6 -0
- data/lib/copyleaks/models/submissions/properties/internal_ai_source_match.rb +7 -0
- data/lib/copyleaks/models/submissions/properties/language.rb +18 -0
- data/lib/copyleaks/models/submissions/properties/masking_policy.rb +11 -0
- data/lib/copyleaks/models/submissions/properties/overview.rb +42 -0
- data/lib/copyleaks/models/submissions/properties/pdf_colors.rb +48 -0
- data/lib/copyleaks/models/submissions/properties/pdf_properties.rb +51 -0
- data/lib/copyleaks/models/submissions/properties/pdf_report_version.rb +9 -0
- data/lib/copyleaks/models/submissions/properties/pdf_version.rb +10 -0
- data/lib/copyleaks/models/submissions/properties/references.rb +26 -0
- data/lib/copyleaks/models/submissions/properties/repository.rb +18 -0
- data/lib/copyleaks/models/submissions/properties/scan_method_algorithm.rb +8 -0
- data/lib/copyleaks/models/submissions/properties/scanning.rb +44 -0
- data/lib/copyleaks/models/submissions/properties/scanning_exclude.rb +47 -0
- data/lib/copyleaks/models/submissions/properties/scanning_include.rb +25 -0
- data/lib/copyleaks/models/submissions/properties/scanning_repository.rb +23 -0
- data/lib/copyleaks/models/submissions/properties/sensitive_data_protection.rb +42 -0
- data/lib/copyleaks/models/submissions/properties/submission_properties.rb +179 -0
- data/lib/copyleaks/models/submissions/properties/webhooks.rb +42 -0
- data/lib/copyleaks/models/submissions/properties/writing_feedback.rb +30 -0
- data/lib/copyleaks/models/submissions/submission_model.rb +24 -0
- data/lib/copyleaks/models/submissions/url_submission_model.rb +41 -0
- data/lib/copyleaks/models/submissions/webhooks/CompletedWebhook.rb +67 -0
- data/lib/copyleaks/models/submissions/webhooks/CreditsCheckedWebhook.rb +24 -0
- data/lib/copyleaks/models/submissions/webhooks/ErrorWebhook.rb +22 -0
- data/lib/copyleaks/models/submissions/webhooks/ExportCompletedWebhook.rb +25 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/Metadata.rb +61 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/StatusWebhook.rb +23 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/Webhook.rb +25 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Notifications.rb +24 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb +54 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/ScannedDocument.rb +36 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ErrorModels/Error.rb +49 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ExportModels/Task.rb +29 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultScore.rb +22 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultsInternet.rb +37 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultsRepositories.rb +28 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/NotificationsModels/Alerts.rb +91 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Batch.rb +26 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Database.rb +26 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Internet.rb +23 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Repositories.rb +36 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/RepositoryMetadata.rb +11 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Score.rb +20 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/SharedResultsModel.rb +22 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Tags.rb +12 -0
- data/lib/copyleaks/models/submissions/webhooks/IndexedWebhook.rb +9 -0
- data/lib/copyleaks/models/submissions/webhooks/NewResultWebhook.rb +32 -0
- data/lib/copyleaks/models/submissions/webhooks/index.rb +34 -0
- data/lib/copyleaks/models/submissions/writing_assistant/score_weights.rb +26 -0
- data/lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb +32 -0
- data/lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationLabel.rb +21 -0
- data/lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb +45 -0
- data/lib/copyleaks/models/textModeration/responses/CopyleaksTextModerationResponseModel.rb +55 -0
- data/lib/copyleaks/models/textModeration/responses/submodules/ModerationsModel.rb +27 -0
- data/lib/copyleaks/models/textModeration/responses/submodules/Text.rb +27 -0
- data/lib/copyleaks/models/textModeration/responses/submodules/TextModerationChars.rb +32 -0
- data/lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb +55 -0
- data/lib/copyleaks/models/textModeration/responses/submodules/TextModerationsLegend.rb +29 -0
- data/lib/copyleaks/models/videoDetection/requests/CopyleaksAiVideoDetectionRequestModel.rb +61 -0
- data/lib/copyleaks/models/videoDetection/responses/CopyleaksAiVideoDetectionResponseModel.rb +177 -0
- data/lib/copyleaks/text_moderation_client.rb +18 -0
- data/lib/copyleaks/utils/copyleaks_client.utils.rb +101 -0
- data/lib/copyleaks/utils/http_client.rb +164 -0
- data/lib/copyleaks/utils/multipart.rb +86 -0
- data/lib/copyleaks/utils/status-code.utils.rb +23 -0
- data/lib/copyleaks/version.rb +3 -0
- data/lib/copyleaks/writing_assistant_client.rb +26 -0
- data/lib/copyleaks.rb +11 -0
- data/lib/index.rb +4 -0
- metadata +248 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
# Scan settings. Only webhooks is required; arguments left nil are not sent, so the server default applies.
|
|
3
|
+
class SubmissionProperties
|
|
4
|
+
attr_reader :webhooks, :includeHtml, :developerPayload, :sandbox, :expiration, :sensitivityLevel, :cheatDetection,
|
|
5
|
+
:action, :author, :filters, :scanning, :indexing, :exclude, :pdf, :sensitiveDataProtection, :scanMethodAlgorithm,
|
|
6
|
+
:aiGeneratedText, :customMetadata, :writingFeedback, :displayLanguage, :aiSourceMatch,
|
|
7
|
+
:overview, :internalAiSourceMatch, :references, :scanTimeZone, :course, :assignment, :institution
|
|
8
|
+
|
|
9
|
+
# @param [String] developerPayload Echoed in the webhooks, at most 512 characters.
|
|
10
|
+
# @param [Boolean] sandbox Free mock results for testing the integration. Turn it off in production.
|
|
11
|
+
# @param [Integer] expiration Hours the scan is kept before it is deleted, 1 to 2880 (server default 2880).
|
|
12
|
+
# @param [Integer] sensitivityLevel 1 (fastest) to 5 (slowest, finds the smallest matches); server default 3.
|
|
13
|
+
# @param [Boolean] cheatDetection Check for cheating; a detection adds a scan alert to the completed webhook.
|
|
14
|
+
# @param [SubmissionCustomMetadata] customMetadata Attached to your document in a Copyleaks repository.
|
|
15
|
+
# @param [String] displayLanguage PDF report language: 'en', 'es', 'pt', 'fr', 'de' or 'it', lowercase and
|
|
16
|
+
# case-sensitive. Only applies when pdf.create is true (server default 'en').
|
|
17
|
+
# @param [String] scanTimeZone IANA time zone for the scan time on the PDF report, e.g. 'America/New_York'.
|
|
18
|
+
def initialize(
|
|
19
|
+
webhooks, includeHtml = nil, developerPayload = nil, sandbox = nil, expiration = nil,
|
|
20
|
+
sensitivityLevel = nil, cheatDetection = nil, action = nil, author = nil, filters = nil,
|
|
21
|
+
scanning = nil, indexing = nil, exclude = nil, pdf = nil, sensitiveDataProtection = nil,
|
|
22
|
+
scanMethodAlgorithm = nil, aiGeneratedText = nil, customMetadata = nil, writingFeedback = nil,
|
|
23
|
+
displayLanguage = nil, aiSourceMatch = nil,
|
|
24
|
+
overview: nil, internalAiSourceMatch: nil, references: nil, scanTimeZone: nil,
|
|
25
|
+
course: nil, assignment: nil, institution: nil
|
|
26
|
+
)
|
|
27
|
+
unless webhooks.instance_of?(SubmissionWebhooks)
|
|
28
|
+
raise 'Copyleaks::SubmissionProperties - webhooks - webhooks must be of type SubmissionWebhooks'
|
|
29
|
+
end
|
|
30
|
+
if !includeHtml.nil? && ![true, false].include?(includeHtml)
|
|
31
|
+
raise 'Copyleaks::SubmissionProperties - includeHtml - includeHtml must be of type Boolean'
|
|
32
|
+
end
|
|
33
|
+
if !developerPayload.nil? && !developerPayload.instance_of?(String)
|
|
34
|
+
raise 'Copyleaks::SubmissionProperties - developerPayload - developerPayload must be of type String'
|
|
35
|
+
end
|
|
36
|
+
if !sandbox.nil? && ![true, false].include?(sandbox)
|
|
37
|
+
raise 'Copyleaks::SubmissionProperties - sandbox - sandbox must be of type Boolean'
|
|
38
|
+
end
|
|
39
|
+
if !expiration.nil? && !expiration.instance_of?(Integer)
|
|
40
|
+
raise 'Copyleaks::SubmissionProperties - expiration - expiration must be of type Integer'
|
|
41
|
+
end
|
|
42
|
+
if !sensitivityLevel.nil? && !sensitivityLevel.instance_of?(Integer)
|
|
43
|
+
raise 'Copyleaks::SubmissionProperties - sensitivityLevel - sensitivityLevel must be of type Integer'
|
|
44
|
+
end
|
|
45
|
+
if !cheatDetection.nil? && ![true, false].include?(cheatDetection)
|
|
46
|
+
raise 'Copyleaks::SubmissionProperties - cheatDetection - cheatDetection must be of type Boolean'
|
|
47
|
+
end
|
|
48
|
+
if !action.nil? && ![0, 1, 2].include?(action)
|
|
49
|
+
raise 'Copyleaks::SubmissionProperties - action - action must be of type SubmissionActions consts'
|
|
50
|
+
end
|
|
51
|
+
if !author.nil? && !author.instance_of?(SubmissionAuthor)
|
|
52
|
+
raise 'Copyleaks::SubmissionProperties - author - author must be of type SubmissionAuthor'
|
|
53
|
+
end
|
|
54
|
+
if !filters.nil? && !filters.instance_of?(SubmissionFilter)
|
|
55
|
+
raise 'Copyleaks::SubmissionProperties - filters - filters must be of type SubmissionFilter'
|
|
56
|
+
end
|
|
57
|
+
if !scanning.nil? && !scanning.instance_of?(SubmissionScanning)
|
|
58
|
+
raise 'Copyleaks::SubmissionProperties - scanning - scanning must be of type SubmissionScanning'
|
|
59
|
+
end
|
|
60
|
+
if !indexing.nil? && !indexing.instance_of?(SubmissionIndexing)
|
|
61
|
+
raise 'Copyleaks::SubmissionProperties - indexing - indexing must be of type SubmissionIndexing'
|
|
62
|
+
end
|
|
63
|
+
if !exclude.nil? && !exclude.instance_of?(SubmissionExclude)
|
|
64
|
+
raise 'Copyleaks::SubmissionProperties - exclude - exclude must be of type SubmissionExclude'
|
|
65
|
+
end
|
|
66
|
+
if !pdf.nil? && !pdf.instance_of?(SubmissionPDF)
|
|
67
|
+
raise 'Copyleaks::SubmissionProperties - pdf - pdf must be of type SubmissionPDF'
|
|
68
|
+
end
|
|
69
|
+
if !sensitiveDataProtection.nil? && !sensitiveDataProtection.instance_of?(SubmissionSensitiveData)
|
|
70
|
+
raise 'Copyleaks::SubmissionProperties - sensitiveDataProtection - sensitiveDataProtection must be of type SubmissionSensitiveData'
|
|
71
|
+
end
|
|
72
|
+
if !scanMethodAlgorithm.nil? && ![0, 1].include?(scanMethodAlgorithm)
|
|
73
|
+
raise 'Copyleaks::SubmissionProperties - scanMethodAlgorithm - scanMethodAlgorithm must be of type SubmissionScanMethodAlgorithm'
|
|
74
|
+
end
|
|
75
|
+
if !aiGeneratedText.nil? && !aiGeneratedText.instance_of?(SubmissionAiGeneratedText)
|
|
76
|
+
raise 'Copyleaks::SubmissionProperties - aiGeneratedText - aiGeneratedText must be of type SubmissionAiGeneratedText'
|
|
77
|
+
end
|
|
78
|
+
if !customMetadata.nil? && !(customMetadata.is_a?(Array) && customMetadata.all? { |element| element.is_a?(SubmissionCustomMetadata) })
|
|
79
|
+
raise 'Copyleaks::SubmissionProperties - customMetadata - customMetadata must be of type SubmissionCustomMetadata[]'
|
|
80
|
+
end
|
|
81
|
+
if !writingFeedback.nil? && !writingFeedback.instance_of?(SubmissionWritingFeedback)
|
|
82
|
+
raise 'Copyleaks::SubmissionProperties - writingFeedback - writingFeedback must be of type SubmissionWritingFeedback'
|
|
83
|
+
end
|
|
84
|
+
if !displayLanguage.nil? && !displayLanguage.instance_of?(String)
|
|
85
|
+
raise 'Copyleaks::SubmissionProperties - displayLanguage - displayLanguage must be of type String'
|
|
86
|
+
end
|
|
87
|
+
if !aiSourceMatch.nil? && !aiSourceMatch.instance_of?(SubmissionAiSourceMatch)
|
|
88
|
+
raise 'Copyleaks::SubmissionProperties - aiSourceMatch - aiSourceMatch must be of type SubmissionAiSourceMatch'
|
|
89
|
+
end
|
|
90
|
+
if !overview.nil? && !overview.instance_of?(SubmissionOverview)
|
|
91
|
+
raise 'Copyleaks::SubmissionProperties - overview - overview must be of type SubmissionOverview'
|
|
92
|
+
end
|
|
93
|
+
if !internalAiSourceMatch.nil? && !internalAiSourceMatch.instance_of?(SubmissionInternalAiSourceMatch)
|
|
94
|
+
raise 'Copyleaks::SubmissionProperties - internalAiSourceMatch - internalAiSourceMatch must be of type SubmissionInternalAiSourceMatch'
|
|
95
|
+
end
|
|
96
|
+
if !references.nil? && !references.instance_of?(SubmissionReferences)
|
|
97
|
+
raise 'Copyleaks::SubmissionProperties - references - references must be of type SubmissionReferences'
|
|
98
|
+
end
|
|
99
|
+
if !scanTimeZone.nil? && !scanTimeZone.instance_of?(String)
|
|
100
|
+
raise 'Copyleaks::SubmissionProperties - scanTimeZone - scanTimeZone must be of type String'
|
|
101
|
+
end
|
|
102
|
+
if !course.nil? && !course.instance_of?(SubmissionCourse)
|
|
103
|
+
raise 'Copyleaks::SubmissionProperties - course - course must be of type SubmissionCourse'
|
|
104
|
+
end
|
|
105
|
+
if !assignment.nil? && !assignment.instance_of?(SubmissionAssignment)
|
|
106
|
+
raise 'Copyleaks::SubmissionProperties - assignment - assignment must be of type SubmissionAssignment'
|
|
107
|
+
end
|
|
108
|
+
if !institution.nil? && !institution.instance_of?(SubmissionInstitution)
|
|
109
|
+
raise 'Copyleaks::SubmissionProperties - institution - institution must be of type SubmissionInstitution'
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
@webhooks = webhooks
|
|
113
|
+
@includeHtml = includeHtml
|
|
114
|
+
@developerPayload = developerPayload
|
|
115
|
+
@sandbox = sandbox
|
|
116
|
+
@expiration = expiration
|
|
117
|
+
@sensitivityLevel = sensitivityLevel
|
|
118
|
+
@cheatDetection = cheatDetection
|
|
119
|
+
@aiGeneratedText = aiGeneratedText
|
|
120
|
+
@action = action
|
|
121
|
+
@author = author
|
|
122
|
+
@filters = filters
|
|
123
|
+
@scanning = scanning
|
|
124
|
+
@indexing = indexing
|
|
125
|
+
@exclude = exclude
|
|
126
|
+
@pdf = pdf
|
|
127
|
+
@sensitiveDataProtection = sensitiveDataProtection
|
|
128
|
+
@scanMethodAlgorithm = scanMethodAlgorithm
|
|
129
|
+
@customMetadata = customMetadata
|
|
130
|
+
@writingFeedback = writingFeedback
|
|
131
|
+
@displayLanguage = displayLanguage
|
|
132
|
+
@aiSourceMatch = aiSourceMatch
|
|
133
|
+
@overview = overview
|
|
134
|
+
@internalAiSourceMatch = internalAiSourceMatch
|
|
135
|
+
@references = references
|
|
136
|
+
@scanTimeZone = scanTimeZone
|
|
137
|
+
@course = course
|
|
138
|
+
@assignment = assignment
|
|
139
|
+
@institution = institution
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def as_json(*_args)
|
|
143
|
+
{
|
|
144
|
+
webhooks: @webhooks,
|
|
145
|
+
includeHtml: @includeHtml,
|
|
146
|
+
developerPayload: @developerPayload,
|
|
147
|
+
sandbox: @sandbox,
|
|
148
|
+
expiration: @expiration,
|
|
149
|
+
sensitivityLevel: @sensitivityLevel,
|
|
150
|
+
cheatDetection: @cheatDetection,
|
|
151
|
+
aiGeneratedText: @aiGeneratedText,
|
|
152
|
+
action: @action,
|
|
153
|
+
author: @author,
|
|
154
|
+
course: @course,
|
|
155
|
+
assignment: @assignment,
|
|
156
|
+
institution: @institution,
|
|
157
|
+
filters: @filters,
|
|
158
|
+
scanning: @scanning,
|
|
159
|
+
indexing: @indexing,
|
|
160
|
+
exclude: @exclude,
|
|
161
|
+
pdf: @pdf,
|
|
162
|
+
sensitiveDataProtection: @sensitiveDataProtection,
|
|
163
|
+
scanMethodAlgorithm: @scanMethodAlgorithm,
|
|
164
|
+
customMetadata: @customMetadata,
|
|
165
|
+
writingFeedback: @writingFeedback,
|
|
166
|
+
displayLanguage: @displayLanguage,
|
|
167
|
+
scanTimeZone: @scanTimeZone,
|
|
168
|
+
aiSourceMatch: @aiSourceMatch,
|
|
169
|
+
internalAiSourceMatch: @internalAiSourceMatch,
|
|
170
|
+
overview: @overview,
|
|
171
|
+
references: @references
|
|
172
|
+
}.select { |_k, v| !v.nil? }
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def to_json(*options)
|
|
176
|
+
as_json(*options).to_json(*options)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
class SubmissionWebhooks
|
|
3
|
+
# See https://docs.copyleaks.com/reference/data-types/authenticity/webhooks/overview
|
|
4
|
+
# @param [String] status Called when the scan status changes. The {STATUS} token in the URL is replaced with
|
|
5
|
+
# completed, error, creditschecked or indexed.
|
|
6
|
+
# @param [String] newResult Called for each new result while the scan runs, so a live report can load gradually.
|
|
7
|
+
# @param [Array] statusHeaders Headers added to the status webhook.
|
|
8
|
+
# @param [Array] newResultHeaders Headers added to the new result webhook.
|
|
9
|
+
def initialize(status, newResult = nil, statusHeaders = nil, newResultHeaders = nil)
|
|
10
|
+
unless status.instance_of? String
|
|
11
|
+
raise 'Copyleaks::SubmissionWebhooks - status - status must be of type String'
|
|
12
|
+
end
|
|
13
|
+
unless newResult.nil? || newResult.instance_of?(String)
|
|
14
|
+
raise 'Copyleaks::SubmissionWebhooks - newResult - newResult must be of type String'
|
|
15
|
+
end
|
|
16
|
+
unless Utils.headers_valid?(statusHeaders)
|
|
17
|
+
raise 'Copyleaks::SubmissionWebhooks - statusHeaders - statusHeaders must be an Array of String Array pairs'
|
|
18
|
+
end
|
|
19
|
+
unless Utils.headers_valid?(newResultHeaders)
|
|
20
|
+
raise 'Copyleaks::SubmissionWebhooks - newResultHeaders - newResultHeaders must be an Array of String Array pairs'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
@newResult = newResult
|
|
24
|
+
@status = status
|
|
25
|
+
@statusHeaders = statusHeaders
|
|
26
|
+
@newResultHeaders = newResultHeaders
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def as_json(*_args)
|
|
30
|
+
{
|
|
31
|
+
newResult: @newResult,
|
|
32
|
+
status: @status,
|
|
33
|
+
statusHeaders: @statusHeaders,
|
|
34
|
+
newResultHeaders: @newResultHeaders
|
|
35
|
+
}.select { |_k, v| !v.nil? }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def to_json(*options)
|
|
39
|
+
as_json(*options).to_json(*options)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
class SubmissionWritingFeedback
|
|
3
|
+
attr_accessor :enable, :score
|
|
4
|
+
|
|
5
|
+
# @param [Boolean] enable Grammar Checker: grammar, spelling and sentence structure corrections. Default false.
|
|
6
|
+
# @param [ScoreWeights] score Optional weights of the writing aspects in the overall score.
|
|
7
|
+
def initialize(enable = nil, score = nil)
|
|
8
|
+
unless enable.nil? || [true, false].include?(enable)
|
|
9
|
+
raise 'Copyleaks::SubmissionWritingFeedback - enable - enable must be of type Boolean'
|
|
10
|
+
end
|
|
11
|
+
unless score.nil? || score.is_a?(ScoreWeights)
|
|
12
|
+
raise 'Copyleaks::SubmissionWritingFeedback - score - score must be of type ScoreWeights'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
@enable = enable
|
|
16
|
+
@score = score
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def as_json(*_args)
|
|
20
|
+
{
|
|
21
|
+
enable: @enable,
|
|
22
|
+
score: @score
|
|
23
|
+
}.reject { |_k, v| v.nil? }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def to_json(*options)
|
|
27
|
+
as_json(*options).to_json(*options)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
class CopyleaksSubmissionModel
|
|
3
|
+
attr_reader :properties
|
|
4
|
+
|
|
5
|
+
# @param [SubmissionProperties] properties
|
|
6
|
+
def initialize(properties)
|
|
7
|
+
unless properties.instance_of?(SubmissionProperties)
|
|
8
|
+
raise 'Copyleaks::CopyleaksURLSubmissionModel - properties - properties must be of type SubmissionProperties'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
@properties = properties
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def as_json(*_args)
|
|
15
|
+
{
|
|
16
|
+
properties: @properties
|
|
17
|
+
}.select { |_k, v| !v.nil? }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_json(*options)
|
|
21
|
+
as_json(*options).to_json(*options)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
class CopyleaksURLSubmissionModel < CopyleaksSubmissionModel
|
|
3
|
+
VERBS = %w[GET POST PUT].freeze
|
|
4
|
+
|
|
5
|
+
attr_reader :url, :verb, :headers
|
|
6
|
+
|
|
7
|
+
# @param [String] verb HTTP method Copyleaks uses to fetch the url: 'GET', 'POST' or 'PUT' (server default: GET).
|
|
8
|
+
# @param [Array<Array<String>>] headers Sent when Copyleaks fetches the url, e.g. [['Cookie', 'session=abc']].
|
|
9
|
+
# When set, Copyleaks does not add its own default headers.
|
|
10
|
+
def initialize(url, properties, verb: nil, headers: nil)
|
|
11
|
+
raise 'Copyleaks::CopyleaksURLSubmissionModel - url - url must be of type String' unless url.instance_of?(String)
|
|
12
|
+
unless properties.instance_of?(SubmissionProperties)
|
|
13
|
+
raise 'Copyleaks::CopyleaksURLSubmissionModel - properties - properties must be of type SubmissionProperties'
|
|
14
|
+
end
|
|
15
|
+
if !verb.nil? && !VERBS.include?(verb)
|
|
16
|
+
raise "Copyleaks::CopyleaksURLSubmissionModel - verb - verb must be one of #{VERBS.join(', ')}"
|
|
17
|
+
end
|
|
18
|
+
unless Utils.headers_valid?(headers)
|
|
19
|
+
raise 'Copyleaks::CopyleaksURLSubmissionModel - headers - headers must be an Array of String Array pairs'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
super(properties)
|
|
23
|
+
@url = url
|
|
24
|
+
@verb = verb
|
|
25
|
+
@headers = headers
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def as_json(*_args)
|
|
29
|
+
{
|
|
30
|
+
url: @url,
|
|
31
|
+
verb: @verb,
|
|
32
|
+
headers: @headers,
|
|
33
|
+
properties: @properties
|
|
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,67 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
class CompletedWebhook < StatusWebhook
|
|
3
|
+
attr_reader :results, :notifications, :scannedDocument, :referencesValidation
|
|
4
|
+
|
|
5
|
+
# @param [Hash] referencesValidation Citation Checker summary. Present when references.validate was enabled.
|
|
6
|
+
def initialize(results: nil, notifications: nil, scannedDocument: nil, referencesValidation: nil, **args)
|
|
7
|
+
super(**args)
|
|
8
|
+
@results = results
|
|
9
|
+
@notifications = notifications
|
|
10
|
+
@scannedDocument = scannedDocument
|
|
11
|
+
@referencesValidation = referencesValidation
|
|
12
|
+
@extra_fields = args # Store any additional fields here
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# The first 'suspected-ai-text' alert of this scan, or nil. notifications may be the raw webhook Hash
|
|
16
|
+
# (String or Symbol keys) or a Copyleaks::Notifications.
|
|
17
|
+
# @raise [ArgumentError, RuntimeError] When the alert lacks category or severity, or a field has the wrong type.
|
|
18
|
+
def ai_detection_alert
|
|
19
|
+
alerts = notification_alerts
|
|
20
|
+
return nil unless alerts.is_a?(Array)
|
|
21
|
+
|
|
22
|
+
alerts.each do |alert|
|
|
23
|
+
if alert.is_a?(Alerts)
|
|
24
|
+
return alert if alert.code == CopyleaksAlertCodes::SUSPECTED_AI_TEXT
|
|
25
|
+
elsif alert.is_a?(Hash)
|
|
26
|
+
code = alert.key?('code') ? alert['code'] : alert[:code]
|
|
27
|
+
return Alerts.from_json(alert) if code == CopyleaksAlertCodes::SUSPECTED_AI_TEXT
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
nil
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Decodes the 'suspected-ai-text' alert's result; nil when there is no such alert. See Alerts#ai_detection_result.
|
|
34
|
+
# @return [CopyleaksAiTextDetectionResponseModel, nil]
|
|
35
|
+
# @raise [JSON::ParserError] When the alert's additionalData is not valid JSON.
|
|
36
|
+
def ai_detection_result
|
|
37
|
+
alert = ai_detection_alert
|
|
38
|
+
alert.nil? ? nil : alert.ai_detection_result
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def as_json(*_args)
|
|
42
|
+
super.merge(
|
|
43
|
+
{
|
|
44
|
+
results: @results.respond_to?(:as_json) ? @results.as_json : @results,
|
|
45
|
+
notifications: @notifications.respond_to?(:as_json) ? @notifications.as_json : @notifications,
|
|
46
|
+
scannedDocument: @scannedDocument.respond_to?(:as_json) ? @scannedDocument.as_json : @scannedDocument,
|
|
47
|
+
referencesValidation: @referencesValidation
|
|
48
|
+
}.reject { |key, value| key == :referencesValidation && value.nil? }
|
|
49
|
+
).merge(@extra_fields)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def to_json(*options)
|
|
53
|
+
as_json.to_json(*options)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
# @return [Array, nil] The notifications alerts, as received or as Alerts objects.
|
|
59
|
+
def notification_alerts
|
|
60
|
+
if @notifications.is_a?(Hash)
|
|
61
|
+
@notifications.key?('alerts') ? @notifications['alerts'] : @notifications[:alerts]
|
|
62
|
+
elsif @notifications.respond_to?(:alerts)
|
|
63
|
+
@notifications.alerts
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
class CreditsCheckedWebhook < StatusWebhook
|
|
3
|
+
attr_reader :credits, :scannedDocument
|
|
4
|
+
|
|
5
|
+
def initialize(credits: nil, scannedDocument: nil, **args)
|
|
6
|
+
super(**args)
|
|
7
|
+
@credits = credits
|
|
8
|
+
@scannedDocument = scannedDocument
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def as_json(*_args)
|
|
12
|
+
super.merge(
|
|
13
|
+
{
|
|
14
|
+
credits: @credits,
|
|
15
|
+
scannedDocument: @scannedDocument.respond_to?(:as_json) ? @scannedDocument.as_json : @scannedDocument
|
|
16
|
+
}
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_json(*options)
|
|
21
|
+
as_json.to_json(*options)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
class ErrorWebhook < StatusWebhook
|
|
3
|
+
attr_reader :error
|
|
4
|
+
|
|
5
|
+
def initialize(error: nil, **args)
|
|
6
|
+
super(**args)
|
|
7
|
+
@error = error
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def as_json(*_args)
|
|
11
|
+
super.merge(
|
|
12
|
+
{
|
|
13
|
+
error: @error.respond_to?(:as_json) ? @error.as_json : @error
|
|
14
|
+
}
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def to_json(*options)
|
|
19
|
+
as_json.to_json(*options)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
class ExportCompletedWebhook < Webhook
|
|
3
|
+
attr_reader :completed, :tasks
|
|
4
|
+
|
|
5
|
+
def initialize(completed: nil, tasks: nil, **args)
|
|
6
|
+
super(**args)
|
|
7
|
+
@completed = completed
|
|
8
|
+
@tasks = tasks
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def as_json(*_args)
|
|
12
|
+
super.merge(
|
|
13
|
+
{
|
|
14
|
+
completed: @completed,
|
|
15
|
+
tasks: @tasks.respond_to?(:map) ? @tasks.map { |t| t.respond_to?(:as_json) ? t.as_json : t } : @tasks
|
|
16
|
+
}
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_json(*options)
|
|
21
|
+
as_json.to_json(*options)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
class Metadata
|
|
3
|
+
attr_reader :finalUrl, :canonicalUrl, :publishDate, :creationDate,
|
|
4
|
+
:lastModificationDate, :author, :organization, :filename
|
|
5
|
+
|
|
6
|
+
def initialize(finalUrl: nil, canonicalUrl: nil, publishDate: nil, creationDate: nil,
|
|
7
|
+
lastModificationDate: nil, author: nil, organization: nil, filename: nil)
|
|
8
|
+
|
|
9
|
+
if !finalUrl.nil? && !finalUrl.is_a?(String)
|
|
10
|
+
raise 'Copyleaks::Metadata - finalUrl must be a String'
|
|
11
|
+
end
|
|
12
|
+
if !canonicalUrl.nil? && !canonicalUrl.is_a?(String)
|
|
13
|
+
raise 'Copyleaks::Metadata - canonicalUrl must be a String'
|
|
14
|
+
end
|
|
15
|
+
if !publishDate.nil? && !publishDate.is_a?(String)
|
|
16
|
+
raise 'Copyleaks::Metadata - publishDate must be a String'
|
|
17
|
+
end
|
|
18
|
+
if !creationDate.nil? && !creationDate.is_a?(String)
|
|
19
|
+
raise 'Copyleaks::Metadata - creationDate must be a String'
|
|
20
|
+
end
|
|
21
|
+
if !lastModificationDate.nil? && !lastModificationDate.is_a?(String)
|
|
22
|
+
raise 'Copyleaks::Metadata - lastModificationDate must be a String'
|
|
23
|
+
end
|
|
24
|
+
if !author.nil? && !author.is_a?(String)
|
|
25
|
+
raise 'Copyleaks::Metadata - author must be a String'
|
|
26
|
+
end
|
|
27
|
+
if !organization.nil? && !organization.is_a?(String)
|
|
28
|
+
raise 'Copyleaks::Metadata - organization must be a String'
|
|
29
|
+
end
|
|
30
|
+
if !filename.nil? && !filename.is_a?(String)
|
|
31
|
+
raise 'Copyleaks::Metadata - filename must be a String'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
@finalUrl = finalUrl
|
|
35
|
+
@canonicalUrl = canonicalUrl
|
|
36
|
+
@publishDate = publishDate
|
|
37
|
+
@creationDate = creationDate
|
|
38
|
+
@lastModificationDate = lastModificationDate
|
|
39
|
+
@author = author
|
|
40
|
+
@organization = organization
|
|
41
|
+
@filename = filename
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def as_json(*_args)
|
|
45
|
+
{
|
|
46
|
+
finalUrl: @finalUrl,
|
|
47
|
+
canonicalUrl: @canonicalUrl,
|
|
48
|
+
publishDate: @publishDate,
|
|
49
|
+
creationDate: @creationDate,
|
|
50
|
+
lastModificationDate: @lastModificationDate,
|
|
51
|
+
author: @author,
|
|
52
|
+
organization: @organization,
|
|
53
|
+
filename: @filename
|
|
54
|
+
}.select { |_k, v| !v.nil? }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def to_json(*options)
|
|
58
|
+
as_json(*options).to_json(*options)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
class StatusWebhook < Webhook
|
|
3
|
+
attr_reader :status
|
|
4
|
+
|
|
5
|
+
def initialize(status:, **args)
|
|
6
|
+
unless status.is_a?(Integer)
|
|
7
|
+
raise 'Copyleaks::StatusWebhook - status must be an Integer'
|
|
8
|
+
end
|
|
9
|
+
super(**args)
|
|
10
|
+
@status = status
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def as_json(*_args)
|
|
14
|
+
{
|
|
15
|
+
status: @status
|
|
16
|
+
}.merge(super)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_json(*options)
|
|
20
|
+
as_json.to_json(*options)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
class Webhook
|
|
3
|
+
|
|
4
|
+
# Echoed from the submission.
|
|
5
|
+
attr_reader :developerPayload
|
|
6
|
+
|
|
7
|
+
def initialize(developerPayload: nil,**args)
|
|
8
|
+
if !developerPayload.nil? && !developerPayload.is_a?(String)
|
|
9
|
+
raise 'Copyleaks::Webhook - developerPayload must be a String'
|
|
10
|
+
end
|
|
11
|
+
@developerPayload = developerPayload
|
|
12
|
+
@extra_fields = args
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def as_json(*_args)
|
|
16
|
+
{
|
|
17
|
+
developerPayload: @developerPayload
|
|
18
|
+
}.compact
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def to_json(*options)
|
|
22
|
+
as_json.to_json(*options)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
class Notifications
|
|
3
|
+
attr_reader :alerts
|
|
4
|
+
|
|
5
|
+
# @param [Array<Alerts>] alerts
|
|
6
|
+
def initialize(alerts: nil)
|
|
7
|
+
if !alerts.nil? && !(alerts.is_a?(Array) && alerts.all? { |a| a.is_a?(Alerts) })
|
|
8
|
+
raise 'Copyleaks::Notifications - alerts must be an array of Alerts objects'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
@alerts = alerts
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def as_json(*_args)
|
|
15
|
+
{
|
|
16
|
+
alerts: @alerts
|
|
17
|
+
}.select { |_k, v| !v.nil? }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_json(*options)
|
|
21
|
+
as_json(*options).to_json(*options)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
class Results
|
|
3
|
+
attr_reader :database, :batch, :repositories, :score, :internet, :internalAIData
|
|
4
|
+
|
|
5
|
+
# @param [Array<Database>] database
|
|
6
|
+
# @param [Array<Batch>] batch
|
|
7
|
+
# @param [Array<Repositories>] repositories
|
|
8
|
+
# @param [Score] score
|
|
9
|
+
# @param [Array<Internet>] internet
|
|
10
|
+
# @param [Array<Hash>] internalAIData Internal AI Source Match results.
|
|
11
|
+
def initialize(database: nil, batch: nil, repositories: nil, score: nil, internet: nil, internalAIData: nil)
|
|
12
|
+
if !internalAIData.nil? && !internalAIData.is_a?(Array)
|
|
13
|
+
raise 'Copyleaks::Results - internalAIData must be an array'
|
|
14
|
+
end
|
|
15
|
+
if !database.nil? && !(database.is_a?(Array) && database.all? { |d| d.is_a?(Database) })
|
|
16
|
+
raise 'Copyleaks::Results - database must be an array of Database objects'
|
|
17
|
+
end
|
|
18
|
+
if !batch.nil? && !(batch.is_a?(Array) && batch.all? { |b| b.is_a?(Batch) })
|
|
19
|
+
raise 'Copyleaks::Results - batch must be an array of Batch objects'
|
|
20
|
+
end
|
|
21
|
+
if !repositories.nil? && !(repositories.is_a?(Array) && repositories.all? { |r| r.is_a?(Repositories) })
|
|
22
|
+
raise 'Copyleaks::Results - repositories must be an array of Repositories objects'
|
|
23
|
+
end
|
|
24
|
+
if !score.nil? && !score.is_a?(Score)
|
|
25
|
+
raise 'Copyleaks::Results - score must be a Score object'
|
|
26
|
+
end
|
|
27
|
+
if !internet.nil? && !(internet.is_a?(Array) && internet.all? { |i| i.is_a?(Internet) })
|
|
28
|
+
raise 'Copyleaks::Results - internet must be an array of Internet objects'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
@database = database
|
|
32
|
+
@batch = batch
|
|
33
|
+
@repositories = repositories
|
|
34
|
+
@score = score
|
|
35
|
+
@internet = internet
|
|
36
|
+
@internalAIData = internalAIData
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def as_json(*_args)
|
|
40
|
+
{
|
|
41
|
+
database: @database,
|
|
42
|
+
batch: @batch,
|
|
43
|
+
repositories: @repositories,
|
|
44
|
+
score: @score,
|
|
45
|
+
internet: @internet,
|
|
46
|
+
internalAIData: @internalAIData
|
|
47
|
+
}.select { |_k, v| !v.nil? }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def to_json(*options)
|
|
51
|
+
as_json(*options).to_json(*options)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|