Skip to content

Commit

Permalink
search by ePID with Auth flow (#140)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rambonette authored May 3, 2021
1 parent 8c9a789 commit 361b40e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/buy-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) : '';
Expand All @@ -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' })) : '');
Expand Down

0 comments on commit 361b40e

Please sign in to comment.