plagiarism-checker 3.4.0 → 3.6.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 (106) 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 +5 -0
  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_expired_exception.rb +0 -0
  15. data/lib/copyleaks/models/exceptions/command_exception.rb +0 -0
  16. data/lib/copyleaks/models/exceptions/index.rb +0 -0
  17. data/lib/copyleaks/models/exceptions/rate_limit_exception.rb +0 -0
  18. data/lib/copyleaks/models/exceptions/under_maintenance_exception.rb +0 -0
  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 +8 -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 +0 -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 +0 -0
  58. data/lib/copyleaks/models/submissions/properties/webhooks.rb +0 -0
  59. data/lib/copyleaks/models/submissions/properties/writing_feedback.rb +0 -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 +42 -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/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb +43 -0
  92. data/lib/copyleaks/models/textModeration/responses/CopyleaksTextModerationResponseModel.rb +36 -0
  93. data/lib/copyleaks/models/textModeration/responses/submodules/ModerationsModel.rb +26 -0
  94. data/lib/copyleaks/models/textModeration/responses/submodules/Text.rb +26 -0
  95. data/lib/copyleaks/models/textModeration/responses/submodules/TextModerationChars.rb +35 -0
  96. data/lib/copyleaks/models/textModeration/responses/submodules/TextModerationScannedDocument.rb +47 -0
  97. data/lib/copyleaks/models/textModeration/responses/submodules/TextModerationsLegend.rb +29 -0
  98. data/lib/copyleaks/text_moderation_client.rb +51 -0
  99. data/lib/copyleaks/utils/copyleaks_client.utils.rb +0 -0
  100. data/lib/copyleaks/utils/status-code.utils.rb +0 -0
  101. data/lib/copyleaks/version.rb +1 -1
  102. data/lib/copyleaks/writing_assistant_client.rb +81 -81
  103. data/lib/copyleaks.rb +0 -0
  104. data/lib/index.rb +0 -0
  105. metadata +38 -7
  106. data/.vscode/launch.json +0 -35
File without changes
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,42 @@
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
+ # @param [Integer] status - The current status of the scan.
22
+ attr_reader :status
23
+
24
+ def initialize(status:, **args)
25
+ unless status.is_a?(Integer)
26
+ raise 'Copyleaks::StatusWebhook - status must be an Integer'
27
+ end
28
+ super(**args)
29
+ @status = status
30
+ end
31
+
32
+ def as_json(*_args)
33
+ {
34
+ status: @status
35
+ }.merge(super)
36
+ end
37
+
38
+ def to_json(*options)
39
+ as_json.to_json(*options)
40
+ end
41
+ end
42
+ 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
@@ -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 Notifications
22
+ attr_reader :alerts
23
+
24
+ # @param [Array<Alerts>] alerts - A list of scan alerts that were detected in the scan.
25
+ def initialize(alerts: nil)
26
+ if !alerts.nil? && !(alerts.is_a?(Array) && alerts.all? { |a| a.is_a?(Alerts) })
27
+ raise 'Copyleaks::Notifications - alerts must be an array of Alerts objects'
28
+ end
29
+
30
+ @alerts = alerts
31
+ end
32
+
33
+ def as_json(*_args)
34
+ {
35
+ alerts: @alerts
36
+ }.select { |_k, v| !v.nil? }
37
+ end
38
+
39
+ def to_json(*options)
40
+ as_json(*options).to_json(*options)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,68 @@
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
+
21
+ module Copyleaks
22
+ class Results
23
+ attr_reader :database, :batch, :repositories, :score, :internet
24
+
25
+ # @param [Array<Database>] database
26
+ # @param [Array<Batch>] batch
27
+ # @param [Array<Repositories>] repositories
28
+ # @param [Score] score
29
+ # @param [Array<Internet>] internet
30
+ def initialize(database: nil, batch: nil, repositories: nil, score: nil, internet: nil)
31
+ if !database.nil? && !(database.is_a?(Array) && database.all? { |d| d.is_a?(Database) })
32
+ raise 'Copyleaks::Results - database must be an array of Database objects'
33
+ end
34
+ if !batch.nil? && !(batch.is_a?(Array) && batch.all? { |b| b.is_a?(Batch) })
35
+ raise 'Copyleaks::Results - batch must be an array of Batch objects'
36
+ end
37
+ if !repositories.nil? && !(repositories.is_a?(Array) && repositories.all? { |r| r.is_a?(Repositories) })
38
+ raise 'Copyleaks::Results - repositories must be an array of Repositories objects'
39
+ end
40
+ if !score.nil? && !score.is_a?(Score)
41
+ raise 'Copyleaks::Results - score must be a Score object'
42
+ end
43
+ if !internet.nil? && !(internet.is_a?(Array) && internet.all? { |i| i.is_a?(Internet) })
44
+ raise 'Copyleaks::Results - internet must be an array of Internet objects'
45
+ end
46
+
47
+ @database = database
48
+ @batch = batch
49
+ @repositories = repositories
50
+ @score = score
51
+ @internet = internet
52
+ end
53
+
54
+ def as_json(*_args)
55
+ {
56
+ database: @database,
57
+ batch: @batch,
58
+ repositories: @repositories,
59
+ score: @score,
60
+ internet: @internet
61
+ }.select { |_k, v| !v.nil? }
62
+ end
63
+
64
+ def to_json(*options)
65
+ as_json(*options).to_json(*options)
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,61 @@
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 ScannedDocument
22
+ attr_reader :scanId, :totalWords, :totalExcluded, :credits, :creationTime, :metadata
23
+
24
+ # @param [String] scanId - The unique scan id provided by you.
25
+ # @param [Integer] totalWords - Total number of words found in the scanned text.
26
+ # @param [Integer] totalExcluded - Number of excluded words in the submitted content.
27
+ # @param [Integer] credits - Overall credits used for the scan.
28
+ # @param [String] creationTime - The creation time of the scan.
29
+ # @param [Metadata] metadata - Metadata object
30
+ def initialize(scanId:, totalWords:, totalExcluded:, credits:, creationTime:, metadata:)
31
+ raise 'scanId must be a String' unless scanId.is_a?(String)
32
+ raise 'totalWords must be an Integer' unless totalWords.is_a?(Integer)
33
+ raise 'totalExcluded must be an Integer' unless totalExcluded.is_a?(Integer)
34
+ raise 'credits must be an Integer' unless credits.is_a?(Integer)
35
+ raise 'creationTime must be a String' unless creationTime.is_a?(String)
36
+ raise 'metadata must be a Metadata object' unless metadata.is_a?(Metadata)
37
+
38
+ @scanId = scanId
39
+ @totalWords = totalWords
40
+ @totalExcluded = totalExcluded
41
+ @credits = credits
42
+ @creationTime = creationTime
43
+ @metadata = metadata
44
+ end
45
+
46
+ def as_json(*_args)
47
+ {
48
+ scanId: @scanId,
49
+ totalWords: @totalWords,
50
+ totalExcluded: @totalExcluded,
51
+ credits: @credits,
52
+ creationTime: @creationTime,
53
+ metadata: @metadata
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,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
+
21
+ module Copyleaks
22
+ class Error
23
+ attr_reader :code, :message
24
+
25
+ # @param [Integer] code - Error code that represents the reason for failure.
26
+ # @param [String] message - Error message that represents the reason for failure.
27
+ def initialize(code:, message:)
28
+ raise 'Copyleaks::Error - code must be an Integer' unless code.is_a?(Integer)
29
+ raise 'Copyleaks::Error - message must be a String' unless message.is_a?(String)
30
+
31
+ @code = code
32
+ @message = message
33
+ end
34
+
35
+ def as_json(*_args)
36
+ {
37
+ code: @code,
38
+ message: @message
39
+ }
40
+ end
41
+
42
+ def to_json(*options)
43
+ as_json(*options).to_json(*options)
44
+ end
45
+ end
46
+ end