Skip to content

Commit ffa4bf3

Browse files
authored
Added filtering to findItemsByCategory api (#104)
* v2.7.7 * fix encodeURI issue * version bump * added filtering for findItemsByCategory api * version bump * version bump
1 parent 8fd0bb5 commit ffa4bf3

File tree

5 files changed

+28
-14
lines changed

5 files changed

+28
-14
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ ebay.getAccessToken()
7878
// To check the format of Data, Go to this url (https://developer.ebay.com/api- docs/buy/browse/resources/item_summary/methods/search#w4-w1-w4-SearchforItemsbyKeyword-0)
7979
})
8080
});
81+
82+
// perform Advance Search Items by Keyword or category or both
83+
// Search Buy It Now ipad items with one day shipping. (https://developer.ebay.com/DevZone/finding/CallRef/findItemsAdvanced.html)
84+
ebay.findItemsAdvanced({
85+
entriesPerPage: 2,
86+
keywords: 'ipad',
87+
ExpeditedShippingType: 'OneDayShipping',
88+
ListingType: 'AuctionWithBIN'
89+
}).then((data) => {
90+
console.log(data);
91+
}, (error) => {
92+
console.log(error);
93+
});
8194
```
8295

8396
[More Examples](https://pajaydev.github.io/ebay-node-api)

demo/finding.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ let ebay = new Ebay({
77
clientID: clientId,
88
});
99

10-
ebay.findItemsByCategory(10181).then((data) => {
10+
ebay.findItemsByCategory({
11+
categoryId: 10181,
12+
Condition: 1000
13+
}).then((data) => {
1114
console.log(data);
1215
}, (error) => {
1316
console.log(error);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ebay-node-api",
3-
"version": "2.8.6",
3+
"version": "2.8.7",
44
"description": "Ebay node api client",
55
"main": "./src/index.js",
66
"homepage": "https://github.com/pajaydev/ebay-node-api",

src/buildURL.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ const buildURL = {
2323
baseUrl += options.param ? '&' + options.param + '=' + options.name : '';
2424
baseUrl += options.additionalParam ? '&' + options.additionalParam : '';
2525
baseUrl += options.sortOrder ? '&sortOrder=' + options.sortOrder : '';
26-
baseUrl += '&outputSelector(0)=SellerInfo';
27-
baseUrl += '&outputSelector(1)=PictureURLLarge';
26+
baseUrl += '&outputSelector(0)=SellerInfo&outputSelector(1)=PictureURLLarge';
2827
baseUrl += options.limit ? '&paginationInput.entriesPerPage=' + options.limit : '';
2928
baseUrl += options.globalID ? '&GLOBAL-ID=' + options.globalID : '';
3029
baseUrl += options.pageNumber ? '&paginationInput.pageNumber=' + options.pageNumber : '';

src/finding.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ const FIND_ITEMS_ADV = 'findItemsAdvanced';
1010
const FIND_EBAY_STORES = 'findItemsIneBayStores';
1111

1212
const findItemsByKeywords = function (options) {
13-
if (!options) {
14-
throw new Error('INVALID_REQUEST_PARMS --> Keyword is missing, Keyword is required');
15-
}
13+
if (!options) throw new Error('INVALID_REQUEST_PARMS --> Keyword is missing, Keyword is required');
1614
this.options.operationName = FIND_ITEMS_BY_KEYWORD;
1715
// support only keyword string.
1816
if (!options.keywords) options = { keywords: options };
@@ -24,11 +22,15 @@ const findItemsByKeywords = function (options) {
2422
);
2523
};
2624

27-
const findItemsByCategory = function (categoryID) {
28-
if (!categoryID) throw new Error('INVALID_REQUEST_PARMS --> Category ID is null or invalid');
29-
this.options.name = categoryID;
25+
/**
26+
* searches for items on eBay using specific eBay category ID numbers (input category ID numbers using categoryId).
27+
* @param {Object} options
28+
*/
29+
const findItemsByCategory = function (options) {
30+
if (!options) throw new Error('INVALID_REQUEST_PARMS --> Category ID is null or invalid');
31+
if (!options.categoryId) options = { categoryId: options };
3032
this.options.operationName = FIND_ITEMS_BY_CATEGORY;
31-
this.options.param = 'categoryId';
33+
this.options.additionalParam = utils.constructAdditionalParams(options);
3234
const url = urlObject.buildSearchUrl(this.options);
3335
return getRequest(url).then((data) => {
3436
return JSON.parse(data).findItemsByCategoryResponse;
@@ -49,7 +51,6 @@ const findCompletedItems = function (options) {
4951
const url = urlObject.buildSearchUrl(this.options);
5052
return getRequest(url).then((data) => {
5153
return JSON.parse(data).findCompletedItemsResponse;
52-
5354
}, console.error // eslint-disable-line no-console
5455
);
5556
};
@@ -94,7 +95,6 @@ const findItemsByProduct = function (options) {
9495
let url = `${urlObject.buildSearchUrl(this.options)}&productId.@type=${type}`;
9596
return getRequest(url).then((data) => {
9697
return JSON.parse(data).findItemsByProductResponse;
97-
9898
}, console.error // eslint-disable-line no-console
9999
);
100100
};
@@ -106,7 +106,6 @@ const findItemsIneBayStores = function (options) {
106106
this.options.additionalParam = utils.constructAdditionalParams(options);
107107
return getRequest(urlObject.buildSearchUrl(this.options)).then((data) => {
108108
return JSON.parse(data).findItemsIneBayStoresResponse;
109-
110109
}, console.error // eslint-disable-line no-console
111110
);
112111
};

0 commit comments

Comments
 (0)