Skip to content

Commit 79aa1cc

Browse files
piggydoughnutpajaydev
authored andcommitted
Finding api improvements (#57)
* fidItemsByKeywords accepts parameters now - keywords, pageNumber, limit, sortOrder. It still supports just passing one keyword * lint fixes * added updates in the readme
1 parent 8141a54 commit 79aa1cc

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ ebay.getAccessToken().then((data) => {
9999

100100
### Finding Api
101101
```javascript
102-
//This call searches for items on eBay using specific eBay category ID numbers
102+
//This call searches for items on eBay using specific eBay category ID numbers
103103
ebay.findItemsByCategory(10181).then((data) => {
104104
console.log(data);
105105
}, (error) => {
@@ -113,6 +113,18 @@ ebay.findItemsByKeywords('iphone').then((data) => {
113113
console.log(error);
114114
});
115115

116+
117+
ebay.findItemsByKeywords({
118+
keywords: 'Garmin nuvi 1300 Automotive GPS Receiver',
119+
sortOrder: 'PricePlusShippingLowest', //https://developer.ebay.com/devzone/finding/callref/extra/fndcmpltditms.rqst.srtordr.html
120+
pageNumber: 2,
121+
limit: 10
122+
}).then((data) => {
123+
console.log(data);
124+
}, (error) => {
125+
console.log(error);
126+
});
127+
116128
// This call searches for items whose listings are completed and are no longer available for sale by category (using categoryId), by keywords (using keywords), or a combination of the two.
117129
ebay.findCompletedItems({
118130
keywords: 'Garmin nuvi 1300 Automotive GPS Receiver',
@@ -292,7 +304,7 @@ ebay.getAllCategories('1234').then((data) => {
292304
console.log(error);
293305
});
294306

295-
// Get User Profile
307+
// Get User Profile
296308
//https://developer.ebay.com/devzone/shopping/docs/callref/GetUserProfile.html
297309
ebay.getUserDetails({ userId: 'ajaykumapratha_0', details: true }).then((data) => {
298310
console.log(data);

src/findingApi.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,24 @@
33
const urlObject = require('./buildURL');
44
const { getRequest } = require('./request');
55

6-
const findItemsByKeywords = function (keyword) {
7-
if (!keyword) throw new Error('Keyword is missing, Keyword is required');
8-
this.options.name = keyword;
6+
const findItemsByKeywords = function (options) {
7+
if (!options || !options.keywords) {
8+
throw new Error('Keyword is missing, Keyword is required');
9+
}
10+
911
this.options.operationName = 'findItemsByKeywords';
1012
this.options.param = 'keywords';
13+
14+
if (!options.keywords) {
15+
this.options.name = options;
16+
}
17+
else {
18+
this.options.name = encodeURIComponent(options.keywords);
19+
this.options.sortOrder = options.sortOrder;
20+
this.options.pageNumber = options.pageNumber;
21+
this.options.limit = options.limit;
22+
}
23+
1124
const url = urlObject.buildSearchUrl(this.options);
1225
return getRequest(url).then((data) => {
1326
return JSON.parse(data).findItemsByKeywordsResponse;

0 commit comments

Comments
 (0)