Skip to content

Commit 6326bd3

Browse files
authored
add person changelog (#29)
1 parent 1027325 commit 6326bd3

File tree

6 files changed

+52
-1
lines changed

6 files changed

+52
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ Peopledatalabs::Retrieve.person(person_id: 'qEnOZ5Oh0poWnQ1luFBfVw_0000')
7979

8080
# By Fuzzy Enrichment
8181
Peopledatalabs::Identify.person(params: { name: 'sean thorne' })
82+
83+
# By Changelog
84+
Peopledatalabs::Changelog.person(params: { current_version: '31.0', origin_version: '30.2', type: 'updated' })
8285
```
8386

8487
**Using Company APIs**
@@ -142,6 +145,7 @@ Peopledatalabs.sandbox = true
142145
| [Person Search API](https://docs.peopledatalabs.com/docs/search-api) | `Peopledatalabs::Search.person(...params)` |
143146
| [Person Retrieve API](https://docs.peopledatalabs.com/docs/person-retrieve-api) | `Peopledatalabs::Autocomplete.retrieve(...params)` |
144147
| [Person Identify API](https://docs.peopledatalabs.com/docs/identify-api) | `Peopledatalabs::Identify.person(...params)` |
148+
| [Person Changelog API](https://docs.peopledatalabs.com/docs/person-changelog-api) | `Peopledatalabs::Changelog.person(...params)` |
145149

146150
**Company Endpoints**
147151
| API Endpoint | peopledatalabs Function |

lib/peopledatalabs.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
require 'peopledatalabs/resources/retrieve'
1212
require 'peopledatalabs/resources/bulk'
1313
require 'peopledatalabs/resources/jobtitle'
14+
require 'peopledatalabs/resources/changelog'
1415

1516

1617
# gem build peopledatalabs.gemspec
@@ -40,6 +41,7 @@
4041
# Peopledatalabs::Search.company(searchType: 'elastic', size: 10, query: { query: { bool: { must: [{term: {location_country: 'mexico'}}, {term: {job_title_role: 'health'}}, {exists: {field: 'phone_numbers'}}]}}})
4142
# Peopledatalabs::JobTitle.retrieve(job_title: 'data scientist')
4243
# Peopledatalabs::Enrichment.ip(ip: '72.212.42.169')
44+
# Peopledatalabs::Changelog.person(params: { current_version: '31.0', origin_version: '30.2', type: 'updated' })
4345

4446
module Peopledatalabs
4547
class Error < StandardError; end

lib/peopledatalabs/api_resource.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ def self.check(params:, path:)
9191
if (!field)
9292
result = { 'status' => 400, 'message' => 'Missing ip' }
9393
end
94+
elsif path.include? '/changelog'
95+
current_version = params['current_version']
96+
origin_version = params['origin_version']
97+
if !current_version || !origin_version
98+
result = { 'status' => 400, 'message' => 'Missing current_version or origin_version' }
99+
elsif !params['ids'] && !params['type']
100+
result = { 'status' => 400, 'message' => 'Missing ids or type' }
101+
end
94102
end
95103
result
96104
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
module Peopledatalabs
4+
class Changelog < APIResource
5+
def self.person(params:)
6+
headers = {
7+
'Accept-Encoding' => 'gzip',
8+
'User-Agent' => 'PDL-RUBY-SDK',
9+
}
10+
11+
stringified_params = params.transform_keys(&:to_s)
12+
13+
post(path: '/v5/person/changelog', headers: headers, body: stringified_params)
14+
end
15+
end
16+
end

lib/peopledatalabs/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Peopledatalabs
2-
VERSION = "5.1.0"
2+
VERSION = "5.2.0"
33
end

spec/peopledatalabs_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,27 @@
125125
end
126126

127127

128+
describe 'person changelog' do
129+
it "should return changelog records" do
130+
result = Peopledatalabs::Changelog.person(params: {
131+
current_version: '31.0',
132+
origin_version: '30.2',
133+
type: 'updated',
134+
})
135+
expect(result).to have_key('data')
136+
expect(result['data']['type']).to eq('updated')
137+
end
138+
139+
it "should error" do
140+
result = Peopledatalabs::Changelog.person(params: {
141+
current_version: '31.0',
142+
origin_version: '30.2'
143+
})
144+
expect(result['status']).to eq(400)
145+
end
146+
end
147+
148+
128149
describe 'company enrichment' do
129150
it "should return company record for a website" do
130151
result = Peopledatalabs::Enrichment.company(params: { website: 'peopledatalabs.com' })

0 commit comments

Comments
 (0)