-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add ip enrichment api * update packages * update version
- Loading branch information
1 parent
f7a9215
commit 9ab0dd5
Showing
11 changed files
with
354 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,12 @@ PDLJSClient.person.enrichment({ phone: '4155688415' }).then((data) => { | |
console.log(error); | ||
}); | ||
|
||
PDLJSClient.person.enrichmentPreview({ phone: '4155688415' }).then((data) => { | ||
console.log(data); | ||
}).catch((error) => { | ||
console.log(error); | ||
}); | ||
|
||
PDLJSClient.person.identify({ phone: '4155688415' }).then((data) => { | ||
console.log(data); | ||
}).catch((error) => { | ||
|
@@ -127,6 +133,12 @@ PDLJSClient.skill({ skill: 'c++' }).then((data) => { | |
console.log(error); | ||
}); | ||
|
||
PDLJSClient.ip({ ip: '72.212.42.169' }).then((data) => { | ||
console.log(data); | ||
}).catch((error) => { | ||
console.log(error); | ||
}); | ||
|
||
// Sandbox APIs | ||
|
||
PDLJSClient.person.enrichment({ email: '[email protected]', sandbox: true }).then((data) => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import axios from 'axios'; | ||
|
||
import { check, errorHandler } from '../../errors'; | ||
import { IPParams, IPResponse } from '../../types/ip-types'; | ||
import { parseRateLimitingResponse } from '../../utils/api-utils'; | ||
|
||
export default ( | ||
basePath: string, | ||
apiKey: string, | ||
params: IPParams, | ||
) => new Promise<IPResponse>((resolve, reject) => { | ||
check(params, basePath, apiKey, null, 'ip').then(() => { | ||
const headers = { | ||
'Accept-Encoding': 'gzip', | ||
'User-Agent': 'PDL-JS-SDK', | ||
}; | ||
|
||
axios.get<IPResponse>(`${basePath}/ip/enrich`, { | ||
params: { | ||
api_key: apiKey, | ||
...params, | ||
}, | ||
headers, | ||
}) | ||
.then((response) => { | ||
if (response?.data?.status === 200) { | ||
resolve(parseRateLimitingResponse(response)); | ||
} | ||
}) | ||
.catch((error) => { | ||
reject(errorHandler(error)); | ||
}); | ||
}).catch((error) => { | ||
reject(error); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export type ErrorEndpoint = 'enrichment' | 'autocomplete' | 'search' | 'identify' | 'bulk' | 'cleaner' | 'retrieve' | 'jobTitle' | 'skill'; | ||
export type ErrorEndpoint = 'enrichment' | 'autocomplete' | 'search' | 'identify' | 'bulk' | 'cleaner' | 'retrieve' | 'jobTitle' | 'skill' | 'ip'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { BaseResponse } from './api-types'; | ||
|
||
export interface IPParams { | ||
ip: string; | ||
return_ip_location?: boolean; | ||
return_ip_metadata?: boolean; | ||
return_person?: boolean; | ||
pretty?: boolean; | ||
titlecase?: boolean; | ||
} | ||
|
||
export interface IPResponse extends BaseResponse { | ||
data?: { | ||
ip?: { | ||
address?: string, | ||
metadata?: { | ||
version?: 4 | 6, | ||
mobile?: boolean, | ||
hosting?: boolean, | ||
proxy?: boolean, | ||
tor?: boolean, | ||
vpn?: boolean, | ||
relay?: boolean, | ||
service?: boolean, | ||
}, | ||
location?: { | ||
name?: string, | ||
locality?: string, | ||
region?: string, | ||
metro?: string, | ||
country?: string, | ||
continent?: string, | ||
postal_code?: string, | ||
geo?: string, | ||
timezone?: string, | ||
}, | ||
}, | ||
company?: { | ||
confidence?: 'very high' | 'high' | 'moderate' | 'low' | 'very low', | ||
id?: string, | ||
domain?: string, | ||
name?: string, | ||
location?: { | ||
name?: string, | ||
locality?: string, | ||
region?: string, | ||
metro?: string, | ||
country?: string, | ||
continent?: string, | ||
street_address?: string, | ||
address_line_2?: string, | ||
postal_code?: string, | ||
geo?: string, | ||
}, | ||
size?: string, | ||
industry?: string, | ||
inferred_revenue?: string, | ||
employee_count?: number, | ||
tags?: Array<string>, | ||
}, | ||
person?: { | ||
confidence?: 'very high' | 'high' | 'moderate' | 'low' | 'very low', | ||
job_title_sub_role?: string, | ||
job_title_role?: string, | ||
job_title_levels?: Array<string>, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,8 @@ const skill = { skill: 'c++' }; | |
|
||
const jobTitle = { jobTitle: 'software engineer' }; | ||
|
||
const ip = { ip: '72.212.42.169' }; | ||
|
||
describe('Person Enrichment', () => { | ||
it(`Should Return Person Record for ${phone}`, async () => { | ||
try { | ||
|
@@ -104,6 +106,30 @@ describe('Person Enrichment', () => { | |
}); | ||
}); | ||
|
||
describe('Person Preview Enrichment', () => { | ||
it(`Should Return Person Preview Record for ${phone}`, async () => { | ||
try { | ||
const response = await PDLJSClient.person.enrichmentPreview({ phone }); | ||
|
||
expect(response.status).to.equal(200); | ||
expect(response).to.be.a('object'); | ||
} catch (error) { | ||
expect(error).to.be.a('object'); | ||
} | ||
}); | ||
|
||
it('Should Error for Person Preview Enrichment', async () => { | ||
try { | ||
const response = await PDLJSClient.person.enrichmentPreview(); | ||
|
||
expect(response.status).to.equal(200); | ||
expect(response).to.be.a('object'); | ||
} catch (error) { | ||
expect(error).to.be.a('object'); | ||
} | ||
}); | ||
}); | ||
|
||
describe('Person Bulk Enrichment', () => { | ||
it(`Should Return Person Records for ${JSON.stringify(records)}`, async () => { | ||
try { | ||
|
@@ -456,6 +482,30 @@ describe('Job Title API', () => { | |
}); | ||
}); | ||
|
||
describe('IP Enrichment API', () => { | ||
it(`Should Return IP Records for ${JSON.stringify(ip)}`, async () => { | ||
try { | ||
const response = await PDLJSClient.ip(ip); | ||
|
||
expect(response.status).to.equal(200); | ||
expect(response).to.be.a('object'); | ||
} catch (error) { | ||
expect(error).to.be.a('object'); | ||
} | ||
}); | ||
|
||
it('Should Error for IP Enrichment', async () => { | ||
try { | ||
const response = await PDLJSClient.ip(); | ||
|
||
expect(response.status).to.equal(200); | ||
expect(response).to.be.a('object'); | ||
} catch (error) { | ||
expect(error).to.be.a('object'); | ||
} | ||
}); | ||
}); | ||
|
||
describe('Sandbox APIs', () => { | ||
it('Should Return Sandbox Person Record for { email: \'[email protected]\' }', async () => { | ||
try { | ||
|
Oops, something went wrong.