verifalia 1.2.0 → 2.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 (59) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +5 -5
  3. data/LICENSE +3 -4
  4. data/README.md +415 -82
  5. data/Rakefile +4 -0
  6. data/lib/verifalia/client.rb +89 -0
  7. data/lib/verifalia/credits/balance.rb +59 -0
  8. data/lib/verifalia/credits/client.rb +54 -0
  9. data/lib/verifalia/email_validation/client.rb +237 -0
  10. data/lib/verifalia/email_validation/completion_callback.rb +44 -0
  11. data/lib/verifalia/email_validation/entry.rb +124 -0
  12. data/lib/verifalia/email_validation/entry_classification.rb +49 -0
  13. data/lib/verifalia/email_validation/entry_status.rb +181 -0
  14. data/lib/verifalia/email_validation/exported_entries_format.rb +46 -0
  15. data/lib/verifalia/email_validation/job.rb +107 -0
  16. data/lib/verifalia/email_validation/job_status.rb +49 -0
  17. data/lib/verifalia/email_validation/overview.rb +108 -0
  18. data/lib/verifalia/email_validation/progress.rb +48 -0
  19. data/lib/verifalia/email_validation/request.rb +48 -0
  20. data/lib/verifalia/email_validation/request_entry.rb +43 -0
  21. data/lib/verifalia/email_validation/wait_options.rb +82 -0
  22. data/lib/verifalia/rest/client.rb +111 -0
  23. data/lib/verifalia/security/certificate_authenticator.rb +50 -0
  24. data/lib/verifalia/security/username_password_authenticator.rb +51 -0
  25. data/lib/verifalia.rb +49 -21
  26. data/sig/completion_callback.rbs +5 -0
  27. data/sig/verifalia/client.rbs +11 -0
  28. data/sig/verifalia/credits/balance.rbs +11 -0
  29. data/sig/verifalia/credits/client.rbs +7 -0
  30. data/sig/verifalia/email_validations/client.rbs +24 -0
  31. data/sig/verifalia/email_validations/entry.rbs +24 -0
  32. data/sig/verifalia/email_validations/entry_classification.rbs +10 -0
  33. data/sig/verifalia/email_validations/entry_status.rbs +50 -0
  34. data/sig/verifalia/email_validations/exported_entries_format.rbs +9 -0
  35. data/sig/verifalia/email_validations/job.rbs +13 -0
  36. data/sig/verifalia/email_validations/job_status.rbs +10 -0
  37. data/sig/verifalia/email_validations/overview.rbs +20 -0
  38. data/sig/verifalia/email_validations/progress.rbs +8 -0
  39. data/sig/verifalia/email_validations/request.rbs +13 -0
  40. data/sig/verifalia/email_validations/request_entry.rbs +8 -0
  41. data/sig/verifalia/email_validations/wait_options.rbs +20 -0
  42. data/sig/verifalia/rest/client.rbs +12 -0
  43. data/sig/verifalia/rest.rbs +6 -0
  44. data/sig/verifalia/security/certificate_authenticator.rbs +8 -0
  45. data/sig/verifalia/security/username_password_authenticator.rbs +10 -0
  46. data/verifalia.gemspec +27 -18
  47. metadata +72 -64
  48. data/.gitignore +0 -24
  49. data/lib/rest/account_balance.rb +0 -93
  50. data/lib/rest/client.rb +0 -83
  51. data/lib/rest/email_validations.rb +0 -195
  52. data/lib/verifalia/util/configuration.rb +0 -7
  53. data/lib/verifalia/version.rb +0 -3
  54. data/spec/rest/account_balance_spec.rb +0 -93
  55. data/spec/rest/client_spec.rb +0 -105
  56. data/spec/rest/email_validations_spec.rb +0 -322
  57. data/spec/spec_helper.rb +0 -21
  58. data/spec/util/configuration_spec.rb +0 -15
  59. data/spec/verifalia_spec.rb +0 -17
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Verifalia - Email list cleaning and real-time email verification service
4
+ # https://verifalia.com/
5
+ # support@verifalia.com
6
+ #
7
+ # Copyright (c) 2005-2024 Cobisi Research
8
+ #
9
+ # Cobisi Research
10
+ # Via Della Costituzione, 31
11
+ # 35010 Vigonza
12
+ # Italy - European Union
13
+ #
14
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ # of this software and associated documentation files (the "Software"), to deal
16
+ # in the Software without restriction, including without limitation the rights
17
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ # copies of the Software, and to permit persons to whom the Software is
19
+ # furnished to do so, subject to the following conditions:
20
+ #
21
+ # The above copyright notice and this permission notice shall be included in
22
+ # all copies or substantial portions of the Software.
23
+ #
24
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ # THE SOFTWARE.
31
+
32
+ require 'openssl/x509'
33
+ require_relative './rest/client'
34
+
35
+ module Verifalia
36
+ # HTTPS-based REST client for Verifalia.
37
+ class Client
38
+ # The version of the Verifalia SDK for Ruby.
39
+ VERSION = '2.1.0'
40
+
41
+ # Allows to verify email addresses and manage email verification jobs using the Verifalia service.
42
+ attr_reader :email_validations
43
+
44
+ # Manages credit packs, daily free credits and usage consumption for the Verifalia account.
45
+ attr_reader :credits
46
+
47
+ # Initializes a new HTTPS-based REST client for Verifalia with the specified options.
48
+ #
49
+ # While authenticating with your Verifalia main account credentials is possible, it is strongly advised to create
50
+ # one or more users (formerly known as sub-accounts) with just the required permissions, for improved security.
51
+ # To create a new user or manage existing ones, please visit 'https://verifalia.com/client-area#/users'
52
+ #
53
+ # @param [nil] authenticator A custom authenticator the client will use to authenticate against the Verifalia API.
54
+ # @param [nil] username The user-name used to authenticate against the Verifalia API using basic auth.
55
+ # @param [nil] password The password used to authenticate against the Verifalia API using basic auth.
56
+ # @param [nil] ssl_client_cert The X.509 client certificate used to authenticate against the Verifalia API using mutual TLS authentication. Available to premium Verifalia plans only.
57
+ # @param [nil] ssl_client_key The private key used to authenticate against the Verifalia API using mutual TLS authentication. Available to premium Verifalia plans only.
58
+ # @param [nil] base_urls Alternative base URLs to use while connecting against the Verifalia API.
59
+ # @param [nil] logger A logger where to write diagnostics messages, useful while debugging.
60
+ def initialize(authenticator: nil, username: nil, password: nil, ssl_client_cert: nil, ssl_client_key: nil, base_urls: nil, logger: nil)
61
+ @base_urls = base_urls
62
+
63
+ # Initialize the authenticator this client will use while connecting to the Verifalia API
64
+
65
+ if !authenticator.nil?
66
+ @authenticator = authenticator
67
+ elsif !username.nil?
68
+ @authenticator = Verifalia::Security::UsernamePasswordAuthenticator.new(username, password)
69
+ elsif !ssl_client_cert.nil?
70
+ @authenticator = Verifalia::Security::CertificateAuthenticator.new(ssl_client_cert, ssl_client_key)
71
+ @base_urls ||= Verifalia::Rest::BASE_CCA_URLS
72
+ else
73
+ raise ArgumentError, 'Username is nil and no other authentication method was specified: please visit https://verifalia.com/client-area to set up a new user, if you don\'t have one.'
74
+ end
75
+
76
+ @base_urls ||= Verifalia::Rest::BASE_URLS
77
+ @rest_client = Verifalia::Rest::Client.new(@authenticator,
78
+ "verifalia-rest-client/ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}/#{VERSION}",
79
+ @base_urls)
80
+
81
+ @rest_client.logger = logger
82
+
83
+ # Initialize the underlying resource clients
84
+
85
+ @email_validations = Verifalia::EmailValidations::Client.new(@rest_client)
86
+ @credits = Verifalia::Credits::Client.new(@rest_client)
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Verifalia - Email list cleaning and real-time email verification service
4
+ # https://verifalia.com/
5
+ # support@verifalia.com
6
+ #
7
+ # Copyright (c) 2005-2024 Cobisi Research
8
+ #
9
+ # Cobisi Research
10
+ # Via Della Costituzione, 31
11
+ # 35010 Vigonza
12
+ # Italy - European Union
13
+ #
14
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ # of this software and associated documentation files (the "Software"), to deal
16
+ # in the Software without restriction, including without limitation the rights
17
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ # copies of the Software, and to permit persons to whom the Software is
19
+ # furnished to do so, subject to the following conditions:
20
+ #
21
+ # The above copyright notice and this permission notice shall be included in
22
+ # all copies or substantial portions of the Software.
23
+ #
24
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ # THE SOFTWARE.
31
+
32
+ module Verifalia
33
+ module Credits
34
+ # The credits balance for the Verifalia account.
35
+ class Balance
36
+ # The number of credit packs (that is, non-expiring credits) available for the account.
37
+ attr_reader :credit_packs
38
+
39
+ # The number of free daily credits of the account, where available.
40
+ attr_reader :free_credits
41
+
42
+ # A string representing the amount of time before the daily credits expire, where available, expressed in the form +hh:mm:ss+.
43
+ attr_reader :free_credits_reset_in
44
+
45
+ def initialize(credit_packs, free_credits, free_credits_reset_in)
46
+ @credit_packs = credit_packs
47
+ @free_credits = free_credits
48
+ @free_credits_reset_in = free_credits_reset_in
49
+ end
50
+
51
+ # Parse a Balance from a JSON string.
52
+ def self.from_json(data)
53
+ Balance.new data['creditPacks'],
54
+ data['freeCredits'],
55
+ data['freeCreditsResetIn']
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Verifalia - Email list cleaning and real-time email verification service
4
+ # https://verifalia.com/
5
+ # support@verifalia.com
6
+ #
7
+ # Copyright (c) 2005-2024 Cobisi Research
8
+ #
9
+ # Cobisi Research
10
+ # Via Della Costituzione, 31
11
+ # 35010 Vigonza
12
+ # Italy - European Union
13
+ #
14
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ # of this software and associated documentation files (the "Software"), to deal
16
+ # in the Software without restriction, including without limitation the rights
17
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ # copies of the Software, and to permit persons to whom the Software is
19
+ # furnished to do so, subject to the following conditions:
20
+ #
21
+ # The above copyright notice and this permission notice shall be included in
22
+ # all copies or substantial portions of the Software.
23
+ #
24
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ # THE SOFTWARE.
31
+
32
+ require_relative 'balance'
33
+
34
+ module Verifalia
35
+ module Credits
36
+ # Manages credit packs, daily free credits and usage consumption for the Verifalia account.
37
+ class Client
38
+ def initialize(rest_client)
39
+ @rest_client = rest_client
40
+ end
41
+
42
+ # Returns the current credits balance for the Verifalia account.
43
+ # @return [Verifalia::Credits::Balance] The account balance.
44
+ def get_balance
45
+ response = @rest_client.invoke 'get',
46
+ 'credits/balance'
47
+
48
+ return Balance.from_json(JSON.parse(response.body)) if response.status == 200
49
+
50
+ raise "Unexpected HTTP response: #{response.status} #{response.body}"
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,237 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Verifalia - Email list cleaning and real-time email verification service
4
+ # https://verifalia.com/
5
+ # support@verifalia.com
6
+ #
7
+ # Copyright (c) 2005-2024 Cobisi Research
8
+ #
9
+ # Cobisi Research
10
+ # Via Della Costituzione, 31
11
+ # 35010 Vigonza
12
+ # Italy - European Union
13
+ #
14
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ # of this software and associated documentation files (the "Software"), to deal
16
+ # in the Software without restriction, including without limitation the rights
17
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ # copies of the Software, and to permit persons to whom the Software is
19
+ # furnished to do so, subject to the following conditions:
20
+ #
21
+ # The above copyright notice and this permission notice shall be included in
22
+ # all copies or substantial portions of the Software.
23
+ #
24
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ # THE SOFTWARE.
31
+
32
+ require 'net/http'
33
+ require_relative 'job'
34
+ require_relative 'overview'
35
+ require_relative 'entry'
36
+ require_relative 'wait_options'
37
+ require_relative 'request'
38
+ require_relative 'request_entry'
39
+ require_relative 'completion_callback'
40
+
41
+ module Verifalia
42
+ module EmailValidations
43
+ # Allows to verify email addresses and manage email verification jobs using the Verifalia service.
44
+ class Client
45
+ def initialize(rest_client)
46
+ @rest_client = rest_client
47
+ end
48
+
49
+ # Submits a new email validation for processing.
50
+ #
51
+ # By default, this method waits for the completion of the email validation job: pass a +WaitOptions+ to request
52
+ # a different waiting behavior.
53
+ #
54
+ # @param data The input data to verify.
55
+ # @param [nil] quality The desired results quality for this email validation.
56
+ # @param [nil] priority
57
+ # @param [nil] deduplication An optional string with the name of the algorithm our engine will use to scrub the list of email addresses and remove its duplicates. The following values are currently supported: +Off+ does not mark duplicated email addresses, +Safe+ mark duplicated email addresses with an algorithm which guarantees no false duplicates are returned, +Relaxed+ mark duplicated email addresses using a set of relaxed rules which assume the target email service providers are configured with modern settings only. If not specified, Verifalia will not mark duplicated email addresses.
58
+ # @param [nil] name An optional user-defined name for the validation job, for your own reference.
59
+ # @param [nil] retention An optional string with the desired data retention period to observe for the validation job, expressed in the format +dd.hh:mm:ss+ (where +dd.+ days, +hh:+ hours, +mm:+ minutes, +ss:+ seconds); the initial +dd.+ part is added only for periods of more than 24 hours. The value has a minimum of 5 minutes (+0:5:0+) and a maximum of 30 days (+30.0:0:0+): Verifalia will delete the job and its data once its data retention period is over, starting to count when it gets completed. If not specified, Verifalia falls back to the configured data retention period of the submitting user / browser app and, should it be unset, to the configured data retention period of the Verifalia account, with a default of 30 days.
60
+ # @param [nil] completion_callback An optional hash describing the desired completion callback behavior, with the following keys: +url+ A string with the URL Verifalia will invoke once the job results are ready. See how to handle completion callbacks. +version+ An optional string which defines the callback schema our dispatcher must obey when invoking the provided callback URL. Valid values are: +1.0+ the callback includes the completed job ID. +1.1+ everything included with +1.0+ plus the job name. If not specified, Verifalia will use the most recent schema available at the time the used API version was released. +skipServerCertificateValidation+ An optional boolean which allows to skip the server certificate validation for the external callback server, useful for testing purposes at development time when the callback server is using a self-signed certificate.
61
+ # @param [nil] wait_options The options which rule out how to wait for the completion of the email validation.
62
+ # @return [Verifalia::EmailValidations::Job] The submitted validation job (or +nil+ if expired / deleted while waiting for its completion).
63
+ def submit(data,
64
+ quality: nil,
65
+ priority: nil,
66
+ deduplication: nil,
67
+ name: nil,
68
+ retention: nil,
69
+ completion_callback: nil,
70
+ wait_options: nil)
71
+ # Determine how to handle the submission, based on the type of the argument
72
+
73
+ if data.nil?
74
+ raise ArgumentError, 'data can\'t be nil.'
75
+ elsif data.is_a?(String)
76
+ data = Request.new [(RequestEntry.new data)],
77
+ quality: quality
78
+ elsif data.is_a? Enumerable
79
+ entries = data.map do |entry|
80
+ case entry
81
+ when String
82
+ # data is an Array[String]
83
+ RequestEntry.new entry.to_s
84
+ when RequestEntry
85
+ # data is an Array[RequestEntry]
86
+ entry
87
+ when Hash
88
+ # data is an Array[{ :inputData, :custom }]
89
+
90
+ raise ArgumentError, 'Input hash must have an :inputData key.' unless entry.key?(:input_data)
91
+
92
+ RequestEntry.new entry[:input_data], entry[:custom]
93
+ else
94
+ raise ArgumentError, 'Cannot map input data.'
95
+ end
96
+ end
97
+
98
+ data = Request.new entries,
99
+ quality: quality
100
+ elsif data.is_a?(RequestEntry)
101
+ data = Request.new data,
102
+ quality: quality
103
+ elsif !data.is_a?(Request)
104
+ raise ArgumentError, "Unsupported data type #{data.class}"
105
+ end
106
+
107
+ # Completion callback
108
+
109
+ if completion_callback.is_a?(Hash)
110
+ completion_callback = Verifalia::EmailValidations::CompletionCallback.new(completion_callback['url'],
111
+ completion_callback['version'],
112
+ completion_callback['skip_server_certificate_validation'])
113
+ end
114
+
115
+ # Send the request to the Verifalia API
116
+
117
+ wait_options_or_default = wait_options.nil? ? WaitOptions.default : wait_options
118
+
119
+ payload = {
120
+ entries: data.entries.map do |entry|
121
+ {
122
+ inputData: entry.input_data,
123
+ custom: entry.custom
124
+ }
125
+ end,
126
+ quality: quality,
127
+ priority: priority,
128
+ deduplication: deduplication,
129
+ name: name,
130
+ retention: retention,
131
+ callback: (
132
+ unless completion_callback.nil?
133
+ {
134
+ url: completion_callback&.url,
135
+ version: completion_callback&.version,
136
+ skipServerCertificateValidation: completion_callback&.skip_server_certificate_validation
137
+ }
138
+ end
139
+ )
140
+ }.compact.to_json
141
+
142
+ response = @rest_client.invoke 'post',
143
+ "email-validations?waitTime=#{wait_options_or_default.submission_wait_time}",
144
+ {
145
+ body: payload,
146
+ headers:
147
+ {
148
+ 'Content-Type': 'application/json',
149
+ 'Accept': 'application/json'
150
+ }
151
+ }
152
+
153
+ if response.status == 202 || response.status == 200
154
+ job = Job.from_json(JSON.parse(response.body))
155
+
156
+ return job if wait_options_or_default == WaitOptions.no_wait || response.status == 200
157
+
158
+ return get(job.overview.id, wait_options: wait_options_or_default)
159
+ end
160
+
161
+ raise "Unexpected HTTP response: #{response.status} #{response.body}"
162
+ end
163
+
164
+ # Returns an email validation job previously submitted for processing.
165
+ #
166
+ # By default, this method waits for the completion of the email validation job: pass a +WaitOptions+ to request
167
+ # a different waiting behavior.
168
+ # @param [String] id The ID of the email validation job to retrieve.
169
+ # @param [nil] wait_options The options which rule out how to wait for the completion of the email validation.
170
+ # @return [Verifalia::EmailValidations::Job] The fetched validation job (or +nil+ if not found).
171
+ def get(id, wait_options: nil)
172
+ wait_options_or_default = wait_options.nil? ? WaitOptions.default : wait_options
173
+
174
+ loop do
175
+ response = @rest_client.invoke 'get',
176
+ "email-validations/#{id}?waitTime=#{wait_options_or_default.poll_wait_time}"
177
+
178
+ return nil if response.status == 404 || response.status == 410
179
+
180
+ unless response.status == 202 || response.status == 200
181
+ raise "Unexpected HTTP response: #{response.status} #{response.body}"
182
+ end
183
+
184
+ job = Job.from_json(JSON.parse(response.body))
185
+
186
+ return job if wait_options_or_default == WaitOptions.no_wait || response.status == 200
187
+
188
+ # Fires a progress, since we are not yet completed
189
+
190
+ wait_options.progress&.call(job.overview)
191
+
192
+ # Wait for the next polling schedule
193
+
194
+ wait_options.wait_for_next_poll(job)
195
+ end
196
+ end
197
+
198
+ # Exports the validated entries for a completed email validation job, using the specified output format.
199
+ # See +ExportedEntriesFormat+ for a list of the values supported at the time this SDK has been released.
200
+ #
201
+ # Supported formats:
202
+ # - Comma-Separated Values (CSV)
203
+ # - Microsoft Excel (.xlsx)
204
+ # - Microsoft Excel 97-2003 (.xls)
205
+ #
206
+ # @param [String] id The ID of the email validation job to retrieve.
207
+ # @param [String] format The MIME content type of the desired output file format.
208
+ # @return [String] The exported data.
209
+ def export(id, format)
210
+ response = @rest_client.invoke 'get',
211
+ "email-validations/#{id}/entries",
212
+ {
213
+ headers:
214
+ {
215
+ 'Accept': format
216
+ }
217
+ }
218
+
219
+ return nil if response.status == 404 || response.status == 410
220
+ return response.body if response.status == 200
221
+
222
+ raise "Unexpected HTTP response: #{response.status} #{response.body}"
223
+ end
224
+
225
+ # Deletes an email validation job previously submitted for processing.
226
+ # @param [String] id The ID of the email validation job to delete.
227
+ def delete(id)
228
+ response = @rest_client.invoke 'delete',
229
+ "email-validations/#{id}"
230
+
231
+ return if response.status == 200 || response.status == 410
232
+
233
+ raise "Unexpected HTTP response: #{response.status} #{response.body}"
234
+ end
235
+ end
236
+ end
237
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Verifalia - Email list cleaning and real-time email verification service
4
+ # https://verifalia.com/
5
+ # support@verifalia.com
6
+ #
7
+ # Copyright (c) 2005-2024 Cobisi Research
8
+ #
9
+ # Cobisi Research
10
+ # Via Della Costituzione, 31
11
+ # 35010 Vigonza
12
+ # Italy - European Union
13
+ #
14
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ # of this software and associated documentation files (the "Software"), to deal
16
+ # in the Software without restriction, including without limitation the rights
17
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ # copies of the Software, and to permit persons to whom the Software is
19
+ # furnished to do so, subject to the following conditions:
20
+ #
21
+ # The above copyright notice and this permission notice shall be included in
22
+ # all copies or substantial portions of the Software.
23
+ #
24
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ # THE SOFTWARE.
31
+
32
+ module Verifalia
33
+ module EmailValidations
34
+ class CompletionCallback
35
+ attr_accessor :url, :version, :skip_server_certificate_validation
36
+
37
+ def initialize(url, version = nil, skip_server_certificate_validation = false)
38
+ @url = url
39
+ @version = version
40
+ @skip_server_certificate_validation = skip_server_certificate_validation
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Verifalia - Email list cleaning and real-time email verification service
4
+ # https://verifalia.com/
5
+ # support@verifalia.com
6
+ #
7
+ # Copyright (c) 2005-2024 Cobisi Research
8
+ #
9
+ # Cobisi Research
10
+ # Via Della Costituzione, 31
11
+ # 35010 Vigonza
12
+ # Italy - European Union
13
+ #
14
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ # of this software and associated documentation files (the "Software"), to deal
16
+ # in the Software without restriction, including without limitation the rights
17
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ # copies of the Software, and to permit persons to whom the Software is
19
+ # furnished to do so, subject to the following conditions:
20
+ #
21
+ # The above copyright notice and this permission notice shall be included in
22
+ # all copies or substantial portions of the Software.
23
+ #
24
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ # THE SOFTWARE.
31
+
32
+ module Verifalia
33
+ module EmailValidations
34
+ # Represents a single validated entry within a job.
35
+ class Entry
36
+ # The input string being validated.
37
+ attr_reader :input_data
38
+
39
+ # The classification for the status of this email address. See +EntryClassification+ for a list of the values
40
+ # supported at the time this SDK has been released.
41
+ attr_reader :classification
42
+
43
+ # The validation status for this entry. See +EntryStatus+ for a list of the values supported at the time this SDK
44
+ # has been released.
45
+ attr_reader :status
46
+
47
+ # Gets the email address, without any eventual comment or folding white space. Returns +nil+ if the input data
48
+ # is not a syntactically invalid e-mail address.
49
+ attr_reader :email_address
50
+
51
+ # Gets the local part of the email address, without comments and folding white spaces.
52
+ attr_reader :email_address_local_part
53
+
54
+ # Gets the domain part of the email address, without comments and folding white spaces.
55
+ #
56
+ # If the ASCII-only (punycode) version of the domain part is needed, use +@ascii_email_address_domain_part+.
57
+ attr_reader :email_address_domain_part
58
+
59
+ # Gets the domain part of the email address, converted to ASCII if needed using the punycode algorithm and with
60
+ # comments and folding white spaces stripped off.
61
+ #
62
+ # If the non-punycode version of the domain part is needed, use +@email_address_domain_part+.
63
+ attr_reader :ascii_email_address_domain_part
64
+
65
+ # If +true+, the email address has an international mailbox name.
66
+ attr_reader :has_international_mailbox_name
67
+
68
+ # If +true+, the email address has an international domain name.
69
+ attr_reader :has_international_domain_name
70
+
71
+ # If +true+, the email address comes from a disposable email address (DEA) provider.
72
+ #
73
+ # See https://verifalia.com/help/email-validations/what-is-a-disposable-email-address-dea for additional information
74
+ # about disposable email addresses.
75
+ attr_reader :is_disposable_email_address
76
+
77
+ # If +true+, the local part of the email address is a well-known role account.
78
+ attr_reader :is_role_account
79
+
80
+ # If +true+, the email address comes from a free email address provider (e.g. gmail, yahoo, outlook / hotmail, ...).
81
+ attr_reader :is_free_email_address
82
+
83
+ # The position of the character in the email address that eventually caused the syntax validation to fail.
84
+ attr_reader :syntax_failure_index
85
+
86
+ # The user-defined, optional string which is passed back upon completing the validation.
87
+ attr_reader :custom
88
+
89
+ # The zero-based index of the first occurrence of this email address in the parent +Job+, in the event the +status+
90
+ # for this entry is +Duplicate+; duplicated items do not expose any result detail apart from this and the eventual
91
+ # +custom+ values.
92
+ attr_reader :duplicate_of
93
+
94
+ # The date this entry has been completed, if available.
95
+ attr_reader :completed_on
96
+
97
+ # The potential corrections for the input data, in the event Verifalia identified potential typos during the verification process.
98
+ attr_reader :suggestions
99
+
100
+ def initialize (input_data, classification, status, email_address, email_address_local_part, email_address_domain_part,
101
+ has_international_mailbox_name, has_international_domain_name, is_disposable_email_address, is_role_account,
102
+ is_free_email_address, syntax_failure_index, custom, duplicate_of, completed_on, ascii_email_address_domain_part,
103
+ suggestions)
104
+ @input_data = input_data
105
+ @classification = classification
106
+ @status = status
107
+ @email_address = email_address
108
+ @email_address_local_part = email_address_local_part
109
+ @email_address_domain_part = email_address_domain_part
110
+ @has_international_mailbox_name = has_international_mailbox_name
111
+ @has_international_domain_name = has_international_domain_name
112
+ @is_disposable_email_address = is_disposable_email_address
113
+ @is_role_account = is_role_account
114
+ @is_free_email_address = is_free_email_address
115
+ @syntax_failure_index = syntax_failure_index
116
+ @custom = custom
117
+ @duplicate_of = duplicate_of
118
+ @completed_on = completed_on
119
+ @ascii_email_address_domain_part = ascii_email_address_domain_part
120
+ @suggestions = suggestions
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Verifalia - Email list cleaning and real-time email verification service
4
+ # https://verifalia.com/
5
+ # support@verifalia.com
6
+ #
7
+ # Copyright (c) 2005-2024 Cobisi Research
8
+ #
9
+ # Cobisi Research
10
+ # Via Della Costituzione, 31
11
+ # 35010 Vigonza
12
+ # Italy - European Union
13
+ #
14
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ # of this software and associated documentation files (the "Software"), to deal
16
+ # in the Software without restriction, including without limitation the rights
17
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ # copies of the Software, and to permit persons to whom the Software is
19
+ # furnished to do so, subject to the following conditions:
20
+ #
21
+ # The above copyright notice and this permission notice shall be included in
22
+ # all copies or substantial portions of the Software.
23
+ #
24
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ # THE SOFTWARE.
31
+
32
+ module Verifalia
33
+ module EmailValidations
34
+ # Provides values for the supported validation statuses for a job +entry+.
35
+ module EntryClassification
36
+ # An +entry+ marked as +Deliverable+ refers to an email which is deliverable.
37
+ DELIVERABLE = 'Deliverable'
38
+
39
+ # An +entry+ marked as +Risky+ refers to an email which could be no longer valid.
40
+ RISKY = 'Risky'
41
+
42
+ # An +entru+ marked as +Undeliverable+ refers to an email which is either invalid or no longer deliverable.
43
+ UNDELIVERABLE = 'Undeliverable'
44
+
45
+ # An +entry+ marked as +Unknown+ contains an email address whose deliverability is unknown.
46
+ UNKNOWN = 'Unknown'
47
+ end
48
+ end
49
+ end