plagiarism-checker 2.1.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -12
  3. data/Gemfile +6 -4
  4. data/LICENSE.txt +21 -21
  5. data/README.md +39 -0
  6. data/Rakefile +4 -2
  7. data/bin/console +10 -2
  8. data/lib/copyleaks/api.rb +493 -0
  9. data/lib/copyleaks/app.config.rb +47 -0
  10. data/lib/copyleaks/models/auth_token.rb +54 -0
  11. data/lib/copyleaks/models/delete_request_model.rb +64 -0
  12. data/lib/copyleaks/models/exceptions/auth_exipred_exception.rb +32 -0
  13. data/lib/copyleaks/models/exceptions/command_exception.rb +32 -0
  14. data/lib/copyleaks/models/exceptions/index.rb +32 -0
  15. data/lib/copyleaks/models/exceptions/rate_limit_exception.rb +32 -0
  16. data/lib/copyleaks/models/exceptions/under_maintenance_exception.rb +32 -0
  17. data/lib/copyleaks/models/exports/export_crawled_version.rb +54 -0
  18. data/lib/copyleaks/models/exports/export_model.rb +84 -0
  19. data/lib/copyleaks/models/exports/export_pdf_report.rb +54 -0
  20. data/lib/copyleaks/models/exports/export_results.rb +56 -0
  21. data/lib/copyleaks/models/exports/index.rb +32 -0
  22. data/lib/copyleaks/models/id_object.rb +44 -0
  23. data/lib/copyleaks/models/index.rb +35 -0
  24. data/lib/copyleaks/models/start_request_model.rb +63 -0
  25. data/lib/copyleaks/models/submissions/file_ocr_submission_model.rb +61 -0
  26. data/lib/copyleaks/models/submissions/file_submission_model.rb +57 -0
  27. data/lib/copyleaks/models/submissions/index.rb +33 -0
  28. data/lib/copyleaks/models/submissions/properties/actions.rb +33 -0
  29. data/lib/copyleaks/models/submissions/properties/author.rb +41 -0
  30. data/lib/copyleaks/models/submissions/properties/copyleaks_db.rb +44 -0
  31. data/lib/copyleaks/models/submissions/properties/domains_mode.rb +31 -0
  32. data/lib/copyleaks/models/submissions/properties/exclude.rb +59 -0
  33. data/lib/copyleaks/models/submissions/properties/filter.rb +67 -0
  34. data/lib/copyleaks/models/submissions/properties/index.rb +45 -0
  35. data/lib/copyleaks/models/submissions/properties/indexing.rb +41 -0
  36. data/lib/copyleaks/models/submissions/properties/pdf_properties.rb +55 -0
  37. data/lib/copyleaks/models/submissions/properties/repository.rb +41 -0
  38. data/lib/copyleaks/models/submissions/properties/scanning.rb +55 -0
  39. data/lib/copyleaks/models/submissions/properties/scanning_exclude.rb +44 -0
  40. data/lib/copyleaks/models/submissions/properties/scanning_repository.rb +46 -0
  41. data/lib/copyleaks/models/submissions/properties/sensitive_data_protection.rb +71 -0
  42. data/lib/copyleaks/models/submissions/properties/submission_properties.rb +136 -0
  43. data/lib/copyleaks/models/submissions/properties/webhooks.rb +44 -0
  44. data/lib/copyleaks/models/submissions/submission_model.rb +47 -0
  45. data/lib/copyleaks/models/submissions/url_submission_model.rb +51 -0
  46. data/lib/copyleaks/utils/status-code.utils.rb +38 -0
  47. data/lib/copyleaks/version.rb +3 -0
  48. data/lib/index.rb +35 -0
  49. data/plagiarism-checker.gemspec +29 -0
  50. metadata +50 -108
  51. data/.rubocop.yml +0 -2
  52. data/copyleaks_api.gemspec +0 -29
  53. data/example_asynchronous.rb +0 -51
  54. data/example_synchronous.rb +0 -74
  55. data/lib/copyleaks_api.rb +0 -24
  56. data/lib/copyleaks_api/Models/ResultRecord.rb +0 -58
  57. data/lib/copyleaks_api/access_token.rb +0 -36
  58. data/lib/copyleaks_api/api.rb +0 -216
  59. data/lib/copyleaks_api/config.rb +0 -37
  60. data/lib/copyleaks_api/copyleaks_cloud.rb +0 -116
  61. data/lib/copyleaks_api/copyleaks_process.rb +0 -78
  62. data/lib/copyleaks_api/errors.rb +0 -29
  63. data/lib/copyleaks_api/validators/custom_fields_validator.rb +0 -35
  64. data/lib/copyleaks_api/validators/email_validator.rb +0 -13
  65. data/lib/copyleaks_api/validators/file_validator.rb +0 -56
  66. data/lib/copyleaks_api/validators/language_validator.rb +0 -12
  67. data/lib/copyleaks_api/validators/response_validator.rb +0 -27
  68. data/lib/copyleaks_api/validators/url_validator.rb +0 -12
  69. data/lib/copyleaks_api/version.rb +0 -3
@@ -0,0 +1,44 @@
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 SubmissionScanningExclude
26
+ # @param [String] idPattern Exclude your submissions from results if their id matches the supplied pattern. Matched submissions will be excluded from batch, internal database and repositories results.
27
+ # * Supported pattern wildcards for idPattern:
28
+ # * * '*' Matches any, zero or more, characters.
29
+ # * * '.' Matches a single (non whitespace) character
30
+ def initialize(idPattern)
31
+ @idPattern = idPattern
32
+ end
33
+
34
+ def as_json(*_args)
35
+ {
36
+ idPattern: @idPattern
37
+ }.select { |_k, v| !v.nil? }
38
+ end
39
+
40
+ def to_json(*options)
41
+ as_json(*options).to_json(*options)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,46 @@
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 SubmissionScanningRepository < SubmissionRepository
26
+ # @param [String] Id of a repository to add the scanned document to.
27
+ # @param [Boolean] includeMySubmissions Compare the scanned document against MY submittions in the repository.
28
+ # @param [Boolean] includeOthersSubmissions Compare the scanned document against OTHER users submittions in the repository.
29
+ def initialize(id, includeMySubmissions, includeOthersSubmissions)
30
+ super(id)
31
+ @includeMySubmissions = includeMySubmissions
32
+ @includeOthersSubmissions = includeOthersSubmissions
33
+ end
34
+
35
+ def as_json(*_args)
36
+ {
37
+ includeMySubmissions: @includeMySubmissions,
38
+ includeOthersSubmissions: @includeOthersSubmissions
39
+ }.select { |_k, v| !v.nil? }
40
+ end
41
+
42
+ def to_json(*options)
43
+ as_json(*options).to_json(*options)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,71 @@
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 SubmissionSensitiveData
26
+ # @param [Boolean] driversLicense - Mask driver's license numbers from the scanned document with # characters. Available for users on a plan for 2500 pages or more.
27
+ # @param [Boolean] credentials - Mask credentials from the scanned document with # characters. Available for users on a plan for 2500 pages or more.
28
+ # @param [Boolean] passport - Mask passports from the scanned document with # characters. Available for users on a plan for 2500 pages or more.
29
+ # @param [Boolean] network - Mask network identifiers from the scanned document with # characters. Available for users on a plan for 2500 pages or more.
30
+ # @param [Boolean] url - Mask url from the scanned document with # characters. Available for users on a plan for 2500 pages or more.
31
+ # @param [Boolean] emailAddress - Mask email addresses from the scanned document with # characters. Available for users on a plan for 2500 pages or more.
32
+ # @param [Boolean] creditCard - Mask credit card numbers and credit card track numbers from the scanned document with # characters. Available for users on a plan for 2500 pages or more.
33
+ # @param [Boolean] phoneNumber - Mask phone numbers from the scanned document with # characters. Available for users on a plan for 2500 pages or more.
34
+ def initialize(
35
+ driversLicense = false,
36
+ credentials = false,
37
+ passport = false,
38
+ network = false,
39
+ url = false,
40
+ emailAddress = false,
41
+ creditCard = false,
42
+ phoneNumber = false
43
+ )
44
+ @driversLicense = driversLicense
45
+ @credentials = credentials
46
+ @passport = passport
47
+ @network = network
48
+ @url = url
49
+ @emailAddress = emailAddress
50
+ @creditCard = creditCard
51
+ @phoneNumber = phoneNumber
52
+ end
53
+
54
+ def as_json(*_args)
55
+ {
56
+ driversLicense: @driversLicense,
57
+ credentials: @credentials,
58
+ passport: @passport,
59
+ network: @network,
60
+ url: @url,
61
+ emailAddress: @emailAddress,
62
+ creditCard: @creditCard,
63
+ phoneNumber: @phoneNumber
64
+ }.select { |_k, v| !v.nil? }
65
+ end
66
+
67
+ def to_json(*options)
68
+ as_json(*options).to_json(*options)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,136 @@
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 SubmissionProperties
26
+ attr_reader :webhooks, :includeHtml, :developerPayload, :sandbox, :expiration, :sensitivityLevel, :cheatDetection,
27
+ :action, :author, :filters, :scanning, :indexing, :exclude, :pdf, :sensitiveDataProtection
28
+
29
+ # @param [SubmissionWebhooks] webhooks - Check inner properties for more details.
30
+ # @param [Boolean] includeHtml - By default, Copyleaks will present the report in text format. If set to true, Copyleaks will also include html format.
31
+ # @param [String] developerPayload - Add custom developer payload that will then be provided on the webhooks. https://api.copyleaks.com/documentation/v3/webhooks
32
+ # @param [Boolean] sandbox - You can test the integration with the Copyleaks API for free using the sandbox mode. You will be able to submit content for a scan and get back mock results, simulating the way Copyleaks will work to make sure that you successfully integrated with the API. Turn off this feature on production environment.
33
+ # @param [Integer] expiration - Specify the maximum life span of a scan in hours on the Copyleaks servers. When expired, the scan will be deleted and will no longer be accessible.
34
+ # @param [Integer] sensitivityLevel - You can control the level of plagiarism sensitivity that will be identified according to the speed of the scan. If you prefer a faster scan with the results that contains the highest amount of plagiarism choose 1, and if a slower, more comprehensive scan, that will also detect the smallest instances choose 5.
35
+ # @param [Boolean] cheatDetection - When set to true the submitted document will be checked for cheating. If a cheating will be detected, a scan alert will be added to the completed webhook.
36
+ # @param [SubmissionActions] action - Types of content submission actions. Possible values: Scan: Start scan immediately. Check Credits: Check how many credits will be used for this scan. Index Only: Only index the file in the Copyleaks internal database. No credits will be used.
37
+ # @param [SubmissionAuthor] author - Check inner properties for more details.
38
+ # @param [SubmissionFilter] filters - Check inner properties for more details.
39
+ # @param [SubmissionScanning] scanning - Check inner properties for more details.
40
+ # @param [SubmissionIndexing] indexing - Check inner properties for more details.
41
+ # @param [SubmissionExclude] exclude - Check inner properties for more details.
42
+ # @param [SubmissionPDF] pdf - Check inner properties for more details.
43
+ # @param [SubmissionSensitiveData] sensitiveDataProtection - Check inner properties for more details.
44
+ def initialize(
45
+ webhooks, includeHtml = nil, developerPayload = nil, sandbox = nil, expiration = nil,
46
+ sensitivityLevel = nil, cheatDetection = nil, action = nil, author = nil, filters = nil,
47
+ scanning = nil, indexing = nil, exclude = nil, pdf = nil, sensitiveDataProtection = nil
48
+ )
49
+ unless webhooks.instance_of?(SubmissionWebhooks)
50
+ raise 'Copyleaks::SubmissionProperties - webhooks - webhooks must be of type SubmissionWebhooks'
51
+ end
52
+ if !includeHtml.nil? && ![true, false].include?(includeHtml)
53
+ raise 'Copyleaks::SubmissionProperties - includeHtml - includeHtml must be of type Boolean'
54
+ end
55
+ unless developerPayload.instance_of?(String)
56
+ raise 'Copyleaks::SubmissionProperties - developerPayload - developerPayload must be of type String'
57
+ end
58
+ if !sandbox.nil? && ![true, false].include?(sandbox)
59
+ raise 'Copyleaks::SubmissionProperties - sandbox - includeHtml must be of type Boolean'
60
+ end
61
+ unless expiration.instance_of?(Integer)
62
+ raise 'Copyleaks::SubmissionProperties - expiration - expiration must be of type Integer'
63
+ end
64
+ unless sensitivityLevel.instance_of?(Integer)
65
+ raise 'Copyleaks::SubmissionProperties - sensitivityLevel - sensitivityLevel must be of type Integer'
66
+ end
67
+ if !cheatDetection.nil? && ![true, false].include?(cheatDetection)
68
+ raise 'Copyleaks::SubmissionProperties - cheatDetection - cheatDetection must be of type Boolean'
69
+ end
70
+ if !action.nil? && ![0, 1, 2].include?(action)
71
+ raise 'Copyleaks::SubmissionProperties - action - action must be of type SubmissionActions consts'
72
+ end
73
+ if !author.nil? && !author.instance_of?(SubmissionAuthor)
74
+ raise 'Copyleaks::SubmissionProperties - author - author must be of type SubmissionAuthor'
75
+ end
76
+ if !filters.nil? && !filters.instance_of?(SubmissionFilter)
77
+ raise 'Copyleaks::SubmissionProperties - filters - filters must be of type SubmissionFilter'
78
+ end
79
+ if !scanning.nil? && !scanning.instance_of?(SubmissionScanning)
80
+ raise 'Copyleaks::SubmissionProperties - scanning - scanning must be of type SubmissionScanning'
81
+ end
82
+ if !indexing.nil? && !indexing.instance_of?(SubmissionIndexing)
83
+ raise 'Copyleaks::SubmissionProperties - indexing - indexing must be of type SubmissionIndexing'
84
+ end
85
+ if !exclude.nil? && !exclude.instance_of?(SubmissionExclude)
86
+ raise 'Copyleaks::SubmissionProperties - exclude - exclude must be of type SubmissionExclude'
87
+ end
88
+ if !pdf.nil? && !pdf.instance_of?(SubmissionPDF)
89
+ raise 'Copyleaks::SubmissionProperties - pdf - pdf must be of type SubmissionPDF'
90
+ end
91
+ if !sensitiveDataProtection.nil? && !sensitiveDataProtection.instance_of?(SubmissionSensitiveData)
92
+ raise 'Copyleaks::SubmissionProperties - sensitiveDataProtection - sensitiveDataProtection must be of type SubmissionSensitiveData'
93
+ end
94
+
95
+ @webhooks = webhooks
96
+ @includeHtml = includeHtml
97
+ @developerPayload = developerPayload
98
+ @sandbox = sandbox
99
+ @expiration = expiration
100
+ @sensitivityLevel = sensitivityLevel
101
+ @cheatDetection = cheatDetection
102
+ @action = action
103
+ @author = author
104
+ @filters = filters
105
+ @scanning = scanning
106
+ @indexing = indexing
107
+ @exclude = exclude
108
+ @pdf = pdf
109
+ @sensitiveDataProtection = sensitiveDataProtection
110
+ end
111
+
112
+ def as_json(*_args)
113
+ {
114
+ webhooks: @webhooks,
115
+ includeHtml: @includeHtml,
116
+ developerPayload: @developerPayload,
117
+ sandbox: @sandbox,
118
+ expiration: @expiration,
119
+ sensitivityLevel: @sensitivityLevel,
120
+ cheatDetection: @cheatDetection,
121
+ action: @action,
122
+ author: @author,
123
+ filters: @filters,
124
+ scanning: @scanning,
125
+ indexing: @indexing,
126
+ exclude: @exclude,
127
+ pdf: @pdf,
128
+ sensitiveDataProtection: @sensitiveDataProtection
129
+ }.select { |_k, v| !v.nil? }
130
+ end
131
+
132
+ def to_json(*options)
133
+ as_json(*options).to_json(*options)
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,44 @@
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 SubmissionWebhooks
26
+ # @param [String] status This webhook event is triggered once the scan status changes. Use the special token {STATUS} to track the current scan status. This special token will automatically be replaced by the Copyleaks servers with the optional values: completed, error, creditsChecked and indexed. Read more about webhooks: https://api.copyleaks.com/documentation/v3/webhooks
27
+ # @param [String] newResult Http endpoint to be triggered while the scan is still running and a new result is found. This is useful when the report is being viewed by the user in real time so the results will load gradually as they are found.
28
+ def initialize(status, newResult = nil)
29
+ @newResult = newResult
30
+ @status = status
31
+ end
32
+
33
+ def as_json(*_args)
34
+ {
35
+ newResult: @newResult,
36
+ status: @status
37
+ }.select { |_k, v| !v.nil? }
38
+ end
39
+
40
+ def to_json(*options)
41
+ as_json(*options).to_json(*options)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,47 @@
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 CopyleaksSubmissionModel
26
+ attr_reader :properties
27
+
28
+ # @param [SubmissionProperties] properties Check inner properties for more details.
29
+ def initialize(properties)
30
+ unless properties.instance_of?(SubmissionProperties)
31
+ raise 'Copyleaks::CopyleaksURLSubmissionModel - properties - properties must be of type SubmissionProperties'
32
+ end
33
+
34
+ @properties = properties
35
+ end
36
+
37
+ def as_json(*_args)
38
+ {
39
+ properties: @properties
40
+ }.select { |_k, v| !v.nil? }
41
+ end
42
+
43
+ def to_json(*options)
44
+ as_json(*options).to_json(*options)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,51 @@
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 CopyleaksURLSubmissionModel < CopyleaksSubmissionModel
26
+ attr_reader :url
27
+
28
+ # @param [String] url The url to be scanned
29
+ # @param [SubmissionProperties] properties Check inner properties for more details.
30
+ def initialize(url, properties)
31
+ raise 'Copyleaks::CopyleaksURLSubmissionModel - url - url must be of type String' unless url.instance_of?(String)
32
+ unless properties.instance_of?(SubmissionProperties)
33
+ raise 'Copyleaks::CopyleaksURLSubmissionModel - properties - properties must be of type SubmissionProperties'
34
+ end
35
+
36
+ super(properties)
37
+ @url = url
38
+ end
39
+
40
+ def as_json(*_args)
41
+ {
42
+ properties: @properties,
43
+ url: @url
44
+ }.select { |_k, v| !v.nil? }
45
+ end
46
+
47
+ def to_json(*options)
48
+ as_json(*options).to_json(*options)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,38 @@
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 Utils
26
+ def self.is_success_status_code(code)
27
+ code.to_i >= 200 && code.to_i <= 299
28
+ end
29
+
30
+ def self.is_under_maintenance_response(code)
31
+ code.to_i == 503
32
+ end
33
+
34
+ def self.is_rate_limit_response(code)
35
+ code.to_i == 429
36
+ end
37
+ end
38
+ end