Skip to content

Deploy full scale oauth functionality #97

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

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
a98fb2c
v2.7.7
pajaydev Jan 28, 2020
3328bd1
pull from upstream
pajaydev Mar 11, 2020
e0d9f15
Merge branch 'master' of github.com-personal:ajay2507/node-api
pajaydev Mar 22, 2020
e910186
Merge branch 'master' of github.com-personal:pajaydev/ebay-node-api
pajaydev Apr 18, 2020
9cc7e6c
Merge branch 'master' of github.com-personal:pajaydev/ebay-node-api
pajaydev Apr 26, 2020
5ae3910
Merge branch 'master' of github.com-personal:pajaydev/ebay-node-api
pajaydev May 7, 2020
81c5628
added include selector to user details
pajaydev May 8, 2020
25b1849
Merge pull request #1 from pajaydev/master
TotallyNotChase May 13, 2020
1c64c5d
Set up base for new oauth
TotallyNotChase May 18, 2020
ecd30c6
Remove misused arrow functions
TotallyNotChase May 18, 2020
5e292b5
Final touches for setting up oauth
TotallyNotChase May 18, 2020
e5b000c
Merge branch 'master' into oauth
TotallyNotChase May 18, 2020
c45c24f
General bug fixes
TotallyNotChase May 19, 2020
2b5a2a1
Delete package-lock.json
TotallyNotChase May 19, 2020
e55bc32
Update with 2.8.5 changes from original repo
TotallyNotChase May 22, 2020
b41c60f
Delete package-lock
TotallyNotChase May 22, 2020
145033e
Update with new utility import
TotallyNotChase May 22, 2020
5111e66
Change version number to 2.8.6
TotallyNotChase May 22, 2020
049a4c3
fix typos
TotallyNotChase May 22, 2020
b66a9ab
Remove unnecessary new line
TotallyNotChase May 22, 2020
78eadcf
Remove unused variable
TotallyNotChase May 23, 2020
435777a
Merge upstream
TotallyNotChase May 23, 2020
ba364d9
Merge pull request #2 from pajaydev/master
TotallyNotChase May 24, 2020
078d2ce
Change package version to 2.8.7
TotallyNotChase May 24, 2020
61dd172
Rename findingApi.js to finding.js
TotallyNotChase May 24, 2020
211dbd3
Merge branch 'oauth' into temp
TotallyNotChase May 24, 2020
33bd9e1
Fix merges
TotallyNotChase May 24, 2020
89022d1
Fix some resource lookups
TotallyNotChase May 24, 2020
39e96e9
Merge pull request #3 from TotallyNotChase/oauth
TotallyNotChase May 24, 2020
94294ce
Small fix for taxonomy api
TotallyNotChase May 24, 2020
d78e866
Properly use buildSearchUrl
TotallyNotChase May 24, 2020
58361bc
Avoid include selector query param from duping
TotallyNotChase May 24, 2020
fdffa30
Use template strings consistently
TotallyNotChase May 24, 2020
2d31163
Fix errorful links
TotallyNotChase May 24, 2020
192aad7
Update the demo files with the new changes
TotallyNotChase May 24, 2020
8b88396
Add setAppAccessToken function calls in demo
TotallyNotChase May 24, 2020
aab631f
Remove helpers
TotallyNotChase May 24, 2020
eb7d5b6
Add user access token demo
TotallyNotChase May 24, 2020
939bb70
Remove unnecessary functions
TotallyNotChase May 24, 2020
4ff27ab
Fix a crooked conditional
TotallyNotChase May 25, 2020
d5e19d6
Update options fields in demo files
TotallyNotChase May 25, 2020
773efbc
Fix missing param in buildSearchUrl
TotallyNotChase May 25, 2020
61fc9cc
Fix wrongly named constant
TotallyNotChase May 25, 2020
1fbac91
Fix some error messages
TotallyNotChase May 25, 2020
d9c5e34
Make variable naming consistent
TotallyNotChase May 25, 2020
59389b0
Fix `isString` use
TotallyNotChase May 25, 2020
deb7dc7
Comment wrongly uncommented line
TotallyNotChase May 25, 2020
b2b8757
Add missing params
TotallyNotChase May 25, 2020
a40be92
Fix a query param bug
TotallyNotChase May 25, 2020
7f76f59
Sync lockfile and eslint
TotallyNotChase May 26, 2020
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
41 changes: 17 additions & 24 deletions demo/browseApi.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,61 @@
const Ebay = require('../src/index');
const { clientId, clientSecret } = require('./credentials/index');

let access_token = '';
let ebay = new Ebay({
clientID: clientId,
clientSecret: clientSecret,
body: {
grant_type: 'client_credentials',
scope: 'https://api.ebay.com/oauth/api_scope'

}
});

// Getting access token and calling getItem method.
ebay.getAccessToken()
ebay.getApplicationToken()
.then((data) => {
Copy link
Owner

Choose a reason for hiding this comment

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

Shall we keep name as getAccessToken since we are using this convention from the start ?.

ebay.getItem('v1|202117468662|0').then((data) => {
ebay.setAppAccessToken(data);
ebay.getItemById('v1|202117468662|0').then((data) => {
console.log(data);
// Data is in format of JSON
// To check the format of Data, Go to this url (https://jsonblob.com/56cbea67-30b8-11e8-953c-5d1886dcf4a0)
})
});


// Reference ebay developer page https://developer.ebay.com/api-docs/buy/browse/resources/item/methods/getItemByLegacyId#_samples
// Getting access token and calling getItemByLegacyId method.
ebay.getAccessToken()
ebay.getApplicationToken()
.then((data) => {
ebay.setAppAccessToken(data);
ebay.getItemByLegacyId({
'legacyItemId': 2628001 // Get Item Details Using a Legacy ID
legacyItemID: 2628001 // Get Item Details Using a Legacy ID
}).then((data) => {
if (!data) console.log(data);
console.log(data);
// Data is in format of JSON
// To check the format of Data, Go to this url (https://jsonblob.com/56cbea67-30b8-11e8-953c-5d1886dcf4a0)
});
});

//Get Item Details Using a Legacy ID and SKU
ebay.getAccessToken()
// Get Item Details Using a Legacy ID and SKU
ebay.getApplicationToken()
.then((data) => {
ebay.setAppAccessToken(data);
ebay.getItemByLegacyId({
'legacyItemId': 2628001,
'legacyVariationSku': 'V-00031-WHM'
legacyItemID: 110039490209,
legacyVariationSku: 'V-00031-WHM'
}).then((data) => {
if (!data) console.log(data);
console.log(data);
// Data is in format of JSON
// To check the format of Data, Go to this url (https://jsonblob.com/56cbea67-30b8-11e8-953c-5d1886dcf4a0)
});
});


//retrieves the details of the individual items in an item group
// retrieves the details of the individual items in an item group
// reference https://developer.ebay.com/api-docs/buy/browse/resources/item/methods/getItemsByItemGroup#uri.item_group_id
ebay.getAccessToken()
ebay.getApplicationToken()
.then((data) => {
ebay.getItemByItemGroup('151915076499').then((data) => {
ebay.setAppAccessToken(data);
ebay.getItemByItemGroup('351825690866').then((data) => {
// Data is in format of JSON
// To check the format of Data, Go to this url (https://jsonblob.com/56cbea67-30b8-11e8-953c-5d1886dcf4a0)
console.log(data)
}, (error) => {
console.log(error);
});
});




8 changes: 4 additions & 4 deletions demo/finding.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ ebay.findItemsByKeywords({
Condition: 3000,
SoldItemsOnly: false,
affiliate: {
networkId: 9,
trackingId: 1234567890
networkID: 9,
trackingID: 1234567890
}
}).then((data) => {
console.log(data);
Expand All @@ -36,7 +36,7 @@ sale by category (using categoryId), by keywords (using keywords), or a combinat
Keyword queries search the title and subtitle of the item; they do not search descriptions. */
ebay.findCompletedItems({
keywords: 'Garmin nuvi 1300 Automotive GPS Receiver',
categoryId: '156955',
categoryID: '156955',
sortOrder: 'PricePlusShippingLowest', //https://developer.ebay.com/devzone/finding/callref/extra/fndcmpltditms.rqst.srtordr.html
Condition: 3000,
SoldItemsOnly: true,
Expand All @@ -50,7 +50,7 @@ ebay.findCompletedItems({
// // This call searches for items on eBay using specific eBay product values.
// https://developer.ebay.com/DevZone/finding/CallRef/findItemsByProduct.html#findItemsByProduct
ebay.findItemsByProduct({
productId: 53039031,
productID: 53039031,
entriesPerPage: 2
Copy link
Owner

Choose a reason for hiding this comment

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

@TotallyNotChase I don't think you have to change variable names as part of this PR, since this library is out and many people are using it. It would be difficult until or unless we have mention these changes as breaking changes and release a major version.

}).then((data) => {
console.log(data);
Expand Down
38 changes: 0 additions & 38 deletions demo/getAccessToken.js

This file was deleted.

27 changes: 27 additions & 0 deletions demo/getAppToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const Ebay = require('../src/index');
const { clientId, clientSecret } = require('./credentials/index');

let ebay = new Ebay({
clientID: clientId,
clientSecret: clientSecret,
});

ebay.getApplicationToken()
.then((data) => {
console.log(data);
if (!data.error) {
ebay.setAppAccessToken(data);
console.log(`App token: ${ebay.appAccessToken}`);
}
});

setTimeout(() => {
ebay.getApplicationToken()
.then((data) => {
console.log(data);
if (!data.error) {
ebay.setAppAccessToken(data);
console.log(`App token: ${ebay.appAccessToken}`);
}
});
}, 7200);
27 changes: 27 additions & 0 deletions demo/getUserToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const readline = require('readline');
const Ebay = require('../src/index');
const { clientId, clientSecret, redirectUri } = require('./credentials/index');

let ebay = new Ebay({
clientID: clientId,
clientSecret: clientSecret,
redirectUri: redirectUri,
});

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});

const authURL = ebay.getUserAuthorizationUrl();
console.log(`Please go here for auth code: ${authURL}`);
rl.question("Enter the auth code recieved from the redirect url: ", code => {
rl.close();
ebay.getAccessTokenByCode(code).then(data => {
console.log(data);
if (!data.error) {
ebay.setUserAccessToken(data);
console.log(`User token: ${ebay.userAccessToken}\nRefresh token: ${ebay.refreshToken}`);
}
})
});
9 changes: 2 additions & 7 deletions demo/merchandisingApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ const { clientId, clientSecret } = require('./credentials/index');
let ebay = new Ebay({
clientID: clientId,
clientSecret: clientSecret,
body: {
grant_type: 'client_credentials',
scope: 'https://api.ebay.com/oauth/api_scope'

}
});


ebay.getMostWatchedItems({
maxResults: 3, // optional
categoryId: 267 // optional
categoryID: 267 // optional
}).then((data) => {
if (data.errorMessage) {
console.log('Error:' + data.errorMessage);
Expand All @@ -25,7 +20,7 @@ ebay.getMostWatchedItems({

ebay.getSimilarItems({
maxResults: 3, // optional
itemId: '280254552262' // optional
itemID: '280254552262' // optional
}).then((data) => {
if (data.errorMessage) {
console.log('Error:' + data.errorMessage);
Expand Down
27 changes: 13 additions & 14 deletions demo/searchApi.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
const Ebay = require('../src/index');
const { clientId, clientSecret } = require('./credentials');
const makeString = require('make-string');

let ebay = new Ebay({
clientID: clientId,
clientSecret: clientSecret,
body: {
grant_type: 'client_credentials',
scope: 'https://api.ebay.com/oauth/api_scope'

}
});


// // //Search for Items by Keyword.
ebay.getAccessToken()
ebay.getApplicationToken()
.then((data) => {
ebay.setAppAccessToken(data);
ebay.searchItems({
keyword: 'drone',
limit: '3'
Expand All @@ -28,10 +23,11 @@ ebay.getAccessToken()


// // Search for Items by Category.
ebay.getAccessToken()
ebay.getApplicationToken()
.then((data) => {
ebay.setAppAccessToken(data);
ebay.searchItems({
categoryId: 2080,
categoryID: 2080,
limit: '3'
}).then((data) => {
console.log(data);
Expand All @@ -43,8 +39,9 @@ ebay.getAccessToken()


// // Retrieve the Item Aspects by Keyword Search.
ebay.getAccessToken()
ebay.getApplicationToken()
.then((data) => {
ebay.setAppAccessToken(data);
ebay.searchItems({
keyword: 'iphone',
fieldgroups: 'ASPECT_REFINEMENTS'
Expand All @@ -58,8 +55,9 @@ ebay.getAccessToken()

// // Return Items with Free Shipping.
// // Pass params inside filter object to filter items.
ebay.getAccessToken()
ebay.getApplicationToken()
.then((data) => {
ebay.setAppAccessToken(data);
ebay.searchItems({
keyword: 'drone',
limit: 3,
Expand All @@ -74,8 +72,9 @@ ebay.getAccessToken()


// Return Items Based on Price and Condition.
ebay.getAccessToken()
ebay.getApplicationToken()
.then((data) => {
ebay.setAppAccessToken(data);
ebay.searchItems({
keyword: 'iphone',
limit: 3,
Expand All @@ -90,9 +89,9 @@ ebay.getAccessToken()

// // Search items by Image, this is in experimental mode.
// https://developer.ebay.com/api-docs/buy/browse/resources/search_by_image/methods/searchByImage
ebay.getAccessToken()
ebay.getApplicationToken()
.then((data) => {
console.log
ebay.setAppAccessToken(data);
ebay.searchByImage({
imgPath: 'demo/shoe.jpg',
limit: 3,
Expand Down
6 changes: 3 additions & 3 deletions 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', includeSelector: 'Details' }).then((data) => {
ebay.getUserDetails({ userID: 'ajaykumapratha_0', includeSelector: 'Details' }).then((data) => {
console.log(data);
}, (error) => {
console.log(error);
Expand All @@ -33,7 +33,7 @@ ebay.getItemStatus(['153265274986', '153265274986']).then((data) => {

// https://developer.ebay.com/devzone/shopping/docs/callref/GetShippingCosts.html
ebay.getShippingCosts({
itemId: '153265274986', destinationCountryCode: 'US',
itemID: '153265274986', destinationCountryCode: 'US',
destinationPostalCode: '95128'
}).then((data) => {
console.log(data);
Expand All @@ -46,6 +46,6 @@ ebay.getSingleItem('153265274986').then((data) => {
console.log(data);
});

ebay.getMultipleItems({ itemId: ['153265274986', '153265274986'] }).then((data) => {
ebay.getMultipleItems({ itemID: ['153265274986', '153265274986'] }).then((data) => {
console.log(data);
});
8 changes: 2 additions & 6 deletions demo/taxonomyApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ const { clientId, clientSecret } = require('./credentials');
let ebay = new Ebay({
clientID: clientId,
clientSecret: clientSecret,
body: {
grant_type: 'client_credentials',
scope: 'https://api.ebay.com/oauth/api_scope'

}
});

// reference https://developer.ebay.com/api-docs/commerce/taxonomy/resources/category_tree/methods/getDefaultCategoryTreeId
ebay.getAccessToken()
ebay.getApplicationToken()
.then((data) => {
ebay.setAppAccessToken(data);
ebay.getDefaultCategoryTreeId('EBAY_US').then((data) => {
console.log(data);
// for EN_US { categoryTreeId: '0', categoryTreeVersion: '119' }
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ebay-node-api",
"version": "2.8.5",
"version": "2.8.7",
"description": "Ebay node api client",
"main": "./src/index.js",
"homepage": "https://github.com/pajaydev/ebay-node-api",
Expand Down Expand Up @@ -37,13 +37,13 @@
"oauth-ebay": "^1.0.0"
},
"devDependencies": {
"chai": "^4.1.2",
"docsify": "^4.10.2",
"chai": "^4.2.0",
"docsify": "^4.11.3",
"documentation": "^12.1.4",
"eslint": "^5.8.0",
"gh-pages": "^2.2.0",
"mocha": "^5.0.1",
"nock": "^9.2.3",
"sinon": "^4.4.5"
"mocha": "^5.2.0",
"nock": "^9.6.1",
"sinon": "^4.5.0"
}
}
}
Loading