-
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.
feat(typescript): added typescript support (#17)
* feat(typescript): added autocomplete types * feat(typescript): added retrieve, enrichment, cleaner and identity types * feat(typescript): finished all endpoints and added types to errors * feat(typescript): added types to examples * feat(typescript): fixes based on questions * feat(typescript): added pretty param to all endpoints * feat(typescript): added rate limiting data and types * feat(typescript): fixed bulk test * feat(typescript): bumped to version 2.0.0 * fix readme * fixes Co-authored-by: Diego Abizaid <diegoabizaid@gmail.com> Co-authored-by: vvillait88 <vvillait88@yahoo.com>
- Loading branch information
1 parent
1091861
commit 1ae87d5
Showing
37 changed files
with
4,613 additions
and
3,925 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
}, | ||
extends: [ | ||
'airbnb-base', | ||
'airbnb-typescript/base', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
project: './tsconfig.json', | ||
}, | ||
plugins: [ | ||
'@typescript-eslint', | ||
], | ||
rules: { | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,26 @@ | ||
import axios from 'axios'; | ||
import { check, errorHandler } from '../../errors'; | ||
import { BulkPersonEnrichmentParams, BulkPersonEnrichmentResponse } from '../../types/bulk-types'; | ||
import { parseRateLimitingResponse } from '../../utils/api-utils'; | ||
|
||
export default (basePath: string, apiKey: string, records: BulkPersonEnrichmentParams) => { | ||
const headers = { | ||
'Content-Type': 'application/json', | ||
'Accept-Encoding': 'gzip', | ||
'X-Api-Key': apiKey, | ||
}; | ||
|
||
return new Promise<BulkPersonEnrichmentResponse>((resolve, reject) => { | ||
check(records, basePath, apiKey, 'Records', 'bulk').then(() => { | ||
axios.post<BulkPersonEnrichmentResponse>(`${basePath}/person/bulk`, records, { headers }) | ||
.then((response) => { | ||
resolve(parseRateLimitingResponse(response)); | ||
}) | ||
.catch((error) => { | ||
reject(errorHandler(error)); | ||
}); | ||
}).catch((error) => { | ||
reject(error); | ||
}); | ||
}); | ||
}; |
This file was deleted.
Oops, something went wrong.
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 { BaseResponse } from '../../types/api-types'; | ||
import { CleanerType } from '../../types/cleaner-types'; | ||
import { parseRateLimitingResponse } from '../../utils/api-utils'; | ||
|
||
export default <T, K extends BaseResponse> ( | ||
basePath: string, | ||
apiKey: string, | ||
params: T, | ||
type: CleanerType, | ||
) => new Promise<K>((resolve, reject) => { | ||
check(params, basePath, apiKey, null, 'cleaner').then(() => { | ||
const headers = { | ||
'Accept-Encoding': 'gzip', | ||
}; | ||
|
||
axios.get<K>(`${basePath}/${type}/clean`, { | ||
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.message); | ||
}); | ||
}); |
Oops, something went wrong.