Skip to content

Commit

Permalink
Add Insights Types, filter_updated param to retrieve, add bulk Retrie…
Browse files Browse the repository at this point in the history
…ve and export Person/Company Response (#46)

* add types for insights fields

* add recommended_personal_email

* update package version

* add filter_updated

* add gics_sector and mic_exchange

* simplify types

* add bulk retrieve

* change to major version change

* update dependencies

* fix it for bulk retrieve test

* fix tsconfig

* lint rules

* fix tsconfig

* package updates

* rename location for bulkEnrichment

* upgrade note readme

* fix docs link
  • Loading branch information
vvillait88 authored Jan 16, 2023
1 parent 692c1e4 commit bbfbca8
Show file tree
Hide file tree
Showing 29 changed files with 667 additions and 159 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ module.exports = {
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: './tsconfig.json',
project: './tsconfig.eslint.json',
},
plugins: [
'@typescript-eslint',
'simple-import-sort',
],
rules: {
'max-len': 'off',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'object-curly-newline': 'off',
},
};
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ This library bundles up PDL API requests into simple function calls, making it e
- [🌐 Endpoints](#endpoints)
- [📘 Documentation](#documentation)
- [Special Note about Search API Support](#special-note)
- [Upgrading to v5.X.X](#upgrading-to-v5)


## 🔧 Installation <a name="installation"></a>
Expand Down Expand Up @@ -72,7 +73,7 @@ PDLJSClient.person.enrichment({ phone: '4155688415' }).then((data) => {
});

// By Bulk Enrichment
const records = {
const bulkEnrichmentRecords = {
requests: [
{
params: {
Expand All @@ -87,7 +88,7 @@ const records = {
],
};

PDLJSClient.person.bulk(records).then((data) => {
PDLJSClient.person.bulk.enrichment(bulkEnrichmentRecords).then((data) => {
console.log(data.items);
}).catch((error) => {
console.log(error);
Expand Down Expand Up @@ -128,6 +129,20 @@ PDLJSClient.person.retrieve({ id: 'qEnOZ5Oh0poWnQ1luFBfVw_0000' }).then((data) =
console.log(error);
});

// By Bulk Retrieve
const bulkRetrieveRecords = {
requests: [
{ id: 'qEnOZ5Oh0poWnQ1luFBfVw_0000' },
{ id: 'PzFD15NINdBWNULBBkwlig_0000' },
],
};

PDLJSClient.person.bulk.retrieve(bulkRetrieveRecords).then((data) => {
console.log(data.items);
}).catch((error) => {
console.log(error);
});

// By Fuzzy Enrichment
PDLJSClient.person.identify({ name: 'sean thorne' }).then((data) => {
console.log(data);
Expand Down Expand Up @@ -281,9 +296,10 @@ PDLJSClient.person.identify({ company: 'walmart', sandbox: true }).then((data) =
| API Endpoint | PDLJS Function |
|-|-|
| [Person Enrichment API](https://docs.peopledatalabs.com/docs/enrichment-api) | `PDLJS.person.enrichment({ ...params })` |
| [Person Bulk Person Enrichment API](https://docs.peopledatalabs.com/docs/bulk-enrichment-api) | `PDLJS.person.bulk({ ...records })` |
| [Person Bulk Person Enrichment API](https://docs.peopledatalabs.com/docs/bulk-enrichment-api) | `PDLJS.person.bulk.enrichment({ ...records })` |
| [Person Search API](https://docs.peopledatalabs.com/docs/search-api) | SQL: `PDLJS.person.search.sql({ ...params })` <br/> Elasticsearch: `PDLJS.person.search.elastic({ ...params })`|
| [Person Retrieve API](https://docs.peopledatalabs.com/docs/person-retrieve-api) | `PDLJS.person.retrieve({ ...params })` |
| [Person Bulk Person Retrieve API](https://docs.peopledatalabs.com/docs/bulk-person-retrieve) | `PDLJS.person.bulk.retrieve({ ...records })` |
| [Person Identify API](https://docs.peopledatalabs.com/docs/identify-api) | `PDLJS.person.identify({ ...params })` |

**Company Endpoints**
Expand Down Expand Up @@ -354,3 +370,7 @@ PDLJSClient.company.search.sql({ searchQuery: sqlQuery, size: 10 }).then((data)
console.log(error);
});
```

#### Upgrading to v5.X.X <a name="upgrading-to-v5"></a>

NOTE: When upgrading to v5.X.X from v4.X.X and below, Bulk Enrichment was moved from `PDLJS.person.bulk({ ...records })` to `PDLJS.person.bulk.enrichment({ ...records })`
18 changes: 15 additions & 3 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint no-console: "off" */

import dotenv from 'dotenv';

import PDLJS from 'peopledatalabs';

dotenv.config({ path: '../.env.local' });
Expand All @@ -22,14 +21,14 @@ PDLJSClient.person.identify({ phone: '4155688415' }).then((data) => {
console.log(error);
});

const records = {
const bulkEnrichmentRecords = {
requests: [
{ params: { profile: ['linkedin.com/in/seanthorne'] } },
{ params: { profile: ['linkedin.com/in/randrewn'] } },
],
};

PDLJSClient.person.bulk(records).then((data) => {
PDLJSClient.person.bulk.enrichment(bulkEnrichmentRecords).then((data) => {
console.log(data.items);
}).catch((error) => {
console.log(error);
Expand All @@ -50,6 +49,19 @@ PDLJSClient.person.retrieve({ id: 'qEnOZ5Oh0poWnQ1luFBfVw_0000' }).then((data) =
console.log(error);
});

const bulkRetrieveRecords = {
requests: [
{ id: 'qEnOZ5Oh0poWnQ1luFBfVw_0000' },
{ id: 'PzFD15NINdBWNULBBkwlig_0000' },
],
};

PDLJSClient.person.bulk.retrieve(bulkRetrieveRecords).then((data) => {
console.log(data.items);
}).catch((error) => {
console.log(error);
});

// Company APIs

PDLJSClient.company.enrichment({ website: 'peopledatalabs.com' }).then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "People Data Labs",
"license": "MIT",
"dependencies": {
"dotenv": "^14.2.0",
"dotenv": "^16.0.3",
"peopledatalabs": "*"
}
}
}
8 changes: 4 additions & 4 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ axios@^0.24.0:
dependencies:
follow-redirects "^1.14.4"

dotenv@^14.2.0:
version "14.3.2"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-14.3.2.tgz#7c30b3a5f777c79a3429cb2db358eef6751e8369"
integrity sha512-vwEppIphpFdvaMCaHfCEv9IgwcxMljMw2TnAQBB4VWPvzXQLTb82jwmdOKzlEVUL3gNFT4l4TPKO+Bn+sqcrVQ==
dotenv@^16.0.3:
version "16.0.3"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.3.tgz#115aec42bac5053db3c456db30cc243a5a836a07"
integrity sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==

follow-redirects@^1.14.4:
version "1.15.1"
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "peopledatalabs",
"version": "4.1.0",
"version": "5.0.0",
"description": "JavaScript client with TypeScript support for the People Data Labs API",
"type": "module",
"main": "dist/index.cjs",
Expand All @@ -16,7 +16,8 @@
"dev": "microbundle watch -p 6008",
"test": "yarn run build && yarn run mocha",
"mocha": "mocha --recursive 'tests/**/*.js'",
"pub": "yarn run build && yarn publish"
"pub": "yarn run build && yarn publish",
"lint": "eslint --fix"
},
"repository": {
"type": "git",
Expand All @@ -43,18 +44,19 @@
"homepage": "https://docs.peopledatalabs.com/docs/javascript-sdk",
"devDependencies": {
"@types/lodash": "^4.14.191",
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"chai": "^4.3.7",
"dotenv": "^16.0.3",
"eslint": "^8.31.0",
"eslint": "^8.32.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-plugin-import": "^2.27.4",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^8.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"esm": "^3.2.25",
"microbundle": "^0.15.1",
Expand Down
1 change: 1 addition & 0 deletions src/endpoints/autocomplete/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios';

import { check, errorHandler } from '../../errors';
import type { AutoCompleteParams, AutoCompleteResponse } from '../../types/autocomplete-types';
import { parseRateLimitingResponse } from '../../utils/api-utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios';

import { check, errorHandler } from '../../errors';
import { BulkPersonEnrichmentParams, BulkPersonEnrichmentResponse } from '../../types/bulk-types';
import { parseRateLimitingResponse } from '../../utils/api-utils';
Expand Down
28 changes: 28 additions & 0 deletions src/endpoints/bulkRetrieve/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import axios from 'axios';

import { check, errorHandler } from '../../errors';
import { BulkPersonRetrieveParams, BulkPersonRetrieveResponse } from '../../types/bulk-retrieve-types';
import { parseRateLimitingResponse } from '../../utils/api-utils';

export default (basePath: string, apiKey: string, records: BulkPersonRetrieveParams) => {
const headers = {
'Content-Type': 'application/json',
'Accept-Encoding': 'gzip',
'X-Api-Key': apiKey,
'User-Agent': 'PDL-JS-SDK',
};

return new Promise<BulkPersonRetrieveResponse>((resolve, reject) => {
check(records, basePath, apiKey, 'Records', 'bulk').then(() => {
axios.post<BulkPersonRetrieveResponse>(`${basePath}/person/retrieve/bulk`, records, { headers })
.then((response) => {
resolve(parseRateLimitingResponse(response));
})
.catch((error) => {
reject(errorHandler(error));
});
}).catch((error) => {
reject(error);
});
});
};
1 change: 1 addition & 0 deletions src/endpoints/cleaner/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios';

import { check, errorHandler } from '../../errors';
import { BaseResponse } from '../../types/api-types';
import { CleanerType } from '../../types/cleaner-types';
Expand Down
5 changes: 2 additions & 3 deletions src/endpoints/enrichment/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import axios from 'axios';
import _ from 'lodash';
import {
PersonEnrichmentParams, CompanyEnrichmentParams, EnrichmentType, PersonEnrichmentResponse, CompanyEnrichmentResponse,
} from '../../types/enrichment-types';

import { check, errorHandler } from '../../errors';
import { CompanyEnrichmentParams, CompanyEnrichmentResponse, EnrichmentType, PersonEnrichmentParams, PersonEnrichmentResponse } from '../../types/enrichment-types';
import { parseRateLimitingResponse } from '../../utils/api-utils';

export default <T extends PersonEnrichmentParams | CompanyEnrichmentParams, K extends PersonEnrichmentResponse | CompanyEnrichmentResponse>(
Expand Down
5 changes: 3 additions & 2 deletions src/endpoints/identify/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import _ from 'lodash';
import axios from 'axios';
import _ from 'lodash';

import { check, errorHandler } from '../../errors';
import { IdentifyResponse, IdentifyParams } from '../../types/identify-types';
import { IdentifyParams, IdentifyResponse } from '../../types/identify-types';
import { parseRateLimitingResponse } from '../../utils/api-utils';

export default (
Expand Down
9 changes: 4 additions & 5 deletions src/endpoints/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import autocomplete from './autocomplete';
import bulk from './bulk';
import bulkEnrichment from './bulkEnrichment';
import bulkRetrieve from './bulkRetrieve';
import cleaner from './cleaner';
import enrichment from './enrichment';
import identify from './identify';
import jobTitle from './jobTitle';
import retrieve from './retrieve';
import search from './search';
import jobTitle from './jobTitle';
import skill from './skill';

export {
autocomplete, bulk, cleaner, enrichment, identify, retrieve, search, jobTitle, skill,
};
export { autocomplete, bulkEnrichment, bulkRetrieve, cleaner, enrichment, identify, jobTitle, retrieve, search, skill };
1 change: 1 addition & 0 deletions src/endpoints/jobTitle/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios';

import { check, errorHandler } from '../../errors';
import { JobTitleParams, JobTitleResponse } from '../../types/jobTitle-types';
import { parseRateLimitingResponse } from '../../utils/api-utils';
Expand Down
1 change: 1 addition & 0 deletions src/endpoints/retrieve/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios';

import { check, errorHandler } from '../../errors';
import { RetrieveParams, RetrieveResponse } from '../../types/retrieve-types';
import { parseRateLimitingResponse } from '../../utils/api-utils';
Expand Down
3 changes: 2 additions & 1 deletion src/endpoints/search/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import axios from 'axios';

import { check, errorHandler } from '../../errors';
import { BaseSearchParams, SearchType } from '../../types/search-types';
import { BaseResponse } from '../../types/api-types';
import { BaseSearchParams, SearchType } from '../../types/search-types';
import { parseRateLimitingResponse } from '../../utils/api-utils';

export default <T extends BaseSearchParams, K extends BaseResponse>(
Expand Down
7 changes: 4 additions & 3 deletions src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { AxiosError } from 'axios';
import { ErrorEndpoint } from './types/error-types';
import { BaseSearchParams } from './types/search-types';

import { AutoCompleteParams } from './types/autocomplete-types';
import { RetrieveParams } from './types/retrieve-types';
import { ErrorEndpoint } from './types/error-types';
import { JobTitleParams } from './types/jobTitle-types';
import { RetrieveParams } from './types/retrieve-types';
import { BaseSearchParams } from './types/search-types';
import { SkillParams } from './types/skill-types';

const check = (
Expand Down
Loading

0 comments on commit bbfbca8

Please sign in to comment.