Skip to content

Commit c52bdcb

Browse files
authored
Bug Fix: add includeSelector to getUserdetails api (#89)
* v2.7.7 * added include selector to user details
1 parent c36e6b3 commit c52bdcb

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

demo/shopping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ebay.getAllCategories('1234').then((data) => {
1616

1717
// // Get User Profile
1818
// // https://developer.ebay.com/devzone/shopping/docs/callref/GetUserProfile.html
19-
ebay.getUserDetails({ userId: 'ajaykumapratha_0', details: true }).then((data) => {
19+
ebay.getUserDetails({ userId: 'ajaykumapratha_0', includeSelector: 'Details' }).then((data) => {
2020
console.log(data);
2121
}, (error) => {
2222
console.log(error);

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ ebay.getAllCategories('1234').then((data) => {
322322
Get User Profile
323323
```javascript
324324
//https://developer.ebay.com/devzone/shopping/docs/callref/GetUserProfile.html
325-
ebay.getUserDetails({ userId: 'ajaykumapratha_0', details: true }).then((data) => {
325+
ebay.getUserDetails({ userId: 'ajaykumapratha_0', includeSelector: true }).then((data) => {
326326
console.log(data);
327327
}, (error) => {
328328
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.3",
3+
"version": "2.8.4",
44
"description": "Ebay node api client",
55
"main": "./src/index.js",
66
"homepage": "https://github.com/pajaydev/ebay-node-api",

src/shopping.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const makeString = require('make-string');
66

77
const getAllCategories = function (categoryID) {
88
const requestURL = `${urlObject.buildShoppingUrl(this.options, 'GetCategoryInfo')}&${stringifyUrl({ 'CategoryID': categoryID || -1 })}`;
9-
console.log(requestURL);
109
return getRequest(requestURL).then((data) => {
1110
return JSON.parse(data);
1211
}, console.error // eslint-disable-line no-console
@@ -16,8 +15,8 @@ const getAllCategories = function (categoryID) {
1615
const getUserDetails = function (input) {
1716
if (!input || typeof input !== 'object') throw new Error('invalid_request_error -> Invalid input');
1817
if (!input.userId) throw new Error('invalid_request_error -> userId is null or invalid');
18+
input.includeSelector = input.includeSelector ? input.includeSelector : 'Details';
1919
const requestUrl = `${urlObject.buildShoppingUrl(this.options, 'GetUserProfile')}&${stringifyUrl(input)}`;
20-
console.log(requestUrl);
2120
return getRequest(requestUrl).then((data) => {
2221
return JSON.parse(data);
2322
}, console.error // eslint-disable-line no-console
@@ -30,7 +29,6 @@ const getItemStatus = function (itemIds) {
3029
'ItemID': makeString(itemIds, { braces: 'false', quotes: 'no' })
3130
};
3231
const requestUrl = `${urlObject.buildShoppingUrl(this.options, 'GetItemStatus')}&${stringifyUrl(paramsObj)}`;
33-
console.log(requestUrl);
3432
return getRequest(requestUrl).then((data) => {
3533
return JSON.parse(data);
3634
}, console.error // eslint-disable-line no-console
@@ -41,7 +39,6 @@ const getShippingCosts = function (input) {
4139
if (!input || typeof input !== 'object') throw new Error('invalid_request_error -> Invalid input');
4240
if (!input.itemId) throw new Error('invalid_request_error -> Item id is null or invalid');
4341
const url = `${urlObject.buildShoppingUrl(this.options, 'GetShippingCosts')}&${stringifyUrl(input)} `;
44-
console.log(url);
4542
return getRequest(url).then((data) => {
4643
return JSON.parse(data);
4744
}, console.error // eslint-disable-line no-console
@@ -56,7 +53,6 @@ const getShippingCosts = function (input) {
5653
const getMultipleItems = function (options) {
5754
if (!options || !options.itemId) throw new Error('invalid_request_error -> Item ID is null or invalid');
5855
const requestUrl = `${urlObject.buildShoppingUrl(this.options, 'GetMultipleItems')}&${stringifyUrl({ 'itemId': makeString(options.itemId, { braces: 'false', quotes: 'no' }) })}`;
59-
console.log(requestUrl);
6056
return getRequest(requestUrl).then((data) => {
6157
return JSON.parse(data);
6258
}, console.error // eslint-disable-line no-console

test/shopping.test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,25 @@ describe('test shopping api', () => {
4949
clientID: 'ABCXXX123'
5050
});
5151
nock('https://api.ebay.com')
52-
.get('/Shopping?appid=ABCXXX123&callname=GetUserProfile&version=967&siteid=0&responseencoding=JSON&userId=test')
52+
.get('/Shopping?appid=ABCXXX123&callname=GetUserProfile&version=967&siteid=0&responseencoding=JSON&userId=test&includeSelector=Details')
5353
.reply(200, { getUserDetails: true });
5454
ebay.getUserDetails({ userId: 'test' }).then((data) => {
5555
expect(data).to.deep.equal({ getUserDetails: true });
5656
});
5757
});
5858

59+
it('test getUserDetails method with include selector', () => {
60+
const ebay = new Ebay({
61+
clientID: 'ABCXXX123'
62+
});
63+
nock('https://api.ebay.com')
64+
.get('/Shopping?appid=ABCXXX123&callname=GetUserProfile&version=967&siteid=0&responseencoding=JSON&userId=test&includeSelector=sample')
65+
.reply(200, { getUserDetailsWithIncludeSelector: true });
66+
ebay.getUserDetails({ userId: 'test', includeSelector: 'sample' }).then((data) => {
67+
expect(data).to.deep.equal({ getUserDetailsWithIncludeSelector: true });
68+
});
69+
});
70+
5971
it('test getShippingCosts method', () => {
6072
const ebay = new Ebay({
6173
clientID: 'ABCXXX123'

0 commit comments

Comments
 (0)