plagiarism-checker 3.2.1 → 3.4.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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -0
  3. data/.vscode/launch.json +35 -0
  4. data/Gemfile +0 -0
  5. data/LICENSE.txt +0 -0
  6. data/README.md +0 -0
  7. data/Rakefile +0 -0
  8. data/bin/console +0 -0
  9. data/bin/setup +0 -0
  10. data/lib/copyleaks/ai_detection_client.rb +98 -0
  11. data/lib/copyleaks/api.rb +18 -21
  12. data/lib/copyleaks/app.config.rb +0 -0
  13. data/lib/copyleaks/models/auth_token.rb +0 -0
  14. data/lib/copyleaks/models/delete_request_model.rb +0 -0
  15. data/lib/copyleaks/models/exceptions/{auth_exipred_exception.rb → auth_expired_exception.rb} +2 -4
  16. data/lib/copyleaks/models/exceptions/command_exception.rb +11 -4
  17. data/lib/copyleaks/models/exceptions/index.rb +1 -1
  18. data/lib/copyleaks/models/exceptions/rate_limit_exception.rb +2 -4
  19. data/lib/copyleaks/models/exceptions/under_maintenance_exception.rb +2 -4
  20. data/lib/copyleaks/models/exports/export_crawled_version.rb +0 -0
  21. data/lib/copyleaks/models/exports/export_model.rb +0 -0
  22. data/lib/copyleaks/models/exports/export_pdf_report.rb +0 -0
  23. data/lib/copyleaks/models/exports/export_results.rb +0 -0
  24. data/lib/copyleaks/models/exports/index.rb +0 -0
  25. data/lib/copyleaks/models/id_object.rb +0 -0
  26. data/lib/copyleaks/models/index.rb +0 -0
  27. data/lib/copyleaks/models/start_request_model.rb +0 -0
  28. data/lib/copyleaks/models/submissions/ai_detection/ai_detection_submission_model.rb +50 -0
  29. data/lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb +52 -0
  30. data/lib/copyleaks/models/submissions/ai_detection/source_code_submission_model.rb +55 -0
  31. data/lib/copyleaks/models/submissions/file_ocr_submission_model.rb +0 -0
  32. data/lib/copyleaks/models/submissions/file_submission_model.rb +0 -0
  33. data/lib/copyleaks/models/submissions/index.rb +7 -0
  34. data/lib/copyleaks/models/submissions/properties/actions.rb +0 -0
  35. data/lib/copyleaks/models/submissions/properties/ai_generated_text.rb +0 -0
  36. data/lib/copyleaks/models/submissions/properties/author.rb +0 -0
  37. data/lib/copyleaks/models/submissions/properties/copyleaks_db.rb +0 -0
  38. data/lib/copyleaks/models/submissions/properties/cross_languages.rb +0 -0
  39. data/lib/copyleaks/models/submissions/properties/custom_metadata.rb +0 -0
  40. data/lib/copyleaks/models/submissions/properties/domains_mode.rb +0 -0
  41. data/lib/copyleaks/models/submissions/properties/exclude.rb +0 -0
  42. data/lib/copyleaks/models/submissions/properties/exclude_code.rb +0 -0
  43. data/lib/copyleaks/models/submissions/properties/filter.rb +6 -2
  44. data/lib/copyleaks/models/submissions/properties/index.rb +1 -0
  45. data/lib/copyleaks/models/submissions/properties/indexing.rb +0 -0
  46. data/lib/copyleaks/models/submissions/properties/indexing_repository.rb +0 -0
  47. data/lib/copyleaks/models/submissions/properties/language.rb +0 -0
  48. data/lib/copyleaks/models/submissions/properties/masking_policy.rb +0 -0
  49. data/lib/copyleaks/models/submissions/properties/pdf_colors.rb +0 -0
  50. data/lib/copyleaks/models/submissions/properties/pdf_properties.rb +0 -0
  51. data/lib/copyleaks/models/submissions/properties/pdf_version.rb +0 -0
  52. data/lib/copyleaks/models/submissions/properties/repository.rb +0 -0
  53. data/lib/copyleaks/models/submissions/properties/scan_method_algorithm.rb +0 -0
  54. data/lib/copyleaks/models/submissions/properties/scanning.rb +0 -0
  55. data/lib/copyleaks/models/submissions/properties/scanning_exclude.rb +0 -0
  56. data/lib/copyleaks/models/submissions/properties/scanning_repository.rb +0 -0
  57. data/lib/copyleaks/models/submissions/properties/sensitive_data_protection.rb +0 -0
  58. data/lib/copyleaks/models/submissions/properties/submission_properties.rb +9 -3
  59. data/lib/copyleaks/models/submissions/properties/webhooks.rb +0 -0
  60. data/lib/copyleaks/models/submissions/properties/writing_feedback.rb +53 -0
  61. data/lib/copyleaks/models/submissions/submission_model.rb +0 -0
  62. data/lib/copyleaks/models/submissions/url_submission_model.rb +0 -0
  63. data/lib/copyleaks/models/submissions/writing_assistant/score_weights.rb +54 -0
  64. data/lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb +56 -0
  65. data/lib/copyleaks/utils/copyleaks_client.utils.rb +56 -0
  66. data/lib/copyleaks/utils/status-code.utils.rb +0 -0
  67. data/lib/copyleaks/version.rb +1 -1
  68. data/lib/copyleaks/writing_assistant_client.rb +81 -0
  69. data/lib/copyleaks.rb +1 -0
  70. data/lib/index.rb +0 -0
  71. metadata +17 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 908a27b3245660f5ceccef151bb1093b740ef3b00b8a79dc3a986279948662c1
4
- data.tar.gz: 05054b5d76f20515f0dee473897cc28a1b7d1bfa6aaeb910a31c0cda06455566
3
+ metadata.gz: 78d078009e0a00e806a132c00e4413146152407dac42d7bcc2c639606e11321e
4
+ data.tar.gz: aed6b1cbe5c60e2731a3e45545cd933ec1a3cad715c2c81bc9340e046107c9a8
5
5
  SHA512:
6
- metadata.gz: b278c9105d8e44a2d1e189f8c6db691592ebef80def66b2e1f8995b903ecdd6a3682b8c7062fc626512bcb2b67abf54140941e53bb3b56c990a608201b9b57ef
7
- data.tar.gz: a7e2d27a67c0e96e43c730a3f66ff235836a66beee3cccfeb43de1f2adca1d3d7c4d13d03f0fafc07113eb2ca535f060f380eb6536ac8c71d9dea632ed19190c
6
+ metadata.gz: 309584bf74ff895cc0c8cb6cddc99418ab1a751707921cbb4eb5c7d91d56dab50738838f4d910bb7d1f04ef14bd4f4baf3fb04b0bf6544ca40c7ae047e01c0a9
7
+ data.tar.gz: 9c49e09e073bd7b23e99a55ec781691424d103b6aae7f1e3ab7dc2ba9ef80859a61bdaf0f31b605fcc8f5b7b457434786cd55a24e7f8e598eeacfe3ad832a0ed
data/.gitignore CHANGED
File without changes
@@ -0,0 +1,35 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "name": "Debug Local File",
9
+ "type": "Ruby",
10
+ "request": "launch",
11
+ "program": "${workspaceRoot}/main.rb"
12
+ },
13
+ // Launch the debugger for any given program. In this case, it will run the current file using Ruby
14
+ {
15
+ "type": "ruby_lsp",
16
+ "name": "Debug",
17
+ "request": "launch",
18
+ "program": "ruby ${file}"
19
+ },
20
+ // Launch the debugger for the current test file
21
+ {
22
+ "type": "ruby_lsp",
23
+ "request": "launch",
24
+ "name": "Debug test file",
25
+ "program": "ruby -Itest ${relativeFile}"
26
+ },
27
+ // Attach the debugger client to an existing Ruby process that has already been launched with the debugger
28
+ // server
29
+ {
30
+ "type": "ruby_lsp",
31
+ "request": "attach",
32
+ "name": "Attach to existing server"
33
+ }
34
+ ]
35
+ }
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
@@ -0,0 +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
data/lib/copyleaks/api.rb CHANGED
@@ -24,6 +24,9 @@
24
24
  require 'net/http'
25
25
  require 'json'
26
26
  require 'date'
27
+ require_relative 'ai_detection_client.rb'
28
+ require_relative 'writing_assistant_client.rb'
29
+ require_relative 'utils/copyleaks_client.utils'
27
30
 
28
31
  module Copyleaks
29
32
  class API
@@ -36,6 +39,10 @@ module Copyleaks
36
39
  _api_server_uri = URI.parse(Config.api_server_uri)
37
40
  @api_client = Net::HTTP.new(_api_server_uri.host, _api_server_uri.port)
38
41
  @api_client.use_ssl = true
42
+
43
+ # Initialize clients
44
+ @ai_detection_client = AIDetectionClient.new(@api_client)
45
+ @writing_assistant_client = WritingAssistantClient.new(@api_client)
39
46
  end
40
47
 
41
48
  # Login to Copyleaks authentication server.
@@ -69,7 +76,7 @@ module Copyleaks
69
76
 
70
77
  # Verify that Copyleaks authentication token is exists and not exipired.
71
78
  # * Exceptions:
72
- # * * AuthExipredException: authentication expired. Need to login again.
79
+ # * * AuthExpiredException: authentication expired. Need to login again.
73
80
  # @param [CopyleaksAuthToken] authToken Copyleaks authentication token
74
81
  def verify_auth_token(authToken)
75
82
  if authToken.nil? || !authToken.instance_of?(CopyleaksAuthToken)
@@ -80,7 +87,7 @@ module Copyleaks
80
87
  _expiresTime = DateTime.parse(authToken.expires)
81
88
 
82
89
  if _expiresTime <= _time
83
- raise AuthExipredException.new.reason # expired
90
+ raise AuthExpiredException # expired
84
91
  end
85
92
  end
86
93
 
@@ -439,25 +446,15 @@ module Copyleaks
439
446
 
440
447
  # this methods is a helper for hanlding reponse data and exceptions.
441
448
  def handle_response(response, used_by)
442
- if Utils.is_success_status_code(response.code)
443
- if response.body.nil? || response.body == ''
444
- nil
445
- else
446
- JSON.parse(response.body)
447
- end
448
- elsif Utils.is_under_maintenance_response(response.code)
449
- raise UnderMaintenanceException.new.reason
450
- elsif Utils.is_rate_limit_response(response.code)
451
- raise RateLimitException.new.reason
452
- else
453
- _err_message = '---------Copyleaks SDK Error (' + used_by + ')---------' + "\n\n"
454
- _err_message += 'status code: ' + response.code + "\n\n"
455
-
456
- _err_message += 'response body:' + "\n" + response.body.to_json + "\n\n" unless response.body.nil?
457
-
458
- _err_message += '-------------------------------------'
459
- raise CommandException.new(_err_message).reason + "\n"
460
- end
449
+ Copyleaks::ClientUtils.handle_response(response, used_by)
450
+ end
451
+
452
+ def ai_detection_client
453
+ @ai_detection_client
454
+ end
455
+
456
+ def writing_assistant_client
457
+ @writing_assistant_client
461
458
  end
462
459
  end
463
460
  end
File without changes
File without changes
File without changes
@@ -22,11 +22,9 @@
22
22
  # SOFTWARE.
23
23
  # =
24
24
  module Copyleaks
25
- class AuthExipredException < StandardError
26
- attr_reader :reason
27
-
25
+ class AuthExpiredException < RuntimeError
28
26
  def initialize
29
- @reason = 'Authentication Expired. Need to login again'
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 < StandardError
26
- attr_reader :reason
25
+ class CommandException < RuntimeError
26
+ attr_reader :response
27
27
 
28
- def initialize(reason)
29
- @reason = reason
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 'auth_exipred_exception.rb'
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 < StandardError
26
- attr_reader :reason
27
-
25
+ class RateLimitException < RuntimeError
28
26
  def initialize
29
- @reason = 'Too many requests. Please wait before calling again.'
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 < StandardError
26
- attr_reader :reason
27
-
25
+ class UnderMaintenanceException < RuntimeError
28
26
  def initialize
29
- @reason = 'Copyleaks is Under Maintenance, please visit https://status.copyleaks.com'
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
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +1,55 @@
1
+ #
2
+ # The MIT License(MIT)
3
+ #
4
+ # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+ # =
24
+
25
+ module Copyleaks
26
+ class SourceCodeSubmissionModel < AIDetectionSubmissionModel
27
+ attr_accessor :filename
28
+
29
+ # @param [String] A text string.
30
+ # @param [String] The name of the file. Make sure to include the right extension for your file type.
31
+ # @param [Boolean] Use sandbox mode to test your integration with the Copyleaks API for free.
32
+ def initialize(text, filename, sandbox = false)
33
+ unless text.instance_of?(String)
34
+ raise 'Copyleaks::SourceCodeSubmissionModel - text - text must be of type String'
35
+ end
36
+ unless filename.instance_of?(String)
37
+ raise 'Copyleaks::SourceCodeSubmissionModel - filename - filename must be of type String'
38
+ end
39
+ super(text, sandbox)
40
+ @filename = filename
41
+ end
42
+
43
+ def as_json(*_args)
44
+ {
45
+ text: @text,
46
+ sandbox: @sandbox,
47
+ filename: @filename
48
+ }.select { |_k, v| !v.nil? }
49
+ end
50
+
51
+ def to_json(*options)
52
+ as_json(*options).to_json(*options)
53
+ end
54
+ end
55
+ end
@@ -28,5 +28,12 @@ require_relative 'file_submission_model.rb'
28
28
  require_relative 'file_ocr_submission_model.rb'
29
29
  require_relative 'url_submission_model.rb'
30
30
 
31
+ require_relative 'ai_detection/ai_detection_submission_model.rb'
32
+ require_relative 'ai_detection/natural_language_submission_model.rb'
33
+ require_relative 'ai_detection/source_code_submission_model.rb'
34
+
35
+ require_relative 'writing_assistant/score_weights.rb'
36
+ require_relative 'writing_assistant/writing_assistant_submission_model.rb'
37
+
31
38
  module Copyleaks
32
39
  end
@@ -30,6 +30,7 @@ module Copyleaks
30
30
  # @param [Boolean] safeSearch Block explicit adult content from the scan results such as web pages containing inappropriate images and videos. SafeSearch is not 100% effective with all websites.
31
31
  # @param [String[]] domains list of domains to either include or exclude from the scan - depending on the value of domainsMode.
32
32
  # @param [SubmissionFilterDomainsMode] domainsMode Include or Exclude the list of domains you specified under the domains property
33
+ # @param [Boolean] allowSameDomain when set to true it will allow results from the same domain as the submitted url.
33
34
  def initialize(
34
35
  identicalEnabled = true,
35
36
  minorChangesEnabled = false,
@@ -37,7 +38,8 @@ module Copyleaks
37
38
  minCopiedWords = nil,
38
39
  safeSearch = false,
39
40
  domains = [],
40
- domainsMode = SubmissionFilterDomainsMode::EXCLUDE
41
+ domainsMode = SubmissionFilterDomainsMode::EXCLUDE,
42
+ allowSameDomain = false
41
43
  )
42
44
  @identicalEnabled = identicalEnabled
43
45
  @minorChangesEnabled = minorChangesEnabled
@@ -46,6 +48,7 @@ module Copyleaks
46
48
  @safeSearch = safeSearch
47
49
  @domains = domains
48
50
  @domainsMode = domainsMode
51
+ @allowSameDomain = allowSameDomain
49
52
  end
50
53
 
51
54
  def as_json(*_args)
@@ -56,7 +59,8 @@ module Copyleaks
56
59
  minCopiedWords: @minCopiedWords,
57
60
  safeSearch: @safeSearch,
58
61
  domains: @domains,
59
- domainsMode: @domainsMode
62
+ domainsMode: @domainsMode,
63
+ allowSameDomain: @allowSameDomain
60
64
  }.select { |_k, v| !v.nil? }
61
65
  end
62
66
 
@@ -48,6 +48,7 @@ require_relative 'scanning_repository.rb'
48
48
  require_relative 'sensitive_data_protection.rb'
49
49
  require_relative 'submission_properties.rb'
50
50
  require_relative 'webhooks.rb'
51
+ require_relative 'writing_feedback.rb'
51
52
 
52
53
 
53
54
 
@@ -25,7 +25,7 @@ module Copyleaks
25
25
  class SubmissionProperties
26
26
  attr_reader :webhooks, :includeHtml, :developerPayload, :sandbox, :expiration, :sensitivityLevel, :cheatDetection,
27
27
  :action, :author, :filters, :scanning, :indexing, :exclude, :pdf, :sensitiveDataProtection, :scanMethodAlgorithm,
28
- :aiGeneratedText, :customMetadata
28
+ :aiGeneratedText, :customMetadata, :writingFeedback
29
29
 
30
30
  # @param [SubmissionWebhooks] webhooks - Check inner properties for more details.
31
31
  # @param [Boolean] includeHtml - By default, Copyleaks will present the report in text format. If set to true, Copyleaks will also include html format.
@@ -45,11 +45,12 @@ module Copyleaks
45
45
  # @param [SubmissionScanMethodAlgorithm] scanMethodAlgorithm - Check inner properties for more details.
46
46
  # @param [SubmissionAiGeneratedText] aiGeneratedText - Check inner properties for more details.
47
47
  # @param [SubmissionCustomMetadata] customMetadata - Add custom properties that will be attached to your document in a Copyleaks repository.
48
+ # @param [SubmissionWritingFeedback] writingFeedback - Check inner properties for more details.
48
49
  def initialize(
49
50
  webhooks, includeHtml = nil, developerPayload = nil, sandbox = nil, expiration = nil,
50
51
  sensitivityLevel = nil, cheatDetection = nil, action = nil, author = nil, filters = nil,
51
52
  scanning = nil, indexing = nil, exclude = nil, pdf = nil, sensitiveDataProtection = nil,
52
- scanMethodAlgorithm = nil, aiGeneratedText = nil, customMetadata = nil
53
+ scanMethodAlgorithm = nil, aiGeneratedText = nil, customMetadata = nil, writingFeedback = nil
53
54
  )
54
55
  unless webhooks.instance_of?(SubmissionWebhooks)
55
56
  raise 'Copyleaks::SubmissionProperties - webhooks - webhooks must be of type SubmissionWebhooks'
@@ -105,6 +106,9 @@ module Copyleaks
105
106
  if !customMetadata.nil? && !(customMetadata.is_a?(Array) && customMetadata.all? { |element| element.is_a?(SubmissionCustomMetadata) })
106
107
  raise 'Copyleaks::SubmissionProperties - customMetadata - customMetadata must be of type SubmissionCustomMetadata[]'
107
108
  end
109
+ if !writingFeedback.nil? && !writingFeedback.instance_of?(SubmissionWritingFeedback)
110
+ raise 'Copyleaks::SubmissionProperties - writingFeedback - writingFeedback must be of type SubmissionWritingFeedback'
111
+ end
108
112
 
109
113
  @webhooks = webhooks
110
114
  @includeHtml = includeHtml
@@ -124,6 +128,7 @@ module Copyleaks
124
128
  @sensitiveDataProtection = sensitiveDataProtection
125
129
  @scanMethodAlgorithm = scanMethodAlgorithm
126
130
  @customMetadata = customMetadata
131
+ @writingFeedback = writingFeedback
127
132
  end
128
133
 
129
134
  def as_json(*_args)
@@ -145,7 +150,8 @@ module Copyleaks
145
150
  pdf: @pdf,
146
151
  sensitiveDataProtection: @sensitiveDataProtection,
147
152
  scanMethodAlgorithm: @scanMethodAlgorithm,
148
- customMetadata: @customMetadata
153
+ customMetadata: @customMetadata,
154
+ writingFeedback: @writingFeedback
149
155
  }.select { |_k, v| !v.nil? }
150
156
  end
151
157
 
@@ -0,0 +1,53 @@
1
+ #
2
+ # The MIT License(MIT)
3
+ #
4
+ # Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+ # =
24
+
25
+ module Copyleaks
26
+ class SubmissionWritingFeedback
27
+ attr_accessor :enable, :score
28
+ # @param [Boolean] Enable automated Writing Assistant . This feature includes grammar checking, spell checking and sentence structure corrections.
29
+ # @param [ScoreWeights] an object containing the score weights for different writing aspects (e.g., grammar, mechanics). Optional.
30
+ def initialize(enable = false, score = nil)
31
+ unless [true, false].include?(enable)
32
+ raise 'Copyleaks::SubmissionWritingFeedback - enable - enable must be of type Boolean'
33
+ end
34
+ unless score.nil? || score.is_a?(ScoreWeights)
35
+ raise 'Copyleaks::SubmissionWritingFeedback - score - score must be of type ScoreWeights'
36
+ end
37
+
38
+ @enable = enable
39
+ @score = score
40
+ end
41
+
42
+ def as_json(*_args)
43
+ {
44
+ enable: @enable,
45
+ score: @score
46
+ }.reject { |_k, v| v.nil? }
47
+ end
48
+
49
+ def to_json(*options)
50
+ as_json(*options).to_json(*options)
51
+ end
52
+ end
53
+ end
File without changes
@@ -0,0 +1,54 @@
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 ScoreWeights
27
+ # @param [Float] Grammar correction category weight in the overall score. 0.0 >= weight <= 1.0
28
+ # @param [Float] Mechanics correction category weight in the overall score. 0.0 >= weight <= 1.0
29
+ # @param [Float] Sentence structure correction category weight in the overall score. 0.0 >= weight <= 1.0
30
+ # @param [Float] Word choice correction category weight in the overall score. 0.0 >= weight <= 1.0
31
+
32
+ attr_accessor :grammar_score_weight, :mechanics_score_weight, :sentence_structure_score_weight, :word_choice_score_weight
33
+
34
+ def initialize(grammar_score_weight, mechanics_score_weight, sentence_structure_score_weight, word_choice_score_weight)
35
+ @grammar_score_weight = grammar_score_weight
36
+ @mechanics_score_weight = mechanics_score_weight
37
+ @sentence_structure_score_weight = sentence_structure_score_weight
38
+ @word_choice_score_weight = word_choice_score_weight
39
+ end
40
+
41
+ def as_json(*_args)
42
+ {
43
+ grammarScoreWeight: @grammar_score_weight,
44
+ mechanicsScoreWeight: @mechanics_score_weight,
45
+ sentenceStructureScoreWeight: @sentence_structure_score_weight,
46
+ wordChoiceScoreWeight: @word_choice_score_weight
47
+ }.reject { |_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
@@ -0,0 +1,56 @@
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 WritingAssistantSubmissionModel
27
+ attr_accessor :text, :sandbox, :language, :score
28
+
29
+ # @param [String] Text to produce Writing Assistant report for. 1 >= characters <= 25000
30
+ # @param [Boolean] Use sandbox mode to test your integration with the Copyleaks API without consuming any credits.
31
+ # @param [String] language The language code of your content. Optional; if not provided, the system will attempt to auto-detect the language.
32
+ # @param [ScoreWeights] an object containing the score weights for different writing aspects (e.g., grammar, mechanics). Optional.
33
+ def initialize(text, sandbox = false, language = nil, score = nil)
34
+ unless text.instance_of?(String)
35
+ raise 'Copyleaks::SourceCodeSubmissionModel - text - text must be of type String'
36
+ end
37
+ @text = text
38
+ @sandbox = sandbox
39
+ @language = language
40
+ @score = score
41
+ end
42
+
43
+ def as_json(*_args)
44
+ {
45
+ text: @text,
46
+ sandbox: @sandbox,
47
+ language: @language,
48
+ score: @score
49
+ }.reject { |_k, v| v.nil? }
50
+ end
51
+
52
+ def to_json(*options)
53
+ as_json(*options).to_json(*options)
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,56 @@
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 ClientUtils
27
+ def self.handle_response(response, used_by)
28
+ if Utils.is_success_status_code(response.code)
29
+ if response.body.nil? || response.body == ''
30
+ nil
31
+ else
32
+ JSON.parse(response.body)
33
+ end
34
+ elsif Utils.is_under_maintenance_response(response.code)
35
+ raise UnderMaintenanceException
36
+ elsif Utils.is_rate_limit_response(response.code)
37
+ raise RateLimitException
38
+ else
39
+ raise CommandException.new(response: response, used_by: used_by)
40
+ end
41
+ end
42
+
43
+ def self.verify_auth_token(authToken)
44
+ if authToken.nil? || !authToken.instance_of?(CopyleaksAuthToken)
45
+ raise 'authToken is Invalid, must be instance of CopyleaksAuthToken'
46
+ end
47
+
48
+ _time = DateTime.now
49
+ _expiresTime = DateTime.parse(authToken.expires)
50
+
51
+ if _expiresTime <= _time
52
+ raise AuthExpiredException # expired
53
+ end
54
+ end
55
+ end
56
+ end
File without changes
@@ -1,3 +1,3 @@
1
1
  module Copyleaks
2
- VERSION = '3.2.1'
2
+ VERSION = '3.4.0'
3
3
  end
@@ -0,0 +1,81 @@
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 WritingAssistantClient
27
+ def initialize(api_client)
28
+ @api_client = api_client
29
+ end
30
+
31
+ # Get a list of correction types supported within the Writing Assistant API. Correction types apply to all supported languages. The supplied language code for this request is used to determine the language of the texts returned.
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 [languageCode] The language for the returned texts to be in. Language codes are in ISO 639-1 standard. Supported Values: en - English
39
+ def get_correction_types(language_code)
40
+ path = "/v1/writing-feedback/correction-types/#{language_code}"
41
+
42
+ headers = {
43
+ 'Content-Type' => 'application/json',
44
+ 'User-Agent' => Config.user_agent
45
+ }
46
+
47
+ request = Net::HTTP::Get.new(path, headers)
48
+ ClientUtils.handle_response(@api_client.request(request), 'get_correction_types')
49
+ end
50
+
51
+ # Use Copyleaks Writing Assistant to generate grammar, spelling and sentence corrections for a given text.
52
+ # * Exceptions:
53
+ # * * CommandExceptions: Server reject the request. See response status code,
54
+ # headers and content for more info.
55
+ # * * UnderMaintenanceException: Copyleaks servers are unavailable for maintenance.
56
+ # We recommend to implement exponential backoff algorithm as described here:
57
+ # https://api.copyleaks.com/documentation/v3/exponential-backoff
58
+ # @param [CopyleaksAuthToken] authToken Copyleaks authentication token
59
+ # @param [String] scanId Attach your own scan Id
60
+ # @param [SourceCodeSubmissionModel] submission document
61
+ def submit_text(authToken, scanId, submission)
62
+ raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String)
63
+ raise 'submission is invalid, must be an instance of WritingAssistantSubmissionModel' if submission.nil? || !submission.instance_of?(Copyleaks::WritingAssistantSubmissionModel)
64
+
65
+ ClientUtils.verify_auth_token(authToken)
66
+
67
+ path = "/v1/writing-feedback/#{scanId}/check"
68
+
69
+ headers = {
70
+ 'Content-Type' => 'application/json',
71
+ 'User-Agent' => Config.user_agent,
72
+ 'Authorization' => "Bearer #{authToken.accessToken}"
73
+ }
74
+
75
+ request = Net::HTTP::Post.new(path, headers)
76
+ request.body = submission.to_json
77
+
78
+ ClientUtils.handle_response(@api_client.request(request), 'submit_writing_assistant')
79
+ end
80
+ end
81
+ end
data/lib/copyleaks.rb CHANGED
@@ -27,6 +27,7 @@ require_relative './copyleaks/version.rb'
27
27
  require_relative './copyleaks/app.config.rb'
28
28
  require_relative './copyleaks/models/index.rb'
29
29
  require_relative './copyleaks/utils/status-code.utils.rb'
30
+ require_relative './copyleaks/utils/copyleaks_client.utils.rb'
30
31
 
31
32
  module Copyleaks
32
33
  end
data/lib/index.rb CHANGED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plagiarism-checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Copyleaks ltd
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-08 00:00:00.000000000 Z
11
+ date: 2025-01-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Copyleaks detects plagiarism and checks content distribution online.
14
14
  Use Copyleaks to find out if textual content is original and if it has been used
@@ -23,6 +23,7 @@ extensions: []
23
23
  extra_rdoc_files: []
24
24
  files:
25
25
  - ".gitignore"
26
+ - ".vscode/launch.json"
26
27
  - Gemfile
27
28
  - LICENSE.txt
28
29
  - README.md
@@ -30,11 +31,12 @@ files:
30
31
  - bin/console
31
32
  - bin/setup
32
33
  - lib/copyleaks.rb
34
+ - lib/copyleaks/ai_detection_client.rb
33
35
  - lib/copyleaks/api.rb
34
36
  - lib/copyleaks/app.config.rb
35
37
  - lib/copyleaks/models/auth_token.rb
36
38
  - lib/copyleaks/models/delete_request_model.rb
37
- - lib/copyleaks/models/exceptions/auth_exipred_exception.rb
39
+ - lib/copyleaks/models/exceptions/auth_expired_exception.rb
38
40
  - lib/copyleaks/models/exceptions/command_exception.rb
39
41
  - lib/copyleaks/models/exceptions/index.rb
40
42
  - lib/copyleaks/models/exceptions/rate_limit_exception.rb
@@ -47,6 +49,9 @@ files:
47
49
  - lib/copyleaks/models/id_object.rb
48
50
  - lib/copyleaks/models/index.rb
49
51
  - lib/copyleaks/models/start_request_model.rb
52
+ - lib/copyleaks/models/submissions/ai_detection/ai_detection_submission_model.rb
53
+ - lib/copyleaks/models/submissions/ai_detection/natural_language_submission_model.rb
54
+ - lib/copyleaks/models/submissions/ai_detection/source_code_submission_model.rb
50
55
  - lib/copyleaks/models/submissions/file_ocr_submission_model.rb
51
56
  - lib/copyleaks/models/submissions/file_submission_model.rb
52
57
  - lib/copyleaks/models/submissions/index.rb
@@ -76,10 +81,15 @@ files:
76
81
  - lib/copyleaks/models/submissions/properties/sensitive_data_protection.rb
77
82
  - lib/copyleaks/models/submissions/properties/submission_properties.rb
78
83
  - lib/copyleaks/models/submissions/properties/webhooks.rb
84
+ - lib/copyleaks/models/submissions/properties/writing_feedback.rb
79
85
  - lib/copyleaks/models/submissions/submission_model.rb
80
86
  - lib/copyleaks/models/submissions/url_submission_model.rb
87
+ - lib/copyleaks/models/submissions/writing_assistant/score_weights.rb
88
+ - lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb
89
+ - lib/copyleaks/utils/copyleaks_client.utils.rb
81
90
  - lib/copyleaks/utils/status-code.utils.rb
82
91
  - lib/copyleaks/version.rb
92
+ - lib/copyleaks/writing_assistant_client.rb
83
93
  - lib/index.rb
84
94
  homepage: https://api.copyleaks.com
85
95
  licenses:
@@ -88,7 +98,7 @@ metadata:
88
98
  homepage_uri: https://api.copyleaks.com
89
99
  source_code_uri: https://github.com/Copyleaks/Ruby-Plagiarism-Checker
90
100
  changelog_uri: https://github.com/Copyleaks/Ruby-Plagiarism-Checker/releases
91
- post_install_message:
101
+ post_install_message:
92
102
  rdoc_options: []
93
103
  require_paths:
94
104
  - lib
@@ -103,8 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
113
  - !ruby/object:Gem::Version
104
114
  version: '0'
105
115
  requirements: []
106
- rubygems_version: 3.3.7
107
- signing_key:
116
+ rubygems_version: 3.3.5
117
+ signing_key:
108
118
  specification_version: 4
109
119
  summary: Detects plagiarism and checks content distribution online.
110
120
  test_files: []