snov 0.3.2 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.byebug_history +5 -0
- data/.rubocop.yml +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +11 -0
- data/README.md +62 -0
- data/lib/snov.rb +3 -0
- data/lib/snov/add_names_to_find_emails.rb +30 -0
- data/lib/snov/client.rb +11 -1
- data/lib/snov/fake_client.rb +1 -1
- data/lib/snov/get_emails_by_social_url.rb +77 -0
- data/lib/snov/get_emails_from_name.rb +68 -0
- data/lib/snov/version.rb +1 -1
- data/snov.gemspec +4 -4
- metadata +14 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 942f3fb545fbe8a8041a2d892389fc14de9360b6c91ad95251586804f1916e9d
|
4
|
+
data.tar.gz: 887f90562027a901cd089bf5e07ed8e1422d8b33d85354f7641a48aff9b3ce7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecdd288293ddd69ba979ec8d727a4393fa895a47f6efd3716f6ffc5db57ab7b5f83ddc0654553f0df6009fbc52e386f78017f2f4112a60f0c81174be7753ac24
|
7
|
+
data.tar.gz: 69bed1aab8e18db671c1db1a535cac8a83a2fea497d3ab6e0b1c4561c02e47b3e186b7d23e8e30cb7602d62ea0e8c2cf8d6edb591f04bf267a6eafae97afa252
|
data/.byebug_history
ADDED
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
* add OutOfCreditsError
|
2
|
+
|
3
|
+
## [0.5.0]
|
4
|
+
* support for https://snov.io/api#EmailFinder (GetEmailsFromName)
|
5
|
+
|
6
|
+
## [0.4.1]
|
7
|
+
* allow forward slash for test response files while using fake client
|
8
|
+
|
9
|
+
## [0.4.0]
|
10
|
+
* search prospect emails with /v1/get-emails-from-url
|
11
|
+
|
1
12
|
## [0.3.2]
|
2
13
|
* increase snov timeout to 90 seconds
|
3
14
|
## [0.3.1]
|
data/README.md
CHANGED
@@ -148,6 +148,68 @@ see https://snov.io/api#ViewProspectsInList
|
|
148
148
|
end
|
149
149
|
```
|
150
150
|
|
151
|
+
### GetEmailsBySocialUrl
|
152
|
+
|
153
|
+
convenience wrapper for `GetEmailsFromUrl` to get a prospect with social url e.g. linkedin profile url
|
154
|
+
|
155
|
+
see https://snov.io/api#GetEmailsFromUrl
|
156
|
+
|
157
|
+
```ruby
|
158
|
+
prospect = Snov::GetEmailsBySocialUrl.new(url: "https://www.linkedin.com/in/john-doe-123456/").prospect
|
159
|
+
|
160
|
+
prospect.data.emails.each do |value|
|
161
|
+
puts value.email
|
162
|
+
puts value.status
|
163
|
+
end
|
164
|
+
|
165
|
+
prospect.data.previous_jobs.each do |value|
|
166
|
+
puts value.company_name
|
167
|
+
puts value.company_type
|
168
|
+
puts value.position
|
169
|
+
puts value.country
|
170
|
+
puts value.start_date
|
171
|
+
puts value.industry
|
172
|
+
puts value.size
|
173
|
+
end
|
174
|
+
|
175
|
+
prospect.data.current_jobs.each do |value|
|
176
|
+
puts value.company_name
|
177
|
+
puts value.company_type
|
178
|
+
puts value.position
|
179
|
+
puts value.country
|
180
|
+
puts value.start_date
|
181
|
+
puts value.industry
|
182
|
+
puts value.size
|
183
|
+
end
|
184
|
+
```
|
185
|
+
|
186
|
+
### GetEmailsFromName
|
187
|
+
|
188
|
+
convenience wrapper for `GetEmailsFromName` to get a prospect with name
|
189
|
+
|
190
|
+
see https://snov.io/api#EmailFinder
|
191
|
+
|
192
|
+
```ruby
|
193
|
+
prospect = Snov::GetEmailsFromName.new(first_name: "gavin", last_name: "vanrooyen", domain: "octagon.com").prospect
|
194
|
+
|
195
|
+
prospect.data.emails.each do |value|
|
196
|
+
puts value.email
|
197
|
+
puts value.email_status
|
198
|
+
end
|
199
|
+
```
|
200
|
+
|
201
|
+
### AddNamesToFindEmails
|
202
|
+
|
203
|
+
convenience wrapper for `AddNamesToFindEmails` to add a prospect with name
|
204
|
+
|
205
|
+
see https://snov.io/api#AddNamestoFindEmails
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
added_name = Snov::AddNamesToFindEmails.new(first_name: "gavin", last_name: "vanrooyen", domain: "octagon.com").add
|
209
|
+
|
210
|
+
puts added_name.sent # true added to snov queue for searching
|
211
|
+
puts added_name.success
|
212
|
+
```
|
151
213
|
|
152
214
|
## Development
|
153
215
|
|
data/lib/snov.rb
CHANGED
@@ -24,4 +24,7 @@ require 'snov/get_all_prospects_from_list'
|
|
24
24
|
require 'snov/get_prospects_by_email'
|
25
25
|
require 'snov/get_prospect_list'
|
26
26
|
require 'snov/get_user_lists'
|
27
|
+
require 'snov/get_emails_by_social_url'
|
28
|
+
require 'snov/get_emails_from_name'
|
29
|
+
require 'snov/add_names_to_find_emails'
|
27
30
|
require 'snov/domain_search'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Snov
|
2
|
+
class AddNamesToFindEmails
|
3
|
+
attr_reader :client
|
4
|
+
|
5
|
+
def initialize(client: Snov.client, first_name:, last_name:, domain:)
|
6
|
+
@client = client
|
7
|
+
@first_name = first_name
|
8
|
+
@last_name = last_name
|
9
|
+
@domain = domain
|
10
|
+
end
|
11
|
+
|
12
|
+
def add
|
13
|
+
@add ||= ProspectResult.new(raw_result)
|
14
|
+
end
|
15
|
+
|
16
|
+
def raw_result
|
17
|
+
@raw_result ||= client.post("/v1/add-names-to-find-emails",
|
18
|
+
"firstName" => @first_name,
|
19
|
+
"lastName" => @last_name,
|
20
|
+
"domain" => @domain)
|
21
|
+
.deep_transform_keys! { |key| key.underscore }
|
22
|
+
end
|
23
|
+
|
24
|
+
class ProspectResult
|
25
|
+
include ActiveModel::Model
|
26
|
+
|
27
|
+
attr_accessor :success, :first_name, :last_name, :domain, :user_id, :sent, :access_token
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/snov/client.rb
CHANGED
@@ -22,6 +22,8 @@ module Snov
|
|
22
22
|
|
23
23
|
class BadGatewayError < ResponseError; end
|
24
24
|
|
25
|
+
class OutOfCreditsError < BadGatewayError; end
|
26
|
+
|
25
27
|
class ForbiddenError < ResponseError; end
|
26
28
|
|
27
29
|
class GatewayTimeOut < ResponseError; end
|
@@ -33,6 +35,14 @@ module Snov
|
|
33
35
|
ERROR_CLASSES = { 401 => UnauthorizedError, 502 => BadGatewayError, 403 => ForbiddenError,
|
34
36
|
504 => GatewayTimeOut, 400 => BadRequest, 405 => MethodNotAllowed }
|
35
37
|
|
38
|
+
def self.select_error_class(resp, fallback: ResponseError)
|
39
|
+
if resp&.body.to_s.include?('you ran out of credits')
|
40
|
+
OutOfCreditsError
|
41
|
+
else
|
42
|
+
ERROR_CLASSES.fetch(resp.status, fallback)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
36
46
|
def initialize(client_id:, client_secret:, access_token: nil, timeout_seconds: 90)
|
37
47
|
self.client_id = client_id.to_str
|
38
48
|
self.client_secret = client_secret.to_str
|
@@ -66,7 +76,7 @@ module Snov
|
|
66
76
|
|
67
77
|
def parse_response(resp, path, _params)
|
68
78
|
unless resp.success?
|
69
|
-
error_class =
|
79
|
+
error_class = Client.select_error_class(resp, fallback: ResponseError)
|
70
80
|
raise error_class.new("#{path} (#{resp.status})", response: resp&.body)
|
71
81
|
end
|
72
82
|
MultiJson.load(resp.body)
|
data/lib/snov/fake_client.rb
CHANGED
@@ -46,7 +46,7 @@ module Snov
|
|
46
46
|
def filename(method, path, payload_hash)
|
47
47
|
add = payload_hash.to_a.map { |v| v.join("=") }.join("&").tr(".", "_")
|
48
48
|
add = "default" if add == ""
|
49
|
-
"#{self.class.folder}/#{method}#{path.tr("/", "_")}/#{add}.json"
|
49
|
+
"#{self.class.folder}/#{method}#{path.tr("/", "_")}/#{add.gsub('/', '-')}.json"
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Snov
|
2
|
+
class GetEmailsBySocialUrl
|
3
|
+
attr_reader :client
|
4
|
+
|
5
|
+
def initialize(client: Snov.client, url:)
|
6
|
+
@client = client
|
7
|
+
@url = url
|
8
|
+
end
|
9
|
+
|
10
|
+
def prospect
|
11
|
+
@prospect ||= ProspectResult.new(raw_result)
|
12
|
+
end
|
13
|
+
|
14
|
+
def raw_result
|
15
|
+
@raw_result ||= client.post("/v1/get-emails-from-url", "url" => @url)
|
16
|
+
.deep_transform_keys! { |key| key.underscore }
|
17
|
+
end
|
18
|
+
|
19
|
+
class ProspectJob
|
20
|
+
include ActiveModel::Model
|
21
|
+
|
22
|
+
attr_accessor :company_name, :company_type, :position, :social_link, :site, :locality, :state,
|
23
|
+
:city, :street, :street2, :country, :start_date, :end_date, :postal, :founded, :size,
|
24
|
+
:industry
|
25
|
+
end
|
26
|
+
|
27
|
+
class ProspectJobList
|
28
|
+
include ActiveModel::Model
|
29
|
+
include Enumerable
|
30
|
+
|
31
|
+
attr_accessor :jobs
|
32
|
+
|
33
|
+
def each(&block)
|
34
|
+
jobs.each(&block)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class ProspectEmail
|
39
|
+
include ActiveModel::Model
|
40
|
+
|
41
|
+
attr_accessor :email, :status
|
42
|
+
end
|
43
|
+
|
44
|
+
class ProspectData
|
45
|
+
include ActiveModel::Model
|
46
|
+
|
47
|
+
attr_reader :emails, :previous_jobs, :current_jobs
|
48
|
+
attr_accessor :id, :name, :first_name, :last_name, :source_page, :source, :industry,
|
49
|
+
:country, :locality, :last_update_date, :social, :skills, :links
|
50
|
+
|
51
|
+
def emails=(val)
|
52
|
+
@emails = Array.wrap(val).map do |rel|
|
53
|
+
ProspectEmail.new(rel)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def previous_job=(val)
|
58
|
+
@previous_jobs = ProspectJobList.new(jobs: Array.wrap(val).map { |job| ProspectJob.new(job) })
|
59
|
+
end
|
60
|
+
|
61
|
+
def current_job=(val)
|
62
|
+
@current_jobs = ProspectJobList.new(jobs: Array.wrap(val).map { |job| ProspectJob.new(job) })
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class ProspectResult
|
67
|
+
include ActiveModel::Model
|
68
|
+
|
69
|
+
attr_accessor :success, :message
|
70
|
+
attr_reader :data
|
71
|
+
|
72
|
+
def data=(val)
|
73
|
+
@data = ProspectData.new(val)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Snov
|
2
|
+
class GetEmailsFromName
|
3
|
+
attr_reader :client
|
4
|
+
|
5
|
+
def initialize(client: Snov.client, first_name:, last_name:, domain:)
|
6
|
+
@client = client
|
7
|
+
@first_name = first_name
|
8
|
+
@last_name = last_name
|
9
|
+
@domain = domain
|
10
|
+
end
|
11
|
+
|
12
|
+
def prospect
|
13
|
+
@prospect ||= ProspectResult.new(raw_result)
|
14
|
+
end
|
15
|
+
|
16
|
+
def raw_result
|
17
|
+
@raw_result ||= client.post("/v1/get-emails-from-names",
|
18
|
+
"firstName" => @first_name,
|
19
|
+
"lastName" => @last_name,
|
20
|
+
"domain" => @domain)
|
21
|
+
.deep_transform_keys! { |key| key.underscore }
|
22
|
+
end
|
23
|
+
|
24
|
+
class ProspectData
|
25
|
+
include ActiveModel::Model
|
26
|
+
|
27
|
+
attr_accessor :first_name, :last_name
|
28
|
+
attr_reader :emails
|
29
|
+
|
30
|
+
def emails=(val)
|
31
|
+
@emails = Array.wrap(val).map do |rel|
|
32
|
+
ProspectEmail.new(rel)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class ProspectEmail
|
38
|
+
include ActiveModel::Model
|
39
|
+
|
40
|
+
attr_accessor :email, :email_status
|
41
|
+
end
|
42
|
+
|
43
|
+
class ProspectStatus
|
44
|
+
include ActiveModel::Model
|
45
|
+
|
46
|
+
attr_accessor :identifier, :description
|
47
|
+
|
48
|
+
def completed?
|
49
|
+
identifier == 'complete'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class ProspectResult
|
54
|
+
include ActiveModel::Model
|
55
|
+
|
56
|
+
attr_accessor :success, :message, :params
|
57
|
+
attr_reader :data, :status
|
58
|
+
|
59
|
+
def data=(val)
|
60
|
+
@data = ProspectData.new(val)
|
61
|
+
end
|
62
|
+
|
63
|
+
def status=(val)
|
64
|
+
@status = ProspectStatus.new(val)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/snov/version.rb
CHANGED
data/snov.gemspec
CHANGED
@@ -3,18 +3,18 @@ require_relative 'lib/snov/version'
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "snov"
|
5
5
|
spec.version = Snov::VERSION
|
6
|
-
spec.authors = ["Grant Petersen-Speelman"]
|
7
|
-
spec.email = ["grantspeelman@gmail.com"]
|
6
|
+
spec.authors = ["Grant Petersen-Speelman", "Bapu Sethi"]
|
7
|
+
spec.email = ["grantspeelman@gmail.com", "bapu.sethi.03@gmail.com"]
|
8
8
|
spec.license = "MIT"
|
9
9
|
|
10
10
|
spec.summary = %q{Snov client to interact with snov api}
|
11
11
|
spec.description = %q{Snov client to interact with snov api}
|
12
12
|
spec.homepage = "https://github.com/NEXL-LTS/snov-ruby"
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
14
14
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
16
16
|
spec.metadata["source_code_uri"] = "https://github.com/NEXL-LTS/snov-ruby"
|
17
|
-
spec.metadata["changelog_uri"] = "https://github.com/NEXL-LTS/snov-ruby/CHANGELOG.md"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/NEXL-LTS/snov-ruby/blob/main/CHANGELOG.md"
|
18
18
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grant Petersen-Speelman
|
8
|
-
|
8
|
+
- Bapu Sethi
|
9
|
+
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2021-
|
12
|
+
date: 2021-06-23 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: activemodel
|
@@ -113,10 +114,12 @@ dependencies:
|
|
113
114
|
description: Snov client to interact with snov api
|
114
115
|
email:
|
115
116
|
- grantspeelman@gmail.com
|
117
|
+
- bapu.sethi.03@gmail.com
|
116
118
|
executables: []
|
117
119
|
extensions: []
|
118
120
|
extra_rdoc_files: []
|
119
121
|
files:
|
122
|
+
- ".byebug_history"
|
120
123
|
- ".gitignore"
|
121
124
|
- ".rspec"
|
122
125
|
- ".rubocop.yml"
|
@@ -131,6 +134,7 @@ files:
|
|
131
134
|
- bin/setup
|
132
135
|
- gems.rb
|
133
136
|
- lib/snov.rb
|
137
|
+
- lib/snov/add_names_to_find_emails.rb
|
134
138
|
- lib/snov/client.rb
|
135
139
|
- lib/snov/domain_search.rb
|
136
140
|
- lib/snov/fake_client.rb
|
@@ -145,6 +149,8 @@ files:
|
|
145
149
|
- lib/snov/fake_client/post_v1_prospect-list/listId=1505383&page=1&perPage=100.json
|
146
150
|
- lib/snov/fake_client/post_v1_prospect-list/listId=1818597&page=1&perPage=100.json
|
147
151
|
- lib/snov/get_all_prospects_from_list.rb
|
152
|
+
- lib/snov/get_emails_by_social_url.rb
|
153
|
+
- lib/snov/get_emails_from_name.rb
|
148
154
|
- lib/snov/get_profile_by_email.rb
|
149
155
|
- lib/snov/get_prospect_list.rb
|
150
156
|
- lib/snov/get_prospects_by_email.rb
|
@@ -158,8 +164,8 @@ licenses:
|
|
158
164
|
metadata:
|
159
165
|
homepage_uri: https://github.com/NEXL-LTS/snov-ruby
|
160
166
|
source_code_uri: https://github.com/NEXL-LTS/snov-ruby
|
161
|
-
changelog_uri: https://github.com/NEXL-LTS/snov-ruby/CHANGELOG.md
|
162
|
-
post_install_message:
|
167
|
+
changelog_uri: https://github.com/NEXL-LTS/snov-ruby/blob/main/CHANGELOG.md
|
168
|
+
post_install_message:
|
163
169
|
rdoc_options: []
|
164
170
|
require_paths:
|
165
171
|
- lib
|
@@ -167,15 +173,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
167
173
|
requirements:
|
168
174
|
- - ">="
|
169
175
|
- !ruby/object:Gem::Version
|
170
|
-
version: 2.
|
176
|
+
version: 2.5.0
|
171
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
178
|
requirements:
|
173
179
|
- - ">="
|
174
180
|
- !ruby/object:Gem::Version
|
175
181
|
version: '0'
|
176
182
|
requirements: []
|
177
|
-
rubygems_version: 3.
|
178
|
-
signing_key:
|
183
|
+
rubygems_version: 3.2.15
|
184
|
+
signing_key:
|
179
185
|
specification_version: 4
|
180
186
|
summary: Snov client to interact with snov api
|
181
187
|
test_files: []
|