Skip to content

Commit

Permalink
Add Updated Title Roles to Autocomplete (#289)
Browse files Browse the repository at this point in the history
* add support for utr in autocomplete

* add test

* update version

* update tests

* fix
  • Loading branch information
vvillait88 authored Dec 17, 2024
1 parent 2d583db commit 7757823
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "peopledatalabs",
"version": "9.4.2",
"version": "9.5.0",
"description": "JavaScript client with TypeScript support for the People Data Labs API",
"type": "module",
"main": "dist/index.cjs",
Expand Down
3 changes: 3 additions & 0 deletions src/endpoints/autocomplete/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export default (
size,
text,
titlecase,
// eslint-disable-next-line @typescript-eslint/naming-convention
updated_title_roles,
} = params;

const autocompleteParams = {
Expand All @@ -24,6 +26,7 @@ export default (
size: size || 10,
pretty: pretty || false,
titlecase: titlecase || false,
updated_title_roles: updated_title_roles || false,
};

const headers = {
Expand Down
2 changes: 1 addition & 1 deletion src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const check = (

if (endpoint === 'autocomplete') {
const { field } = params as AutoCompleteParams;
const validFields = ['company', 'country', 'industry', 'location', 'major', 'region', 'role', 'school', 'sub_role', 'skill', 'title'];
const validFields = ['class', 'company', 'country', 'industry', 'location', 'major', 'region', 'role', 'school', 'sub_role', 'skill', 'title'];
if (!field) {
error.message = 'Missing field';
error.status = 400;
Expand Down
2 changes: 2 additions & 0 deletions src/types/autocomplete-types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BaseResponse } from './api-types.js';

export type AutoCompleteField =
'class' |
'company' |
'country' |
'industry' |
Expand All @@ -20,6 +21,7 @@ export interface AutoCompleteParams {
size?: number;
text?: string;
titlecase?: boolean;
updated_title_roles?: boolean;
}

export interface AutoCompleteResponse extends BaseResponse {
Expand Down
17 changes: 17 additions & 0 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,23 @@ describe('Autocomplete', () => {
}
});

it('Should Return Autocomplete for `class` field', async () => {
const autocompleteClassParams = {
field: 'class',
text: 'sales',
updated_title_roles: true,
};

try {
const response = await PDLJSClient.autocomplete(autocompleteClassParams);

expect(response.status).to.equal(200);
expect(response).to.be.a('object');
} catch (error) {
expect(error).to.be.null();
}
});

it('Should Error for Autocomplete', async () => {
try {
const response = await PDLJSClient.autocomplete();
Expand Down

0 comments on commit 7757823

Please sign in to comment.