blackstack-enrichment 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c1adb325c2208f76b6784af820b5045710678ace1b651e4bd9f7a6fcdb5db981
4
+ data.tar.gz: eb0455821bce876a0f6000147d5ca4a9987b2737ccd19684f57eb849368402e8
5
+ SHA512:
6
+ metadata.gz: e80809e301cd4211e5de508ab54aefb7e8363a995e181686d9dff7d8ab7983201bb36056eb3192b5be29cf6d6182794b769f1748703a47f1d743b389e48a8f4a
7
+ data.tar.gz: 8a39e8e4b28ab8876c832aff9872b9af38ad80f3c5a1db9e88c3838b930361bc0d5805d857d811fd38711f58148db31325aa10c9e9edfa50c48acf1a77c4d6a8
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'blackstack-enrichment'
3
+ s.version = '1.0.1'
4
+ s.date = '2024-03-19'
5
+ s.summary = "Ruby library for connecting some enrichment services like Apillo or FindyMail."
6
+ s.description = "Ruby library for connecting some enrichment services like Apillo or FindyMail."
7
+ s.authors = ["Leandro Daniel Sardi"]
8
+ s.email = 'leandro@connectionsphere.com'
9
+ s.files = [
10
+ 'lib/blackstack-enrichment.rb',
11
+ 'blackstack-enrichment.gemspec'
12
+ ]
13
+ s.homepage = 'https://github.com/leandrosardi/blackstack-enrichment'
14
+ s.license = 'MIT'
15
+ s.add_runtime_dependency 'json', '~> 2.6.3', '>= 2.6.3'
16
+ end
@@ -0,0 +1,106 @@
1
+ require 'json'
2
+
3
+ module BlackStack
4
+ class Enrichment
5
+ @@apollo_apikey = nil
6
+
7
+ def initialize(h={})
8
+ @apollo_apikey = h[:apollo_apikey]
9
+ @findymail_apikey = h[:findymail_apikey]
10
+ end # def initialize
11
+
12
+ # Retrieve the email of a person from a LinkedIn URL
13
+ #
14
+ # Reference: https://apolloio.github.io/apollo-api-docs/?shell#enrichment-api
15
+ #
16
+ #
17
+ def find_person_from_linkedin_url(url:)
18
+ raise 'Error: apollo_apikey is required for find_person_from_linkedin_url operation.' if @apollo_apikey.nil?
19
+
20
+ ret = `curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
21
+ "api_key": "#{@apollo_apikey}",
22
+ "reveal_personal_emails": true,
23
+ "details": [
24
+ {
25
+ "linkedin_url": "#{url}"
26
+ }
27
+ ]
28
+ }' "https://api.apollo.io/api/v1/people/bulk_match"`
29
+ j = JSON.parse(ret)
30
+ raise "Error: #{j['error_message']}" if j['error_message']
31
+ raise "Error: #{j['error_code']}" if j['error_code']
32
+ match = j['matches'].first
33
+ return nil if match.nil?
34
+ match['email']
35
+ end # def find_person_email_from_linkedin_url
36
+
37
+ # Retrieve the email of a person from his name and company.
38
+ #
39
+ # Reference: https://apolloio.github.io/apollo-api-docs/?shell#enrichment-api
40
+ #
41
+ #
42
+ def find_person_from_name_and_company(name:, company:)
43
+ raise 'Error: apollo_apikey is required for find_person_from_linkedin_url operation.' if @apollo_apikey.nil?
44
+
45
+ ret = `curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
46
+ "api_key": "#{@apollo_apikey}",
47
+ "reveal_personal_emails": true,
48
+ "details": [
49
+ {
50
+ "name": "#{name}",
51
+ "organization_name": "#{company}"
52
+ }
53
+ ]
54
+ }' "https://api.apollo.io/api/v1/people/bulk_match"`
55
+ j = JSON.parse(ret)
56
+ raise "Error: #{j['error_message']}" if j['error_message']
57
+ raise "Error: #{j['error_code']}" if j['error_code']
58
+ match = j['matches'].first
59
+ return nil if match.nil?
60
+ match['email']
61
+ end # def find_person_from_name_and_company
62
+
63
+ # Retrieve the email of a person from his name and company.
64
+ #
65
+ # Reference: https://apolloio.github.io/apollo-api-docs/?shell#enrichment-api
66
+ #
67
+ #
68
+ def find_person_from_name_and_domain(name:, domain:)
69
+ raise 'Error: apollo_apikey or findymail_apikey are required for find_person_from_linkedin_url operation.' if @apollo_apikey.nil? && @findymail_apikey.nil?
70
+
71
+ if @findymail_apikey
72
+ ret = `curl --request POST \
73
+ "https://app.findymail.com/api/search/name" \
74
+ --header "Authorization: Bearer #{@findymail_apikey}" \
75
+ --header "Content-Type: application/json" \
76
+ --header "Accept: application/json" \
77
+ --data "{
78
+ \\"name\\": \\"#{name}\\",
79
+ \\"domain\\": \\"#{domain}\\"
80
+ }"`
81
+ j = JSON.parse(ret)
82
+ raise "Error: #{j['error']}" if j['error']
83
+ return nil if j['contact'].nil?
84
+ return j['contact']['email']
85
+ elsif @apollo_apikey
86
+ ret = `curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
87
+ "api_key": "#{@apollo_apikey}",
88
+ "reveal_personal_emails": true,
89
+ "details": [
90
+ {
91
+ "name": "#{name}",
92
+ "domain": "#{domain}"
93
+ }
94
+ ]
95
+ }' "https://api.apollo.io/api/v1/people/bulk_match"`
96
+ j = JSON.parse(ret)
97
+ raise "Error: #{j['error_message']}" if j['error_message']
98
+ raise "Error: #{j['error_code']}" if j['error_code']
99
+ match = j['matches'].first
100
+ return nil if match.nil?
101
+ return match['email']
102
+ end
103
+ end # def find_person_from_name_and_website
104
+
105
+ end # class Enrichment
106
+ end # module BlackStack
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blackstack-enrichment
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Leandro Daniel Sardi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-03-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.6.3
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.6.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 2.6.3
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.6.3
33
+ description: Ruby library for connecting some enrichment services like Apillo or FindyMail.
34
+ email: leandro@connectionsphere.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - blackstack-enrichment.gemspec
40
+ - lib/blackstack-enrichment.rb
41
+ homepage: https://github.com/leandrosardi/blackstack-enrichment
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubygems_version: 3.3.7
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Ruby library for connecting some enrichment services like Apillo or FindyMail.
64
+ test_files: []