From 67e986c0d652663ec4eec095d1ce78695b284f93 Mon Sep 17 00:00:00 2001 From: Ben Waples Date: Thu, 19 Dec 2024 17:21:03 -0800 Subject: [PATCH] feat: GET /details API client can send multiple sort_by query params (#1032) --- .../js-client-library/src/client.ts | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/javascript/js-client-library/src/client.ts b/packages/javascript/js-client-library/src/client.ts index 22a3f1908..eaf6c08b8 100644 --- a/packages/javascript/js-client-library/src/client.ts +++ b/packages/javascript/js-client-library/src/client.ts @@ -534,17 +534,22 @@ class BHEAPIClient { skip: number, limit: number, filterAccepted?: boolean, - sortBy?: string, + sortBy?: string | string[], options?: types.RequestOptions ) => { - const params: types.RiskDetailsRequest = { - finding: finding, - skip: skip, - limit: limit, - sort_by: sortBy, - }; + const params = new URLSearchParams(); + params.append('finding', finding); + params.append('skip', skip.toString()); + params.append('limit', limit.toString()); + if (sortBy) { + if (typeof sortBy === 'string') { + params.append('sort_by', sortBy); + } else { + sortBy.forEach((sort) => params.append('sort_by', sort)); + } + } - if (typeof filterAccepted === 'boolean') params.Accepted = `eq:${filterAccepted}`; + if (typeof filterAccepted === 'boolean') params.append('Accepted', `eq:${filterAccepted}`); return this.baseClient.get( `/api/v2/domains/${domainId}/details`,