appending 1.4.2 → 1.4.4

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appending.rb +48 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e018ab896cfc8ade090d1520b22241d6a6ff94af9680466ce659aa5ad6e7fb9b
4
- data.tar.gz: 1d9ddd8428910b8085399bbcdbba8198cb05bdc112200714844c29a35bde0ff0
3
+ metadata.gz: 22c3a4eaaa1fb0b5d2f95e36c66dbb16da5423f6f3ff7ea31373d5e6deaf7911
4
+ data.tar.gz: af05a378cc68d44b8c2053eb23a0d707f1d4ed36b873b6efd3ef54d067bdaf08
5
5
  SHA512:
6
- metadata.gz: 721ec624c8fe4594ab7fff4aac354fbc0dafb1215abb5c5c51c88d942eb8929877fa4bfe85ae4b9f960166caee84bd480ba318c26b998d3b4b68dd4aa69c6539
7
- data.tar.gz: 9a16c08e7ff289a88253b81dafe553aee4792672e4ac83c4325e554a9da743ddf9282f0ee13f9c4d5ce312694268882da2daad730d28aade85777c69268ec2d1
6
+ metadata.gz: 9a1ac36820492dde1d8bb15d9b90d4738e72358b9a87caafa3570ad150aafc61fe0de7242a84ad047684f12dee31c7c8776d8b660f8febf4c8f94c7a064f2189
7
+ data.tar.gz: 11a6f6df6f7d6afeeec8d1969a17316536e3a1e1ad213068a5e8b0470abb1fb3f78c41818d11db92d67f8e24724d4d3943185a4e7e104bebdfcf7d82d7c1f0a9
data/lib/appending.rb CHANGED
@@ -14,6 +14,9 @@ module BlackStack
14
14
  @@phone_fields = []
15
15
  @@company_domain_fields = []
16
16
 
17
+ @@zerobounce_api_key = nil
18
+ @@emailverify_api_key = nil
19
+
17
20
  ## @@logger
18
21
  def self.set_logger(logger)
19
22
  @@logger = logger
@@ -162,6 +165,45 @@ module BlackStack
162
165
  @@email_fields = h[:email_fields] if h[:email_fields]
163
166
  @@phone_fields = h[:phone_fields] if h[:phone_fields]
164
167
  @@company_domain_fields = h[:company_domain_fields] if h[:company_domain_fields]
168
+
169
+ # zerobounce api key
170
+ @@zerobounce_api_key = h[:zerobounce_api_key] if h[:zerobounce_api_key]
171
+
172
+ # emailverify api key
173
+ @@emailverify_api_key = h[:emailverify_api_key] if h[:emailverify_api_key]
174
+ end
175
+
176
+ # call zerobounce api
177
+ def self.zerobounce_verify(email)
178
+ # validation: email must be a string
179
+ raise "Invalid email: #{email.class}. Expected: String." if !email.is_a?(String)
180
+ url = "https://api.zerobounce.net/v2/validate"
181
+ params = {
182
+ :api_key => @@zerobounce_api_key,
183
+ :email => email,
184
+ :ip_address => nil,
185
+ }
186
+ res = BlackStack::Netting::call_get(url, params)
187
+ JSON.parse(res.body)
188
+ end
189
+
190
+ # call emailverify api to verify an email
191
+ # reutrn 'ok' if the email is valid
192
+ def self.emailverify_verify(email)
193
+ # validation: email must be a string
194
+ raise "Invalid email: #{email.class}. Expected: String." if !email.is_a?(String)
195
+ url = "https://apps.emaillistverify.com/api/verifEmail"
196
+ params = {
197
+ :secret => @@emailverify_api_key,
198
+ :email => email,
199
+ }
200
+ res = BlackStack::Netting::call_get(url, params)
201
+ res.body
202
+ end
203
+
204
+ # call emailverify api to ask if there are credits
205
+ def self.emailverify_credits?
206
+ BlackStack::Appending.emailverify_verify('x') == 'error_credit'
165
207
  end
166
208
 
167
209
  # return true if the domain get any random address as valid
@@ -337,6 +379,8 @@ module BlackStack
337
379
  emails = []
338
380
  domains = []
339
381
  verified_emails = []
382
+ #
383
+ return verified_emails if cname =~ /Self.*employed/i
340
384
  # get lead emails from in the indexes
341
385
  l.logs ("Searching index emails... ")
342
386
  emails = BlackStack::Appending.find_persons(fname, lname, cname, l).map { |res|
@@ -345,6 +389,7 @@ module BlackStack
345
389
  email.to_s.empty?
346
390
  }.uniq
347
391
  # remove duplications
392
+ # IMPORTANT: be sure you have no spances, and no duplications, in order to don't repeat this issue https://github.com/leandrosardi/emails/issues/124
348
393
  emails = emails.map { |email| email.to_s.downcase.strip }.uniq
349
394
  l.logf "done (#{emails.to_s})"
350
395
  # get company domains from the indexes
@@ -358,6 +403,7 @@ module BlackStack
358
403
  domain.to_s.gsub('www.', '').downcase
359
404
  }.uniq
360
405
  # remove duplications
406
+ # IMPORTANT: be sure you have no spances, and no duplications, in order to don't repeat this issue https://github.com/leandrosardi/emails/issues/124
361
407
  domains = domains.map { |domain| domain.to_s.downcase.strip }.uniq
362
408
  l.logf "done (#{domains.to_s})"
363
409
  # add emails using fname and lname and company domains
@@ -389,10 +435,12 @@ module BlackStack
389
435
  l.logs "Verifying #{email}... "
390
436
  verified_emails << email if BlackStack::Appending.verify(email)
391
437
  l.done
438
+ # IMPORTANT: I added this line in order to resolve this issue https://github.com/leandrosardi/emails/issues/124
392
439
  break if verified_emails.size > 0
393
440
  }
394
441
  l.done
395
442
  # verify all the emails found in the indexes
443
+ # IMPORTANT: I added this double-check in order to don't repeat this issue https://github.com/leandrosardi/emails/issues/124
396
444
  l.logs ("Double check emails... ")
397
445
  verified_emails.each { |email|
398
446
  l.logs "Double-checking #{email}... "
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appending
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-21 00:00:00.000000000 Z
11
+ date: 2023-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: csv