From 7757823648a5fb5f43c6e377262294359c8c5728 Mon Sep 17 00:00:00 2001 From: Varun Villait Date: Tue, 17 Dec 2024 09:53:12 -0700 Subject: [PATCH] Add Updated Title Roles to Autocomplete (#289) * add support for utr in autocomplete * add test * update version * update tests * fix --- package.json | 2 +- src/endpoints/autocomplete/index.ts | 3 +++ src/errors.ts | 2 +- src/types/autocomplete-types.ts | 2 ++ tests/index.test.js | 17 +++++++++++++++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d1bf13c..62e3d29 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/endpoints/autocomplete/index.ts b/src/endpoints/autocomplete/index.ts index 0a2c346..3894349 100644 --- a/src/endpoints/autocomplete/index.ts +++ b/src/endpoints/autocomplete/index.ts @@ -16,6 +16,8 @@ export default ( size, text, titlecase, + // eslint-disable-next-line @typescript-eslint/naming-convention + updated_title_roles, } = params; const autocompleteParams = { @@ -24,6 +26,7 @@ export default ( size: size || 10, pretty: pretty || false, titlecase: titlecase || false, + updated_title_roles: updated_title_roles || false, }; const headers = { diff --git a/src/errors.ts b/src/errors.ts index 42fa244..2daa733 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -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; diff --git a/src/types/autocomplete-types.ts b/src/types/autocomplete-types.ts index 825c8a6..730b3da 100644 --- a/src/types/autocomplete-types.ts +++ b/src/types/autocomplete-types.ts @@ -1,6 +1,7 @@ import { BaseResponse } from './api-types.js'; export type AutoCompleteField = + 'class' | 'company' | 'country' | 'industry' | @@ -20,6 +21,7 @@ export interface AutoCompleteParams { size?: number; text?: string; titlecase?: boolean; + updated_title_roles?: boolean; } export interface AutoCompleteResponse extends BaseResponse { diff --git a/tests/index.test.js b/tests/index.test.js index d09aa47..161c63a 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -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();