plagiarism-checker 3.7.0 → 4.1.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 (27) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -0
  3. data/README.md +225 -31
  4. data/lib/copyleaks/ai_detection_client.rb +1 -35
  5. data/lib/copyleaks/{models/submissions/ai_detection/source_code_submission_model.rb → ai_image_detection_client.rb} +22 -23
  6. data/lib/copyleaks/api.rb +6 -9
  7. data/lib/copyleaks/models/constants/CopyleaksAiImageDetectionModels.rb +28 -0
  8. data/lib/copyleaks/models/constants/CopyleaksTextModerationConstants.rb +39 -0
  9. data/lib/copyleaks/models/constants/CopyleaksTextModerationLanguages.rb +29 -0
  10. data/lib/copyleaks/models/constants/index.rb +4 -1
  11. data/lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb +120 -0
  12. data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionImageInfoModel.rb +63 -0
  13. data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResponseModel.rb +90 -0
  14. data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResultModel.rb +63 -0
  15. data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionScannedDocumentModel.rb +77 -0
  16. data/lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionSummaryModel.rb +65 -0
  17. data/lib/copyleaks/models/imageDetection/responses/CopyleaksImageMetadataModel.rb +70 -0
  18. data/lib/copyleaks/models/imageDetection/responses/CopyleaksImageShapeModel.rb +63 -0
  19. data/lib/copyleaks/models/index.rb +10 -0
  20. data/lib/copyleaks/models/submissions/index.rb +0 -1
  21. data/lib/copyleaks/models/submissions/writing_assistant/writing_assistant_submission_model.rb +1 -1
  22. data/lib/copyleaks/{deprecationService.rb → models/textModeration/requests/CopyleaksTextModerationLabel.rb} +18 -12
  23. data/lib/copyleaks/models/textModeration/requests/CopyleaksTextModerationRequestModel.rb +23 -0
  24. data/lib/copyleaks/version.rb +1 -1
  25. data/lib/copyleaks/writing_assistant_client.rb +1 -1
  26. metadata +14 -4
  27. data/lib/copyleaks/models/constants/supportedFilesTypes.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e6c39eff469e6df12ee451517a9d7fc26665972d34df112e3e5af0fc0358c1a
4
- data.tar.gz: 5a58f319e6d4b5b458986f17ec55c5467e61ee8066e0a28371f10b98cd1a82cb
3
+ metadata.gz: 39393e80d6d74245563438a02c382e7de87c22acbc425ffd3d4e92a6b96d669f
4
+ data.tar.gz: 170a23529cde53bcc693de8f847200855b03964001c0d33f72af74fe804b6138
5
5
  SHA512:
6
- metadata.gz: 55397ee13aaecc378f384013952297274028d7281e5942177a1e5b2b7c403781ee536679bb87816e3d1ecd3850f7bb27f484152edde70a4f8a1c201e86ff5858
7
- data.tar.gz: bb14ad845218add504b353f7feaf8a0205a2da9d655abd348b9b959c2fbd8b738ef931600fbe769e3ec2bf9ff0a1be0c412ff4b6dd8fe43b991c130ff3601606
6
+ metadata.gz: 4efd08769fac76f7f0846835cf977efd8190a91883f76df6e3576909328071cb9fcfcc6f382af6dd7a66dbba5139469045612b0ec2b829348ceea19786d5c316
7
+ data.tar.gz: a6640272ad89bc07d0f99c17562d549dcfc116cac4ddbca10846f066cc94cc702c058197ee99722a1e9136a679ba9207f70095d965b96fe3ff6849751f5e5aca
data/.gitignore CHANGED
@@ -6,3 +6,12 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+
10
+ # Generated gem files
11
+ *.gem
12
+ plagiarism-checker-3.2.1.gem
13
+ plagiarism-checker-3.5.0.gem
14
+ plagiarism-checker-3.6.0.gem
15
+ plagiarism-checker-3.6.1.gem
16
+ plagiarism-checker-3.7.0.gem
17
+ plagiarism-checker-4.0.0.gem
data/README.md CHANGED
@@ -1,47 +1,241 @@
1
- # Copyleaks Ruby SDK
1
+ # Copyleaks SDK
2
+ The official [Copyleaks](https://copyleaks.com/) Ruby library.
2
3
 
3
- Copyleaks SDK is a simple framework that allows you to scan text for plagiarism and detect content distribution online, using the Copyleaks plagiarism checker cloud.
4
+ ## 🚀 Getting Started
5
+ Before you start, ensure you have the following:
4
6
 
5
- Using Copyleaks SDK you can check for plagiarism in:
6
- * Online content and webpages
7
- * Local and cloud files (see [supported files](https://api.copyleaks.com/documentation/specifications#2-supported-file-types))
8
- * Free text
9
- * OCR (Optical Character Recognition) - scanning pictures with textual content (see [supported files](https://api.copyleaks.com/documentation/specifications#6-supported-image-types-ocr))
7
+ * An active Copyleaks account. If you don’t have one, [sign up for free](https://copyleaks.com/signup).
8
+ * You can find your API key on the [API Dashboard](https://api.copyleaks.com/dashboard).
10
9
 
11
- ## Installation
12
-
13
- Install using [RubyGems](https://rubygems.org/gems/plagiarism-checker)
10
+ Once you have your account and API key:
14
11
 
12
+ **Install the SDK**:
13
+
14
+ Install using [RubyGems](https://rubygems.org/gems/plagiarism-checker)
15
15
  ```bash
16
16
  gem install plagiarism-checker
17
17
  ```
18
18
 
19
- ## Register and Get Your API Key
20
- To use the Copyleaks API you need to first be a registered user. The registration to Copyleaks takes a minute and is free of charge. [Signup](https://api.copyleaks.com/?register=true) and make sure to confirm your account.
19
+ ## 📚 Documentation
20
+ To learn more about how to use Copyleaks API please check out our [Documentation](https://docs.copyleaks.com/resources/sdks/ruby/).
21
+
22
+ ## 💡 Usage Examples
23
+ Here are some common usage examples for the Copyleaks SDK. You can also see a comprehensive code example in the `demo.rb` file on our GitHub repository: [demo.rb](https://github.com/Copyleaks/Ruby-Plagiarism-Checker/blob/master/demo/demo.rb).
24
+
25
+ ### Get Authentication Token
26
+ This example demonstrates how to log in to the Copyleaks API and obtain an authentication token.
27
+
28
+ ```ruby
29
+ require 'copyleaks'
30
+ require 'base64'
31
+
32
+ # --- Your Credentials ---
33
+ USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
34
+ USER_API_KEY = 'YOUR_API_KEY'
35
+ # --------------------
36
+
37
+ begin
38
+ # Log in to the Copyleaks API
39
+ puts "Authenticating..."
40
+ copyleaks = Copyleaks::API.new
41
+ auth_token = copyleaks.login(USER_EMAIL, USER_API_KEY)
42
+ puts "✅ Logged in successfully!"
43
+
44
+ end
45
+ ```
46
+ For a detailed understanding of the authentication process, refer to the Copyleaks Login Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/account/login).
47
+ ##
48
+ ### Submit Text for Plagiarism Scan
49
+ This example shows how to prepare and submit raw text content for a plagiarism scan.
50
+
51
+ ```ruby
52
+ require 'copyleaks'
53
+ require 'base64'
54
+
55
+ # --- Your Credentials ---
56
+ USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
57
+ USER_API_KEY = 'YOUR_API_KEY'
58
+ WEBHOOK_URL = 'https://your-server.com'
59
+ # --------------------
60
+
61
+ begin
62
+ scanId = DateTime.now.strftime('%Q').to_s
63
+ submisson = Copyleaks::CopyleaksFileSubmissionModel.new(
64
+ 'aGVsbG8gd29ybGQ=',
65
+ 'ruby.txt',
66
+ Copyleaks::SubmissionProperties.new(
67
+ Copyleaks::SubmissionWebhooks.new("#{WEBHOOK_URL}/webhook/{STATUS}","#{WEBHOOK_URL}/url-webhook/new-result"),
68
+ true,
69
+ 'developer_payloads_test',
70
+ true,
71
+ 60,
72
+ 1,
73
+ true,
74
+ Copyleaks::SubmissionActions::SCAN,
75
+ Copyleaks::SubmissionAuthor.new('Author_name'),
76
+ Copyleaks::SubmissionFilter.new(true, true, true),
77
+ Copyleaks::SubmissionScanning.new(true, nil, nil, Copyleaks::SubmissionScanningCopyleaksDB.new(true, true)),
78
+ Copyleaks::SubmissionIndexing.new([Copyleaks::SubmissionRepository.new('repo-1')]),
79
+ Copyleaks::SubmissionExclude.new(true, true, true, true, true),
80
+ Copyleaks::SubmissionPDF.new(true, 'pdf-title', BASE64_LOGO, false),
81
+ Copyleaks::SubmissionSensitiveData.new(false)
82
+ )
83
+ )
84
+
85
+ @copyleaks.submit_file(_authToken, scanId, submisson)
86
+
87
+ end
88
+ ```
89
+ For a full guide please refer to our step by step [Guide](https://docs.copyleaks.com/guides/authenticity/detect-plagiarism-text)
90
+
91
+ For a detailed understanding of the plagiarism detection process, refer to the Copyleaks Submit Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/scans/submit-file)
92
+ ##
93
+ ### AI-Generated Text Detection
94
+ Use the AI detection client to determine if content was generated by artificial intelligence.
95
+
96
+ ```ruby
97
+ require 'copyleaks'
98
+ require 'base64'
99
+
100
+ # --- Your Credentials ---
101
+ USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
102
+ USER_API_KEY = 'YOUR_API_KEY'
103
+ # --------------------
104
+
105
+ begin
106
+ scanId = DateTime.now.strftime('%Q').to_s
107
+ text = "Lions are social animals, living in groups called prides, typically consisting of several females, their offspring, and a few males. Female lions are the primary hunters, working together to catch prey. Lions are known for their strength, teamwork, and complex social structures."
108
+ submission = Copyleaks::NaturalLanguageSubmissionModel.new(
109
+ text,
110
+ )
111
+ submission.sandbox = true
112
+
113
+ res = @copyleaks.ai_detection_client.submit_natural_language(_authToken, scanId, submission)
21
114
 
22
- As a signed user you can generate your personal API key. Do so on your [dashboard home](https://api.copyleaks.com/dashboard) under 'API Access Credentials'.
115
+ end
116
+ ```
117
+ For a full guide please refer to our step by step [Guide](https://docs.copyleaks.com/guides/ai-detector/ai-text-detection/)
23
118
 
24
- For more information check out our [API guide](https://api.copyleaks.com/documentation/v3).
119
+ For a detailed understanding of the Ai detection process, refer to the Copyleaks detect natural language Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/writer-detector/check/)
120
+ ##
121
+ ### Writing Assistant
122
+ Get intelligent suggestions for improving grammar, spelling, style, and overall writing quality.
25
123
 
26
- ## Usage
27
- ```rb
124
+ ```ruby
28
125
  require 'copyleaks'
29
- copyleaks = Copyleaks::API.new
30
- res = copyleaks.login(<your email>,<your api key>)
31
- puts res.to_json
126
+ require 'base64'
127
+
128
+ # --- Your Credentials ---
129
+ USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
130
+ USER_API_KEY = 'YOUR_API_KEY'
131
+ # --------------------
132
+
133
+ begin
134
+ text = "Lions are the only cat that live in groups, called pride. A prides typically consists of a few adult males, several feales, and their offspring. This social structure is essential for hunting and raising young cubs. Female lions, or lionesses are the primary hunters of the prid. They work together in cordinated groups to take down prey usually targeting large herbiores like zbras, wildebeest and buffalo. Their teamwork and strategy during hunts highlight the intelligence and coperation that are key to their survival."
135
+ scanId = DateTime.now.strftime('%Q').to_s
136
+ score_weights = Copyleaks::ScoreWeights.new(0.1, 0.2, 0.3, 0.4)
137
+ submission = Copyleaks::WritingAssistantSubmissionModel.new(
138
+ text,
139
+ )
140
+ submission.sandbox = true
141
+ submission.score = score_weights
142
+ res = @copyleaks.writing_assistant_client.submit_text(_authToken, scanId, submission)
143
+
144
+ end
32
145
  ```
33
- * (Option) To change the Identity server URI (default:"https://id.copyleaks.com"):
34
- ```rb
35
- Copyleaks::Config.identity_server_uri = "<your identity server uri>"
146
+ For a full guide please refer to our step by step [Guide](https://docs.copyleaks.com/guides/writing/check-grammar/)
147
+
148
+ For a detailed understanding of the Writing assistant process, refer to the Copyleaks writing feedback Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/writing-assistant/check/)
149
+ ##
150
+ ### Text Moderation
151
+ Scan and moderate text content for unsafe, inappropriate, or policy-violating material across various categories.
152
+
153
+ ```ruby
154
+ require 'copyleaks'
155
+ require 'base64'
156
+
157
+ # --- Your Credentials ---
158
+ USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
159
+ USER_API_KEY = 'YOUR_API_KEY'
160
+ # --------------------
161
+
162
+ begin
163
+ scanId = DateTime.now.strftime('%Q').to_s
164
+ labelsArray=[
165
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::ADULT_V1),
166
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::TOXIC_V1),
167
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::VIOLENT_V1),
168
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::PROFANITY_V1),
169
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::SELF_HARM_V1),
170
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::HARASSMENT_V1),
171
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::HATE_SPEECH_V1),
172
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::DRUGS_V1),
173
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::FIREARMS_V1),
174
+ Copyleaks::CopyleaksTextModerationLabel.new(Copyleaks::CopyleaksTextModerationConstants::CYBERSECURITY_V1)
175
+ ]
176
+
177
+ text_moderation_request = Copyleaks::CopyleaksTextModerationRequestModel.new(
178
+ text: "This is some text to scan.",
179
+ sandbox: true,
180
+ language: Copyleaks::CopyleaksTextModerationLanguages::ENGLISH,
181
+ labels: labelsArray
182
+ )
183
+ res = @copyleaks.text_moderation_client.submit_text(_authToken, scanId, text_moderation_request)
184
+
185
+ textModerationResponse = Copyleaks::CopyleaksTextModerationResponseModel.new(
186
+ moderations: res['moderations'],
187
+ legend: res['legend'],
188
+ scanned_document: res['scannedDocument'])
189
+
190
+ end
36
191
  ```
37
- * (Option) To change the API server URI (default:"https://api.copyleaks.com"):
38
- ```rb
39
- Copyleaks::Config.api_server_uri = "<your api server uri>"
192
+ For a full guide please refer to our step by step [Guide](https://docs.copyleaks.com/guides/moderation/moderate-text/)
193
+
194
+ For a detailed understanding of the Text moderation process, refer to the Copyleaks text moderation Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/text-moderation/check/)
195
+ ##
196
+ ### AI Image Detection
197
+ Determine if a given image was generated or partially generated by an AI.
198
+
199
+ ```ruby
200
+ require 'copyleaks'
201
+ require 'base64'
202
+ # --- Your Credentials ---
203
+ USER_EMAIL = 'YOUR_EMAIL_ADDRESS'
204
+ USER_API_KEY = 'YOUR_API_KEY'
205
+ # --------------------
206
+ begin
207
+ puts "Submitting a new image for AI image detection..."
208
+
209
+ scanId = DateTime.now.strftime('%Q').to_s
210
+
211
+ # Read and encode your image file to base64
212
+ image_path = "Path/to/your/image.jpg" # Update this path to your image
213
+ base64_image = Base64.strict_encode64(File.read(image_path))
214
+
215
+ model = Copyleaks::CopyleaksAiImageDetectionRequestModel.new(
216
+ base64_image,
217
+ "image.jpg",
218
+ Copyleaks::CopyleaksAiImageDetectionModels::AI_IMAGE_1_ULTRA,
219
+ true # sandbox mode
220
+ )
221
+
222
+ res = copyleaks.ai_image_detection_client.submit_(authToken, scanId, model)
223
+ rescue StandardError => e
224
+ puts "Error in test_image_detection: #{e.message}"
225
+ end
226
+ end
40
227
  ```
228
+ For a full guide please refer to our step by step [Guide](https://docs.copyleaks.com/guides/ai-detector/ai-image-detection/)
229
+
230
+ For a detailed understanding of the AI image detection process, refer to the Copyleaks AI image detection Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/ai-image-detector/check/)
231
+
232
+ ##
233
+ ### Further Resources
234
+
235
+ * **Copyleaks API Dashboard:** Manage your API keys, monitor usage, and view analytics from your personalized dashboard. [Access Dashboard](https://api.copyleaks.com/dashboard)
236
+ * **Copyleaks SDK Documentation:** Explore comprehensive guides, API references, and code examples for seamless integration. [Read Documentation](https://docs.copyleaks.com/resources/sdks/overview/)
237
+
41
238
 
42
- ## Demo
43
- See [demo.rb](./demo/demo.rb) under demo folder for an example.
44
- ## Read More
45
- * [API Homepage](https://api.copyleaks.com/)
46
- * [API Documentation](https://api.copyleaks.com/documentation)
47
- * [Plagiarism Report](https://github.com/Copyleaks/plagiarism-report)
239
+ ## Support
240
+ * If you need assistance, please contact Copyleaks Support via our support portal: Contact Copyleaks [Support](https://help.copyleaks.com/s/contactsupport).
241
+ * To arrange a product demonstration, book a demo here: [Booking Link](https://copyleaks.com/book-a-demo).
@@ -21,7 +21,6 @@
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  # SOFTWARE.
23
23
  # =
24
- require_relative 'deprecationService.rb'
25
24
 
26
25
  module Copyleaks
27
26
  class AIDetectionClient
@@ -29,39 +28,6 @@ module Copyleaks
29
28
  @api_client = api_client
30
29
  end
31
30
 
32
- # Use Copyleaks AI Content Detection to differentiate between human source code and AI written source code.
33
- # * Exceptions:
34
- # * * CommandExceptions: Server reject the request. See response status code,
35
- # headers and content for more info.
36
- # * * UnderMaintenanceException: Copyleaks servers are unavailable for maintenance.
37
- # We recommend to implement exponential backoff algorithm as described here:
38
- # https://api.copyleaks.com/documentation/v3/exponential-backoff
39
- # @param [CopyleaksAuthToken] authToken Copyleaks authentication token
40
- # @param [String] scanId Attach your own scan Id
41
- # @param [SourceCodeSubmissionModel] submission document
42
- def submit_source_code(authToken, scanId, submission)
43
- raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String)
44
- if submission.nil? || !submission.instance_of?(Copyleaks::SourceCodeSubmissionModel)
45
- raise 'submission is Invalid, must be instance of type Copyleaks::SourceCodeSubmissionModel'
46
- end
47
-
48
- ClientUtils.verify_auth_token(authToken)
49
- Copyleaks::DeprecationService.show_deprecation_message
50
- path = "/v2/writer-detector/source-code/#{scanId}/check"
51
-
52
- headers = {
53
- 'Content-Type' => 'application/json',
54
- 'User-Agent' => Config.user_agent,
55
- 'Authorization' => "Bearer #{authToken.accessToken}"
56
- }
57
-
58
- request = Net::HTTP::Post.new(path, headers)
59
- request.body = submission.to_json
60
-
61
- ClientUtils.handle_response(@api_client.request(request), 'submit_source_code')
62
- end
63
-
64
-
65
31
  # Use Copyleaks AI Content Detection to differentiate between human texts and AI written texts.
66
32
  # * Exceptions:
67
33
  # * * CommandExceptions: Server reject the request. See response status code,
@@ -71,7 +37,7 @@ module Copyleaks
71
37
  # https://api.copyleaks.com/documentation/v3/exponential-backoff
72
38
  # @param [CopyleaksAuthToken] authToken Copyleaks authentication token
73
39
  # @param [String] scanId Attach your own scan Id
74
- # @param [SourceCodeSubmissionModel] submission document
40
+ # @param [NaturalLanguageSubmissionModel] submission document
75
41
  def submit_natural_language(authToken, scanId, submission)
76
42
  raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String)
77
43
  if submission.nil? || !submission.instance_of?(Copyleaks::NaturalLanguageSubmissionModel)
@@ -23,33 +23,32 @@
23
23
  # =
24
24
 
25
25
  module Copyleaks
26
- class SourceCodeSubmissionModel < AIDetectionSubmissionModel
27
- attr_accessor :filename
26
+ class AIImageDetectionClient
27
+ def initialize(api_client)
28
+ @api_client = api_client
29
+ end
28
30
 
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'
31
+ def submit_(authToken, scanId, submission)
32
+ raise 'scanId is Invalid, must be instance of String' if scanId.nil? || !scanId.instance_of?(String)
33
+ if submission.nil? || !submission.instance_of?(Copyleaks::CopyleaksAiImageDetectionRequestModel)
34
+ raise 'submission is Invalid, must be instance of type Copyleaks::CopyleaksAiImageDetectionRequestModel'
38
35
  end
39
- super(text, sandbox)
40
- @filename = filename
41
- end
42
36
 
43
- def as_json(*_args)
44
- {
45
- text: @text,
46
- sandbox: @sandbox,
47
- filename: @filename
48
- }.select { |_k, v| !v.nil? }
49
- end
37
+ ClientUtils.verify_auth_token(authToken)
38
+
39
+ path = "/v1/ai-image-detector/#{scanId}/check"
40
+
41
+ headers = {
42
+ 'Content-Type' => 'application/json',
43
+ 'User-Agent' => Config.user_agent,
44
+ 'Authorization' => "Bearer #{authToken.accessToken}"
45
+ }
46
+
47
+ request = Net::HTTP::Post.new(path, headers)
48
+ request.body = submission.to_json
50
49
 
51
- def to_json(*options)
52
- as_json(*options).to_json(*options)
50
+ res = ClientUtils.handle_response(@api_client.request(request), 'submit_image_detection')
51
+ res
53
52
  end
54
53
  end
55
54
  end
data/lib/copyleaks/api.rb CHANGED
@@ -27,7 +27,7 @@ require 'date'
27
27
  require_relative 'ai_detection_client.rb'
28
28
  require_relative 'writing_assistant_client.rb'
29
29
  require_relative 'text_moderation_client.rb'
30
- require_relative 'deprecationService.rb'
30
+ require_relative 'ai_image_detection_client.rb'
31
31
  require_relative 'utils/copyleaks_client.utils'
32
32
 
33
33
  module Copyleaks
@@ -46,6 +46,7 @@ module Copyleaks
46
46
  @ai_detection_client = AIDetectionClient.new(@api_client)
47
47
  @writing_assistant_client = WritingAssistantClient.new(@api_client)
48
48
  @text_moderation_client = TextModerationClient.new(@api_client)
49
+ @ai_image_detection_client = AIImageDetectionClient.new(@api_client)
49
50
  end
50
51
 
51
52
  # Login to Copyleaks authentication server.
@@ -114,14 +115,6 @@ module Copyleaks
114
115
  end
115
116
 
116
117
  verify_auth_token(authToken)
117
- file_extension = File.extname(submission.filename).delete_prefix('.')
118
-
119
- if file_extension.empty?
120
- raise ArgumentError, "File extension could not be determined for filename: #{submission.filename}"
121
- end
122
- if Copyleaks::SupportedFilesTypes::SUPPORTED_CODE_EXTENSIONS.include?(file_extension)
123
- Copyleaks::DeprecationService.show_deprecation_message
124
- end
125
118
 
126
119
  path = "/v3/scans/submit/file/#{scanId}"
127
120
 
@@ -470,5 +463,9 @@ module Copyleaks
470
463
  def text_moderation_client
471
464
  @text_moderation_client
472
465
  end
466
+
467
+ def ai_image_detection_client
468
+ @ai_image_detection_client
469
+ end
473
470
  end
474
471
  end
@@ -0,0 +1,28 @@
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
+ module Copyleaks
25
+ class CopyleaksAiImageDetectionModels
26
+ AI_IMAGE_1_ULTRA = "ai-image-1-ultra"
27
+ end
28
+ end
@@ -0,0 +1,39 @@
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
+ module Copyleaks
25
+ class CopyleaksTextModerationConstants
26
+ # Provides a collection of constants representing different text moderation categories supported by the Copyleaks
27
+ # Text Moderation API.
28
+ ADULT_V1 = "adult-v1"
29
+ TOXIC_V1 = "toxic-v1"
30
+ VIOLENT_V1 = "violent-v1"
31
+ PROFANITY_V1 = "profanity-v1"
32
+ SELF_HARM_V1 = "self-harm-v1"
33
+ HARASSMENT_V1 = "harassment-v1"
34
+ HATE_SPEECH_V1 = "hate-speech-v1"
35
+ DRUGS_V1 = "drugs-v1"
36
+ FIREARMS_V1 = "firearms-v1"
37
+ CYBERSECURITY_V1 = "cybersecurity-v1"
38
+ end
39
+ end
@@ -0,0 +1,29 @@
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
+ module Copyleaks
25
+ class CopyleaksTextModerationLanguages
26
+ # Supported languages for text moderation.
27
+ ENGLISH = "en"
28
+ end
29
+ end
@@ -22,7 +22,10 @@
22
22
  # SOFTWARE.
23
23
  # =
24
24
 
25
- require_relative 'supportedFilesTypes.rb'
25
+ require_relative 'CopyleaksTextModerationConstants.rb'
26
+ require_relative 'CopyleaksTextModerationLanguages.rb'
27
+ require_relative 'CopyleaksAiImageDetectionModels.rb'
28
+
26
29
 
27
30
  module Copyleaks
28
31
  end