fc_enrich 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/.travis.yml +15 -0
- data/CHANGELOG.md +2 -0
- data/README.md +73 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/rspec +29 -0
- data/bin/rubocop +29 -0
- data/bin/setup +8 -0
- data/fc_enrich.gemspec +30 -0
- data/gems.rb +18 -0
- data/lib/fc_enrich.rb +16 -0
- data/lib/fc_enrich/http_client.rb +15 -0
- data/lib/fc_enrich/person_enrich_request.rb +51 -0
- data/lib/fc_enrich/version.rb +3 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a1147796dccb881da70e654d2b12e5cef243b66eff4feff1724ec687239d5cb9
|
4
|
+
data.tar.gz: '09873689133407f5417ea027ef65bdff980fe94f55b12f1d9f627201146786a7'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b9a4a0d143d97658d104dec92a3530842657db225b6fecb7d44ec7af394cf7286a30d472b50cd78da90181e52ac138d7186ec1093b6e06b4287660c7d2859f90
|
7
|
+
data.tar.gz: 30390d4b4c729a78dd3a83a7cfb169593c083d88b250a1957f1cdbde2231d8be0b2dba9e51bbb8d9c279ef6ef8db115e0f5208f4ade334054b9bc23faff0c2fb
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Full Contact Api
|
2
|
+
[![Build Status](https://travis-ci.org/NEXL-LTS/full_contact-ruby.svg?branch=main)](https://travis-ci.org/NEXL-LTS/full_contact-ruby)
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'fc_enrich'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle install
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install fc_enrich
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
# setup
|
24
|
+
FcEnrich.api_key = "[API_KEY]"
|
25
|
+
```
|
26
|
+
|
27
|
+
see https://platform.fullcontact.com/docs/apis/enrich/multi-field-request
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
person_request = FcEnrich::PersonEnrichRequest.new(email: "bart@fullcontact.com")
|
31
|
+
person = person_request.perform
|
32
|
+
puts person.full_name # "Bart Lorang"
|
33
|
+
puts person.age_range # "30-39"
|
34
|
+
puts person.gender # "Male"
|
35
|
+
puts person.location # "Denver, CO, United States"
|
36
|
+
puts person.title # "Co-Founder & Managing Director"
|
37
|
+
puts person.organization # "V1.vc"
|
38
|
+
puts person.twitter # "https://twitter.com/bartlorang"
|
39
|
+
puts person.linkedin # "https://www.linkedin.com/in/bartlorang"
|
40
|
+
puts person.bio # "CEO & Co-Founder of @FullContact, Managing Director @v1vc_. Tech Entrepreneur, Investor."
|
41
|
+
puts person.avatar # "https://d2ojpxxtu63wzl.cloudfront.net/static/a7e6a5aba590d4933e35eaadabd97fd2_44e00e968ac57725a15b32f9ca714827aff8e4818d290cb0c611f2e2585253b3"
|
42
|
+
|
43
|
+
# example with all options
|
44
|
+
person_request = FcEnrich::PersonEnrichRequest.new(
|
45
|
+
emails: ["bart@fullcontact.com", "bart.lorang@fullcontact.com"],
|
46
|
+
phones: ["+17202227799", "+13035551234"],
|
47
|
+
location: { "address_line1": "123 Main Street",
|
48
|
+
"address_line2": "Unit 2",
|
49
|
+
"city": "Denver",
|
50
|
+
"region": "Colorado",
|
51
|
+
"region_code": "CO",
|
52
|
+
"postal_code": "80203" },
|
53
|
+
name: { "full": "Bart Lorang",
|
54
|
+
"given": "Bart",
|
55
|
+
"family": "Lorang" },
|
56
|
+
profiles: [{ "service": "twitter", "username": "bartlorang" },
|
57
|
+
{ "service": "twitter", "userid": "5998422" },
|
58
|
+
{ "service": "linkedin", "url": "https://www.linkedin.com/in/bartlorang" },
|
59
|
+
{ "service": "github", "url": "https://www.github.com/lorangb"}],
|
60
|
+
maids: ["ape2ch30-pifn-cbvi-30yy-nia-zex7aw5u"],
|
61
|
+
person_id: "eYxWc0B-dKRxerTw_uQpxCssM_GyPaLErj0Eu3y2FrU6py1J",
|
62
|
+
record_id: "customer123",
|
63
|
+
infer: true,
|
64
|
+
data_filter: ["social", "employment_history"])
|
65
|
+
```
|
66
|
+
|
67
|
+
## Development
|
68
|
+
|
69
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
70
|
+
|
71
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
72
|
+
|
73
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fc_enrich"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../gems.rb",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/rubocop
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rubocop' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../gems.rb",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rubocop", "rubocop")
|
data/bin/setup
ADDED
data/fc_enrich.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'lib/fc_enrich/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "fc_enrich"
|
5
|
+
spec.version = FcEnrich::VERSION
|
6
|
+
spec.authors = ["Grant Petersen-Speelman"]
|
7
|
+
spec.email = ["grant@nexl.io"]
|
8
|
+
spec.license = "MIT"
|
9
|
+
|
10
|
+
spec.summary = %q{A ruby client to interact with Full contact API}
|
11
|
+
spec.description = %q{A ruby client to interact with Full contact API}
|
12
|
+
spec.homepage = "https://github.com/NEXL-LTS/full_contact-ruby"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = "https://github.com/NEXL-LTS/full_contact-ruby"
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/NEXL-LTS/full_contact-ruby/blob/main/CHANGELOG.md"
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.add_dependency 'activesupport', '>= 3.2', '< 7.0'
|
27
|
+
spec.add_dependency 'hashie', '>= 3.1.0', '< 5.0'
|
28
|
+
spec.add_dependency 'multi_json', '>= 1.0.0', '< 2.0'
|
29
|
+
spec.add_dependency 'rest-client', '>= 2.0.0', '< 3.0'
|
30
|
+
end
|
data/gems.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in snov.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem "rake", "~> 12.0"
|
7
|
+
gem "rspec", "~> 3.0"
|
8
|
+
gem "rubocop"
|
9
|
+
gem "rubocop-rspec"
|
10
|
+
gem "simplecov"
|
11
|
+
gem "webmock"
|
12
|
+
|
13
|
+
if ENV['GEM_VERSIONS'] == 'min'
|
14
|
+
gem 'activesupport', '~> 3.2.0'
|
15
|
+
gem 'hashie', '~> 3.1.0'
|
16
|
+
gem 'multi_json', '~> 1.0.0'
|
17
|
+
gem 'rest-client', '~> 2.0.0'
|
18
|
+
end
|
data/lib/fc_enrich.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "fc_enrich/version"
|
2
|
+
|
3
|
+
module FcEnrich
|
4
|
+
class Error < StandardError; end
|
5
|
+
# Your code goes here...
|
6
|
+
|
7
|
+
def self.api_key=(val)
|
8
|
+
@key = val.to_str
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.api_key
|
12
|
+
@key
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'fc_enrich/person_enrich_request'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module FcEnrich
|
5
|
+
class HttpClient
|
6
|
+
def post(path, payload_hash)
|
7
|
+
response = RestClient.post("https://api.fullcontact.com#{path}",
|
8
|
+
MultiJson.encode(payload_hash),
|
9
|
+
authorization: "Bearer #{FcEnrich.api_key}")
|
10
|
+
MultiJson.decode(response.body)
|
11
|
+
rescue RestClient::NotFound
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'hashie'
|
2
|
+
require 'active_support/core_ext/string'
|
3
|
+
|
4
|
+
require_relative 'http_client'
|
5
|
+
|
6
|
+
module FcEnrich
|
7
|
+
class PersonEnrichRequest < Hashie::Trash
|
8
|
+
include Hashie::Extensions::IndifferentAccess
|
9
|
+
|
10
|
+
property :email
|
11
|
+
property :emails
|
12
|
+
property :phone
|
13
|
+
property :phones
|
14
|
+
property :location,
|
15
|
+
transform_with: ->(v) { v.transform_keys! { |key| key.to_s.camelize(:lower) } }
|
16
|
+
property :name
|
17
|
+
property :profiles
|
18
|
+
property :maids
|
19
|
+
property :personId, from: :person_id
|
20
|
+
property :recordId, from: :record_id
|
21
|
+
property :dataFilter, from: :data_filter
|
22
|
+
property :infer
|
23
|
+
|
24
|
+
def perform(http_client: HttpClient.new)
|
25
|
+
Response.new(
|
26
|
+
http_client.post("/v3/person.enrich", to_hash)
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
class Response < Hashie::Trash
|
31
|
+
include Hashie::Extensions::IndifferentAccess
|
32
|
+
include Hashie::Extensions::IgnoreUndeclared
|
33
|
+
include Hashie::Extensions::Coercion
|
34
|
+
|
35
|
+
property :full_name, from: :fullName
|
36
|
+
property :age_range, from: :ageRange
|
37
|
+
property :gender
|
38
|
+
property :location
|
39
|
+
property :title
|
40
|
+
property :organization
|
41
|
+
property :twitter
|
42
|
+
property :linkedin
|
43
|
+
property :facebook
|
44
|
+
property :bio
|
45
|
+
property :avatar
|
46
|
+
property :details
|
47
|
+
|
48
|
+
coerce_key :details, Hashie::Mash
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fc_enrich
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Grant Petersen-Speelman
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-12-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: hashie
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 3.1.0
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '5.0'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 3.1.0
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '5.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: multi_json
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.0.0
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '2.0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.0.0
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '2.0'
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: rest-client
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 2.0.0
|
80
|
+
- - "<"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.0.0
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '3.0'
|
93
|
+
description: A ruby client to interact with Full contact API
|
94
|
+
email:
|
95
|
+
- grant@nexl.io
|
96
|
+
executables: []
|
97
|
+
extensions: []
|
98
|
+
extra_rdoc_files: []
|
99
|
+
files:
|
100
|
+
- ".gitignore"
|
101
|
+
- ".rspec"
|
102
|
+
- ".rubocop.yml"
|
103
|
+
- ".travis.yml"
|
104
|
+
- CHANGELOG.md
|
105
|
+
- README.md
|
106
|
+
- Rakefile
|
107
|
+
- bin/console
|
108
|
+
- bin/rspec
|
109
|
+
- bin/rubocop
|
110
|
+
- bin/setup
|
111
|
+
- fc_enrich.gemspec
|
112
|
+
- gems.rb
|
113
|
+
- lib/fc_enrich.rb
|
114
|
+
- lib/fc_enrich/http_client.rb
|
115
|
+
- lib/fc_enrich/person_enrich_request.rb
|
116
|
+
- lib/fc_enrich/version.rb
|
117
|
+
homepage: https://github.com/NEXL-LTS/full_contact-ruby
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata:
|
121
|
+
homepage_uri: https://github.com/NEXL-LTS/full_contact-ruby
|
122
|
+
source_code_uri: https://github.com/NEXL-LTS/full_contact-ruby
|
123
|
+
changelog_uri: https://github.com/NEXL-LTS/full_contact-ruby/blob/main/CHANGELOG.md
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 2.4.0
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubygems_version: 3.1.4
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: A ruby client to interact with Full contact API
|
143
|
+
test_files: []
|