diff --git a/README.md b/README.md index a2ca647..e153783 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,9 @@ Peopledatalabs::Retrieve.person(person_id: 'qEnOZ5Oh0poWnQ1luFBfVw_0000') # By Fuzzy Enrichment Peopledatalabs::Identify.person(params: { name: 'sean thorne' }) + +# By Changelog +Peopledatalabs::Changelog.person(params: { current_version: '31.0', origin_version: '30.2', type: 'updated' }) ``` **Using Company APIs** @@ -142,6 +145,7 @@ Peopledatalabs.sandbox = true | [Person Search API](https://docs.peopledatalabs.com/docs/search-api) | `Peopledatalabs::Search.person(...params)` | | [Person Retrieve API](https://docs.peopledatalabs.com/docs/person-retrieve-api) | `Peopledatalabs::Autocomplete.retrieve(...params)` | | [Person Identify API](https://docs.peopledatalabs.com/docs/identify-api) | `Peopledatalabs::Identify.person(...params)` | +| [Person Changelog API](https://docs.peopledatalabs.com/docs/person-changelog-api) | `Peopledatalabs::Changelog.person(...params)` | **Company Endpoints** | API Endpoint | peopledatalabs Function | diff --git a/lib/peopledatalabs.rb b/lib/peopledatalabs.rb index 44dc76b..8e4971c 100644 --- a/lib/peopledatalabs.rb +++ b/lib/peopledatalabs.rb @@ -11,6 +11,7 @@ require 'peopledatalabs/resources/retrieve' require 'peopledatalabs/resources/bulk' require 'peopledatalabs/resources/jobtitle' +require 'peopledatalabs/resources/changelog' # gem build peopledatalabs.gemspec @@ -40,6 +41,7 @@ # Peopledatalabs::Search.company(searchType: 'elastic', size: 10, query: { query: { bool: { must: [{term: {location_country: 'mexico'}}, {term: {job_title_role: 'health'}}, {exists: {field: 'phone_numbers'}}]}}}) # Peopledatalabs::JobTitle.retrieve(job_title: 'data scientist') # Peopledatalabs::Enrichment.ip(ip: '72.212.42.169') +# Peopledatalabs::Changelog.person(params: { current_version: '31.0', origin_version: '30.2', type: 'updated' }) module Peopledatalabs class Error < StandardError; end diff --git a/lib/peopledatalabs/api_resource.rb b/lib/peopledatalabs/api_resource.rb index ac0c891..a48d98a 100644 --- a/lib/peopledatalabs/api_resource.rb +++ b/lib/peopledatalabs/api_resource.rb @@ -91,6 +91,14 @@ def self.check(params:, path:) if (!field) result = { 'status' => 400, 'message' => 'Missing ip' } end + elsif path.include? '/changelog' + current_version = params['current_version'] + origin_version = params['origin_version'] + if !current_version || !origin_version + result = { 'status' => 400, 'message' => 'Missing current_version or origin_version' } + elsif !params['ids'] && !params['type'] + result = { 'status' => 400, 'message' => 'Missing ids or type' } + end end result end diff --git a/lib/peopledatalabs/resources/changelog.rb b/lib/peopledatalabs/resources/changelog.rb new file mode 100644 index 0000000..4d3382e --- /dev/null +++ b/lib/peopledatalabs/resources/changelog.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Peopledatalabs + class Changelog < APIResource + def self.person(params:) + headers = { + 'Accept-Encoding' => 'gzip', + 'User-Agent' => 'PDL-RUBY-SDK', + } + + stringified_params = params.transform_keys(&:to_s) + + post(path: '/v5/person/changelog', headers: headers, body: stringified_params) + end + end +end diff --git a/lib/peopledatalabs/version.rb b/lib/peopledatalabs/version.rb index 1dd39b3..cdc6e4b 100644 --- a/lib/peopledatalabs/version.rb +++ b/lib/peopledatalabs/version.rb @@ -1,3 +1,3 @@ module Peopledatalabs - VERSION = "5.1.0" + VERSION = "5.2.0" end diff --git a/spec/peopledatalabs_spec.rb b/spec/peopledatalabs_spec.rb index 31923ab..e7bed31 100644 --- a/spec/peopledatalabs_spec.rb +++ b/spec/peopledatalabs_spec.rb @@ -125,6 +125,27 @@ end + describe 'person changelog' do + it "should return changelog records" do + result = Peopledatalabs::Changelog.person(params: { + current_version: '31.0', + origin_version: '30.2', + type: 'updated', + }) + expect(result).to have_key('data') + expect(result['data']['type']).to eq('updated') + end + + it "should error" do + result = Peopledatalabs::Changelog.person(params: { + current_version: '31.0', + origin_version: '30.2' + }) + expect(result['status']).to eq(400) + end + end + + describe 'company enrichment' do it "should return company record for a website" do result = Peopledatalabs::Enrichment.company(params: { website: 'peopledatalabs.com' })