peopledatalabs 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8fb77aedefcc1a398eda2c13ba723c6c621644b69149946599f33fea1c776f90
4
+ data.tar.gz: 237971300ff900343783aed2a61d420afbaa066ec455db221309e68109cee4e8
5
+ SHA512:
6
+ metadata.gz: b2dd9f3206c667e2b707838b9110325602bf872aa54db0acaa06c5914c0a0ceefe3d76892b41d3ee1b2a24e0c6d2a18492381b0c8f4690cbe3249735ae666b88
7
+ data.tar.gz: 43ebb2f98b0b9416d24e43c043e87175894f4c4bc233865d02943845ce89d2abff8b22d5939ee20a871bb17e375360a1e40c925cd1941cb79c5e58f20f6180eb
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+
16
+ **Expected behavior**
17
+ A clear and concise description of what you expected to happen.
18
+
19
+ **Screenshots**
20
+ If applicable, add screenshots to help explain your problem.
21
+ - peopledatalabs Library Version
22
+ - Node Version
23
+ - NPM Version
24
+
25
+ **Additional context**
26
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,10 @@
1
+ ## Description of the change
2
+
3
+ > Description here
4
+
5
+ ## Type of change
6
+
7
+ - [ ] Bug fix (non-breaking change that fixes an issue)
8
+ - [ ] Chore (cleanup or minor QOL tweak that has little to no impact on functionality)
9
+ - [ ] New feature (non-breaking change that adds functionality)
10
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
@@ -0,0 +1,33 @@
1
+ name: Publish Ruby Gem
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ name: Build + Publish
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ packages: write
14
+
15
+ steps:
16
+ - uses: actions/checkout@v3
17
+ - name: Set up Ruby 2.6
18
+ uses: actions/setup-ruby@v1
19
+ with:
20
+ ruby-version: 2.6.x
21
+
22
+ - name: Publish to RubyGems
23
+ run: |
24
+ mkdir -p $HOME/.gem
25
+ touch $HOME/.gem/credentials
26
+ chmod 0600 $HOME/.gem/credentials
27
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
28
+ gem install bundler
29
+ bundle install
30
+ gem build *.gemspec
31
+ gem push *.gem
32
+ env:
33
+ GEM_HOST_API_KEY: "${{secrets.RUBY_TOKEN}}"
@@ -0,0 +1,28 @@
1
+ name: Test Package
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - name: Setup Ruby
16
+ uses: actions/setup-ruby@v1
17
+ with:
18
+ ruby-version: 2.6.x
19
+
20
+ - name: Build and run test
21
+ env:
22
+ PDL_API_KEY: ${{secrets.PDL_API_KEY}}
23
+ run: |
24
+ gem install bundler
25
+ bundle install
26
+ gem build peopledatalabs.gemspec
27
+ gem install ./peopledatalabs-1.0.0.gem
28
+ rake spec
data/.gitignore ADDED
@@ -0,0 +1,67 @@
1
+ *.gem
2
+ /.bundle/
3
+ *.rbc
4
+ /.yardoc
5
+ /.config
6
+ /_yardoc/
7
+ /coverage/
8
+ /InstalledFiles
9
+ /doc/
10
+ /pkg/
11
+ /spec/reports/
12
+ /spec/examples.txt
13
+ /test/tmp/
14
+ /test/version_tmp/
15
+ /tmp/
16
+ /.idea
17
+
18
+
19
+ # Used by dotenv library to load environment variables.
20
+ # rspec failure tracking
21
+ # .env
22
+ .rspec_status
23
+
24
+ # Ignore Byebug command history file.
25
+ .byebug_history
26
+
27
+ ## Specific to RubyMotion:
28
+ .dat*
29
+ .repl_history
30
+ build/
31
+ *.bridgesupport
32
+ build-iPhoneOS/
33
+ build-iPhoneSimulator/
34
+
35
+ ## Specific to RubyMotion (use of CocoaPods):
36
+ #
37
+ # We recommend against adding the Pods directory to your .gitignore. However
38
+ # you should judge for yourself, the pros and cons are mentioned at:
39
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
40
+ #
41
+ # vendor/Pods/
42
+
43
+ ## Documentation cache and generated files:
44
+ /.yardoc/
45
+ /_yardoc/
46
+ /doc/
47
+ /rdoc/
48
+
49
+ ## Environment normalization:
50
+ /vendor/bundle
51
+ /lib/bundler/man/
52
+
53
+ # for a library or gem, you might want to ignore these files since the code is
54
+ # intended to run in multiple environments; otherwise, check them in:
55
+ Gemfile.lock
56
+ .ruby-version
57
+ .ruby-gemset
58
+
59
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
60
+ .rvmrc
61
+
62
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
63
+ # .rubocop-https?--*
64
+
65
+
66
+
67
+
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.8
7
+ before_install: gem install bundler -v 1.17.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in peopledatalabs.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 People Data Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,153 @@
1
+ <p align="center">
2
+ <img src="https://i.imgur.com/S7DkZtr.png" width="250" alt="People Data Labs Logo">
3
+ </p>
4
+ <h1 align="center">People Data Labs Ruby Library</h1>
5
+ <p align="center">Official Ruby client for the People Data Labs API.</p>
6
+
7
+ <p align="center">
8
+ <a href="">
9
+ <img src="https://img.shields.io/badge/repo%20status-Active-limegreen" alt="Repo Status">
10
+ </a>&nbsp;
11
+ <a href="https://rubygems.org/gems/peopledatalabs">
12
+ <img src="https://img.shields.io/gem/v/twilio-ruby.svg" alt="People Data Labs on RubyGems" />
13
+ </a>&nbsp;
14
+ <a href="">
15
+ <img src="https://github.com/peopledatalabs/peopledatalabs-ruby/actions/workflows/test.yaml/badge.svg" alt="Tests Status" />
16
+ </a>
17
+ </p>
18
+
19
+ #
20
+ This is a simple Ruby client library to access the various API endpoints provided by [People Data Labs](https://www.peopledatalabs.com/).
21
+
22
+ This library bundles up PDL API requests into simple function calls, making it easy to integrate into your projects. You can use the various [API endpoints](#endpoints) to access up-to-date, real-world data from our massive [Person](https://docs.peopledatalabs.com/docs/stats) and [Company](https://docs.peopledatalabs.com/docs/company-stats) Datasets.
23
+
24
+ ## Table of Contents
25
+ - [🔧 Installation](#installation)
26
+ - [🚀 Usage](#usage)
27
+ - [🌐 Endpoints](#endpoints)
28
+ - [📘 Documentation](#documentation)
29
+
30
+ ## Installation <a name="installation"></a>
31
+
32
+ 1. Add this line to your application's Gemfile:
33
+
34
+ ```ruby
35
+ gem 'peopledatalabs'
36
+ ```
37
+
38
+ 2. And then execute:
39
+
40
+ ```bash
41
+ $ bundle
42
+ ```
43
+
44
+ Or install it yourself as:
45
+
46
+ ```bash
47
+ $ gem install peopledatalabs
48
+ ```
49
+
50
+ 3. Sign up for a [free PDL API key](https://www.peopledatalabs.com/signup)
51
+
52
+ ## 🚀 Usage <a name="usage"></a>
53
+
54
+ First, add your API Key:
55
+ ```ruby
56
+ Peopledatalabs.api_key = 'api_key'
57
+ ```
58
+
59
+ Then, send requests to any PDL API Endpoint:
60
+
61
+ **Getting Person Data**
62
+ ```ruby
63
+ # By Enrichment
64
+ Peopledatalabs::Enrichment.person(params: { phone: '4155688415' })
65
+
66
+ # By Bulk Enrichment
67
+ Peopledatalabs::Bulk.people(params: {requests: [{params: {profile: ['linkedin.com/in/seanthorne']}}, {params: {profile: ['linkedin.com/in/randrewn']}}]})
68
+
69
+ # By Search (SQL)
70
+ Peopledatalabs::Search.people(searchType: 'sql', query: "SELECT * FROM person WHERE job_company_name='people data labs'")
71
+
72
+ # By Search (Elasticsearch)
73
+ Peopledatalabs::Search.people(searchType: 'elastic', query: {"query": {"term": {"job_company_name": "people data labs"}}})
74
+
75
+ # By PDL_ID
76
+ Peopledatalabs::Retrieve.person(person_id: 'qEnOZ5Oh0poWnQ1luFBfVw_0000')
77
+
78
+ # By Fuzzy Enrichment
79
+ Peopledatalabs::Identify.person(params: { name: 'sean thorne' })
80
+ ```
81
+
82
+ **Getting Company Data**
83
+ ```ruby
84
+ # By Enrichment
85
+ Peopledatalabs::Enrichment.company(params: { website: 'peopledatalabs.com' })
86
+
87
+ # By Search (SQL)
88
+ Peopledatalabs::Search.company(searchType: 'sql', query: "SELECT * FROM company WHERE tags='big data' AND industry='financial services' AND location.country='united states'")
89
+
90
+ # By Search (Elasticsearch)
91
+ Peopledatalabs::Search.company(searchType: 'elastic', query: {"query": "must": [{"term": {"tags": "big data"}}, {"term": {"industry": "financial services"}}, {"term": {"location_country": "united states"}}]})
92
+ ```
93
+
94
+ **Using Supporting APIs**
95
+ ```ruby
96
+ # Get Autocomplete Suggestions
97
+ Peopledatalabs::Autocomplete.retrieve(field: 'title', text: 'full', size: 10)
98
+
99
+ # Clean Raw Company Strings
100
+ Peopledatalabs::Cleaner.company(kind: 'name', value: 'peOple DaTa LabS')
101
+
102
+ # Clean Raw Location Strings
103
+ Peopledatalabs::Cleaner.location(value: '455 Market Street, San Francisco, California 94105, US')
104
+
105
+ # Clean Raw School Strings
106
+ Peopledatalabs::Cleaner.school(kind: 'name', value: 'university of oregon')
107
+ ```
108
+
109
+ ## 🌐 Endpoints <a name="endpoints"></a>
110
+
111
+ **Person Endpoints**
112
+ | API Endpoint | peopledatalabs Function |
113
+ |-|-|
114
+ | [Person Enrichment API](https://docs.peopledatalabs.com/docs/enrichment-api) | `Peopledatalabs::Enrichment.person(...params)` |
115
+ | [Person Bulk Person Enrichment API](https://docs.peopledatalabs.com/docs/bulk-enrichment-api) | `Peopledatalabs::Bulk.people(...records)` |
116
+ | [Person Search API](https://docs.peopledatalabs.com/docs/search-api) | `Peopledatalabs::Search.person(...params)` |
117
+ | [Person Retrieve API](https://docs.peopledatalabs.com/docs/person-retrieve-api) | `Peopledatalabs::Autocomplete.retrieve(...params)` |
118
+ | [Person Identify API](https://docs.peopledatalabs.com/docs/identify-api) | `Peopledatalabs::Identify.person(...params)` |
119
+
120
+ **Company Endpoints**
121
+ | API Endpoint | peopledatalabs Function |
122
+ |-|-|
123
+ | [Company Enrichment API](https://docs.peopledatalabs.com/docs/company-enrichment-api) | `Peopledatalabs::Enrichment.company(...params)` |
124
+ | [Company Search API](https://docs.peopledatalabs.com/docs/company-search-api) | `Peopledatalabs::Search.company(...params)` |
125
+
126
+ **Supporting Endpoints**
127
+ | API Endpoint | peopledatalabs Function |
128
+ |-|-|
129
+ | [Autocomplete API](https://docs.peopledatalabs.com/docs/autocomplete-api) | `Peopledatalabs::Autocomplete.retrieve(...params)` |
130
+ | [Company Cleaner API](https://docs.peopledatalabs.com/docs/cleaner-apis#companyclean) | `Peopledatalabs::Cleaner.company(...params)` |
131
+ | [Location Cleaner API](https://docs.peopledatalabs.com/docs/cleaner-apis#locationclean) | `Peopledatalabs::Cleaner.location(...params)` |
132
+ | [School Cleaner API](https://docs.peopledatalabs.com/docs/cleaner-apis#schoolclean) | `Peopledatalabs::Cleaner.school(...params)` |
133
+
134
+
135
+ ## 📘 Documentation <a name="documentation"></a>
136
+
137
+ All of our API endpoints are documented at: https://docs.peopledatalabs.com/
138
+
139
+ These docs describe the supported input parameters, output responses and also provide additional technical context.
140
+
141
+ As illustrated in the [Endpoints](#endpoints) section above, each of our API endpoints is mapped to a specific method in the peopledatalabs class. For each of these class methods, **all function inputs are mapped as input parameters to the respective API endpoint**, meaning that you can use the API documentation linked above to determine the input parameters for each endpoint.
142
+
143
+ As an example:
144
+
145
+ The following is **valid** because `name` is a [supported input parameter to the Person Identify API](https://docs.peopledatalabs.com/docs/identify-api-reference#input-parameters):
146
+ ```ruby
147
+ Peopledatalabs::Identify.person(params: { name: 'sean thorne' })
148
+ ```
149
+
150
+ Conversely, this would be **invalid** because `fake_parameter` is not an input parameter to the Person Identify API:
151
+ ```ruby
152
+ Peopledatalabs::Identify.person(params: { fake_parameter: 'anything' })
153
+ ```
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "peopledatalabs"
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/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,119 @@
1
+ module Peopledatalabs
2
+ class APIResource
3
+
4
+ protected
5
+
6
+ VALID_AUTOCOMPLETE_FIELDS = ['company', 'country', 'industry', 'location', 'major', 'region', 'role', 'school', 'sub_role', 'skill', 'title'].freeze
7
+
8
+ def self.get(path:, headers: {}, params: {})
9
+ request = check(params: params, path: path)
10
+ return request unless request['status'] == 200
11
+
12
+ response = HTTP
13
+ .timeout(Peopledatalabs.read_timeout)
14
+ .headers(headers)
15
+ .get(url(path), params: query_authentication(params))
16
+ handle_response(response)
17
+ end
18
+
19
+ def self.post(path:, headers: {}, body: {})
20
+ request = check(params: body, path: path)
21
+ return request unless request['status'] == 200
22
+
23
+ response = HTTP
24
+ .timeout(Peopledatalabs.read_timeout)
25
+ .headers(header_authentication(headers))
26
+ .post(url(path), json: body)
27
+ handle_response(response)
28
+ end
29
+
30
+ def self.url(path)
31
+ "#{Peopledatalabs.api_base}#{path}"
32
+ end
33
+
34
+ def self.query_authentication(params)
35
+ params.merge({ :api_key => Peopledatalabs.api_key })
36
+ end
37
+
38
+ def self.header_authentication(headers)
39
+ headers.merge({ 'X-Api-Key' => Peopledatalabs.api_key })
40
+ end
41
+
42
+ def self.to_number(number)
43
+ return number if number.nil?
44
+
45
+ Float(number)
46
+ i, f = number.to_i, number.to_f
47
+ i == f ? i : f
48
+ rescue ArgumentError
49
+ nil
50
+ end
51
+
52
+ def self.check(params:, path:)
53
+ result = { 'status' => 200 }
54
+
55
+ if !Peopledatalabs.api_key
56
+ result = {
57
+ 'status' => 401,
58
+ 'message' => 'Invalid API Key'
59
+ }
60
+ elsif !Peopledatalabs.api_base
61
+ result = {
62
+ 'status' => 400,
63
+ 'message' => 'Missing API Base Path'
64
+ }
65
+ elsif params.empty?
66
+ result = {
67
+ 'status' => 400,
68
+ 'message' => "Missing Params"
69
+ }
70
+ elsif path.include? '/search'
71
+ query = params['sql'] || params['query']
72
+ result = { 'status' => 400, 'message' => 'Missing searchQuery' } unless query
73
+ elsif path.include?'/retrieve'
74
+ result = { 'status' => 400, 'message' => 'Missing id' } unless path.match(/\/retrieve\/.+$/)
75
+ elsif path.include? '/autocomplete'
76
+ field = params['field']
77
+ if (!field)
78
+ result = { 'status' => 400, 'message' => 'Missing field' }
79
+ elsif (!VALID_AUTOCOMPLETE_FIELDS.include?(field))
80
+ result = { 'status' => 400, 'message' => "Field should be one of: #{VALID_AUTOCOMPLETE_FIELDS.join(', ')}" }
81
+ end
82
+ end
83
+ result
84
+ end
85
+
86
+ def self.handle_response(response)
87
+ # Would prefer to keep consistent and always put it in data but right now matching the js lib response
88
+ # {
89
+ # 'retry_after' => to_number(response.headers['Retry-After']),
90
+ # 'rate_limit' => to_number(response.headers['X-RateLimit-Limit']),
91
+ # 'rateLimit_reset' => to_number(response.headers['X-RateLimit-Reset']),
92
+ # 'total_limit' => to_number(response.headers['X-TotalLimit-Limit']),
93
+ # 'total_limit_remaining' => to_number(response.headers['X-RateLimit-Remaining']),
94
+ # 'search_limit_remaining' => to_number(response.headers['X-SearchLimit-Remaining']),
95
+ # 'enrich_company_limit_remaining' => to_number(response.headers['X-EnrichCompanyLimit-Remaining']),
96
+ # 'person_identify_limit_remaining' => to_number(response.headers['X-PersonIdentifyLimit-Remaining'])
97
+ # 'data' => response.parse
98
+ # }
99
+
100
+ rate_limit = {
101
+ 'retry_after' => to_number(response.headers['Retry-After']),
102
+ 'rate_limit' => to_number(response.headers['X-RateLimit-Limit']),
103
+ 'rateLimit_reset' => to_number(response.headers['X-RateLimit-Reset']),
104
+ 'total_limit' => to_number(response.headers['X-TotalLimit-Limit']),
105
+ 'total_limit_remaining' => to_number(response.headers['X-RateLimit-Remaining']),
106
+ 'search_limit_remaining' => to_number(response.headers['X-SearchLimit-Remaining']),
107
+ 'enrich_company_limit_remaining' => to_number(response.headers['X-EnrichCompanyLimit-Remaining']),
108
+ 'person_identify_limit_remaining' => to_number(response.headers['X-PersonIdentifyLimit-Remaining'])
109
+ }
110
+
111
+ parsed_response = response.parse
112
+ if response.parse.is_a? Array
113
+ rate_limit.merge('items' => parsed_response)
114
+ else
115
+ rate_limit.merge(parsed_response)
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peopledatalabs
4
+ class Configuration
5
+ attr_accessor :api_key
6
+ attr_accessor :api_base
7
+ attr_accessor :read_timeout
8
+
9
+ def self.setup
10
+ new.tap do |instance|
11
+ yield(instance) if block_given?
12
+ end
13
+ end
14
+
15
+ def initialize
16
+ @api_base = "https://api.peopledatalabs.com"
17
+ @read_timeout = 10
18
+ @api_key ||= ENV['PDL_API_KEY']
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peopledatalabs
4
+ class Autocomplete < APIResource
5
+ def self.retrieve(field:, text: '', size: 10, pretty: false)
6
+
7
+ params = {
8
+ 'field' => field,
9
+ 'text' => text,
10
+ 'size' => size,
11
+ 'pretty' => pretty,
12
+ };
13
+
14
+ # headers = { 'Accept-Encoding' => 'gzip' }
15
+ get(path: '/v5/autocomplete', params: params)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peopledatalabs
4
+ class Bulk < APIResource
5
+ def self.people(params:)
6
+ # TODO: possibly add gzip encoding
7
+ # headers = { 'Accept-Encoding' => 'gzip' }
8
+ post(path: '/v5/person/bulk', body: params)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peopledatalabs
4
+ class Cleaner < APIResource
5
+ def self.company(kind:, value:)
6
+ # TODO: possibly add gzip encoding
7
+ # headers = { 'Accept-Encoding' => 'gzip' }
8
+ get(path: '/v5/company/clean', params: { kind => value })
9
+ end
10
+
11
+ def self.school(kind:, value:)
12
+ # TODO: possibly add gzip encoding
13
+ # headers = { 'Accept-Encoding' => 'gzip' }
14
+ get(path: '/v5/school/clean', params: { kind => value })
15
+ end
16
+
17
+ def self.location(value:)
18
+ # TODO: possibly add gzip encoding
19
+ # headers = { 'Accept-Encoding' => 'gzip' }
20
+ get(path: '/v5/location/clean', params: { 'location' => value })
21
+ end
22
+
23
+
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peopledatalabs
4
+ class Enrichment < APIResource
5
+ def self.person(params:)
6
+ # TODO: possibly add gzip encoding
7
+ # headers = { 'Accept-Encoding' => 'gzip' }
8
+ get(path: '/v5/person/enrich', params: params)
9
+ end
10
+
11
+ def self.company(params:)
12
+ # TODO: possibly add gzip encoding
13
+ # headers = { 'Accept-Encoding' => 'gzip' }
14
+ get(path: '/v5/company/enrich', params: params)
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peopledatalabs
4
+ class Identify < APIResource
5
+ def self.person(params:)
6
+ # TODO: possibly add gzip encoding
7
+ # headers = { 'Accept-Encoding' => 'gzip' }
8
+ get(path: '/v5/person/identify', params: params)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peopledatalabs
4
+ class Retrieve < APIResource
5
+ def self.person(person_id:, pretty: false)
6
+ # TODO: possibly add gzip encoding
7
+ # headers = { 'Accept-Encoding' => 'gzip' }
8
+ get(path: "/v5/person/retrieve/#{person_id}", params: { 'pretty' => pretty })
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Peopledatalabs
4
+ class Search < APIResource
5
+ def self.people(searchType:, query: , titlecase: false, dataset: 'all', size: 10, pretty: false, scroll_token: nil)
6
+ search(searchType: searchType,
7
+ query: query,
8
+ titlecase: titlecase,
9
+ dataset: dataset, size: size,
10
+ pretty: pretty,
11
+ scroll_token: scroll_token,
12
+ kind: 'person')
13
+ end
14
+
15
+ def self.company(searchType:, query: , titlecase: false, dataset: 'all', size: 10, pretty: false, scroll_token: nil)
16
+ search(searchType: searchType,
17
+ query: query,
18
+ titlecase: titlecase,
19
+ dataset: dataset, size: size,
20
+ pretty: pretty,
21
+ scroll_token: scroll_token,
22
+ kind: 'company')
23
+ end
24
+
25
+ def self.search(searchType:, query:, kind:, titlecase: false, dataset: 'all', size: 10, pretty: false, scroll_token: nil)
26
+
27
+ body = {
28
+ searchType === 'sql' ? 'sql' : 'query' => query,
29
+ dataset => dataset,
30
+ size => size,
31
+ pretty => pretty,
32
+ titlecase => titlecase,
33
+ scroll_token => scroll_token
34
+ }
35
+
36
+ # TODO: possibly add gzip encoding
37
+ # headers = { 'Accept-Encoding' => 'gzip' }
38
+ post(path: "/v5/#{kind}/search", body: body)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module Peopledatalabs
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,56 @@
1
+ require "forwardable"
2
+ require "http"
3
+ require "peopledatalabs/version"
4
+ require 'peopledatalabs/configuration'
5
+ require 'peopledatalabs/api_resource'
6
+ require 'peopledatalabs/resources/cleaner'
7
+ require 'peopledatalabs/resources/search'
8
+ require 'peopledatalabs/resources/autocomplete'
9
+ require 'peopledatalabs/resources/enrichment'
10
+ require 'peopledatalabs/resources/identify'
11
+ require 'peopledatalabs/resources/retrieve'
12
+ require 'peopledatalabs/resources/bulk'
13
+
14
+
15
+ # gem build peopledatalabs.gemspec
16
+ # gem install ./peopledatalabs-1.0.0.gem
17
+ # irb
18
+ # require 'peopledatalabs'
19
+
20
+ # Usage
21
+ # First set api key
22
+ # Peopledatalabs.api_key = 'api_key'
23
+ # Examples Calls:
24
+ # Peopledatalabs::Cleaner.company(kind: 'website', value: 'peopledatalabs.com')
25
+ # Peopledatalabs::Cleaner.school(kind: 'profile', value: 'linkedin.com/school/ucla')
26
+ # Peopledatalabs::Cleaner.location(value: '239 NW 13th Ave, Portland, Oregon 97209, US')
27
+ # Peopledatalabs::Search.people(searchType: 'elastic', query: {"query": {"term": {"job_company_name": "people data labs"}}})
28
+ # Peopledatalabs::Search.people(searchType: 'sql', query: "SELECT * FROM person WHERE job_company_name='people data labs'")
29
+ # Peopledatalabs::Autocomplete.retrieve(field: 'school', text: 'university of michigan')
30
+ # Peopledatalabs::Enrichment.person(params: { name: 'Jennifer C. Jackson', locality: 'Boise' })
31
+ # Peopledatalabs::Bulk.people(params: {requests: [{params: {profile: ['linkedin.com/in/seanthorne']}}, {params: {profile: ['linkedin.com/in/randrewn']}}]})
32
+ # Peopledatalabs::Enrichment.company(params: { name: 'Google, Inc.', ticker: 'GOOGL'})
33
+ # Peopledatalabs::Identify.person(params: { name: 'Jennifer C. Jackson', location: 'Medford, OR USA' })
34
+ # Peopledatalabs::Retrieve.person(person_id: 'qEnOZ5Oh0poWnQ1luFBfVw_0000')
35
+ # Peopledatalabs::Search.company(searchType: 'sql', size: 10, query: "SELECT * FROM company WHERE tags='big data' AND industry='financial services' AND location.country='united states';")
36
+ # Peopledatalabs::Search.company(searchType: 'elastic', size: 10, query: { query: { bool: { must: [{term: {location_country: 'mexico'}}, {term: {job_title_role: 'health'}}, {exists: {field: 'phone_numbers'}}]}}})
37
+
38
+ module Peopledatalabs
39
+ class Error < StandardError; end
40
+
41
+ @config = Peopledatalabs::Configuration.setup
42
+
43
+ class << self
44
+ extend Forwardable
45
+
46
+ attr_reader :config
47
+
48
+ def_delegators :@config, :api_key, :api_key=
49
+ def_delegators :@config, :api_base, :api_base=
50
+ def_delegators :@config, :read_timeout, :read_timeout=
51
+ end
52
+ end
53
+
54
+
55
+
56
+
@@ -0,0 +1,43 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "peopledatalabs/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "peopledatalabs"
8
+ spec.version = Peopledatalabs::VERSION
9
+ spec.authors = ["People Data Labs"]
10
+ spec.email = ["hello@peopledatalabs.com"]
11
+
12
+ spec.summary = "Official Ruby client for the People Data Labs API."
13
+ spec.description = "People Data Labs builds people data. Use our dataset of 1.5 Billion unique person profiles to build products, enrich person profiles, power predictive modeling/ai, analysis, and more."
14
+ spec.homepage = "https://www.peopledatalabs.com"
15
+ spec.license = "MIT"
16
+
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/peopledatalabs/peopledatalabs-ruby"
20
+ spec.metadata["github_repo"] = "https://github.com/peopledatalabs/peopledatalabs-ruby"
21
+ spec.metadata["documentation_uri"] = "https://docs.peopledatalabs.com"
22
+ spec.metadata["bug_tracker_uri"] = "https://github.com/peopledatalabs/peopledatalabs-ruby/issues"
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against " \
25
+ "public gem pushes."
26
+ end
27
+
28
+ # Specify which files should be added to the gem when it is released.
29
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
31
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
+ end
33
+ spec.bindir = "exe"
34
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ["lib"]
36
+
37
+ spec.add_development_dependency "bundler", "~> 2.3"
38
+ spec.add_development_dependency "rake", "~> 13.0"
39
+ spec.add_development_dependency "rspec", "~> 3.0"
40
+
41
+ spec.add_runtime_dependency "http", "~> 5.0"
42
+ spec.add_runtime_dependency "forwardable", "~> 1.3"
43
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: peopledatalabs
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - People Data Labs
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: http
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: forwardable
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ description: People Data Labs builds people data. Use our dataset of 1.5 Billion unique
84
+ person profiles to build products, enrich person profiles, power predictive modeling/ai,
85
+ analysis, and more.
86
+ email:
87
+ - hello@peopledatalabs.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
93
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
94
+ - ".github/pull_request_template.md"
95
+ - ".github/workflows/publish.yaml"
96
+ - ".github/workflows/test.yaml"
97
+ - ".gitignore"
98
+ - ".rspec"
99
+ - ".travis.yml"
100
+ - Gemfile
101
+ - LICENSE
102
+ - README.md
103
+ - Rakefile
104
+ - bin/console
105
+ - bin/setup
106
+ - lib/peopledatalabs.rb
107
+ - lib/peopledatalabs/api_resource.rb
108
+ - lib/peopledatalabs/configuration.rb
109
+ - lib/peopledatalabs/resources/autocomplete.rb
110
+ - lib/peopledatalabs/resources/bulk.rb
111
+ - lib/peopledatalabs/resources/cleaner.rb
112
+ - lib/peopledatalabs/resources/enrichment.rb
113
+ - lib/peopledatalabs/resources/identify.rb
114
+ - lib/peopledatalabs/resources/retrieve.rb
115
+ - lib/peopledatalabs/resources/search.rb
116
+ - lib/peopledatalabs/version.rb
117
+ - peopledatalabs.gemspec
118
+ homepage: https://www.peopledatalabs.com
119
+ licenses:
120
+ - MIT
121
+ metadata:
122
+ homepage_uri: https://www.peopledatalabs.com
123
+ source_code_uri: https://github.com/peopledatalabs/peopledatalabs-ruby
124
+ github_repo: https://github.com/peopledatalabs/peopledatalabs-ruby
125
+ documentation_uri: https://docs.peopledatalabs.com
126
+ bug_tracker_uri: https://github.com/peopledatalabs/peopledatalabs-ruby/issues
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubygems_version: 3.0.3.1
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Official Ruby client for the People Data Labs API.
146
+ test_files: []