apiverve_facedetect 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: e632ac037451fb0fdcfde3de0f9d0152756cce5b4d5a35469e33b43a02a6eeea
4
+ data.tar.gz: f2081c77dbd1b6d89e26fb975939f30bccf1c212104ecbaf9f2b43f14b2cdeb6
5
+ SHA512:
6
+ metadata.gz: 0a4b4447f9ac3f16d15efe8ba2684b882f5d05ef5f4ff32db0b5e4d50bc016a7dfcacd864364edbc92de9caf0e20b8bda8abec3f75f2b4541add10dbcb4ad82e
7
+ data.tar.gz: 8240db0ce9d4c14b8c0c388cee2147a344e642bf898bae1e282e1ef910cb85dc416c4255455a9e124a58e2e27593ec57521b6a31ed83cec7b7650017d0ce7bbe
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,133 @@
1
+ # Face Detector API - Ruby Gem
2
+
3
+ Face Detector API analyzes images to detect human faces and returns bounding box coordinates for each detected face.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'apiverve_facedetect'
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_facedetect
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_facedetect'
33
+
34
+ # Initialize the client
35
+ client = APIVerve::Facedetect::Client.new(api_key: "YOUR_API_KEY")
36
+
37
+ # Make a request
38
+ response = client.execute({
39
+ url: "https://example.com/group-photo.jpg",
40
+ confidence: 0.5
41
+ })
42
+
43
+ # Print the response
44
+ puts response
45
+ ```
46
+
47
+ ### File Upload
48
+
49
+ ```ruby
50
+ # Upload a file
51
+ response = client.execute_with_file("/path/to/file.jpg")
52
+
53
+ # Or use a URL
54
+ response = client.execute_with_url("https://example.com/image.jpg")
55
+ ```
56
+
57
+ ### Error Handling
58
+
59
+ ```ruby
60
+ begin
61
+ response = client.execute({ url: "https://example.com/group-photo.jpg", confidence: 0.5 })
62
+ puts response["data"]
63
+ rescue APIVerve::Facedetect::ValidationError => e
64
+ puts "Validation error: #{e.errors.join(', ')}"
65
+ rescue APIVerve::Facedetect::APIError => e
66
+ puts "API error: #{e.message}"
67
+ puts "Status code: #{e.status_code}"
68
+ end
69
+ ```
70
+
71
+ ### Debug Mode
72
+
73
+ ```ruby
74
+ # Enable debug logging
75
+ client = APIVerve::Facedetect::Client.new(
76
+ api_key: "YOUR_API_KEY",
77
+ debug: true
78
+ )
79
+ ```
80
+
81
+ ## Example Response
82
+
83
+ ```json
84
+ {
85
+ "status": "ok",
86
+ "error": null,
87
+ "data": {
88
+ "faces": [
89
+ {
90
+ "x": 142,
91
+ "y": 85,
92
+ "width": 98,
93
+ "height": 112,
94
+ "confidence": 0.9847
95
+ },
96
+ {
97
+ "x": 312,
98
+ "y": 92,
99
+ "width": 87,
100
+ "height": 103,
101
+ "confidence": 0.9623
102
+ },
103
+ {
104
+ "x": 478,
105
+ "y": 78,
106
+ "width": 95,
107
+ "height": 118,
108
+ "confidence": 0.9412
109
+ }
110
+ ],
111
+ "faceCount": 3,
112
+ "hasFaces": true,
113
+ "imageWidth": 640,
114
+ "imageHeight": 480,
115
+ "averageConfidence": 0.9627,
116
+ "imageCoverage": 10.23
117
+ },
118
+ "code": 200
119
+ }
120
+ ```
121
+
122
+ ## Documentation
123
+
124
+ For more information, visit the [API Documentation](https://docs.apiverve.com/ref/facedetect?utm_source=rubygems&utm_medium=readme).
125
+
126
+ ## Support
127
+
128
+ - Website: [https://apiverve.com/marketplace/facedetect?utm_source=ruby&utm_medium=readme](https://apiverve.com/marketplace/facedetect?utm_source=ruby&utm_medium=readme)
129
+ - Email: hello@apiverve.com
130
+
131
+ ## License
132
+
133
+ 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 Facedetect
9
+ # Client for the Face Detector API
10
+ #
11
+ # @example Basic usage
12
+ # client = APIVerve::Facedetect::Client.new(api_key: "your_api_key")
13
+ # response = client.execute({ url: "https://example.com/group-photo.jpg", confidence: 0.5 })
14
+ # puts response
15
+ #
16
+ # @see https://apiverve.com/marketplace/facedetect?utm_source=ruby&utm_medium=readme
17
+ class Client
18
+ BASE_URL = "https://api.apiverve.com/v1/facedetect"
19
+ DEFAULT_TIMEOUT = 30
20
+
21
+ # Validation rules for parameters
22
+ VALIDATION_RULES = { 'image' => { type: 'string', required: true }, 'confidence' => { type: 'number', required: false, min: 0.1, max: 1 } }
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::Facedetect] #{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,241 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "faraday/multipart"
5
+ require "json"
6
+
7
+ module APIVerve
8
+ module Facedetect
9
+ # Client for the Face Detector API
10
+ #
11
+ # @example Basic usage
12
+ # client = APIVerve::Facedetect::Client.new(api_key: "your_api_key")
13
+ # response = client.execute({ url: "https://example.com/group-photo.jpg", confidence: 0.5 })
14
+ # puts response
15
+ #
16
+ # @see https://apiverve.com/marketplace/facedetect?utm_source=ruby&utm_medium=readme
17
+ class Client
18
+ BASE_URL = "https://api.apiverve.com/v1/facedetect"
19
+ DEFAULT_TIMEOUT = 30
20
+
21
+ # Validation rules for parameters
22
+ VALIDATION_RULES = {
23
+ 'url' => { type: 'string', required: true, format: 'url' },
24
+ 'confidence' => { type: 'number', required: false, min: 0.1, max: 1 }
25
+ }
26
+
27
+ # Format validation patterns
28
+ FORMAT_PATTERNS = {
29
+ 'email' => /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
30
+ 'url' => /^https?:\/\/.+/,
31
+ '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}$/,
32
+ 'date' => /^\d{4}-\d{2}-\d{2}$/,
33
+ 'hexColor' => /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/
34
+ }.freeze
35
+
36
+ # Initialize the client
37
+ #
38
+ # @param api_key [String] Your APIVerve API key
39
+ # @param timeout [Integer] Request timeout in seconds (default: 30)
40
+ # @param debug [Boolean] Enable debug logging (default: false)
41
+ # @raise [ArgumentError] If API key is invalid
42
+ def initialize(api_key:, timeout: DEFAULT_TIMEOUT, debug: false)
43
+ validate_api_key!(api_key)
44
+
45
+ @api_key = api_key
46
+ @timeout = timeout
47
+ @debug = debug
48
+
49
+ @connection = Faraday.new(url: BASE_URL) do |conn|
50
+ conn.request :multipart
51
+ conn.request :url_encoded
52
+ conn.adapter Faraday.default_adapter
53
+ conn.options.timeout = @timeout
54
+ conn.headers["x-api-key"] = @api_key
55
+ conn.headers["auth-mode"] = "rubygems-package"
56
+ conn.headers["Content-Type"] = "application/json"
57
+ end
58
+ end
59
+
60
+ # Execute the API request
61
+ #
62
+ # @param params [Hash] Query parameters or request body
63
+ # @return [Hash] API response
64
+ # @raise [APIError] If the request fails
65
+ # @raise [ValidationError] If parameter validation fails
66
+ def execute(params = {})
67
+ validate_params!(params)
68
+
69
+ log("Making POST request to #{BASE_URL}")
70
+ log("Parameters: #{params.inspect}") if params.any?
71
+
72
+ response = @connection.post do |req|
73
+ req.body = params.to_json
74
+ end
75
+
76
+ handle_response(response)
77
+ end
78
+
79
+ # Execute the API request with a file upload
80
+ #
81
+ # @param file_path [String] Path to the file to upload
82
+ # @param params [Hash] Additional parameters
83
+ # @return [Hash] API response
84
+ # @raise [APIError] If the request fails
85
+ # @raise [ArgumentError] If the file doesn't exist
86
+ def execute_with_file(file_path, params = {})
87
+ raise ArgumentError, "File not found: #{file_path}" unless File.exist?(file_path)
88
+
89
+ log("Uploading file: #{file_path}")
90
+
91
+ payload = {
92
+ "image" => Faraday::Multipart::FilePart.new(
93
+ file_path,
94
+ mime_type_for(file_path),
95
+ File.basename(file_path)
96
+ )
97
+ }
98
+ payload.merge!(params.transform_keys(&:to_s))
99
+
100
+ response = @connection.post do |req|
101
+ req.headers.delete("Content-Type") # Let Faraday set it
102
+ req.body = payload
103
+ end
104
+
105
+ handle_response(response)
106
+ end
107
+
108
+ # Execute the API request with a file URL
109
+ #
110
+ # @param url [String] URL of the file to process
111
+ # @param params [Hash] Additional parameters
112
+ # @return [Hash] API response
113
+ # @raise [APIError] If the request fails
114
+ def execute_with_url(url, params = {})
115
+ raise ArgumentError, "URL must be a string" unless url.is_a?(String)
116
+ raise ArgumentError, "Invalid URL format" unless url.match?(/^https?:\/\/.+/)
117
+
118
+ execute(params.merge(url: url))
119
+ end
120
+
121
+ private
122
+
123
+ def mime_type_for(file_path)
124
+ ext = File.extname(file_path).downcase
125
+ case ext
126
+ when ".jpg", ".jpeg" then "image/jpeg"
127
+ when ".png" then "image/png"
128
+ when ".gif" then "image/gif"
129
+ when ".webp" then "image/webp"
130
+ when ".pdf" then "application/pdf"
131
+ else "application/octet-stream"
132
+ end
133
+ end
134
+
135
+ def validate_api_key!(api_key)
136
+ raise ArgumentError, "API key is required. Get your API key at: https://apiverve.com" if api_key.nil? || api_key.strip.empty?
137
+
138
+ unless api_key.match?(/^[a-zA-Z0-9_-]+$/)
139
+ raise ArgumentError, "Invalid API key format. API key should only contain letters, numbers, hyphens, and underscores."
140
+ end
141
+ end
142
+
143
+ def validate_params!(params)
144
+ return if VALIDATION_RULES.empty?
145
+
146
+ errors = []
147
+
148
+ VALIDATION_RULES.each do |param_name, rules|
149
+ value = params[param_name.to_sym] || params[param_name]
150
+
151
+ # Check required
152
+ if rules[:required] && (value.nil? || value.to_s.empty?)
153
+ errors << "Required parameter [#{param_name}] is missing."
154
+ next
155
+ end
156
+
157
+ next if value.nil?
158
+
159
+ case rules[:type]
160
+ when "integer", "number"
161
+ begin
162
+ num_value = rules[:type] == "number" ? Float(value) : Integer(value)
163
+ errors << "Parameter [#{param_name}] must be at least #{rules[:min]}." if rules[:min] && num_value < rules[:min]
164
+ errors << "Parameter [#{param_name}] must be at most #{rules[:max]}." if rules[:max] && num_value > rules[:max]
165
+ rescue ArgumentError, TypeError
166
+ errors << "Parameter [#{param_name}] must be a valid #{rules[:type]}."
167
+ end
168
+ when "string"
169
+ unless value.is_a?(String)
170
+ errors << "Parameter [#{param_name}] must be a string."
171
+ next
172
+ end
173
+ errors << "Parameter [#{param_name}] must be at least #{rules[:min_length]} characters." if rules[:min_length] && value.length < rules[:min_length]
174
+ errors << "Parameter [#{param_name}] must be at most #{rules[:max_length]} characters." if rules[:max_length] && value.length > rules[:max_length]
175
+
176
+ if rules[:format] && FORMAT_PATTERNS[rules[:format]]
177
+ unless value.match?(FORMAT_PATTERNS[rules[:format]])
178
+ errors << "Parameter [#{param_name}] must be a valid #{rules[:format]}."
179
+ end
180
+ end
181
+ when "boolean"
182
+ unless [true, false, "true", "false"].include?(value)
183
+ errors << "Parameter [#{param_name}] must be a boolean."
184
+ end
185
+ end
186
+
187
+ # Enum validation
188
+ if rules[:enum] && !rules[:enum].include?(value)
189
+ errors << "Parameter [#{param_name}] must be one of: #{rules[:enum].join(', ')}."
190
+ end
191
+ end
192
+
193
+ raise ValidationError, errors unless errors.empty?
194
+ end
195
+
196
+ def handle_response(response)
197
+ log("Response status: #{response.status}")
198
+
199
+ data = JSON.parse(response.body)
200
+
201
+ if data["status"] == "error"
202
+ raise APIError.new(data["error"] || "Unknown API error", response.status, data)
203
+ end
204
+
205
+ unless response.success?
206
+ raise APIError.new(data["error"] || "HTTP #{response.status} error", response.status, data)
207
+ end
208
+
209
+ log("Request successful")
210
+ data
211
+ rescue JSON::ParserError => e
212
+ raise APIError.new("Invalid JSON response: #{e.message}", response.status)
213
+ end
214
+
215
+ def log(message)
216
+ puts "[APIVerve::Facedetect] #{message}" if @debug
217
+ end
218
+ end
219
+
220
+ # Custom error class for API errors
221
+ class APIError < StandardError
222
+ attr_reader :status_code, :response
223
+
224
+ def initialize(message, status_code = nil, response = nil)
225
+ @status_code = status_code
226
+ @response = response
227
+ super(message)
228
+ end
229
+ end
230
+
231
+ # Custom error class for validation errors
232
+ class ValidationError < StandardError
233
+ attr_reader :errors
234
+
235
+ def initialize(errors)
236
+ @errors = errors
237
+ super("Validation failed: #{errors.join(' ')}")
238
+ end
239
+ end
240
+ end
241
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "apiverve_facedetect/client"
4
+
5
+ module APIVerve
6
+ module Facedetect
7
+ VERSION = "1.2.0"
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: apiverve_facedetect
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: Face Detector API analyzes images to detect human faces and returns bounding
61
+ box coordinates for each detected face.
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_facedetect.rb
72
+ - lib/apiverve_facedetect/client.rb
73
+ homepage: https://apiverve.com/marketplace/facedetect?utm_source=ruby&utm_medium=homepage
74
+ licenses:
75
+ - MIT
76
+ metadata:
77
+ homepage_uri: https://apiverve.com/marketplace/facedetect?utm_source=ruby&utm_medium=homepage
78
+ source_code_uri: https://github.com/apiverve/facedetect-API/tree/main/ruby
79
+ changelog_uri: https://apiverve.com/changelog
80
+ documentation_uri: https://docs.apiverve.com/ref/facedetect
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: Face Detector API - Ruby Client
98
+ test_files: []