Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search by ePID with Auth flow #140

Merged
merged 5 commits into from
May 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

epid is not required field, you can remove this from the if loop.

https://developer.ebay.com/api-docs/buy/browse/resources/item_summary/methods/search#h2-input

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not possible to seach only by epid then?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rambonette You are right, we can search using epid. We can change the error message like this

'Error --> Kindly provide the valid Keyword, category id, epid or gtin in query param

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pajaydev That's perfect! I readded the !searchConfig.epid condition and updated the error message with the text you provided! Let me know if there's anything more to be changed :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rambonette Cool. Thanks I appreciate it.

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