peopledatalabs
Advanced tools
Comparing version 2.0.2 to 3.0.0
@@ -50,3 +50,3 @@ import dotenv from 'dotenv'; | ||
PDLJSClient.person.retrieve('qEnOZ5Oh0poWnQ1luFBfVw_0000').then((data) => { | ||
PDLJSClient.person.retrieve({ id: 'qEnOZ5Oh0poWnQ1luFBfVw_0000' }).then((data) => { | ||
console.log(data); | ||
@@ -53,0 +53,0 @@ }).catch((error) => { |
{ | ||
"name": "peopledatalabs", | ||
"version": "2.0.2", | ||
"description": "An universal client for the People Data Labs API", | ||
"version": "3.0.0", | ||
"description": "JavaScript client with TypeScript support for the People Data Labs API", | ||
"type": "module", | ||
@@ -33,3 +33,3 @@ "main": "dist/index.cjs", | ||
"client", | ||
"universal" | ||
"sdk" | ||
], | ||
@@ -47,3 +47,3 @@ "author": "People Data Labs", | ||
"dotenv": "^16.0.0", | ||
"eslint": "^8.11.0", | ||
"eslint": "^8.14.0", | ||
"eslint-config-airbnb": "^18.2.1", | ||
@@ -50,0 +50,0 @@ "eslint-config-airbnb-base": "^15.0.0", |
<p align="center"> | ||
<img src="https://i.imgur.com/S7DkZtr.png" width="250" alt="People Data Labs Logo"> | ||
</p> | ||
<h1 align="center">People Data Labs JS Library</h1> | ||
<h1 align="center">People Data Labs JavaScript Library</h1> | ||
<p align="center"> | ||
A tiny, universal JS client for the People Data Labs API. | ||
JavaScript client with TypeScript support for the People Data Labs API. | ||
</p> | ||
@@ -123,3 +123,3 @@ | ||
// By PDL_ID | ||
PDLJSClient.person.retrieve('qEnOZ5Oh0poWnQ1luFBfVw_0000').then((data) => { | ||
PDLJSClient.person.retrieve({ id: 'qEnOZ5Oh0poWnQ1luFBfVw_0000' }).then((data) => { | ||
console.log(data); | ||
@@ -126,0 +126,0 @@ }).catch((error) => { |
import axios from 'axios'; | ||
import { check, errorHandler } from '../../errors'; | ||
import { RetrieveResponse } from '../../types/retrieve-types'; | ||
import { RetrieveParams, RetrieveResponse } from '../../types/retrieve-types'; | ||
import { parseRateLimitingResponse } from '../../utils/api-utils'; | ||
@@ -9,6 +9,5 @@ | ||
apiKey: string, | ||
id: string, | ||
pretty?: boolean, | ||
params: RetrieveParams, | ||
) => new Promise<RetrieveResponse>((resolve, reject) => { | ||
check(id, basePath, apiKey, 'ID', 'retrieve').then(() => { | ||
check(params.id, basePath, apiKey, 'ID', 'retrieve').then(() => { | ||
const headers = { | ||
@@ -18,6 +17,6 @@ 'Accept-Encoding': 'gzip', | ||
axios.get<RetrieveResponse>(`${basePath}/person/retrieve/${id}`, { | ||
axios.get<RetrieveResponse>(`${basePath}/person/retrieve/${params.id}`, { | ||
params: { | ||
api_key: apiKey, | ||
pretty: pretty || false, | ||
...params, | ||
}, | ||
@@ -24,0 +23,0 @@ headers, |
@@ -48,9 +48,15 @@ import { AxiosError } from 'axios'; | ||
// @ts-ignore | ||
return (`${status} Error: ${errorMessages[status >= 500 && status < 600 ? 500 : status]}`); | ||
return ({ | ||
status: status >= 500 && status < 600 ? 500 : status, | ||
// eslint-disable-next-line max-len | ||
message: errorMessages[status >= 500 && status < 600 ? 500 : status as keyof typeof errorMessages], | ||
}); | ||
} | ||
// @ts-ignore | ||
return (`Error: ${error.toJSON().message}`); | ||
return ({ | ||
status: 500, | ||
message: error.message, | ||
}); | ||
}; | ||
export { check, errorHandler }; |
@@ -28,3 +28,3 @@ import { AutoCompleteParams, AutoCompleteResponse } from './types/autocomplete-types'; | ||
import { APISettings } from './types/api-types'; | ||
import { RetrieveResponse } from './types/retrieve-types'; | ||
import { RetrieveParams, RetrieveResponse } from './types/retrieve-types'; | ||
@@ -41,3 +41,3 @@ class PDLJS { | ||
identify: (params: IdentifyParams) => Promise<IdentifyResponse>; | ||
retrieve: (id: string, pretty: boolean) => Promise<RetrieveResponse>; | ||
retrieve: (params: RetrieveParams) => Promise<RetrieveResponse>; | ||
bulk: (records: BulkPersonEnrichmentParams) => Promise<BulkPersonEnrichmentResponse> | ||
@@ -75,3 +75,3 @@ }; | ||
identify: (params) => identify(this.basePath, this.apiKey, params), | ||
retrieve: (id, pretty) => retrieve(this.basePath, this.apiKey, id, pretty), | ||
retrieve: (params) => retrieve(this.basePath, this.apiKey, params), | ||
}; | ||
@@ -78,0 +78,0 @@ |
@@ -14,167 +14,258 @@ export interface LocationResponse { | ||
interface PersonEmailResponse { address: string, type: string } | ||
interface PersonEmailResponse { | ||
address?: string, | ||
type?: string, | ||
first_seen?: string, | ||
last_seen?: string, | ||
num_sources?: number | ||
} | ||
interface PersonExperienceResponse { | ||
company: { | ||
name: string, | ||
size: string, | ||
id: string, | ||
founded: string, | ||
industry: string, | ||
location: LocationResponse, | ||
linkedin_url: string, | ||
linkedin_id: string, | ||
facebook_url: string, | ||
twitter_url: string, | ||
website: string, | ||
ticker: null, | ||
type: string, | ||
raw: Array<string>, | ||
fuzzy_match: boolean | ||
company?: { | ||
name?: string, | ||
size?: string, | ||
id?: string, | ||
founded?: string, | ||
industry?: string, | ||
location?: LocationResponse, | ||
linkedin_url?: string, | ||
linkedin_id?: string, | ||
facebook_url?: string, | ||
twitter_url?: string, | ||
website?: string, | ||
ticker?: string, | ||
type?: string, | ||
raw?: Array<string>, | ||
fuzzy_match?: boolean | ||
}, | ||
location_names: Array<string>, | ||
end_date: string, | ||
start_date: string, | ||
title: { | ||
name: string, | ||
role: string, | ||
sub_role: string, | ||
levels: Array<string> | ||
location_names?: Array<string>, | ||
end_date?: string, | ||
start_date?: string, | ||
title?: { | ||
name?: string, | ||
role?: string, | ||
sub_role?: string, | ||
levels?: Array<string>, | ||
raw?: Array<string>, | ||
}, | ||
is_primary: string, | ||
summary: string, | ||
is_primary?: string, | ||
summary?: string, | ||
first_seen?: string, | ||
last_seen?: string | ||
} | ||
interface PersonEducationResponse { | ||
school: { | ||
name: string, | ||
type: string, | ||
id: string, | ||
location: LocationResponse, | ||
linkedin_url: string, | ||
facebook_url: string, | ||
twitter_url: string, | ||
linkedin_id: string, | ||
website: string, | ||
domain: string, | ||
raw: Array<string> | ||
school?: { | ||
name?: string, | ||
type?: string, | ||
id?: string, | ||
location?: LocationResponse, | ||
linkedin_url?: string, | ||
facebook_url?: string, | ||
twitter_url?: string, | ||
linkedin_id?: string, | ||
website?: string, | ||
domain?: string, | ||
raw?: Array<string> | ||
}, | ||
end_date: string, | ||
start_date: string, | ||
gpa: string, | ||
degrees: Array<string>, | ||
majors: Array<string>, | ||
minors: Array<string>, | ||
raw: Array<string> | ||
summary: string | ||
end_date?: string, | ||
start_date?: string, | ||
gpa?: string, | ||
degrees?: Array<string>, | ||
majors?: Array<string>, | ||
minors?: Array<string>, | ||
raw?: Array<string> | ||
summary?: string | ||
} | ||
interface PersonProfileResponse { | ||
network: string, | ||
id: string, | ||
url: string, | ||
username: string | ||
network?: string, | ||
id?: string, | ||
url?: string, | ||
username?: string, | ||
first_seen?: string, | ||
last_seen?: string, | ||
num_sources?: number | ||
} | ||
interface PersonPhoneResponse { | ||
number?: string, | ||
first_seen?: string, | ||
last_seen?: string, | ||
num_sources?: number | ||
} | ||
interface PersonStreetAddressResponse { | ||
street_address?: string, | ||
address_line_2?: string, | ||
name?: string, | ||
locality?: string, | ||
metro?: string, | ||
region?: string, | ||
postal_code?: string, | ||
country?: string, | ||
geo?: string, | ||
continent?: string, | ||
first_seen?: string, | ||
last_seen?: string, | ||
num_sources?: number | ||
} | ||
interface PersonCertificateResponse { | ||
start_date?: string, | ||
end_date?: string, | ||
name?: string, | ||
organization?: string | ||
} | ||
interface PersonBirthdateResponse { | ||
month?: string, | ||
day?: string, | ||
year?: string | ||
} | ||
interface PersonLanguageResponse { | ||
name?: string, | ||
proficiency?: number | ||
} | ||
interface PersonJobHistoryResponse { | ||
company_id?: string, | ||
company_name?: string, | ||
title?: string, | ||
first_seen?: string, | ||
last_seen?: string, | ||
num_sources?: number | ||
} | ||
export interface PersonResponse { | ||
id: string, | ||
full_name: string, | ||
first_name: string, | ||
middle_initial: string, | ||
middle_name: string, | ||
last_name: string, | ||
gender: string, | ||
birth_year: string, | ||
birth_date: string, | ||
linkedin_url: string, | ||
linkedin_username: string, | ||
linkedin_id: string, | ||
facebook_url: string, | ||
facebook_username: string, | ||
facebook_id: string, | ||
twitter_url: string, | ||
twitter_username: string, | ||
github_url: string, | ||
github_username: string, | ||
work_email: string, | ||
personal_emails: Array<string>, | ||
mobile_phone: string, | ||
industry: string, | ||
job_title: string, | ||
job_title_role: string, | ||
job_title_sub_role: string, | ||
job_title_levels: Array<string>, | ||
job_company_id: string, | ||
job_company_name: string, | ||
job_company_website: string, | ||
job_company_size: string, | ||
job_company_founded: string, | ||
job_company_industry: string, | ||
job_company_linkedin_url: string, | ||
job_company_linkedin_id: string, | ||
job_company_facebook_url: string, | ||
job_company_twitter_url: string, | ||
job_company_location_name: string, | ||
job_company_location_locality: string, | ||
job_company_location_metro: string, | ||
job_company_location_region: string, | ||
job_company_location_geo: string, | ||
job_company_location_street_address: string, | ||
job_company_location_address_line_2: string, | ||
job_company_location_postal_code: string, | ||
job_company_location_country: string, | ||
job_company_location_continent: string, | ||
job_last_updated: string, | ||
job_start_date: string, | ||
location_name: string, | ||
location_locality: string, | ||
location_metro: string, | ||
location_region: string, | ||
location_country: string, | ||
location_continent: string, | ||
location_street_address: string, | ||
location_address_line_2: string, | ||
location_postal_code: string, | ||
location_geo: string, | ||
location_last_updated: string, | ||
linkedin_connections: number, | ||
inferred_salary: string, | ||
inferred_years_experience: number, | ||
summary: string, | ||
phone_numbers: Array<string>, | ||
emails: Array<PersonEmailResponse>, | ||
interests: Array<string>, | ||
skills: Array<string>, | ||
location_names: Array<string>, | ||
regions: Array<string>, | ||
countries: Array<string>, | ||
street_addresses: Array<string>, | ||
experience: Array<PersonExperienceResponse>, | ||
education: Array<PersonEducationResponse>, | ||
profiles: Array<PersonProfileResponse>, | ||
id?: string, | ||
full_name?: string, | ||
first_name?: string, | ||
middle_initial?: string, | ||
middle_name?: string, | ||
last_name?: string, | ||
gender?: string, | ||
birth_year?: string, | ||
birth_date?: string, | ||
linkedin_url?: string, | ||
linkedin_username?: string, | ||
linkedin_id?: string, | ||
facebook_url?: string, | ||
facebook_username?: string, | ||
facebook_id?: string, | ||
twitter_url?: string, | ||
twitter_username?: string, | ||
github_url?: string, | ||
github_username?: string, | ||
work_email?: string, | ||
personal_emails?: Array<string>, | ||
mobile_phone?: string, | ||
industry?: string, | ||
job_title?: string, | ||
job_title_role?: string, | ||
job_title_sub_role?: string, | ||
job_title_levels?: Array<string>, | ||
job_company_id?: string, | ||
job_company_name?: string, | ||
job_company_website?: string, | ||
job_company_size?: string, | ||
job_company_founded?: string, | ||
job_company_industry?: string, | ||
job_company_linkedin_url?: string, | ||
job_company_linkedin_id?: string, | ||
job_company_facebook_url?: string, | ||
job_company_twitter_url?: string, | ||
job_company_location_name?: string, | ||
job_company_location_locality?: string, | ||
job_company_location_metro?: string, | ||
job_company_location_region?: string, | ||
job_company_location_geo?: string, | ||
job_company_location_street_address?: string, | ||
job_company_location_address_line_2?: string, | ||
job_company_location_postal_code?: string, | ||
job_company_location_country?: string, | ||
job_company_location_continent?: string, | ||
job_company_ticker?: string, | ||
job_company_type?: string, | ||
job_onet_code?: string, | ||
job_onet_major_group?: string, | ||
job_onet_minor_group?: string, | ||
job_onet_broad_occupation?: string, | ||
job_onet_specific_occupation?: string, | ||
job_onet_title?: string, | ||
job_summary?: string, | ||
job_last_updated?: string, | ||
job_start_date?: string, | ||
languages?: Array<PersonLanguageResponse>, | ||
location_name?: string, | ||
location_locality?: string, | ||
location_metro?: string, | ||
location_region?: string, | ||
location_country?: string, | ||
location_continent?: string, | ||
location_street_address?: string, | ||
location_address_line_2?: string, | ||
location_postal_code?: string, | ||
location_geo?: string, | ||
location_last_updated?: string, | ||
linkedin_connections?: number, | ||
inferred_salary?: string, | ||
inferred_years_experience?: number, | ||
summary?: string, | ||
phone_numbers?: Array<string>, | ||
emails?: Array<PersonEmailResponse>, | ||
interests?: Array<string>, | ||
skills?: Array<string>, | ||
location_names?: Array<string>, | ||
regions?: Array<string>, | ||
countries?: Array<string>, | ||
street_addresses?: Array<PersonStreetAddressResponse>, | ||
experience?: Array<PersonExperienceResponse>, | ||
education?: Array<PersonEducationResponse>, | ||
profiles?: Array<PersonProfileResponse>, | ||
phones?: Array<PersonPhoneResponse>, | ||
facebook_friends?: number, | ||
name_aliases?: Array<string>, | ||
possible_emails?: Array<PersonEmailResponse>, | ||
possible_phones?: Array<PersonPhoneResponse>, | ||
possible_profiles?: Array<PersonProfileResponse>, | ||
possible_street_addresses?: Array<PersonStreetAddressResponse>, | ||
possible_birth_dates?: Array<PersonBirthdateResponse>, | ||
possible_location_names?: Array<string>, | ||
job_history?: Array<PersonJobHistoryResponse>, | ||
num_records?: number, | ||
num_sources?: number, | ||
first_seen?: string, | ||
certifications?: Array<PersonCertificateResponse> | ||
} | ||
export interface CompanyResponse { | ||
name: string, | ||
size: string, | ||
employee_count: number, | ||
id: string, | ||
founded: number, | ||
industry: string, | ||
location: LocationResponse, | ||
linkedin_id: string, | ||
linkedin_url: string, | ||
facebook_url: string, | ||
twitter_url: string, | ||
profiles: Array<string>, | ||
website: string, | ||
ticker: string, | ||
type: string, | ||
summary: string, | ||
tags: Array<string>, | ||
headline: null, | ||
alternative_names: Array<string>, | ||
alternative_domains: Array<string>, | ||
affiliated_profiles: Array<string>, | ||
likelihood: number | ||
name?: string, | ||
size?: string, | ||
employee_count?: number, | ||
id?: string, | ||
founded?: number, | ||
industry?: string, | ||
location?: LocationResponse, | ||
linkedin_id?: string, | ||
linkedin_url?: string, | ||
facebook_url?: string, | ||
twitter_url?: string, | ||
profiles?: Array<string>, | ||
website?: string, | ||
ticker?: string, | ||
type?: string, | ||
summary?: string, | ||
tags?: Array<string>, | ||
headline?: null, | ||
alternative_names?: Array<string>, | ||
alternative_domains?: Array<string>, | ||
affiliated_profiles?: Array<string>, | ||
likelihood?: number | ||
} | ||
export interface ErrorResponse { | ||
message: string, | ||
status?: number | ||
} |
import { BaseResponse } from './api-types'; | ||
import { PersonResponse } from './common-types'; | ||
export type RetrieveParams = { | ||
id: string; | ||
} & { | ||
pretty?: boolean; | ||
}; | ||
export interface RetrieveResponse extends BaseResponse { | ||
data: PersonResponse | ||
} |
@@ -132,3 +132,3 @@ import { expect } from 'chai'; | ||
it(`Should Return Person Record for ${personID}`, (done) => { | ||
PDLJSClient.person.retrieve(personID).then((data) => { | ||
PDLJSClient.person.retrieve({ id: personID }).then((data) => { | ||
expect(data.status).to.equal(200); | ||
@@ -135,0 +135,0 @@ expect(data).to.be.a('object'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
60565
1305