clearbit 0.1.7.pre → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f17cc8ca100cf101bd462ffeca2cacb7e8dd5969
4
- data.tar.gz: 5b338dd73e8ab2be9c0d790c8bbc550f708f1f33
3
+ metadata.gz: c1cbcaad8e2ee14c22b25ed8f50604323650f1a1
4
+ data.tar.gz: 5ac8cee9d7485cfd251821175008da4da0ec88c1
5
5
  SHA512:
6
- metadata.gz: 6c6fbd82648fd28a1f3811beba2deffe93aa0015ded42015edc552bbb7190328dc0c94ab650c9db1f4b910f95b17654f884e78bee9b3cfef637474df6a0c6c02
7
- data.tar.gz: 27b5f136e9677c56ae2e678892adcbd93c30ff738d116f5fe88240da48b6fabe22bf8c92fc93dd264bba0b1a1e6fa1fdaba41655ad124e19e80c324088a47702
6
+ metadata.gz: e1510ceb002969ef533fe8c0722a0d966f53159e7c6ffd1244b8061973186b7391f1cb55fb2fe2f45111e391febbbc6cdbd0ae0ac91554219f65123f2027e0ba
7
+ data.tar.gz: f110fd6a47ede030d80fefedefa9b84627775f3b10154f91ec33ad23f58451a8b41cb3ee120b537de164aa94145082af9e0a5593b53953c43ab2320bc987dead
data/README.md CHANGED
@@ -29,10 +29,13 @@ Clearbit.key = ENV['CLEARBIT_KEY']
29
29
  Then you can lookup people by email address:
30
30
 
31
31
  ``` ruby
32
- person = Clearbit::Streaming::Person[email: 'alex@alexmaccaw.com']
32
+ result = Clearbit::Enrichment.find(email: 'alex@alexmaccaw.com', stream: true)
33
+
34
+ person = result.person
35
+ company = result.company
33
36
  ```
34
37
 
35
- If the person can't be found, then `nil` will be returned.
38
+ Passing the `stream` option makes the operation blocking - it could hang for 4-5 seconds if we haven't seen the email before. Alternatively you can use our [webhook](https://clearbit.com/docs#webhooks) API. If a person or company can't be found, then they'll be `nil`.
36
39
 
37
40
  See the [documentation](https://clearbit.com/docs#person-api) for more information.
38
41
 
@@ -41,42 +44,16 @@ See the [documentation](https://clearbit.com/docs#person-api) for more informati
41
44
  You can lookup company data by domain name:
42
45
 
43
46
  ``` ruby
44
- company = Clearbit::Streaming::Company[domain: 'uber.com']
47
+ company = Clearbit::Enrichment::Company.find(domain: 'uber.com', stream: true)
45
48
  ```
46
49
 
47
50
  If the company can't be found, then `nil` will be returned.
48
51
 
49
52
  See the [documentation](https://clearbit.com/docs#company-api) for more information.
50
53
 
51
- ## CLI
52
-
53
- The gem also includes a `clearbit` executable, which you can use like this:
54
-
55
- $ clearbit person --email alex@alexmaccaw.com
56
-
57
- {
58
- "name": {
59
- "fullName": "Alex MacCaw",
60
- "givenName": "Alex",
61
- "familyName": "MacCaw"
62
- },
63
- ...
64
-
65
- Or to look up a company:
66
-
67
- $ clearbit company --domain uber.com
54
+ ## Other APIs
68
55
 
69
- {
70
- "name": "Uber",
71
- "legalName": "Uber, Inc.",
72
- "categories": [
73
- "Transport"
74
- ],
75
- "founders": [
76
- "Travis Kalanick",
77
- "Garrett Camp"
78
- ],
79
- ...
56
+ For more info on our other APIs (such as the Watchlist or Discover APIs), please see our [main documentation](https://clearbit.com/docs).
80
57
 
81
58
  ## Webhooks
82
59
 
data/clearbit.gemspec CHANGED
@@ -24,5 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'rake'
25
25
  spec.add_development_dependency 'rspec'
26
26
  spec.add_development_dependency 'rack'
27
+ spec.add_development_dependency 'webmock'
27
28
  spec.add_dependency 'nestful', '~> 1.1.0'
28
29
  end
data/examples/company.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require 'clearbit'
2
2
  require 'pp'
3
3
 
4
- pp Clearbit::Company.find(domain: 'stripe.com')
4
+ pp Clearbit::Enrichment::Company.find(domain: 'stripe.com', stream: true)
@@ -0,0 +1,4 @@
1
+ require 'clearbit'
2
+ require 'pp'
3
+
4
+ pp Clearbit::Discovery.search(query: {tech: 'marketo'})
@@ -0,0 +1,4 @@
1
+ require 'clearbit'
2
+ require 'pp'
3
+
4
+ pp Clearbit::Enrichment.find(email: 'alex@alexmaccaw.com')
data/examples/person.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require 'clearbit'
2
2
  require 'pp'
3
3
 
4
- pp Clearbit::Person.find(email: 'alex@alexmaccaw.com')
4
+ pp Clearbit::Enrichment::Person.find(email: 'alex@alexmaccaw.com')
data/lib/clearbit.rb CHANGED
@@ -19,12 +19,11 @@ module Clearbit
19
19
  end
20
20
 
21
21
  autoload :Base, 'clearbit/base'
22
- autoload :Company, 'clearbit/company'
23
- autoload :CompanySearch, 'clearbit/company_search'
22
+ autoload :Enrichment, 'clearbit/enrichment'
23
+ autoload :Discovery, 'clearbit/discovery'
24
24
  autoload :Logo, 'clearbit/logo'
25
25
  autoload :Mash, 'clearbit/mash'
26
- autoload :Person, 'clearbit/person'
27
- autoload :PersonCompany, 'clearbit/person_company'
26
+ autoload :Pending, 'clearbit/pending'
28
27
  autoload :Prospector, 'clearbit/prospector'
29
28
  autoload :Resource, 'clearbit/resource'
30
29
  autoload :Streaming, 'clearbit/streaming'
@@ -38,4 +37,8 @@ module Clearbit
38
37
  if clearbit_key = ENV['CLEARBIT_KEY']
39
38
  Clearbit.key = clearbit_key
40
39
  end
40
+
41
+ # Backwards compatibility
42
+ Person = Enrichment::Person
43
+ Company = Enrichment::Company
41
44
  end
data/lib/clearbit/base.rb CHANGED
@@ -17,5 +17,9 @@ module Clearbit
17
17
  def self.key
18
18
  @key
19
19
  end
20
+
21
+ def pending?
22
+ false
23
+ end
20
24
  end
21
25
  end
@@ -0,0 +1,44 @@
1
+ require 'delegate'
2
+
3
+ module Clearbit
4
+ class Discovery < Base
5
+ endpoint 'https://discovery.clearbit.com'
6
+ path '/v1/companies/search'
7
+
8
+ class PagedResult < Delegator
9
+ def initialize(params, response)
10
+ @params = params
11
+ super Mash.new(response)
12
+ end
13
+
14
+ def __getobj__
15
+ @response
16
+ end
17
+
18
+ def __setobj__(obj)
19
+ @response = obj
20
+ end
21
+
22
+ def each(&block)
23
+ return enum_for(:each) unless block_given?
24
+
25
+ results.each do |result|
26
+ yield result
27
+ end
28
+
29
+ if results.any?
30
+ search = Discovery.search(
31
+ @params.merge(page: page + 1)
32
+ )
33
+ search.each(&block)
34
+ end
35
+ end
36
+ end
37
+
38
+ def self.search(values = {})
39
+ response = post('', values)
40
+
41
+ PagedResult.new(values, response)
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,21 @@
1
+ module Clearbit
2
+ module Enrichment extend self
3
+ autoload :Company, 'clearbit/enrichment/company'
4
+ autoload :Person, 'clearbit/enrichment/person'
5
+ autoload :PersonCompany, 'clearbit/enrichment/person_company'
6
+
7
+ def find(values)
8
+ if domain = values[:domain]
9
+ result = Company.find(values)
10
+
11
+ if result && result.pending?
12
+ Pending.new
13
+ else
14
+ PersonCompany.new(company: result)
15
+ end
16
+ else
17
+ PersonCompany.find(values)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,37 @@
1
+ module Clearbit
2
+ module Enrichment
3
+ class Company < Base
4
+ endpoint 'https://company.clearbit.com'
5
+ path '/v1/companies'
6
+
7
+ def self.find(values)
8
+ unless values.is_a?(Hash)
9
+ values = {:id => values}
10
+ end
11
+
12
+ if domain = values.delete(:domain)
13
+ response = get(uri(:domain, domain), values)
14
+ elsif id = values.delete(:id)
15
+ response = get(id, values)
16
+ else
17
+ raise ArgumentError, 'Invalid values'
18
+ end
19
+
20
+ if response.status == 202
21
+ Pending.new
22
+ else
23
+ self.new(response)
24
+ end
25
+ rescue Nestful::ResourceNotFound
26
+ end
27
+
28
+ class << self
29
+ alias_method :[], :find
30
+ end
31
+
32
+ def flag!(attrs = {})
33
+ self.class.post(uri('flag'), attrs)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,40 @@
1
+ module Clearbit
2
+ module Enrichment
3
+ class Person < Base
4
+ endpoint 'https://person.clearbit.com'
5
+ path '/v1/people'
6
+
7
+ def self.find(values)
8
+ unless values.is_a?(Hash)
9
+ values = {:id => values}
10
+ end
11
+
12
+ if email = values.delete(:email)
13
+ response = get(uri(:email, email), values)
14
+
15
+ elsif id = values.delete(:id)
16
+ response = get(id, values)
17
+
18
+ else
19
+ raise ArgumentError, 'Invalid values'
20
+ end
21
+
22
+ if response.status == 202
23
+ Pending.new
24
+ else
25
+ self.new(response)
26
+ end
27
+
28
+ rescue Nestful::ResourceNotFound
29
+ end
30
+
31
+ class << self
32
+ alias_method :[], :find
33
+ end
34
+
35
+ def flag!(attrs = {})
36
+ self.class.post(uri('flag'), attrs)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,31 @@
1
+ module Clearbit
2
+ module Enrichment
3
+ class PersonCompany < Base
4
+ endpoint 'https://person.clearbit.com'
5
+ path '/v1/combined'
6
+
7
+ def self.find(values)
8
+ unless values.is_a?(Hash)
9
+ values = {:id => values}
10
+ end
11
+
12
+ if email = values.delete(:email)
13
+ response = get(uri(:email, email), values)
14
+ else
15
+ raise ArgumentError, 'Invalid values'
16
+ end
17
+
18
+ if response.status == 202
19
+ Pending.new
20
+ else
21
+ self.new(response)
22
+ end
23
+ rescue Nestful::ResourceNotFound
24
+ end
25
+
26
+ class << self
27
+ alias_method :[], :find
28
+ end
29
+ end
30
+ end
31
+ end
data/lib/clearbit/logo.rb CHANGED
@@ -29,7 +29,6 @@ module Clearbit
29
29
  else
30
30
  raise ArgumentError, 'Invalid values'
31
31
  end
32
-
33
32
  end
34
33
 
35
34
  class << self
@@ -0,0 +1,15 @@
1
+ module Clearbit
2
+ class Pending
3
+ def pending?
4
+ true
5
+ end
6
+
7
+ def queued?
8
+ true
9
+ end
10
+
11
+ def inspect
12
+ 'Your request is pending - please try again in few seconds, or pass the :stream option as true.'
13
+ end
14
+ end
15
+ end
@@ -3,8 +3,8 @@ module Clearbit
3
3
  endpoint 'https://prospector.clearbit.com'
4
4
  path '/v1/people'
5
5
 
6
- def self.search(params = {})
7
- self.new get('search', params)
6
+ def self.search(values = {})
7
+ self.new get('search', values)
8
8
  end
9
9
  end
10
10
  end
@@ -32,7 +32,7 @@ module Clearbit
32
32
  alias_method :add_options, :options
33
33
  end
34
34
 
35
- def self.url
35
+ def self.url(options = {})
36
36
  URI.join(endpoint.to_s, path.to_s).to_s
37
37
  end
38
38
 
@@ -42,35 +42,70 @@ module Clearbit
42
42
  return uri if uri.host
43
43
  end
44
44
 
45
- URI.parse(Nestful::Helpers.to_path(url, *parts))
45
+ value = Nestful::Helpers.to_path(url, *parts)
46
+
47
+ URI.parse(value)
46
48
  end
47
49
 
48
- def self.get(action = '', params = {}, options = {})
49
- request(uri(action), options.merge(method: :get, params: params))
50
+ OPTION_KEYS = %i{
51
+ params key headers stream
52
+ proxy user password auth_type
53
+ timeout ssl_options
54
+ }
55
+
56
+ def self.parse_values(values)
57
+ params = values.reject {|k,_| OPTION_KEYS.include?(k) }
58
+ options = values.select {|k,_| OPTION_KEYS.include?(k) }
59
+
60
+ [params, options]
50
61
  end
51
62
 
52
- def self.put(action = '', params = {}, options = {})
53
- request(uri(action), options.merge(method: :put, params: params))
63
+ def self.get(action = '', values = {})
64
+ params, options = parse_values(values)
65
+
66
+ request(
67
+ uri(action),
68
+ options.merge(method: :get, params: params))
54
69
  end
55
70
 
56
- def self.post(action = '', params = {}, options = {})
57
- request(uri(action), options.merge(method: :post, params: params))
71
+ def self.put(action = '', values = {})
72
+ params, options = parse_values(values)
73
+
74
+ request(
75
+ uri(action),
76
+ options.merge(method: :put, params: params, format: :json))
58
77
  end
59
78
 
60
- def self.delete(action = '', params = {}, options = {})
61
- request(uri(action), options.merge(method: :delete, params: params))
79
+ def self.post(action = '', values = {})
80
+ params, options = parse_values(values)
81
+
82
+ request(
83
+ uri(action),
84
+ options.merge(method: :post, params: params, format: :json))
62
85
  end
63
86
 
64
- def self.request(url, options = {})
87
+ def self.delete(action = '', values = {})
88
+ params, options = parse_values(values)
89
+
90
+ request(
91
+ uri(action),
92
+ options.merge(method: :delete, params: params))
93
+ end
94
+
95
+ def self.request(uri, options = {})
65
96
  options = Nestful::Helpers.deep_merge(self.options, options)
66
97
 
98
+ if options[:stream]
99
+ uri.host = uri.host.gsub('.clearbit.com', '-stream.clearbit.com')
100
+ end
101
+
67
102
  Nestful::Request.new(
68
- url, options
103
+ uri, options
69
104
  ).execute
70
105
  end
71
106
 
72
107
  def uri(*parts)
73
- id ? self.class.uri(id, *parts) : self.class.uri(*parts)
108
+ self.class.uri(*[id, *parts].compact)
74
109
  end
75
110
  end
76
111
  end
@@ -1,3 +1,3 @@
1
1
  module Clearbit
2
- VERSION = "0.1.7.pre"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -3,8 +3,8 @@ module Clearbit
3
3
  endpoint 'https://watchlist.clearbit.com'
4
4
  path '/v1/search/all'
5
5
 
6
- def self.search(params, options = {})
7
- response = post('', params, options)
6
+ def self.search(values)
7
+ response = post('', values)
8
8
  self.new(response)
9
9
  end
10
10
 
@@ -19,18 +19,18 @@ module Clearbit
19
19
  class Candidate < Watchlist
20
20
  path '/v1/candidates'
21
21
 
22
- def self.find(id, options = {})
23
- response = get(id, {}, options)
22
+ def self.find(id, values)
23
+ response = get(id, values)
24
24
  self.new(response)
25
25
  end
26
26
 
27
- def self.all(options = {})
28
- response = get('', {}, options)
27
+ def self.all(values)
28
+ response = get('', values)
29
29
  self.new(response)
30
30
  end
31
31
 
32
- def self.create(params, options = {})
33
- response = post('', params, options)
32
+ def self.create(values)
33
+ response = post('', values)
34
34
  self.new(response)
35
35
  end
36
36
 
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Clearbit::Discovery do
4
+ before do |example|
5
+ Clearbit.key = 'clearbit_key'
6
+ end
7
+
8
+ it 'returns results from the Discovery API' do
9
+ body = []
10
+ query = {query: {name: 'stripe'}}
11
+
12
+ stub_request(:post, "https://discovery.clearbit.com/v1/companies/search").
13
+ with(:headers => {'Authorization'=>'Bearer clearbit_key'}, body: query.to_json).
14
+ to_return(:status => 200, :body => body.to_json, headers: {'Content-Type' => 'application/json'})
15
+
16
+ Clearbit::Discovery.search(query: {name: 'stripe'})
17
+ end
18
+ end
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ describe Clearbit::Enrichment do
4
+ before do |example|
5
+ Clearbit.key = 'clearbit_key'
6
+ end
7
+
8
+ context 'combined API' do
9
+ it 'should call out to the combined API' do
10
+ body = {
11
+ person: nil,
12
+ company: nil
13
+ }
14
+
15
+ stub_request(:get, "https://person.clearbit.com/v1/combined/email/test@example.com").
16
+ with(:headers => {'Authorization'=>'Bearer clearbit_key'}).
17
+ to_return(:status => 200, :body => body.to_json, headers: {'Content-Type' => 'application/json'})
18
+
19
+ Clearbit::Enrichment.find(email: 'test@example.com')
20
+ end
21
+
22
+ it 'uses streaming option' do
23
+ body = {
24
+ person: nil,
25
+ company: nil
26
+ }
27
+
28
+ stub_request(:get, "https://person-stream.clearbit.com/v1/combined/email/test@example.com").
29
+ with(:headers => {'Authorization'=>'Bearer clearbit_key'}).
30
+ to_return(:status => 200, :body => body.to_json, headers: {'Content-Type' => 'application/json'})
31
+
32
+ Clearbit::Enrichment.find(email: 'test@example.com', stream: true)
33
+ end
34
+
35
+ it 'returns pending? if 202 response' do
36
+ body = {
37
+ person: nil,
38
+ company: nil
39
+ }
40
+
41
+ stub_request(:get, "https://person.clearbit.com/v1/combined/email/test@example.com").
42
+ with(:headers => {'Authorization'=>'Bearer clearbit_key'}).
43
+ to_return(:status => 202, :body => body.to_json, headers: {'Content-Type' => 'application/json'})
44
+
45
+ result = Clearbit::Enrichment.find(email: 'test@example.com')
46
+
47
+ expect(result.pending?).to be true
48
+ end
49
+
50
+ it 'should use the Company API if domain is provided' do
51
+ body = {}
52
+
53
+ stub_request(:get, "https://company.clearbit.com/v1/companies/domain/example.com").
54
+ with(:headers => {'Authorization'=>'Bearer clearbit_key'}).
55
+ to_return(:status => 200, :body => body.to_json, headers: {'Content-Type' => 'application/json'})
56
+
57
+ Clearbit::Enrichment.find(domain: 'example.com')
58
+ end
59
+ end
60
+
61
+ context 'person API' do
62
+ it 'should call out to the person API' do
63
+ body = {}
64
+
65
+ stub_request(:get, "https://person.clearbit.com/v1/people/email/test@example.com").
66
+ with(:headers => {'Authorization'=>'Bearer clearbit_key'}).
67
+ to_return(:status => 200, :body => body.to_json, headers: {'Content-Type' => 'application/json'})
68
+
69
+ Clearbit::Enrichment::Person.find(email: 'test@example.com')
70
+ end
71
+ end
72
+
73
+ context 'company API' do
74
+ it 'should call out to the company API' do
75
+ body = {}
76
+
77
+ stub_request(:get, "https://company.clearbit.com/v1/companies/domain/example.com").
78
+ with(:headers => {'Authorization'=>'Bearer clearbit_key'}).
79
+ to_return(:status => 200, :body => body.to_json, headers: {'Content-Type' => 'application/json'})
80
+
81
+ Clearbit::Enrichment::Company.find(domain: 'example.com')
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Clearbit::Prospector do
4
+ before do |example|
5
+ Clearbit.key = 'clearbit_key'
6
+ end
7
+
8
+ context 'Prospector API' do
9
+ it 'should call out to the Prospector API' do
10
+ body = []
11
+
12
+ stub_request(:get, "https://prospector.clearbit.com/v1/people/search?domain=stripe.com").
13
+ with(:headers => {'Authorization'=>'Bearer clearbit_key'}).
14
+ to_return(:status => 200, :body => body.to_json, headers: {'Content-Type' => 'application/json'})
15
+
16
+ Clearbit::Prospector.search(domain: 'stripe.com')
17
+ end
18
+ end
19
+ end
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,7 @@ $LOAD_PATH << File.join(File.dirname(__FILE__))
5
5
  require 'rubygems'
6
6
  require 'rspec'
7
7
  require 'pry'
8
+ require 'webmock/rspec'
8
9
 
9
10
  # Library
10
11
  require 'clearbit'
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.1.7.pre
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex MacCaw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-15 00:00:00.000000000 Z
11
+ date: 2015-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: nestful
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -111,8 +125,7 @@ dependencies:
111
125
  description: API client for clearbit.com
112
126
  email:
113
127
  - alex@clearbit.com
114
- executables:
115
- - clearbit
128
+ executables: []
116
129
  extensions: []
117
130
  extra_rdoc_files: []
118
131
  files:
@@ -120,32 +133,33 @@ files:
120
133
  - Gemfile
121
134
  - README.md
122
135
  - Rakefile
123
- - bin/clearbit
124
136
  - clearbit.gemspec
125
137
  - examples/company.rb
138
+ - examples/discovery.rb
139
+ - examples/enrichment.rb
126
140
  - examples/logo.rb
127
141
  - examples/person.rb
128
- - examples/person_company.rb
129
142
  - examples/version.rb
130
143
  - examples/watchlist.rb
131
144
  - lib/clearbit.rb
132
145
  - lib/clearbit/base.rb
133
- - lib/clearbit/company.rb
134
- - lib/clearbit/company_search.rb
146
+ - lib/clearbit/discovery.rb
147
+ - lib/clearbit/enrichment.rb
148
+ - lib/clearbit/enrichment/company.rb
149
+ - lib/clearbit/enrichment/person.rb
150
+ - lib/clearbit/enrichment/person_company.rb
135
151
  - lib/clearbit/errors/invalid_webhook_signature.rb
136
152
  - lib/clearbit/logo.rb
137
153
  - lib/clearbit/mash.rb
138
- - lib/clearbit/person.rb
139
- - lib/clearbit/person_company.rb
154
+ - lib/clearbit/pending.rb
140
155
  - lib/clearbit/prospector.rb
141
156
  - lib/clearbit/resource.rb
142
- - lib/clearbit/streaming.rb
143
- - lib/clearbit/streaming/company.rb
144
- - lib/clearbit/streaming/person.rb
145
- - lib/clearbit/streaming/person_company.rb
146
157
  - lib/clearbit/version.rb
147
158
  - lib/clearbit/watchlist.rb
148
159
  - lib/clearbit/webhook.rb
160
+ - spec/lib/clearbit/discovery_spec.rb
161
+ - spec/lib/clearbit/enrichment_spec.rb
162
+ - spec/lib/clearbit/prospector_spec.rb
149
163
  - spec/lib/clearbit/webhook_spec.rb
150
164
  - spec/spec_helper.rb
151
165
  homepage: https://github.com/maccman/clearbit-ruby
@@ -163,9 +177,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
177
  version: '0'
164
178
  required_rubygems_version: !ruby/object:Gem::Requirement
165
179
  requirements:
166
- - - ">"
180
+ - - ">="
167
181
  - !ruby/object:Gem::Version
168
- version: 1.3.1
182
+ version: '0'
169
183
  requirements: []
170
184
  rubyforge_project:
171
185
  rubygems_version: 2.2.2
@@ -173,6 +187,9 @@ signing_key:
173
187
  specification_version: 4
174
188
  summary: API client for clearbit.com
175
189
  test_files:
190
+ - spec/lib/clearbit/discovery_spec.rb
191
+ - spec/lib/clearbit/enrichment_spec.rb
192
+ - spec/lib/clearbit/prospector_spec.rb
176
193
  - spec/lib/clearbit/webhook_spec.rb
177
194
  - spec/spec_helper.rb
178
195
  has_rdoc:
data/bin/clearbit DELETED
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'clearbit'
4
- require 'json'
5
- require 'optparse'
6
-
7
- begin
8
- require 'awesome_print'
9
- rescue LoadError
10
- def ap(value)
11
- puts JSON.pretty_generate(value)
12
- end
13
- end
14
-
15
- options = {}
16
- values = {}
17
-
18
- parser = OptionParser.new do |opts|
19
- opts.banner = "Usage: clearbit [person|company] [options]"
20
-
21
- opts.on("--email EMAIL", String, "Email") do |v|
22
- values[:email] = v
23
- end
24
-
25
- opts.on("--domain DOMAIN", String, "Domain") do |v|
26
- values[:domain] = v
27
- end
28
-
29
- opts.on("--api-key KEY", String, "Clearbit") do |v|
30
- options[:api_key] = v
31
- end
32
- end
33
-
34
- parser.parse!
35
-
36
- case ARGV[0]
37
- when 'person'
38
- entity = Clearbit::Streaming::Person
39
- when 'company'
40
- entity = Clearbit::Streaming::Company
41
- else
42
- puts parser
43
- exit
44
- end
45
-
46
- if values == {}
47
- puts parser
48
- exit
49
- end
50
-
51
- if key = ENV['CLEARBIT_KEY']
52
- options[:api_key] ||= key
53
- end
54
-
55
- if key = options.delete(:api_key)
56
- Clearbit.api_key = key
57
- else
58
- puts 'API Key required'
59
- puts parser
60
- exit
61
- end
62
-
63
- object = entity.find(values, options)
64
-
65
- if object
66
- ap object.to_hash
67
- else
68
- puts 'Not found'
69
- end
@@ -1,4 +0,0 @@
1
- require 'clearbit'
2
- require 'pp'
3
-
4
- pp Clearbit::PersonCompany.find(email: 'alex@alexmaccaw.com', given_name: 'Alex', family_name: 'MacCaw')
@@ -1,59 +0,0 @@
1
- module Clearbit
2
- class Company < Base
3
- endpoint 'https://company.clearbit.com'
4
- path '/v1/companies'
5
-
6
- def self.find(values, old_options = nil)
7
- unless values.is_a?(Hash)
8
- values = {:id => values}
9
- end
10
-
11
- if old_options
12
- # Deprecated API
13
- warn '[DEPRECATION] passing multiple args to find() is deprecated'
14
- (values[:request] ||= {}).merge!(old_options)
15
- end
16
-
17
- options = values.delete(:request) || {}
18
- params = values.delete(:params) || {}
19
-
20
- if webhook_id = values.delete(:webhook_id)
21
- params.merge!(webhook_id: webhook_id)
22
- end
23
-
24
- if webhook_url = values.delete(:webhook_url)
25
- params.merge!(webhook_url: webhook_url)
26
- end
27
-
28
- if subscribe = values.delete(:subscribe)
29
- params.merge!(subscribe: subscribe)
30
- end
31
-
32
- if domain = values[:domain]
33
- response = get(uri(:domain, domain), params, options)
34
-
35
- elsif id = values[:id]
36
- response = get(id, params, options)
37
-
38
- else
39
- raise ArgumentError, 'Invalid values'
40
- end
41
-
42
- if response.status == 202
43
- self.new(pending: true)
44
- else
45
- self.new(response)
46
- end
47
-
48
- rescue Nestful::ResourceNotFound
49
- end
50
-
51
- class << self
52
- alias_method :[], :find
53
- end
54
-
55
- def flag!(attrs = {})
56
- self.class.post(uri('flag'), attrs)
57
- end
58
- end
59
- end
@@ -1,18 +0,0 @@
1
- module Clearbit
2
- class CompanySearch < Base
3
- endpoint 'https://company.clearbit.com'
4
- path '/v1/companies/search'
5
-
6
- def self.search(query, params = {})
7
- options = params.delete(:request) || {}
8
- options = options.merge(format: :json)
9
-
10
- query = [query] if query.is_a?(Hash)
11
- params = params.merge(query: query)
12
-
13
- response = post('', params, options)
14
-
15
- self.new(response)
16
- end
17
- end
18
- end
@@ -1,65 +0,0 @@
1
- module Clearbit
2
- class Person < Base
3
- endpoint 'https://person.clearbit.com'
4
- path '/v1/people'
5
-
6
- def self.find(values, old_options = nil)
7
- unless values.is_a?(Hash)
8
- values = {:id => values}
9
- end
10
-
11
- if old_options
12
- # Deprecated API
13
- warn '[DEPRECATION] passing multiple args to find() is deprecated'
14
- (values[:request] ||= {}).merge!(old_options)
15
- end
16
-
17
- options = values.delete(:request) || {}
18
- params = values.delete(:params) || {}
19
-
20
- if webhook_id = values.delete(:webhook_id)
21
- params.merge!(webhook_id: webhook_id)
22
- end
23
-
24
- if webhook_url = values.delete(:webhook_url)
25
- params.merge!(webhook_url: webhook_url)
26
- end
27
-
28
- if subscribe = values.delete(:subscribe)
29
- params.merge!(subscribe: subscribe)
30
- end
31
-
32
- if email = values[:email]
33
- response = get(uri(:email, email), params, options)
34
-
35
- elsif twitter = values[:twitter]
36
- response = get(uri(:twitter, twitter), params, options)
37
-
38
- elsif github = values[:github]
39
- response = get(uri(:github, github), params, options)
40
-
41
- elsif id = values[:id]
42
- response = get(id, params, options)
43
-
44
- else
45
- raise ArgumentError, 'Invalid values'
46
- end
47
-
48
- if response.status == 202
49
- self.new(pending: true)
50
- else
51
- self.new(response)
52
- end
53
-
54
- rescue Nestful::ResourceNotFound
55
- end
56
-
57
- class << self
58
- alias_method :[], :find
59
- end
60
-
61
- def flag!(attrs = {})
62
- self.class.post(uri('flag'), attrs)
63
- end
64
- end
65
- end
@@ -1,50 +0,0 @@
1
- module Clearbit
2
- class PersonCompany < Base
3
- endpoint 'https://person.clearbit.com'
4
- path '/v1/combined'
5
-
6
- def self.find(values, old_options = nil)
7
- unless values.is_a?(Hash)
8
- values = {:id => values}
9
- end
10
-
11
- if old_options
12
- # Deprecated API
13
- warn '[DEPRECATION] passing multiple args to find() is deprecated'
14
- (values[:request] ||= {}).merge!(old_options)
15
- end
16
-
17
- options = values.delete(:request) || {}
18
- params = values.delete(:params) || {}
19
-
20
- if webhook_id = values.delete(:webhook_id)
21
- params.merge!(webhook_id: webhook_id)
22
- end
23
-
24
- if webhook_url = values.delete(:webhook_url)
25
- params.merge!(webhook_url: webhook_url)
26
- end
27
-
28
- if subscribe = values.delete(:subscribe)
29
- params.merge!(subscribe: subscribe)
30
- end
31
-
32
- if email = values[:email]
33
- response = get(uri(:email, email), params, options)
34
- else
35
- raise ArgumentError, 'Invalid values'
36
- end
37
-
38
- if response.status == 202
39
- self.new(pending: true)
40
- else
41
- self.new(response)
42
- end
43
- rescue Nestful::ResourceNotFound
44
- end
45
-
46
- class << self
47
- alias_method :[], :find
48
- end
49
- end
50
- end
@@ -1,7 +0,0 @@
1
- module Clearbit
2
- module Streaming
3
- autoload :Company, 'clearbit/streaming/company'
4
- autoload :Person, 'clearbit/streaming/person'
5
- autoload :PersonCompany, 'clearbit/streaming/person_company'
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- module Clearbit
2
- module Streaming
3
- class Company < Clearbit::Company
4
- endpoint 'https://company-stream.clearbit.com'
5
- end
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- module Clearbit
2
- module Streaming
3
- class Person < Clearbit::Person
4
- endpoint 'https://person-stream.clearbit.com'
5
- end
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- module Clearbit
2
- module Streaming
3
- class PersonCompany < Clearbit::PersonCompany
4
- endpoint 'https://person-stream.clearbit.com'
5
- end
6
- end
7
- end