blackstack-enrichment 1.0.2 → 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: d8ec86e0997ec73aab38e8d887c98416ee41dcf241ada80b4a6441a4a391186a
4
- data.tar.gz: ebe656db65707a761502b7da63983b19a4675a7f692be0eed55d41d436e905e8
3
+ metadata.gz: 480a8f9e861397f1185da6959032036559c0df712b53627e5b52b907b81fd5ae
4
+ data.tar.gz: 73b28d0ee030c0b901ea0f8cf6893b64e146b6efa98b05c6e2a92bcc9fd81ad5
5
5
  SHA512:
6
- metadata.gz: 76987b586a286438a004c5474c546e1a90c4cf725d3142499d2b84be5e3efe64452b381f70f2e82b5a1abee9f7515fcc54dcc749565df3fd54457cd2b85b3310
7
- data.tar.gz: 85add5a58fada7899a4190defbd2702968ee680fff8f9c47fcee17199c7aaa204bff8c778b9b603c943f1326821badb082f9309e1725fbd770751efa9f444e8e
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.2'
4
- s.date = '2024-04-06'
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"]
@@ -27,9 +27,9 @@ module BlackStack
27
27
  ]
28
28
  }' "https://api.apollo.io/api/v1/people/bulk_match"`
29
29
  j = JSON.parse(ret)
30
- raise "Error: #{j['error']}" if j['error']
31
30
  raise "Error: #{j['error_message']}" if j['error_message']
32
31
  raise "Error: #{j['error_code']}" if j['error_code']
32
+ raise "Error: #{j['error']}" if j['error']
33
33
  match = j['matches'].first
34
34
  return nil if match.nil?
35
35
  match['email']
@@ -41,7 +41,7 @@ module BlackStack
41
41
  #
42
42
  #
43
43
  def find_person_from_name_and_company(name:, company:)
44
- 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?
45
45
 
46
46
  ret = `curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
47
47
  "api_key": "#{@apollo_apikey}",
@@ -56,6 +56,7 @@ module BlackStack
56
56
  j = JSON.parse(ret)
57
57
  raise "Error: #{j['error_message']}" if j['error_message']
58
58
  raise "Error: #{j['error_code']}" if j['error_code']
59
+ raise "Error: #{j['error']}" if j['error']
59
60
  match = j['matches'].first
60
61
  return nil if match.nil?
61
62
  match['email']
@@ -67,7 +68,7 @@ module BlackStack
67
68
  #
68
69
  #
69
70
  def find_person_from_name_and_domain(name:, domain:)
70
- 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?
71
72
 
72
73
  if @findymail_apikey
73
74
  ret = `curl --request POST \
@@ -97,11 +98,88 @@ module BlackStack
97
98
  j = JSON.parse(ret)
98
99
  raise "Error: #{j['error_message']}" if j['error_message']
99
100
  raise "Error: #{j['error_code']}" if j['error_code']
101
+ raise "Error: #{j['error']}" if j['error']
100
102
  match = j['matches'].first
101
103
  return nil if match.nil?
102
104
  return match['email']
103
105
  end
104
- 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
105
183
 
106
184
  end # class Enrichment
107
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.2
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-04-06 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