Skip to content

Commit

Permalink
Bug Fix: add includeSelector to getUserdetails api (#89)
Browse files Browse the repository at this point in the history
* v2.7.7

* added include selector to user details
  • Loading branch information
pajaydev authored May 9, 2020
1 parent c36e6b3 commit c52bdcb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion demo/shopping.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ebay.getAllCategories('1234').then((data) => {

// // Get User Profile
// // https://developer.ebay.com/devzone/shopping/docs/callref/GetUserProfile.html
ebay.getUserDetails({ userId: 'ajaykumapratha_0', details: true }).then((data) => {
ebay.getUserDetails({ userId: 'ajaykumapratha_0', includeSelector: 'Details' }).then((data) => {
console.log(data);
}, (error) => {
console.log(error);
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ ebay.getAllCategories('1234').then((data) => {
Get User Profile
```javascript
//https://developer.ebay.com/devzone/shopping/docs/callref/GetUserProfile.html
ebay.getUserDetails({ userId: 'ajaykumapratha_0', details: true }).then((data) => {
ebay.getUserDetails({ userId: 'ajaykumapratha_0', includeSelector: true }).then((data) => {
console.log(data);
}, (error) => {
console.log(error);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ebay-node-api",
"version": "2.8.3",
"version": "2.8.4",
"description": "Ebay node api client",
"main": "./src/index.js",
"homepage": "https://github.com/pajaydev/ebay-node-api",
Expand Down
6 changes: 1 addition & 5 deletions src/shopping.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const makeString = require('make-string');

const getAllCategories = function (categoryID) {
const requestURL = `${urlObject.buildShoppingUrl(this.options, 'GetCategoryInfo')}&${stringifyUrl({ 'CategoryID': categoryID || -1 })}`;
console.log(requestURL);
return getRequest(requestURL).then((data) => {
return JSON.parse(data);
}, console.error // eslint-disable-line no-console
Expand All @@ -16,8 +15,8 @@ const getAllCategories = function (categoryID) {
const getUserDetails = function (input) {
if (!input || typeof input !== 'object') throw new Error('invalid_request_error -> Invalid input');
if (!input.userId) throw new Error('invalid_request_error -> userId is null or invalid');
input.includeSelector = input.includeSelector ? input.includeSelector : 'Details';
const requestUrl = `${urlObject.buildShoppingUrl(this.options, 'GetUserProfile')}&${stringifyUrl(input)}`;
console.log(requestUrl);
return getRequest(requestUrl).then((data) => {
return JSON.parse(data);
}, console.error // eslint-disable-line no-console
Expand All @@ -30,7 +29,6 @@ const getItemStatus = function (itemIds) {
'ItemID': makeString(itemIds, { braces: 'false', quotes: 'no' })
};
const requestUrl = `${urlObject.buildShoppingUrl(this.options, 'GetItemStatus')}&${stringifyUrl(paramsObj)}`;
console.log(requestUrl);
return getRequest(requestUrl).then((data) => {
return JSON.parse(data);
}, console.error // eslint-disable-line no-console
Expand All @@ -41,7 +39,6 @@ const getShippingCosts = function (input) {
if (!input || typeof input !== 'object') throw new Error('invalid_request_error -> Invalid input');
if (!input.itemId) throw new Error('invalid_request_error -> Item id is null or invalid');
const url = `${urlObject.buildShoppingUrl(this.options, 'GetShippingCosts')}&${stringifyUrl(input)} `;
console.log(url);
return getRequest(url).then((data) => {
return JSON.parse(data);
}, console.error // eslint-disable-line no-console
Expand All @@ -56,7 +53,6 @@ const getShippingCosts = function (input) {
const getMultipleItems = function (options) {
if (!options || !options.itemId) throw new Error('invalid_request_error -> Item ID is null or invalid');
const requestUrl = `${urlObject.buildShoppingUrl(this.options, 'GetMultipleItems')}&${stringifyUrl({ 'itemId': makeString(options.itemId, { braces: 'false', quotes: 'no' }) })}`;
console.log(requestUrl);
return getRequest(requestUrl).then((data) => {
return JSON.parse(data);
}, console.error // eslint-disable-line no-console
Expand Down
14 changes: 13 additions & 1 deletion test/shopping.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,25 @@ describe('test shopping api', () => {
clientID: 'ABCXXX123'
});
nock('https://api.ebay.com')
.get('/Shopping?appid=ABCXXX123&callname=GetUserProfile&version=967&siteid=0&responseencoding=JSON&userId=test')
.get('/Shopping?appid=ABCXXX123&callname=GetUserProfile&version=967&siteid=0&responseencoding=JSON&userId=test&includeSelector=Details')
.reply(200, { getUserDetails: true });
ebay.getUserDetails({ userId: 'test' }).then((data) => {
expect(data).to.deep.equal({ getUserDetails: true });
});
});

it('test getUserDetails method with include selector', () => {
const ebay = new Ebay({
clientID: 'ABCXXX123'
});
nock('https://api.ebay.com')
.get('/Shopping?appid=ABCXXX123&callname=GetUserProfile&version=967&siteid=0&responseencoding=JSON&userId=test&includeSelector=sample')
.reply(200, { getUserDetailsWithIncludeSelector: true });
ebay.getUserDetails({ userId: 'test', includeSelector: 'sample' }).then((data) => {
expect(data).to.deep.equal({ getUserDetailsWithIncludeSelector: true });
});
});

it('test getShippingCosts method', () => {
const ebay = new Ebay({
clientID: 'ABCXXX123'
Expand Down

0 comments on commit c52bdcb

Please sign in to comment.