plagiarism-checker 3.3.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/lib/copyleaks/ai_detection_client.rb +98 -98
- data/lib/copyleaks/api.rb +4 -21
- data/lib/copyleaks/app.config.rb +0 -0
- data/lib/copyleaks/models/auth_token.rb +0 -0
- data/lib/copyleaks/models/delete_request_model.rb +0 -0
- data/lib/copyleaks/models/exceptions/{auth_exipred_exception.rb → auth_expired_exception.rb} +2 -4
- data/lib/copyleaks/models/exceptions/command_exception.rb +11 -4
- data/lib/copyleaks/models/exceptions/index.rb +1 -1
- data/lib/copyleaks/models/exceptions/rate_limit_exception.rb +2 -4
- data/lib/copyleaks/models/exceptions/under_maintenance_exception.rb +2 -4
- data/lib/copyleaks/models/exports/export_crawled_version.rb +0 -0
- data/lib/copyleaks/models/exports/export_model.rb +0 -0
- data/lib/copyleaks/models/exports/export_pdf_report.rb +0 -0
- data/lib/copyleaks/models/exports/export_results.rb +0 -0
- data/lib/copyleaks/models/exports/index.rb +0 -0
- data/lib/copyleaks/models/id_object.rb +0 -0
- data/lib/copyleaks/models/index.rb +0 -0
- data/lib/copyleaks/models/start_request_model.rb +0 -0
- data/lib/copyleaks/models/submissions/ai_detection/ai_detection_submission_model.rb +50 -50
- data/lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb +52 -52
- data/lib/copyleaks/models/submissions/ai_detection/source_code_submission_model.rb +55 -55
- data/lib/copyleaks/models/submissions/file_ocr_submission_model.rb +0 -0
- data/lib/copyleaks/models/submissions/file_submission_model.rb +0 -0
- data/lib/copyleaks/models/submissions/index.rb +1 -0
- data/lib/copyleaks/models/submissions/properties/actions.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/ai_generated_text.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/author.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/copyleaks_db.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/cross_languages.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/custom_metadata.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/domains_mode.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/exclude.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/exclude_code.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/filter.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/index.rb +1 -0
- data/lib/copyleaks/models/submissions/properties/indexing.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/indexing_repository.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/language.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/masking_policy.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/pdf_colors.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/pdf_properties.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/pdf_version.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/repository.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/scan_method_algorithm.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/scanning.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/scanning_exclude.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/scanning_repository.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/sensitive_data_protection.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/submission_properties.rb +9 -3
- data/lib/copyleaks/models/submissions/properties/webhooks.rb +0 -0
- data/lib/copyleaks/models/submissions/properties/writing_feedback.rb +53 -0
- data/lib/copyleaks/models/submissions/submission_model.rb +0 -0
- data/lib/copyleaks/models/submissions/url_submission_model.rb +0 -0
- data/lib/copyleaks/models/submissions/webhooks/CompletedWebhook.rb +46 -0
- data/lib/copyleaks/models/submissions/webhooks/CreditsCheckedWebhook.rb +43 -0
- data/lib/copyleaks/models/submissions/webhooks/ErrorWebhook.rb +41 -0
- data/lib/copyleaks/models/submissions/webhooks/ExportCompletedWebhook.rb +44 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/Metadata.rb +89 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/StatusWebhook.rb +41 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/BaseModels/Webhook.rb +43 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Notifications.rb +43 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Results.rb +68 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/ScannedDocument.rb +61 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ErrorModels/Error.rb +46 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ExportModels/Task.rb +49 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultScore.rb +42 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultsInternet.rb +60 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/NewResultsModels/NewResultsRepositories.rb +49 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/NotificationsModels/Alerts.rb +65 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Batch.rb +46 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Database.rb +46 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Internet.rb +42 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Repositories.rb +57 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/RepositoryMetadata.rb +30 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Score.rb +40 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/SharedResultsModel.rb +46 -0
- data/lib/copyleaks/models/submissions/webhooks/HelperModels/ResultsModels/Tags.rb +33 -0
- data/lib/copyleaks/models/submissions/webhooks/IndexedWebhook.rb +29 -0
- data/lib/copyleaks/models/submissions/webhooks/NewResultWebhook.rb +46 -0
- data/lib/copyleaks/models/submissions/webhooks/index.rb +34 -0
- data/lib/copyleaks/models/submissions/writing_assistant/score_weights.rb +54 -54
- data/lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb +56 -56
- data/lib/copyleaks/utils/copyleaks_client.utils.rb +56 -64
- data/lib/copyleaks/utils/status-code.utils.rb +0 -0
- data/lib/copyleaks/version.rb +1 -1
- data/lib/copyleaks/writing_assistant_client.rb +81 -81
- data/lib/copyleaks.rb +0 -0
- data/lib/index.rb +0 -0
- metadata +36 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8861ba4abf0d4978576fee7a8667865cf75ead57b6fe97aadcd5a8dcbd938ca4
|
4
|
+
data.tar.gz: 0646e0627f98928111112bb0e3e2fa4964342621754159c63e62086f91f0ca1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4ae513036ed69b983eced3db5ef330c946d83009a03faca018297f53b554936057e6df9ee23a5f7b7505f72d199649e464d173fe5acad897dc58c8fc4a86cae
|
7
|
+
data.tar.gz: f98ab2a48d28947e540e85164b2e331ba7ef7d8671d901b6f12ba3c9146bb4ffae80427aefd0ce22819c53e41dcdf90841d7c52ac867d3fd64471b066bda252f
|
data/.gitignore
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
File without changes
|
@@ -1,98 +1,98 @@
|
|
1
|
-
#
|
2
|
-
# The MIT License(MIT)
|
3
|
-
#
|
4
|
-
# Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
|
5
|
-
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in all
|
14
|
-
# copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
-
# SOFTWARE.
|
23
|
-
# =
|
24
|
-
|
25
|
-
module Copyleaks
|
26
|
-
class AIDetectionClient
|
27
|
-
def initialize(api_client)
|
28
|
-
@api_client = api_client
|
29
|
-
end
|
30
|
-
|
31
|
-
# Use Copyleaks AI Content Detection to differentiate between human source code and AI written source code.
|
32
|
-
# * Exceptions:
|
33
|
-
# * * CommandExceptions: Server reject the request. See response status code,
|
34
|
-
# headers and content for more info.
|
35
|
-
# * * UnderMaintenanceException: Copyleaks servers are unavailable for maintenance.
|
36
|
-
# We recommend to implement exponential backoff algorithm as described here:
|
37
|
-
# https://api.copyleaks.com/documentation/v3/exponential-backoff
|
38
|
-
# @param [CopyleaksAuthToken] authToken Copyleaks authentication token
|
39
|
-
# @param [String] scanId Attach your own scan Id
|
40
|
-
# @param [SourceCodeSubmissionModel] submission document
|
41
|
-
def submit_source_code(authToken, scanId, submission)
|
42
|
-
raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String)
|
43
|
-
if submission.nil? || !submission.instance_of?(Copyleaks::SourceCodeSubmissionModel)
|
44
|
-
raise 'submission is Invalid, must be instance of type Copyleaks::SourceCodeSubmissionModel'
|
45
|
-
end
|
46
|
-
|
47
|
-
ClientUtils.verify_auth_token(authToken)
|
48
|
-
|
49
|
-
path = "/v2/writer-detector/source-code/#{scanId}/check"
|
50
|
-
|
51
|
-
headers = {
|
52
|
-
'Content-Type' => 'application/json',
|
53
|
-
'User-Agent' => Config.user_agent,
|
54
|
-
'Authorization' => "Bearer #{authToken.accessToken}"
|
55
|
-
}
|
56
|
-
|
57
|
-
request = Net::HTTP::Post.new(path, headers)
|
58
|
-
request.body = submission.to_json
|
59
|
-
|
60
|
-
ClientUtils.handle_response(@api_client.request(request), 'submit_source_code')
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
# Use Copyleaks AI Content Detection to differentiate between human texts and AI written texts.
|
65
|
-
# * Exceptions:
|
66
|
-
# * * CommandExceptions: Server reject the request. See response status code,
|
67
|
-
# headers and content for more info.
|
68
|
-
# * * UnderMaintenanceException: Copyleaks servers are unavailable for maintenance.
|
69
|
-
# We recommend to implement exponential backoff algorithm as described here:
|
70
|
-
# https://api.copyleaks.com/documentation/v3/exponential-backoff
|
71
|
-
# @param [CopyleaksAuthToken] authToken Copyleaks authentication token
|
72
|
-
# @param [String] scanId Attach your own scan Id
|
73
|
-
# @param [SourceCodeSubmissionModel] submission document
|
74
|
-
def submit_natural_language(authToken, scanId, submission)
|
75
|
-
raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String)
|
76
|
-
if submission.nil? || !submission.instance_of?(Copyleaks::NaturalLanguageSubmissionModel)
|
77
|
-
raise 'submission is Invalid, must be instance of type Copyleaks::NaturalLanguageSubmissionModel'
|
78
|
-
end
|
79
|
-
|
80
|
-
ClientUtils.verify_auth_token(authToken)
|
81
|
-
|
82
|
-
path = "/v2/writer-detector/#{scanId}/check"
|
83
|
-
|
84
|
-
headers = {
|
85
|
-
'Content-Type' => 'application/json',
|
86
|
-
'User-Agent' => Config.user_agent,
|
87
|
-
'Authorization' => "Bearer #{authToken.accessToken}"
|
88
|
-
}
|
89
|
-
|
90
|
-
request = Net::HTTP::Post.new(path, headers)
|
91
|
-
request.body = submission.to_json
|
92
|
-
|
93
|
-
res = ClientUtils.handle_response(@api_client.request(request), 'submit_natural_language')
|
94
|
-
puts "RES: #{res}"
|
95
|
-
res
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
1
|
+
#
|
2
|
+
# The MIT License(MIT)
|
3
|
+
#
|
4
|
+
# Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
# =
|
24
|
+
|
25
|
+
module Copyleaks
|
26
|
+
class AIDetectionClient
|
27
|
+
def initialize(api_client)
|
28
|
+
@api_client = api_client
|
29
|
+
end
|
30
|
+
|
31
|
+
# Use Copyleaks AI Content Detection to differentiate between human source code and AI written source code.
|
32
|
+
# * Exceptions:
|
33
|
+
# * * CommandExceptions: Server reject the request. See response status code,
|
34
|
+
# headers and content for more info.
|
35
|
+
# * * UnderMaintenanceException: Copyleaks servers are unavailable for maintenance.
|
36
|
+
# We recommend to implement exponential backoff algorithm as described here:
|
37
|
+
# https://api.copyleaks.com/documentation/v3/exponential-backoff
|
38
|
+
# @param [CopyleaksAuthToken] authToken Copyleaks authentication token
|
39
|
+
# @param [String] scanId Attach your own scan Id
|
40
|
+
# @param [SourceCodeSubmissionModel] submission document
|
41
|
+
def submit_source_code(authToken, scanId, submission)
|
42
|
+
raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String)
|
43
|
+
if submission.nil? || !submission.instance_of?(Copyleaks::SourceCodeSubmissionModel)
|
44
|
+
raise 'submission is Invalid, must be instance of type Copyleaks::SourceCodeSubmissionModel'
|
45
|
+
end
|
46
|
+
|
47
|
+
ClientUtils.verify_auth_token(authToken)
|
48
|
+
|
49
|
+
path = "/v2/writer-detector/source-code/#{scanId}/check"
|
50
|
+
|
51
|
+
headers = {
|
52
|
+
'Content-Type' => 'application/json',
|
53
|
+
'User-Agent' => Config.user_agent,
|
54
|
+
'Authorization' => "Bearer #{authToken.accessToken}"
|
55
|
+
}
|
56
|
+
|
57
|
+
request = Net::HTTP::Post.new(path, headers)
|
58
|
+
request.body = submission.to_json
|
59
|
+
|
60
|
+
ClientUtils.handle_response(@api_client.request(request), 'submit_source_code')
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
# Use Copyleaks AI Content Detection to differentiate between human texts and AI written texts.
|
65
|
+
# * Exceptions:
|
66
|
+
# * * CommandExceptions: Server reject the request. See response status code,
|
67
|
+
# headers and content for more info.
|
68
|
+
# * * UnderMaintenanceException: Copyleaks servers are unavailable for maintenance.
|
69
|
+
# We recommend to implement exponential backoff algorithm as described here:
|
70
|
+
# https://api.copyleaks.com/documentation/v3/exponential-backoff
|
71
|
+
# @param [CopyleaksAuthToken] authToken Copyleaks authentication token
|
72
|
+
# @param [String] scanId Attach your own scan Id
|
73
|
+
# @param [SourceCodeSubmissionModel] submission document
|
74
|
+
def submit_natural_language(authToken, scanId, submission)
|
75
|
+
raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String)
|
76
|
+
if submission.nil? || !submission.instance_of?(Copyleaks::NaturalLanguageSubmissionModel)
|
77
|
+
raise 'submission is Invalid, must be instance of type Copyleaks::NaturalLanguageSubmissionModel'
|
78
|
+
end
|
79
|
+
|
80
|
+
ClientUtils.verify_auth_token(authToken)
|
81
|
+
|
82
|
+
path = "/v2/writer-detector/#{scanId}/check"
|
83
|
+
|
84
|
+
headers = {
|
85
|
+
'Content-Type' => 'application/json',
|
86
|
+
'User-Agent' => Config.user_agent,
|
87
|
+
'Authorization' => "Bearer #{authToken.accessToken}"
|
88
|
+
}
|
89
|
+
|
90
|
+
request = Net::HTTP::Post.new(path, headers)
|
91
|
+
request.body = submission.to_json
|
92
|
+
|
93
|
+
res = ClientUtils.handle_response(@api_client.request(request), 'submit_natural_language')
|
94
|
+
puts "RES: #{res}"
|
95
|
+
res
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/lib/copyleaks/api.rb
CHANGED
@@ -26,6 +26,7 @@ require 'json'
|
|
26
26
|
require 'date'
|
27
27
|
require_relative 'ai_detection_client.rb'
|
28
28
|
require_relative 'writing_assistant_client.rb'
|
29
|
+
require_relative 'utils/copyleaks_client.utils'
|
29
30
|
|
30
31
|
module Copyleaks
|
31
32
|
class API
|
@@ -75,7 +76,7 @@ module Copyleaks
|
|
75
76
|
|
76
77
|
# Verify that Copyleaks authentication token is exists and not exipired.
|
77
78
|
# * Exceptions:
|
78
|
-
# * *
|
79
|
+
# * * AuthExpiredException: authentication expired. Need to login again.
|
79
80
|
# @param [CopyleaksAuthToken] authToken Copyleaks authentication token
|
80
81
|
def verify_auth_token(authToken)
|
81
82
|
if authToken.nil? || !authToken.instance_of?(CopyleaksAuthToken)
|
@@ -86,7 +87,7 @@ module Copyleaks
|
|
86
87
|
_expiresTime = DateTime.parse(authToken.expires)
|
87
88
|
|
88
89
|
if _expiresTime <= _time
|
89
|
-
raise
|
90
|
+
raise AuthExpiredException # expired
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
@@ -445,25 +446,7 @@ module Copyleaks
|
|
445
446
|
|
446
447
|
# this methods is a helper for hanlding reponse data and exceptions.
|
447
448
|
def handle_response(response, used_by)
|
448
|
-
|
449
|
-
if response.body.nil? || response.body == ''
|
450
|
-
nil
|
451
|
-
else
|
452
|
-
JSON.parse(response.body)
|
453
|
-
end
|
454
|
-
elsif Utils.is_under_maintenance_response(response.code)
|
455
|
-
raise UnderMaintenanceException.new.reason
|
456
|
-
elsif Utils.is_rate_limit_response(response.code)
|
457
|
-
raise RateLimitException.new.reason
|
458
|
-
else
|
459
|
-
_err_message = '---------Copyleaks SDK Error (' + used_by + ')---------' + "\n\n"
|
460
|
-
_err_message += 'status code: ' + response.code + "\n\n"
|
461
|
-
|
462
|
-
_err_message += 'response body:' + "\n" + response.body.to_json + "\n\n" unless response.body.nil?
|
463
|
-
|
464
|
-
_err_message += '-------------------------------------'
|
465
|
-
raise CommandException.new(_err_message).reason + "\n"
|
466
|
-
end
|
449
|
+
Copyleaks::ClientUtils.handle_response(response, used_by)
|
467
450
|
end
|
468
451
|
|
469
452
|
def ai_detection_client
|
data/lib/copyleaks/app.config.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/lib/copyleaks/models/exceptions/{auth_exipred_exception.rb → auth_expired_exception.rb}
RENAMED
@@ -22,11 +22,9 @@
|
|
22
22
|
# SOFTWARE.
|
23
23
|
# =
|
24
24
|
module Copyleaks
|
25
|
-
class
|
26
|
-
attr_reader :reason
|
27
|
-
|
25
|
+
class AuthExpiredException < RuntimeError
|
28
26
|
def initialize
|
29
|
-
|
27
|
+
super 'Authentication Expired. Need to login again'
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
@@ -22,11 +22,18 @@
|
|
22
22
|
# SOFTWARE.
|
23
23
|
# =
|
24
24
|
module Copyleaks
|
25
|
-
class CommandException <
|
26
|
-
attr_reader :
|
25
|
+
class CommandException < RuntimeError
|
26
|
+
attr_reader :response
|
27
27
|
|
28
|
-
def initialize(
|
29
|
-
@
|
28
|
+
def initialize(response:, used_by:)
|
29
|
+
@response = response
|
30
|
+
@used_by = used_by
|
31
|
+
|
32
|
+
message = "---------Copyleaks SDK Error (#{used_by})---------\n\n"
|
33
|
+
message += "status code: #{response.code}\n\n"
|
34
|
+
message += "response body:\n#{response.body.to_json}\n\n" unless response.body.nil?
|
35
|
+
message += "-------------------------------------\n"
|
36
|
+
super message
|
30
37
|
end
|
31
38
|
end
|
32
39
|
end
|
@@ -22,7 +22,7 @@
|
|
22
22
|
# SOFTWARE.
|
23
23
|
# =
|
24
24
|
|
25
|
-
require_relative '
|
25
|
+
require_relative 'auth_expired_exception.rb'
|
26
26
|
require_relative 'command_exception.rb'
|
27
27
|
require_relative 'rate_limit_exception.rb'
|
28
28
|
require_relative 'under_maintenance_exception.rb'
|
@@ -22,11 +22,9 @@
|
|
22
22
|
# SOFTWARE.
|
23
23
|
# =
|
24
24
|
module Copyleaks
|
25
|
-
class RateLimitException <
|
26
|
-
attr_reader :reason
|
27
|
-
|
25
|
+
class RateLimitException < RuntimeError
|
28
26
|
def initialize
|
29
|
-
|
27
|
+
super 'Too many requests. Please wait before calling again.'
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
@@ -22,11 +22,9 @@
|
|
22
22
|
# SOFTWARE.
|
23
23
|
# =
|
24
24
|
module Copyleaks
|
25
|
-
class UnderMaintenanceException <
|
26
|
-
attr_reader :reason
|
27
|
-
|
25
|
+
class UnderMaintenanceException < RuntimeError
|
28
26
|
def initialize
|
29
|
-
|
27
|
+
super 'Copyleaks is Under Maintenance, please visit https://status.copyleaks.com'
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,50 +1,50 @@
|
|
1
|
-
#
|
2
|
-
# The MIT License(MIT)
|
3
|
-
#
|
4
|
-
# Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
|
5
|
-
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in all
|
14
|
-
# copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
-
# SOFTWARE.
|
23
|
-
# =
|
24
|
-
|
25
|
-
module Copyleaks
|
26
|
-
class AIDetectionSubmissionModel
|
27
|
-
attr_accessor :text, :sandbox
|
28
|
-
|
29
|
-
# @param [String] A text string.
|
30
|
-
# @param [Boolean] Use sandbox mode to test your integration with the Copyleaks API for free.
|
31
|
-
def initialize(text, sandbox = false)
|
32
|
-
unless text.instance_of?(String)
|
33
|
-
raise 'Copyleaks::AIDetectionSubmissionModel - text - text must be of type String'
|
34
|
-
end
|
35
|
-
@text = text
|
36
|
-
@sandbox = sandbox
|
37
|
-
end
|
38
|
-
|
39
|
-
def as_json(*_args)
|
40
|
-
{
|
41
|
-
'text' => @text,
|
42
|
-
'sandbox' => @sandbox
|
43
|
-
}.reject { |_, v| v.nil? }
|
44
|
-
end
|
45
|
-
|
46
|
-
def to_json(*options)
|
47
|
-
as_json(*options).to_json(*options)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
1
|
+
#
|
2
|
+
# The MIT License(MIT)
|
3
|
+
#
|
4
|
+
# Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
# =
|
24
|
+
|
25
|
+
module Copyleaks
|
26
|
+
class AIDetectionSubmissionModel
|
27
|
+
attr_accessor :text, :sandbox
|
28
|
+
|
29
|
+
# @param [String] A text string.
|
30
|
+
# @param [Boolean] Use sandbox mode to test your integration with the Copyleaks API for free.
|
31
|
+
def initialize(text, sandbox = false)
|
32
|
+
unless text.instance_of?(String)
|
33
|
+
raise 'Copyleaks::AIDetectionSubmissionModel - text - text must be of type String'
|
34
|
+
end
|
35
|
+
@text = text
|
36
|
+
@sandbox = sandbox
|
37
|
+
end
|
38
|
+
|
39
|
+
def as_json(*_args)
|
40
|
+
{
|
41
|
+
'text' => @text,
|
42
|
+
'sandbox' => @sandbox
|
43
|
+
}.reject { |_, v| v.nil? }
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_json(*options)
|
47
|
+
as_json(*options).to_json(*options)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,52 +1,52 @@
|
|
1
|
-
#
|
2
|
-
# The MIT License(MIT)
|
3
|
-
#
|
4
|
-
# Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
|
5
|
-
#
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
#
|
13
|
-
# The above copyright notice and this permission notice shall be included in all
|
14
|
-
# copies or substantial portions of the Software.
|
15
|
-
#
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
-
# SOFTWARE.
|
23
|
-
# =
|
24
|
-
|
25
|
-
module Copyleaks
|
26
|
-
class NaturalLanguageSubmissionModel < AIDetectionSubmissionModel
|
27
|
-
attr_accessor :language
|
28
|
-
|
29
|
-
# @param [String] A text string.
|
30
|
-
# @param [String] The language code of your content. The selected language should be on the Supported Languages list above. If the 'language' field is not supplied , our system will automatically detect the language of the content.
|
31
|
-
# @param [Boolean] Use sandbox mode to test your integration with the Copyleaks API for free.
|
32
|
-
def initialize(text, language = nil, sandbox = false)
|
33
|
-
unless text.instance_of?(String)
|
34
|
-
raise 'Copyleaks::NaturalLanguageSubmissionModel - text - text must be of type String'
|
35
|
-
end
|
36
|
-
super(text, sandbox)
|
37
|
-
@language = language
|
38
|
-
end
|
39
|
-
|
40
|
-
def as_json(*_args)
|
41
|
-
{
|
42
|
-
text: @text,
|
43
|
-
sandbox: @sandbox,
|
44
|
-
language: @language
|
45
|
-
}.select { |_k, v| !v.nil? }
|
46
|
-
end
|
47
|
-
|
48
|
-
def to_json(*options)
|
49
|
-
as_json(*options).to_json(*options)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
1
|
+
#
|
2
|
+
# The MIT License(MIT)
|
3
|
+
#
|
4
|
+
# Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
# =
|
24
|
+
|
25
|
+
module Copyleaks
|
26
|
+
class NaturalLanguageSubmissionModel < AIDetectionSubmissionModel
|
27
|
+
attr_accessor :language
|
28
|
+
|
29
|
+
# @param [String] A text string.
|
30
|
+
# @param [String] The language code of your content. The selected language should be on the Supported Languages list above. If the 'language' field is not supplied , our system will automatically detect the language of the content.
|
31
|
+
# @param [Boolean] Use sandbox mode to test your integration with the Copyleaks API for free.
|
32
|
+
def initialize(text, language = nil, sandbox = false)
|
33
|
+
unless text.instance_of?(String)
|
34
|
+
raise 'Copyleaks::NaturalLanguageSubmissionModel - text - text must be of type String'
|
35
|
+
end
|
36
|
+
super(text, sandbox)
|
37
|
+
@language = language
|
38
|
+
end
|
39
|
+
|
40
|
+
def as_json(*_args)
|
41
|
+
{
|
42
|
+
text: @text,
|
43
|
+
sandbox: @sandbox,
|
44
|
+
language: @language
|
45
|
+
}.select { |_k, v| !v.nil? }
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_json(*options)
|
49
|
+
as_json(*options).to_json(*options)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|