From e4a78e119c913a08e8d652bc0515e38125dc3e47 Mon Sep 17 00:00:00 2001 From: rambonette Date: Thu, 15 Apr 2021 13:00:03 +0200 Subject: [PATCH 1/5] Update buy-api.js add epid in searchItems --- 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..4ef24ba 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 --> Keyword or category id is required 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.sort ? '&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' })) : ''); From f9649376fb303e06738086b3d1df97e2823190d0 Mon Sep 17 00:00:00 2001 From: rambonette Date: Fri, 16 Apr 2021 14:53:14 +0200 Subject: [PATCH 2/5] Update PULL_REQUEST_TEMPLATE.md --- PULL_REQUEST_TEMPLATE.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index c538b25..23835b1 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -1,9 +1,25 @@ ## Goal of the pull request: * [ ] Documentation -* [ ] Bugfix +* [x] Bugfix * [ ] Feature (New!) -* [ ] Enhancement +* [x] Enhancement ## Description + +added the ability so search by epid in function 'searchItems'. It was stated in the repo's docs but there was no real way to do it using the auth flow. + +marked both bugfix and enhancement because it's not a proper bug, but it's not an enhancement either since it was stated in the docs that 'searchItems' could search by ePID. + +Details: +just two lines in 'src/buy-api.js' + ++ 52 + +if (!searchConfig.keyword && !searchConfig.categoryId && !searchConfig.gtin && !searchConfig.epid) throw new Error('Error --> Keyword or category id is required in query param'); + ++ 61 + +queryParam = queryParam + (searchConfig.epid ? '&epid=' + searchConfig.epid : ''); + From c2adb1420e6898c3dca98f934782f1fbb87c5975 Mon Sep 17 00:00:00 2001 From: rambonette Date: Fri, 16 Apr 2021 14:57:11 +0200 Subject: [PATCH 3/5] Update PULL_REQUEST_TEMPLATE.md --- PULL_REQUEST_TEMPLATE.md | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 23835b1..c538b25 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -1,25 +1,9 @@ ## Goal of the pull request: * [ ] Documentation -* [x] Bugfix +* [ ] Bugfix * [ ] Feature (New!) -* [x] Enhancement +* [ ] Enhancement ## Description - -added the ability so search by epid in function 'searchItems'. It was stated in the repo's docs but there was no real way to do it using the auth flow. - -marked both bugfix and enhancement because it's not a proper bug, but it's not an enhancement either since it was stated in the docs that 'searchItems' could search by ePID. - -Details: -just two lines in 'src/buy-api.js' - -+ 52 - -if (!searchConfig.keyword && !searchConfig.categoryId && !searchConfig.gtin && !searchConfig.epid) throw new Error('Error --> Keyword or category id is required in query param'); - -+ 61 - -queryParam = queryParam + (searchConfig.epid ? '&epid=' + searchConfig.epid : ''); - From f6e079e42fa7b85170a2f34e20664df4b0768c23 Mon Sep 17 00:00:00 2001 From: Ramiro Cordero Date: Sat, 1 May 2021 14:28:54 +0200 Subject: [PATCH 4/5] searchItems - fixes --- src/buy-api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/buy-api.js b/src/buy-api.js index 4ef24ba..f9021a8 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 && !searchConfig.epid) throw new Error('Error --> Keyword or category id is required in query param'); + if (!searchConfig.keyword && !searchConfig.categoryId && !searchConfig.gtin) throw new Error('Error --> Keyword or category id is required 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,7 +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.sort ? '&epid=' + searchConfig.epid : ''); + 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' })) : ''); From 92b31c23ea61b7bfe670bdbf9c1e1da634510e4c Mon Sep 17 00:00:00 2001 From: Ramiro Cordero Date: Mon, 3 May 2021 12:20:05 +0200 Subject: [PATCH 5/5] searchItems - allow search by epid --- src/buy-api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buy-api.js b/src/buy-api.js index f9021a8..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) : '';