Skip to content

Commit

Permalink
Merge pull request #31 from bhushankumarl/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Bhushankumar L authored Feb 27, 2020
2 parents 562637f + 2208305 commit c573773
Show file tree
Hide file tree
Showing 21 changed files with 503 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ typings/
.idea

#Temp Directory
temp/*
temp/*
.DS_Store
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
node_modules/*
.npm-debug.log
tags
package-lock.json
.idea
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ node_js:
- "7"
- "8"
- "9"
- "10"
- "11"
- "12"
sudo: false
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
0.0.10
- Add support for override content language
- Add support for the fulfillment API
- Add support for override marketplace
- Add support for the payment policy API
- Add support for the return policy API
- Add support for the searchByImage API
- Add example sample for the bulkCreateOrReplaceInventoryItem & bulkUpdatePriceQuantity;
- Add typescript support for the bulkCreateOrReplaceInventoryItem & bulkUpdatePriceQuantity;

0.0.9
- Add support for trading APIs, shopping APIs & Finding APIs

Expand Down
146 changes: 146 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ const eBay = new eBay();
eBay.setApiKey('YOUR_KEY', 'YOUR_SECRET');
```

## Set Application Access Token
```js
eBay.setToken(token.access_token);
```

## Set User Token
```js
eBay.setUserToken(userToken);
```

## Set Content Language (Default is en-US)
```js
eBay.setContentLanguage('en-GB');
```

## Set MarketplaceId
```js
eBay.setMarketplaceId('EBAY_US');
```

## Pull Request
- Contributors can send their Pull Request to `development` branch.
- Kindly validate test cases & linting before opening new PR.
Expand Down Expand Up @@ -134,6 +154,24 @@ Originally by [Bhushankumar L](mailto:[email protected]).
}
```

#### Search By Image
```
var userToken = utils.USER_TOKEN;
eBay.setUserToken(userToken);
var base64Content = base64_encode('sample-image.jpg');
// console.log('base64Content ', base64Content);
var data = {
image: base64Content
};
try {
var response = await eBay.browse.searchByImage(data);
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
```

### Commerce
### Catalog
#### Create Change Request
Expand Down Expand Up @@ -480,6 +518,23 @@ Originally by [Bhushankumar L](mailto:[email protected]).
}
```

### Fulfillment Policy
#### Get Fulfillment Policies
```
var userToken = utils.USER_TOKEN;
eBay.setUserToken(userToken);
var data = {
marketplace_id: 'EBAY_US'
};
try {
var response = await eBay.fulfillmentPolicy.getFulfillmentPolicies(data);
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
```

#### Get Sales Tax
```
var userToken = utils.USER_TOKEN;
Expand Down Expand Up @@ -511,7 +566,98 @@ Originally by [Bhushankumar L](mailto:[email protected]).
}
```

### Payment Policy
#### Get Payment Policies
```
var userToken = utils.USER_TOKEN;
eBay.setUserToken(userToken);
var data = {
marketplace_id: 'EBAY_US'
};
try {
var response = await eBay.paymentPolicy.getPaymentPolicies(data);
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
```

### Return Policy
#### Get Return Policies
```
var userToken = utils.USER_TOKEN;
eBay.setUserToken(userToken);
var data = {
marketplace_id: 'EBAY_US'
};
try {
var response = await eBay.returnPolicy.getReturnPolicies(data);
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
```

### Inventory
#### Bulk Create Or Replace Inventory Item
```
var userToken = utils.USER_TOKEN;
eBay.setUserToken(userToken);
var data = {
'requests': [
{
'sku': '13465446'
},
{
'sku': '132165496'
}
]
};
try {
var response = await eBay.inventory.bulkCreateOrReplaceInventoryItem(data);
console.log('response ', response);
} catch (error) {
console.log('error ', error);
return;
}
```

#### Bulk Update Price Quantity
```
var userToken = utils.USER_TOKEN;
eBay.setUserToken(userToken);
var data = { /* BulkPriceQuantity */
'requests': [
{ /* PriceQuantity */
'offers': [
{ /* OfferPriceQuantity */
'availableQuantity': 'integer',
'offerId': 'string',
'price': { /* Amount */
'currency': 'string',
'value': 'string'
}
}
],
'shipToLocationAvailability': {
/* ShipToLocationAvailability */
'quantity': 'integer'
},
'sku': 'string'
}
]
}
try {
var response = await eBay.inventory.bulkUpdatePriceQuantity(sku, data);
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
```

#### Create Or Replace Inventory Item
```
var userToken = utils.USER_TOKEN;
Expand Down
Binary file added examples/javaScript/buy/browse/sample-image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions examples/javaScript/buy/browse/searchByImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'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 utils = require('../../../javaScript/utils');

var fs = require('fs');

// function to encode file data to base64 encoded string
function base64_encode (file) {
// read binary data
var bitmap = fs.readFileSync(file);
// convert binary data to base64 encoded string
return new Buffer(bitmap).toString('base64');
}

var browseRequest = async function () {
var userToken = utils.USER_TOKEN;
eBay.setUserToken(userToken);
var base64Content = base64_encode('sample-image.jpg');
// console.log('base64Content ', base64Content);
var data = {
image: base64Content
};
try {
var response = await eBay.browse.searchByImage(data);
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
};

browseRequest();
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'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 utils = require('../../../../javaScript/utils');

var accountRequest = async function () {
var userToken = utils.USER_TOKEN;
eBay.setUserToken(userToken);
var data = {
marketplace_id: 'EBAY_US'
};
try {
var response = await eBay.fulfillmentPolicy.getFulfillmentPolicies(data);
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
};

accountRequest();
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'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 utils = require('../../../utils');

var accountRequest = async function () {
var userToken = utils.USER_TOKEN;
eBay.setUserToken(userToken);
var data = {
marketplace_id: 'EBAY_US'
};
try {
var response = await eBay.paymentPolicy.getPaymentPolicies(data);
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
};

accountRequest();
24 changes: 24 additions & 0 deletions examples/javaScript/sell/account/returnPolicy/getReturnPolicies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'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 utils = require('../../../utils');

var accountRequest = async function () {
var userToken = utils.USER_TOKEN;
eBay.setUserToken(userToken);
var data = {
marketplace_id: 'EBAY_US'
};
try {
var response = await eBay.returnPolicy.getReturnPolicies(data);
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
};

accountRequest();
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'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 utils = require('../../utils');

var inventoryRequest = async function () {
var userToken = utils.USER_TOKEN;
eBay.setUserToken(userToken);
var data = {
'requests': [
{
'sku': '13465446'
},
{
'sku': '132165496'
}
]
};
try {
var response = await eBay.inventory.bulkCreateOrReplaceInventoryItem(data);
console.log('response ', response);
} catch (error) {
console.log('error ', error);
return;
}
};

inventoryRequest();
Loading

0 comments on commit c573773

Please sign in to comment.