blackstack-enrichment 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1adb325c2208f76b6784af820b5045710678ace1b651e4bd9f7a6fcdb5db981
4
- data.tar.gz: eb0455821bce876a0f6000147d5ca4a9987b2737ccd19684f57eb849368402e8
3
+ metadata.gz: 480a8f9e861397f1185da6959032036559c0df712b53627e5b52b907b81fd5ae
4
+ data.tar.gz: 73b28d0ee030c0b901ea0f8cf6893b64e146b6efa98b05c6e2a92bcc9fd81ad5
5
5
  SHA512:
6
- metadata.gz: e80809e301cd4211e5de508ab54aefb7e8363a995e181686d9dff7d8ab7983201bb36056eb3192b5be29cf6d6182794b769f1748703a47f1d743b389e48a8f4a
7
- data.tar.gz: 8a39e8e4b28ab8876c832aff9872b9af38ad80f3c5a1db9e88c3838b930361bc0d5805d857d811fd38711f58148db31325aa10c9e9edfa50c48acf1a77c4d6a8
6
+ metadata.gz: c6b4bfa7a069362a8cd4370e099855892a48fd46f62ca33d5ed773dd01cc09ef4ba4bc62e6bae6b6fff3cad181b36a0ace2dd8e731ffb65e982c6396f19f779a
7
+ data.tar.gz: 3f329e4cb00303d911d8724df8b002cab015c70d2119594d50744e6c29a4f4a0b60451be2e2323c8325289261ee65e4ec349b797ae5d129a5cd21518e5b02a95
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'blackstack-enrichment'
3
- s.version = '1.0.1'
4
- s.date = '2024-03-19'
3
+ s.version = '1.0.3'
4
+ s.date = '2024-04-22'
5
5
  s.summary = "Ruby library for connecting some enrichment services like Apillo or FindyMail."
6
6
  s.description = "Ruby library for connecting some enrichment services like Apillo or FindyMail."
7
7
  s.authors = ["Leandro Daniel Sardi"]
@@ -29,6 +29,7 @@ module BlackStack
29
29
  j = JSON.parse(ret)
30
30
  raise "Error: #{j['error_message']}" if j['error_message']
31
31
  raise "Error: #{j['error_code']}" if j['error_code']
32
+ raise "Error: #{j['error']}" if j['error']
32
33
  match = j['matches'].first
33
34
  return nil if match.nil?
34
35
  match['email']
@@ -40,7 +41,7 @@ module BlackStack
40
41
  #
41
42
  #
42
43
  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
+ raise 'Error: apollo_apikey is required for find_person_from_name_and_company operation.' if @apollo_apikey.nil?
44
45
 
45
46
  ret = `curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
46
47
  "api_key": "#{@apollo_apikey}",
@@ -55,6 +56,7 @@ module BlackStack
55
56
  j = JSON.parse(ret)
56
57
  raise "Error: #{j['error_message']}" if j['error_message']
57
58
  raise "Error: #{j['error_code']}" if j['error_code']
59
+ raise "Error: #{j['error']}" if j['error']
58
60
  match = j['matches'].first
59
61
  return nil if match.nil?
60
62
  match['email']
@@ -66,7 +68,7 @@ module BlackStack
66
68
  #
67
69
  #
68
70
  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?
71
+ raise 'Error: apollo_apikey or findymail_apikey are required for find_person_from_name_and_domain operation.' if @apollo_apikey.nil? && @findymail_apikey.nil?
70
72
 
71
73
  if @findymail_apikey
72
74
  ret = `curl --request POST \
@@ -96,11 +98,88 @@ module BlackStack
96
98
  j = JSON.parse(ret)
97
99
  raise "Error: #{j['error_message']}" if j['error_message']
98
100
  raise "Error: #{j['error_code']}" if j['error_code']
101
+ raise "Error: #{j['error']}" if j['error']
99
102
  match = j['matches'].first
100
103
  return nil if match.nil?
101
104
  return match['email']
102
105
  end
103
- end # def find_person_from_name_and_website
106
+ end # def find_person_from_name_and_domain
107
+
108
+ # Retrieve the name, job position and email of a person from a list of allowed titles and company domain.
109
+ #
110
+ # Reference: https://apolloio.github.io/apollo-api-docs/?shell#people-api
111
+ #
112
+ #
113
+ def find_persons_from_title_and_domain(titles:, domain:, limit: 1, calls_delay: 1)
114
+ raise 'Error: apollo_apikey is required for find_persons_from_title_and_domain operation.' if @apollo_apikey.nil?
115
+ b = []
116
+
117
+ # search leads
118
+ s = "curl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{
119
+ \"api_key\": \"#{@apollo_apikey}\",
120
+ \"page\" : 1,
121
+ \"per_page\": #{limit.to_s},
122
+ \"person_titles\": [\"#{titles.join('", "')}\"],
123
+ \"q_organization_domains\": \"#{domain}\",
124
+ \"contact_email_status\": [\"verified\"]
125
+ }' \"https://api.apollo.io/v1/mixed_people/search\""
126
+ ret = `#{s}`
127
+ j = JSON.parse(ret)
128
+
129
+ raise "Error: #{j['error_message']}" if j['error_message']
130
+ raise "Error: #{j['error_message']}" if j['error_message']
131
+ raise "Error: #{j['error']}" if j['error']
132
+
133
+ a = j['people']
134
+ return ret if a.nil?
135
+
136
+ a.each { |h|
137
+ # add delay to don't oberload the API
138
+ sleep calls_delay
139
+
140
+ i = {}
141
+ i['id'] = h['id']
142
+ i['first_name'] = h['first_name']
143
+ i['last_name'] = h['last_name']
144
+ i['title'] = h['title']
145
+ i['linkedin_url'] = h['linkedin_url']
146
+ i['facebook_url'] = h['facebook_url']
147
+
148
+ # find the email of the lead
149
+ s = "curl -X POST -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" -d '{
150
+ \"api_key\": \"#{@apollo_apikey}\",
151
+ \"reveal_personal_emails\": true,
152
+ \"id\": \"#{i['id']}\"
153
+ }' \"https://api.apollo.io/v1/people/match\""
154
+ ret = `#{s}`
155
+ j = JSON.parse(ret)
156
+
157
+ raise "Error: #{j['error_message']}" if j['error_message']
158
+ raise "Error: #{j['error_code']}" if j['error_code']
159
+ raise "Error: #{j['error']}" if j['error']
160
+
161
+ next if j['person'].nil?
162
+ k = j['person'] if j['person']
163
+
164
+ # append emails and phone numbers to the hash
165
+ i['emails'] = []
166
+ i['emails'] << k['email'] if k['email']
167
+ i['emails'] += k['personal_emails'] if k['personal_emails']
168
+
169
+ i['phone_numbers'] = []
170
+ i['phone_numbers'] = k['phone_numbers'].map { |o| {
171
+ 'value' => o['raw_number'],
172
+ 'type' => o['type']
173
+ } } if k['phone_numbers']
174
+
175
+ i['raw'] = k
176
+
177
+ b << i
178
+ }
179
+
180
+ # return
181
+ b
182
+ end # def find_persons_from_title_and_domain
104
183
 
105
184
  end # class Enrichment
106
185
  end # module BlackStack
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blackstack-enrichment
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
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: 2024-03-19 00:00:00.000000000 Z
11
+ date: 2024-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json