Skip to content

Commit

Permalink
Merge pull request #2 from bhushankumarl/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Bhushankumar L authored Sep 18, 2018
2 parents 43137cc + 0b3b574 commit 5827ca1
Show file tree
Hide file tree
Showing 19 changed files with 307 additions and 102 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.0.2 September 19, 2018
- Add Support for browse API : search
- Add SANDBOX usage using environment variable
- Changes for the Taxonomy API
- Add Support for Inventory API : createOrReplaceInventoryItem, getInventoryItem

0.0.1 September 19, 2018
- Initial release with Taxonomy API
- Add Support for getOAuthToken
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@ export EBAY_CLIENT_ID=KEY
export EBAY_CLIENT_SECRET=SECRET
```

## To Enable Sanbox Purpose
```bash
export EBAY_CLIENT_SANDBOX='true'
```

## Configuration Using JavaScript
```js
var eBay = require('../../../lib/eBay-node-client')('YOUR_KEY', 'YOUR_SECRET');
var eBay = require('ebay-node-client')('YOUR_KEY', 'YOUR_SECRET');
```

## Configuration Using TypeScript
```typescript
import * as eBay from 'eBay-node-client';
import * as eBay from 'ebay-node-client';

const eBay = new eBay();
eBay.setApiKey('YOUR_KEY', 'YOUR_SECRET');
Expand Down
5 changes: 3 additions & 2 deletions examples/javaScript/application/oauthToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';

var eBay = require('../../../lib/eBay-node-client')(clientId, clientSecret);

var feedRequest = async function () {
var applicationRequest = async function () {

try {
var token = await eBay.application.getOAuthToken({
grant_type: 'client_credentials',
scope: 'https://api.ebay.com/oauth/api_scope'
});
console.log('token.access_token ', token.access_token);
eBay.setToken(token.access_token);
} catch (error) {
console.log('error ', error);
}
};

feedRequest();
applicationRequest();
29 changes: 29 additions & 0 deletions examples/javaScript/buy/browse/getItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';

var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret);

var browseRequest = async function () {
try {
var token = await eBay.application.getOAuthToken({
grant_type: 'client_credentials',
scope: 'https://api.ebay.com/oauth/api_scope'
});
eBay.setToken(token.access_token);
} catch (error) {

}

var itemId = 'v1|110329773707|410089528845';
eBay.browse.getItem(itemId, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
console.log('response', response);
});
};

browseRequest();
32 changes: 32 additions & 0 deletions examples/javaScript/buy/browse/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';

var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret);

var browseRequest = async function () {
try {
var token = await eBay.application.getOAuthToken({
grant_type: 'client_credentials',
scope: 'https://api.ebay.com/oauth/api_scope'
});
eBay.setToken(token.access_token);
} catch (error) {

}

var data = {
gtin: '010942122258',
limit: '1'
};
eBay.browse.search(data, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
console.log('response', response);
});
};

browseRequest();
8 changes: 5 additions & 3 deletions examples/javaScript/commerce/taxonomy/getCategorySubtree.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';

var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret, true);
var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret);

var categoryRequest = async function () {
try {
Expand All @@ -17,9 +17,11 @@ var categoryRequest = async function () {
}

var categoryTreeId = 203;
var categoryId = 179623;
var data = {
category_id: '179623'
};

eBay.taxonomy.getCategorySubtree(categoryTreeId, categoryId, function (error, response) {
eBay.taxonomy.getCategorySubtree(categoryTreeId, data , function (error, response) {
if (error) {
console.log('error ', error);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';

var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret, true);
var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret);

var categoryRequest = async function () {
try {
Expand All @@ -17,9 +17,11 @@ var categoryRequest = async function () {
}

var categoryTreeId = 203;
var search_terms = 'abc';

eBay.taxonomy.getCategorySuggestions(categoryTreeId, search_terms, function (error, response) {
var data = {
'q': 'abc'
};
eBay.taxonomy.getCategorySuggestions(categoryTreeId, data, function (error, response) {
if (error) {
console.log('error ', error);
return;
Expand Down
2 changes: 1 addition & 1 deletion examples/javaScript/commerce/taxonomy/getCategoryTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';

var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret, true);
var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret);

var categoryRequest = async function () {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';

var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret, true);
var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret);

var categoryRequest = async function () {
try {
Expand All @@ -16,7 +16,10 @@ var categoryRequest = async function () {

}

eBay.taxonomy.getDefaultCategoryTreeId('EBAY_IN', function (error, response) {
var data = {
marketplace_id: 'EBAY_IN'
};
eBay.taxonomy.getDefaultCategoryTreeId(data, function (error, response) {
if (error) {
console.log('error ', error);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';

var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret, true);
var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret);

var categoryRequest = async function () {
try {
Expand All @@ -17,9 +17,11 @@ var categoryRequest = async function () {
}

var categoryTreeId = 203;
var categoryId = 179623;
var data = {
category_id: '179623'
};

eBay.taxonomy.getItemAspectsForCategory(categoryTreeId, categoryId, function (error, response) {
eBay.taxonomy.getItemAspectsForCategory(categoryTreeId, data, function (error, response) {
if (error) {
console.log('error ', error);
return;
Expand Down
50 changes: 50 additions & 0 deletions examples/javaScript/sell/inventory/createOrReplaceInventoryItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict';

var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';

var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret);

var browseRequest = async function () {
var userToken = 'USER_TOKEN';
eBay.setUserToken(userToken);

var data = {
'availability': {
'shipToLocationAvailability': {
'quantity': 50
}
},
'condition': 'NEW',
'product': {
'title': 'GoPro Hero4 Helmet Cam',
'description': 'New GoPro Hero4 Helmet Cam. Unopened box.',
'aspects': {
'Brand': ['GoPro'],
'Type': ['Helmet/Action'],
'Storage Type': ['Removable'],
'Recording Definition': ['High Definition'],
'Media Format': ['Flash Drive (SSD)'],
'Optical Zoom': ['10x']
},
'brand': 'GoPro',
'mpn': 'CHDHX-401',
'imageUrls': [
'http://i.ebayimg.com/images/i/182196556219-0-1/s-l1000.jpg',
'http://i.ebayimg.com/images/i/182196556219-0-1/s-l1001.jpg',
'http://i.ebayimg.com/images/i/182196556219-0-1/s-l1002.jpg'
]
}
};

var sku = '32984729384729';
eBay.inventory.createOrReplaceInventoryItem(sku, data, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
console.log('response', response);
});
};

browseRequest();
23 changes: 23 additions & 0 deletions examples/javaScript/sell/inventory/getInventoryItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';

var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret);

var inventoryRequest = async function () {

var userToken = 'USER_TOKEN';
eBay.setUserToken(userToken);

var sku = '32984729384729';
eBay.inventory.getInventoryItem(sku, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
console.log('response', response);
});
};

inventoryRequest();
25 changes: 25 additions & 0 deletions examples/javaScript/sell/inventory/getInventoryItems.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';

var eBay = require('../../../../lib/eBay-node-client')(clientId, clientSecret);

var inventoryRequest = async function () {

var userToken = 'USER_TOKEN';
eBay.setUserToken(userToken);

var data = {
limit: '10'
};
eBay.inventory.getInventoryItems(data, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
console.log('response', response);
});
};

inventoryRequest();
15 changes: 13 additions & 2 deletions lib/eBay-node-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ eBay.USER_AGENT_SERIALIZED = null;
var exec = require('child_process').exec;

var resources = {
taxonomy: require('./resources/commerce/taxonomy'),
application: require('./resources/application')
application: require('./resources/application'),
browse: require('./resources/buy/browse'),
inventory: require('./resources/sell/inventory'),
taxonomy: require('./resources/commerce/taxonomy')
};

eBay.eBayResource = require('./eBayResource');
Expand All @@ -51,6 +53,9 @@ function eBay(clientId, clientSecret, isSandbox) {
dev: false
};

if (process.env.EBAY_CLIENT_SANDBOX === 'true') {
this._api.host = eBay.DEFAULT_SANDBOX_HOST;
}
if (isSandbox === true) {
this._api.host = eBay.DEFAULT_SANDBOX_HOST;
}
Expand Down Expand Up @@ -98,6 +103,12 @@ eBay.prototype = {
}
},

setUserToken: function (token) {
if (token) {
this._setApiField('userToken', token);
}
},

setTimeout: function (timeout) {
this._setApiField('timeout', timeout === null ? eBay.DEFAULT_TIMEOUT : timeout);
},
Expand Down
Loading

0 comments on commit 5827ca1

Please sign in to comment.