apiverve_nsfwimagedetector 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cd9b1563a9464bb81b7dfd4617a4ecdf028c005c9c38b62b132ce263a32842db
4
+ data.tar.gz: 063e9328bd825688f77c0d68860dfe34dd2752d37a3f5d55b9d2dcbf0796082a
5
+ SHA512:
6
+ metadata.gz: 13bec85a09813f8b5e8fbf86e0a9d5e9d3aaf6f6cfbaec4073b7f2755d851710b8a900d48d808732b5260c21344551620311444a9a2ab9aab8a685ff0dbb715d
7
+ data.tar.gz: cd2766c90ede8605647745fa5a64283a02c3feb6ff2ca75fd0cb460c7f8a64b7ad40e3871bb0c961795b6747433c9e485d40391ae8b042de5401cacd4912496b
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) {{year}} APIVerve
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # NSFW Image Detector API - Ruby Gem
2
+
3
+ NSFW Detector is a simple tool for detecting NSFW content. It returns a boolean
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'apiverve_nsfwimagedetector'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ $ bundle install
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ $ gem install apiverve_nsfwimagedetector
23
+ ```
24
+
25
+ ## Getting Started
26
+
27
+ Get your API key at [APIVerve](https://apiverve.com)
28
+
29
+ ### Basic Usage
30
+
31
+ ```ruby
32
+ require 'apiverve_nsfwimagedetector'
33
+
34
+ # Initialize the client
35
+ client = APIVerve::Nsfwimagedetector::Client.new(api_key: "YOUR_API_KEY")
36
+
37
+ # Make a request
38
+ response = client.execute({ image: "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Camponotus_flavomarginatus_ant.jpg/640px-Camponotus_flavomarginatus_ant.jpg" })
39
+
40
+ # Print the response
41
+ puts response
42
+ ```
43
+
44
+ ### File Upload
45
+
46
+ ```ruby
47
+ # Upload a file
48
+ response = client.execute_with_file("/path/to/file.jpg")
49
+
50
+ # Or use a URL
51
+ response = client.execute_with_url("https://example.com/image.jpg")
52
+ ```
53
+
54
+ ### Error Handling
55
+
56
+ ```ruby
57
+ begin
58
+ response = client.execute({ image: "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Camponotus_flavomarginatus_ant.jpg/640px-Camponotus_flavomarginatus_ant.jpg" })
59
+ puts response["data"]
60
+ rescue APIVerve::Nsfwimagedetector::ValidationError => e
61
+ puts "Validation error: #{e.errors.join(', ')}"
62
+ rescue APIVerve::Nsfwimagedetector::APIError => e
63
+ puts "API error: #{e.message}"
64
+ puts "Status code: #{e.status_code}"
65
+ end
66
+ ```
67
+
68
+ ### Debug Mode
69
+
70
+ ```ruby
71
+ # Enable debug logging
72
+ client = APIVerve::Nsfwimagedetector::Client.new(
73
+ api_key: "YOUR_API_KEY",
74
+ debug: true
75
+ )
76
+ ```
77
+
78
+ ## Example Response
79
+
80
+ ```json
81
+ {
82
+ "status": "ok",
83
+ "error": null,
84
+ "data": {
85
+ "isNSFW": false,
86
+ "isSafe": true,
87
+ "confidence": 0.987,
88
+ "category": "neutral"
89
+ }
90
+ }
91
+ ```
92
+
93
+ ## Documentation
94
+
95
+ For more information, visit the [API Documentation](https://docs.apiverve.com/ref/nsfwimagedetector?utm_source=rubygems&utm_medium=readme).
96
+
97
+ ## Support
98
+
99
+ - Website: [https://apiverve.com/marketplace/nsfwimagedetector?utm_source=ruby&utm_medium=readme](https://apiverve.com/marketplace/nsfwimagedetector?utm_source=ruby&utm_medium=readme)
100
+ - Email: hello@apiverve.com
101
+
102
+ ## License
103
+
104
+ This gem is available under the [MIT License](LICENSE).
@@ -0,0 +1,238 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "faraday/multipart"
5
+ require "json"
6
+
7
+ module APIVerve
8
+ module Nsfwimagedetector
9
+ # Client for the NSFW Image Detector API
10
+ #
11
+ # @example Basic usage
12
+ # client = APIVerve::Nsfwimagedetector::Client.new(api_key: "your_api_key")
13
+ # response = client.execute({ image: "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Camponotus_flavomarginatus_ant.jpg/640px-Camponotus_flavomarginatus_ant.jpg" })
14
+ # puts response
15
+ #
16
+ # @see https://apiverve.com/marketplace/nsfwimagedetector?utm_source=ruby&utm_medium=readme
17
+ class Client
18
+ BASE_URL = "https://api.apiverve.com/v1/nsfwimagedetector"
19
+ DEFAULT_TIMEOUT = 30
20
+
21
+ # Validation rules for parameters
22
+ VALIDATION_RULES = { 'image' => { type: 'string', required: false } }
23
+
24
+ # Format validation patterns
25
+ FORMAT_PATTERNS = {
26
+ 'email' => /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
27
+ 'url' => /^https?:\/\/.+/,
28
+ 'ip' => /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/,
29
+ 'date' => /^\d{4}-\d{2}-\d{2}$/,
30
+ 'hexColor' => /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/
31
+ }.freeze
32
+
33
+ # Initialize the client
34
+ #
35
+ # @param api_key [String] Your APIVerve API key
36
+ # @param timeout [Integer] Request timeout in seconds (default: 30)
37
+ # @param debug [Boolean] Enable debug logging (default: false)
38
+ # @raise [ArgumentError] If API key is invalid
39
+ def initialize(api_key:, timeout: DEFAULT_TIMEOUT, debug: false)
40
+ validate_api_key!(api_key)
41
+
42
+ @api_key = api_key
43
+ @timeout = timeout
44
+ @debug = debug
45
+
46
+ @connection = Faraday.new(url: BASE_URL) do |conn|
47
+ conn.request :multipart
48
+ conn.request :url_encoded
49
+ conn.adapter Faraday.default_adapter
50
+ conn.options.timeout = @timeout
51
+ conn.headers["x-api-key"] = @api_key
52
+ conn.headers["auth-mode"] = "rubygems-package"
53
+ conn.headers["Content-Type"] = "application/json"
54
+ end
55
+ end
56
+
57
+ # Execute the API request
58
+ #
59
+ # @param params [Hash] Query parameters or request body
60
+ # @return [Hash] API response
61
+ # @raise [APIError] If the request fails
62
+ # @raise [ValidationError] If parameter validation fails
63
+ def execute(params = {})
64
+ validate_params!(params)
65
+
66
+ log("Making POST request to #{BASE_URL}")
67
+ log("Parameters: #{params.inspect}") if params.any?
68
+
69
+ response = @connection.post do |req|
70
+ req.body = params.to_json
71
+ end
72
+
73
+ handle_response(response)
74
+ end
75
+
76
+ # Execute the API request with a file upload
77
+ #
78
+ # @param file_path [String] Path to the file to upload
79
+ # @param params [Hash] Additional parameters
80
+ # @return [Hash] API response
81
+ # @raise [APIError] If the request fails
82
+ # @raise [ArgumentError] If the file doesn't exist
83
+ def execute_with_file(file_path, params = {})
84
+ raise ArgumentError, "File not found: #{file_path}" unless File.exist?(file_path)
85
+
86
+ log("Uploading file: #{file_path}")
87
+
88
+ payload = {
89
+ "image" => Faraday::Multipart::FilePart.new(
90
+ file_path,
91
+ mime_type_for(file_path),
92
+ File.basename(file_path)
93
+ )
94
+ }
95
+ payload.merge!(params.transform_keys(&:to_s))
96
+
97
+ response = @connection.post do |req|
98
+ req.headers.delete("Content-Type") # Let Faraday set it
99
+ req.body = payload
100
+ end
101
+
102
+ handle_response(response)
103
+ end
104
+
105
+ # Execute the API request with a file URL
106
+ #
107
+ # @param url [String] URL of the file to process
108
+ # @param params [Hash] Additional parameters
109
+ # @return [Hash] API response
110
+ # @raise [APIError] If the request fails
111
+ def execute_with_url(url, params = {})
112
+ raise ArgumentError, "URL must be a string" unless url.is_a?(String)
113
+ raise ArgumentError, "Invalid URL format" unless url.match?(/^https?:\/\/.+/)
114
+
115
+ execute(params.merge(url: url))
116
+ end
117
+
118
+ private
119
+
120
+ def mime_type_for(file_path)
121
+ ext = File.extname(file_path).downcase
122
+ case ext
123
+ when ".jpg", ".jpeg" then "image/jpeg"
124
+ when ".png" then "image/png"
125
+ when ".gif" then "image/gif"
126
+ when ".webp" then "image/webp"
127
+ when ".pdf" then "application/pdf"
128
+ else "application/octet-stream"
129
+ end
130
+ end
131
+
132
+ def validate_api_key!(api_key)
133
+ raise ArgumentError, "API key is required. Get your API key at: https://apiverve.com" if api_key.nil? || api_key.strip.empty?
134
+
135
+ unless api_key.match?(/^[a-zA-Z0-9_-]+$/)
136
+ raise ArgumentError, "Invalid API key format. API key should only contain letters, numbers, hyphens, and underscores."
137
+ end
138
+ end
139
+
140
+ def validate_params!(params)
141
+ return if VALIDATION_RULES.empty?
142
+
143
+ errors = []
144
+
145
+ VALIDATION_RULES.each do |param_name, rules|
146
+ value = params[param_name.to_sym] || params[param_name]
147
+
148
+ # Check required
149
+ if rules[:required] && (value.nil? || value.to_s.empty?)
150
+ errors << "Required parameter [#{param_name}] is missing."
151
+ next
152
+ end
153
+
154
+ next if value.nil?
155
+
156
+ case rules[:type]
157
+ when "integer", "number"
158
+ begin
159
+ num_value = rules[:type] == "number" ? Float(value) : Integer(value)
160
+ errors << "Parameter [#{param_name}] must be at least #{rules[:min]}." if rules[:min] && num_value < rules[:min]
161
+ errors << "Parameter [#{param_name}] must be at most #{rules[:max]}." if rules[:max] && num_value > rules[:max]
162
+ rescue ArgumentError, TypeError
163
+ errors << "Parameter [#{param_name}] must be a valid #{rules[:type]}."
164
+ end
165
+ when "string"
166
+ unless value.is_a?(String)
167
+ errors << "Parameter [#{param_name}] must be a string."
168
+ next
169
+ end
170
+ errors << "Parameter [#{param_name}] must be at least #{rules[:min_length]} characters." if rules[:min_length] && value.length < rules[:min_length]
171
+ errors << "Parameter [#{param_name}] must be at most #{rules[:max_length]} characters." if rules[:max_length] && value.length > rules[:max_length]
172
+
173
+ if rules[:format] && FORMAT_PATTERNS[rules[:format]]
174
+ unless value.match?(FORMAT_PATTERNS[rules[:format]])
175
+ errors << "Parameter [#{param_name}] must be a valid #{rules[:format]}."
176
+ end
177
+ end
178
+ when "boolean"
179
+ unless [true, false, "true", "false"].include?(value)
180
+ errors << "Parameter [#{param_name}] must be a boolean."
181
+ end
182
+ end
183
+
184
+ # Enum validation
185
+ if rules[:enum] && !rules[:enum].include?(value)
186
+ errors << "Parameter [#{param_name}] must be one of: #{rules[:enum].join(', ')}."
187
+ end
188
+ end
189
+
190
+ raise ValidationError, errors unless errors.empty?
191
+ end
192
+
193
+ def handle_response(response)
194
+ log("Response status: #{response.status}")
195
+
196
+ data = JSON.parse(response.body)
197
+
198
+ if data["status"] == "error"
199
+ raise APIError.new(data["error"] || "Unknown API error", response.status, data)
200
+ end
201
+
202
+ unless response.success?
203
+ raise APIError.new(data["error"] || "HTTP #{response.status} error", response.status, data)
204
+ end
205
+
206
+ log("Request successful")
207
+ data
208
+ rescue JSON::ParserError => e
209
+ raise APIError.new("Invalid JSON response: #{e.message}", response.status)
210
+ end
211
+
212
+ def log(message)
213
+ puts "[APIVerve::Nsfwimagedetector] #{message}" if @debug
214
+ end
215
+ end
216
+
217
+ # Custom error class for API errors
218
+ class APIError < StandardError
219
+ attr_reader :status_code, :response
220
+
221
+ def initialize(message, status_code = nil, response = nil)
222
+ @status_code = status_code
223
+ @response = response
224
+ super(message)
225
+ end
226
+ end
227
+
228
+ # Custom error class for validation errors
229
+ class ValidationError < StandardError
230
+ attr_reader :errors
231
+
232
+ def initialize(errors)
233
+ @errors = errors
234
+ super("Validation failed: #{errors.join(' ')}")
235
+ end
236
+ end
237
+ end
238
+ end
@@ -0,0 +1,240 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "faraday/multipart"
5
+ require "json"
6
+
7
+ module APIVerve
8
+ module Nsfwimagedetector
9
+ # Client for the NSFW Image Detector API
10
+ #
11
+ # @example Basic usage
12
+ # client = APIVerve::Nsfwimagedetector::Client.new(api_key: "your_api_key")
13
+ # response = client.execute({ image: "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a7/Camponotus_flavomarginatus_ant.jpg/640px-Camponotus_flavomarginatus_ant.jpg" })
14
+ # puts response
15
+ #
16
+ # @see https://apiverve.com/marketplace/nsfwimagedetector?utm_source=ruby&utm_medium=readme
17
+ class Client
18
+ BASE_URL = "https://api.apiverve.com/v1/nsfwimagedetector"
19
+ DEFAULT_TIMEOUT = 30
20
+
21
+ # Validation rules for parameters
22
+ VALIDATION_RULES = {
23
+ 'image' => { type: 'string', required: false }
24
+ }
25
+
26
+ # Format validation patterns
27
+ FORMAT_PATTERNS = {
28
+ 'email' => /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
29
+ 'url' => /^https?:\/\/.+/,
30
+ 'ip' => /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/,
31
+ 'date' => /^\d{4}-\d{2}-\d{2}$/,
32
+ 'hexColor' => /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/
33
+ }.freeze
34
+
35
+ # Initialize the client
36
+ #
37
+ # @param api_key [String] Your APIVerve API key
38
+ # @param timeout [Integer] Request timeout in seconds (default: 30)
39
+ # @param debug [Boolean] Enable debug logging (default: false)
40
+ # @raise [ArgumentError] If API key is invalid
41
+ def initialize(api_key:, timeout: DEFAULT_TIMEOUT, debug: false)
42
+ validate_api_key!(api_key)
43
+
44
+ @api_key = api_key
45
+ @timeout = timeout
46
+ @debug = debug
47
+
48
+ @connection = Faraday.new(url: BASE_URL) do |conn|
49
+ conn.request :multipart
50
+ conn.request :url_encoded
51
+ conn.adapter Faraday.default_adapter
52
+ conn.options.timeout = @timeout
53
+ conn.headers["x-api-key"] = @api_key
54
+ conn.headers["auth-mode"] = "rubygems-package"
55
+ conn.headers["Content-Type"] = "application/json"
56
+ end
57
+ end
58
+
59
+ # Execute the API request
60
+ #
61
+ # @param params [Hash] Query parameters or request body
62
+ # @return [Hash] API response
63
+ # @raise [APIError] If the request fails
64
+ # @raise [ValidationError] If parameter validation fails
65
+ def execute(params = {})
66
+ validate_params!(params)
67
+
68
+ log("Making POST request to #{BASE_URL}")
69
+ log("Parameters: #{params.inspect}") if params.any?
70
+
71
+ response = @connection.post do |req|
72
+ req.body = params.to_json
73
+ end
74
+
75
+ handle_response(response)
76
+ end
77
+
78
+ # Execute the API request with a file upload
79
+ #
80
+ # @param file_path [String] Path to the file to upload
81
+ # @param params [Hash] Additional parameters
82
+ # @return [Hash] API response
83
+ # @raise [APIError] If the request fails
84
+ # @raise [ArgumentError] If the file doesn't exist
85
+ def execute_with_file(file_path, params = {})
86
+ raise ArgumentError, "File not found: #{file_path}" unless File.exist?(file_path)
87
+
88
+ log("Uploading file: #{file_path}")
89
+
90
+ payload = {
91
+ "image" => Faraday::Multipart::FilePart.new(
92
+ file_path,
93
+ mime_type_for(file_path),
94
+ File.basename(file_path)
95
+ )
96
+ }
97
+ payload.merge!(params.transform_keys(&:to_s))
98
+
99
+ response = @connection.post do |req|
100
+ req.headers.delete("Content-Type") # Let Faraday set it
101
+ req.body = payload
102
+ end
103
+
104
+ handle_response(response)
105
+ end
106
+
107
+ # Execute the API request with a file URL
108
+ #
109
+ # @param url [String] URL of the file to process
110
+ # @param params [Hash] Additional parameters
111
+ # @return [Hash] API response
112
+ # @raise [APIError] If the request fails
113
+ def execute_with_url(url, params = {})
114
+ raise ArgumentError, "URL must be a string" unless url.is_a?(String)
115
+ raise ArgumentError, "Invalid URL format" unless url.match?(/^https?:\/\/.+/)
116
+
117
+ execute(params.merge(url: url))
118
+ end
119
+
120
+ private
121
+
122
+ def mime_type_for(file_path)
123
+ ext = File.extname(file_path).downcase
124
+ case ext
125
+ when ".jpg", ".jpeg" then "image/jpeg"
126
+ when ".png" then "image/png"
127
+ when ".gif" then "image/gif"
128
+ when ".webp" then "image/webp"
129
+ when ".pdf" then "application/pdf"
130
+ else "application/octet-stream"
131
+ end
132
+ end
133
+
134
+ def validate_api_key!(api_key)
135
+ raise ArgumentError, "API key is required. Get your API key at: https://apiverve.com" if api_key.nil? || api_key.strip.empty?
136
+
137
+ unless api_key.match?(/^[a-zA-Z0-9_-]+$/)
138
+ raise ArgumentError, "Invalid API key format. API key should only contain letters, numbers, hyphens, and underscores."
139
+ end
140
+ end
141
+
142
+ def validate_params!(params)
143
+ return if VALIDATION_RULES.empty?
144
+
145
+ errors = []
146
+
147
+ VALIDATION_RULES.each do |param_name, rules|
148
+ value = params[param_name.to_sym] || params[param_name]
149
+
150
+ # Check required
151
+ if rules[:required] && (value.nil? || value.to_s.empty?)
152
+ errors << "Required parameter [#{param_name}] is missing."
153
+ next
154
+ end
155
+
156
+ next if value.nil?
157
+
158
+ case rules[:type]
159
+ when "integer", "number"
160
+ begin
161
+ num_value = rules[:type] == "number" ? Float(value) : Integer(value)
162
+ errors << "Parameter [#{param_name}] must be at least #{rules[:min]}." if rules[:min] && num_value < rules[:min]
163
+ errors << "Parameter [#{param_name}] must be at most #{rules[:max]}." if rules[:max] && num_value > rules[:max]
164
+ rescue ArgumentError, TypeError
165
+ errors << "Parameter [#{param_name}] must be a valid #{rules[:type]}."
166
+ end
167
+ when "string"
168
+ unless value.is_a?(String)
169
+ errors << "Parameter [#{param_name}] must be a string."
170
+ next
171
+ end
172
+ errors << "Parameter [#{param_name}] must be at least #{rules[:min_length]} characters." if rules[:min_length] && value.length < rules[:min_length]
173
+ errors << "Parameter [#{param_name}] must be at most #{rules[:max_length]} characters." if rules[:max_length] && value.length > rules[:max_length]
174
+
175
+ if rules[:format] && FORMAT_PATTERNS[rules[:format]]
176
+ unless value.match?(FORMAT_PATTERNS[rules[:format]])
177
+ errors << "Parameter [#{param_name}] must be a valid #{rules[:format]}."
178
+ end
179
+ end
180
+ when "boolean"
181
+ unless [true, false, "true", "false"].include?(value)
182
+ errors << "Parameter [#{param_name}] must be a boolean."
183
+ end
184
+ end
185
+
186
+ # Enum validation
187
+ if rules[:enum] && !rules[:enum].include?(value)
188
+ errors << "Parameter [#{param_name}] must be one of: #{rules[:enum].join(', ')}."
189
+ end
190
+ end
191
+
192
+ raise ValidationError, errors unless errors.empty?
193
+ end
194
+
195
+ def handle_response(response)
196
+ log("Response status: #{response.status}")
197
+
198
+ data = JSON.parse(response.body)
199
+
200
+ if data["status"] == "error"
201
+ raise APIError.new(data["error"] || "Unknown API error", response.status, data)
202
+ end
203
+
204
+ unless response.success?
205
+ raise APIError.new(data["error"] || "HTTP #{response.status} error", response.status, data)
206
+ end
207
+
208
+ log("Request successful")
209
+ data
210
+ rescue JSON::ParserError => e
211
+ raise APIError.new("Invalid JSON response: #{e.message}", response.status)
212
+ end
213
+
214
+ def log(message)
215
+ puts "[APIVerve::Nsfwimagedetector] #{message}" if @debug
216
+ end
217
+ end
218
+
219
+ # Custom error class for API errors
220
+ class APIError < StandardError
221
+ attr_reader :status_code, :response
222
+
223
+ def initialize(message, status_code = nil, response = nil)
224
+ @status_code = status_code
225
+ @response = response
226
+ super(message)
227
+ end
228
+ end
229
+
230
+ # Custom error class for validation errors
231
+ class ValidationError < StandardError
232
+ attr_reader :errors
233
+
234
+ def initialize(errors)
235
+ @errors = errors
236
+ super("Validation failed: #{errors.join(' ')}")
237
+ end
238
+ end
239
+ end
240
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "apiverve_nsfwimagedetector/client"
4
+
5
+ module APIVerve
6
+ module Nsfwimagedetector
7
+ VERSION = "1.2.0"
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apiverve_nsfwimagedetector
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ platform: ruby
6
+ authors:
7
+ - APIVerve
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: faraday
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '1.0'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '1.0'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '3.0'
32
+ - !ruby/object:Gem::Dependency
33
+ name: faraday-multipart
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - "~>"
37
+ - !ruby/object:Gem::Version
38
+ version: '1.0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - "~>"
44
+ - !ruby/object:Gem::Version
45
+ version: '1.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: json
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '2.0'
53
+ type: :runtime
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '2.0'
60
+ description: NSFW Detector is a simple tool for detecting NSFW content. It returns
61
+ a boolean
62
+ email:
63
+ - hello@apiverve.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - LICENSE
69
+ - README.md
70
+ - lib/apiverve/client.rb
71
+ - lib/apiverve_nsfwimagedetector.rb
72
+ - lib/apiverve_nsfwimagedetector/client.rb
73
+ homepage: https://apiverve.com/marketplace/nsfwimagedetector?utm_source=ruby&utm_medium=homepage
74
+ licenses:
75
+ - MIT
76
+ metadata:
77
+ homepage_uri: https://apiverve.com/marketplace/nsfwimagedetector?utm_source=ruby&utm_medium=homepage
78
+ source_code_uri: https://github.com/apiverve/nsfwimagedetector-API/tree/main/ruby
79
+ changelog_uri: https://apiverve.com/changelog
80
+ documentation_uri: https://docs.apiverve.com/ref/nsfwimagedetector
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 2.7.0
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubygems_version: 3.6.9
96
+ specification_version: 4
97
+ summary: NSFW Image Detector API - Ruby Client
98
+ test_files: []