clearbit 0.2.7 → 0.3.3

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.
@@ -1,6 +1,7 @@
1
1
  module Clearbit
2
2
  module Enrichment extend self
3
3
  autoload :Company, 'clearbit/enrichment/company'
4
+ autoload :News, 'clearbit/enrichment/news'
4
5
  autoload :Person, 'clearbit/enrichment/person'
5
6
  autoload :PersonCompany, 'clearbit/enrichment/person_company'
6
7
 
@@ -0,0 +1,18 @@
1
+ module Clearbit
2
+ module Enrichment
3
+ class News < Base
4
+ endpoint 'https://company.clearbit.com'
5
+ path '/v1/news'
6
+
7
+ def self.articles(values)
8
+ if values.key?(:domain)
9
+ response = get(uri(:articles), values)
10
+ else
11
+ raise ArgumentError, 'Invalid values'
12
+ end
13
+
14
+ new(response)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ module Clearbit
2
+ class NameDomain < Base
3
+ endpoint 'https://company.clearbit.com'
4
+ path '/v1/domains'
5
+
6
+ def self.find(values)
7
+ response = get(uri(:find), values)
8
+ Mash.new(response.decoded)
9
+ rescue Nestful::ResourceNotFound
10
+ end
11
+
12
+ class << self
13
+ alias_method :[], :find
14
+ end
15
+ end
16
+ end
17
+
@@ -4,7 +4,7 @@ module Clearbit
4
4
  path '/v1'
5
5
 
6
6
  def self.calculate(values = {})
7
- self.new get('calculate', values)
7
+ self.new post('calculate', values)
8
8
  end
9
9
 
10
10
  def self.confirmed(values = {})
@@ -1,3 +1,3 @@
1
1
  module Clearbit
2
- VERSION = '0.2.7'
2
+ VERSION = '0.3.3'
3
3
  end
@@ -23,7 +23,9 @@ module Clearbit
23
23
  end
24
24
 
25
25
  def self.generate_signature(key, body)
26
- 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), key, body)
26
+ signed_body = body
27
+ signed_body = JSON.dump(signed_body) unless signed_body.is_a?(String)
28
+ 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), key, signed_body)
27
29
  end
28
30
 
29
31
  def initialize(env, key = nil)
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+ require 'base64'
3
+
4
+ describe Clearbit::Analytics do
5
+ before do |example|
6
+ Clearbit.key = 'clearbit_key'
7
+ end
8
+
9
+ describe '#identify' do
10
+ it 'sends an identify request to Clearbit X' do
11
+ basic_auth = Base64.encode64('clearbit_key:').strip
12
+ x_stub = stub_request(:post, 'https://x.clearbit.com/v1/import').
13
+ with(
14
+ headers: { 'Authorization' => "Basic #{basic_auth}" }
15
+ ).to_return(status: 200, body: {success: true}.to_json)
16
+
17
+ Clearbit::Analytics.identify(
18
+ user_id: '123',
19
+ traits: {
20
+ email: 'david@clearbit.com',
21
+ },
22
+ )
23
+
24
+ expect(x_stub).to have_been_requested
25
+ end
26
+ end
27
+
28
+ describe '#page' do
29
+ it 'sends an identify request to Clearbit X' do
30
+ basic_auth = Base64.encode64('clearbit_key:').strip
31
+ x_stub = stub_request(:post, 'https://x.clearbit.com/v1/import').
32
+ with(
33
+ headers: { 'Authorization' => "Basic #{basic_auth}" }
34
+ ).to_return(status: 200, body: {success: true}.to_json)
35
+
36
+ Clearbit::Analytics.page(
37
+ user_id: '123',
38
+ traits: {
39
+ email: 'david@clearbit.com',
40
+ },
41
+ )
42
+
43
+ expect(x_stub).to have_been_requested
44
+ end
45
+ end
46
+
47
+ describe '#group' do
48
+ it 'sends an identify request to Clearbit X' do
49
+ basic_auth = Base64.encode64('clearbit_key:').strip
50
+ x_stub = stub_request(:post, 'https://x.clearbit.com/v1/import').
51
+ with(
52
+ headers: { 'Authorization' => "Basic #{basic_auth}" }
53
+ ).to_return(status: 200, body: {success: true}.to_json)
54
+
55
+ Clearbit::Analytics.group(
56
+ user_id: '123',
57
+ group_id: '123',
58
+ traits: {
59
+ domain: 'clearbit.com',
60
+ },
61
+ )
62
+
63
+ expect(x_stub).to have_been_requested
64
+ end
65
+ end
66
+ end
@@ -6,8 +6,8 @@ describe Clearbit::Prospector do
6
6
  end
7
7
 
8
8
  context 'Prospector API' do
9
- it 'should call out to the Prospector API' do
10
- body = []
9
+ it 'calls the Prospector API' do
10
+ body = { page: 1, page_size: 5, total: 723, results: [] }
11
11
 
12
12
  stub_request(:get, "https://prospector.clearbit.com/v1/people/search?domain=stripe.com").
13
13
  with(:headers => {'Authorization'=>'Bearer clearbit_key'}).
@@ -15,5 +15,15 @@ describe Clearbit::Prospector do
15
15
 
16
16
  Clearbit::Prospector.search(domain: 'stripe.com')
17
17
  end
18
+
19
+ it 'can page through records' do
20
+ body = { page: 2, page_size: 10, total: 12, results: [] }
21
+
22
+ stub_request(:get, "https://prospector.clearbit.com/v1/people/search?domain=stripe.com&page=2&page_size=10").
23
+ with(:headers => {'Authorization'=>'Bearer clearbit_key'}).
24
+ to_return(:status => 200, :body => body.to_json, headers: {'Content-Type' => 'application/json'})
25
+
26
+ Clearbit::Prospector.search(domain: 'stripe.com', page: 2, page_size: 10)
27
+ end
18
28
  end
19
29
  end
@@ -2,7 +2,9 @@ module Spec
2
2
  module Support
3
3
  module Helpers
4
4
  def generate_signature(clearbit_key, webhook_body)
5
- 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), clearbit_key, webhook_body)
5
+ signed_body = webhook_body
6
+ signed_body = JSON.dump(signed_body) unless signed_body.is_a?(String)
7
+ 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), clearbit_key, signed_body)
6
8
  end
7
9
  end
8
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clearbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex MacCaw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-22 00:00:00.000000000 Z
11
+ date: 2020-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,8 +129,10 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - ".github/CODEOWNERS"
132
133
  - ".gitignore"
133
134
  - Gemfile
135
+ - LICENSE
134
136
  - README.md
135
137
  - Rakefile
136
138
  - clearbit.gemspec
@@ -138,21 +140,41 @@ files:
138
140
  - examples/discovery.rb
139
141
  - examples/enrichment.rb
140
142
  - examples/logo.rb
143
+ - examples/name_domain.rb
141
144
  - examples/person.rb
142
145
  - examples/prospector.rb
146
+ - examples/reveal.rb
147
+ - examples/risk.rb
148
+ - examples/risk_flag.rb
143
149
  - examples/version.rb
144
150
  - examples/watchlist.rb
145
151
  - lib/clearbit.rb
152
+ - lib/clearbit/analytics.rb
153
+ - lib/clearbit/analytics/LICENSE
154
+ - lib/clearbit/analytics/README.md
155
+ - lib/clearbit/analytics/backoff_policy.rb
156
+ - lib/clearbit/analytics/client.rb
157
+ - lib/clearbit/analytics/defaults.rb
158
+ - lib/clearbit/analytics/field_parser.rb
159
+ - lib/clearbit/analytics/logging.rb
160
+ - lib/clearbit/analytics/message_batch.rb
161
+ - lib/clearbit/analytics/request.rb
162
+ - lib/clearbit/analytics/response.rb
163
+ - lib/clearbit/analytics/utils.rb
164
+ - lib/clearbit/analytics/worker.rb
165
+ - lib/clearbit/audiences.rb
146
166
  - lib/clearbit/autocomplete.rb
147
167
  - lib/clearbit/base.rb
148
168
  - lib/clearbit/discovery.rb
149
169
  - lib/clearbit/enrichment.rb
150
170
  - lib/clearbit/enrichment/company.rb
171
+ - lib/clearbit/enrichment/news.rb
151
172
  - lib/clearbit/enrichment/person.rb
152
173
  - lib/clearbit/enrichment/person_company.rb
153
174
  - lib/clearbit/errors/invalid_webhook_signature.rb
154
175
  - lib/clearbit/logo.rb
155
176
  - lib/clearbit/mash.rb
177
+ - lib/clearbit/name_domain.rb
156
178
  - lib/clearbit/pending.rb
157
179
  - lib/clearbit/prospector.rb
158
180
  - lib/clearbit/resource.rb
@@ -161,6 +183,7 @@ files:
161
183
  - lib/clearbit/version.rb
162
184
  - lib/clearbit/watchlist.rb
163
185
  - lib/clearbit/webhook.rb
186
+ - spec/lib/clearbit/analytics_spec.rb
164
187
  - spec/lib/clearbit/discovery_spec.rb
165
188
  - spec/lib/clearbit/enrichment_spec.rb
166
189
  - spec/lib/clearbit/logo_spec.rb
@@ -188,11 +211,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
211
  version: '0'
189
212
  requirements: []
190
213
  rubyforge_project:
191
- rubygems_version: 2.2.2
214
+ rubygems_version: 2.7.3
192
215
  signing_key:
193
216
  specification_version: 4
194
217
  summary: API client for clearbit.com
195
218
  test_files:
219
+ - spec/lib/clearbit/analytics_spec.rb
196
220
  - spec/lib/clearbit/discovery_spec.rb
197
221
  - spec/lib/clearbit/enrichment_spec.rb
198
222
  - spec/lib/clearbit/logo_spec.rb
@@ -200,4 +224,3 @@ test_files:
200
224
  - spec/lib/clearbit/webhook_spec.rb
201
225
  - spec/spec_helper.rb
202
226
  - spec/support/helpers.rb
203
- has_rdoc: