From 361b40e4de346192a842ceb8eaa0f8c078df8734 Mon Sep 17 00:00:00 2001 From: Ramiro Cordero Date: Mon, 3 May 2021 18:53:13 +0200 Subject: [PATCH] search by ePID with Auth flow (#140) * Update buy-api.js add epid in searchItems * Update PULL_REQUEST_TEMPLATE.md * Update PULL_REQUEST_TEMPLATE.md * searchItems - fixes * searchItems - allow search by epid --- src/buy-api.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/buy-api.js b/src/buy-api.js index 9b9c0a1..2fdb6c1 100644 --- a/src/buy-api.js +++ b/src/buy-api.js @@ -49,7 +49,7 @@ const getItemByItemGroup = function (itemGroupId) { const searchItems = function (searchConfig) { if (!searchConfig) throw new Error('Error --> Missing or invalid input parameter to search'); - if (!searchConfig.keyword && !searchConfig.categoryId && !searchConfig.gtin) throw new Error('Error --> Keyword or category id is required in query param'); + if (!searchConfig.keyword && !searchConfig.categoryId && !searchConfig.gtin && !searchConfig.epid) throw new Error('Error --> Kindly provide the valid Keyword, category id, epid or gtin in query param'); if (!this.options.appAccessToken) throw new Error('Error -->Missing Access token, Generate access token'); const auth = 'Bearer ' + this.options.appAccessToken; let queryParam = searchConfig.keyword ? 'q=' + encodeURIComponent(searchConfig.keyword) : ''; @@ -58,6 +58,7 @@ const searchItems = function (searchConfig) { queryParam = queryParam + (searchConfig.limit ? '&limit=' + searchConfig.limit : ''); queryParam = queryParam + (searchConfig.offset ? '&offset=' + searchConfig.offset : ''); queryParam = queryParam + (searchConfig.sort ? '&sort=' + searchConfig.sort : ''); + queryParam = queryParam + (searchConfig.epid ? '&epid=' + searchConfig.epid : ''); if (searchConfig.fieldgroups !== undefined) queryParam = queryParam + '&fieldgroups=' + searchConfig.fieldgroups; if (searchConfig.filter !== undefined) queryParam = queryParam + '&filter=' + encodeURLQuery(makeString(searchConfig.filter, { quotes: 'no', braces: 'false' })); queryParam = queryParam + (searchConfig.aspect_filter ? '&aspect_filter=' + encodeURLQuery(makeString(searchConfig.aspect_filter, { quotes: 'no', braces: 'false' })) : '');