Skip to content

Commit

Permalink
Merge pull request #26 from bhushankumarl/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Bhushankumar L committed Feb 9, 2020
2 parents d9ee7fe + cc69119 commit 562637f
Show file tree
Hide file tree
Showing 21 changed files with 2,219 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.0.9
- Add support for trading APIs, shopping APIs & Finding APIs

0.0.8 December 13, 2018
- Add Support for eBay User Token : Get Redirect URL, Retrieve User Token & Refresh User Token

Expand Down
93 changes: 91 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ export DEBUG=eBay:*
```

## Usage
```bash
```
export EBAY_CLIENT_ID=KEY
export EBAY_CLIENT_SECRET=SECRET
```

## Additional Parameters based on different API Call
```
export EBAY_DEV_ID=DEV_ID
```

## To Enable Sandbox Purpose
```bash
export EBAY_CLIENT_SANDBOX='true'
Expand Down Expand Up @@ -425,6 +430,20 @@ Originally by [Bhushankumar L](mailto:bhushankumar.lilapara@gmail.com).
}
```

### Finding
#### Find Items By Product
```
try {
var content = fse.readFileSync('./sample.xml', 'UTF-8');
var response = await eBay.finding.findItemsByProduct({content: content});
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
```

### Sell
### Account
#### Create Or Replace Sales Tax
Expand Down Expand Up @@ -576,7 +595,7 @@ Originally by [Bhushankumar L](mailto:bhushankumar.lilapara@gmail.com).
```
var userToken = utils.USER_TOKEN;
eBay.setUserToken(userToken);
var sku = '32984729384729';
var sku = '32984729384730';
try {
var response = await eBay.inventory.getInventoryItem(sku);
console.log('response ', response);
Expand Down Expand Up @@ -937,6 +956,76 @@ Originally by [Bhushankumar L](mailto:bhushankumar.lilapara@gmail.com).
}
```

### Shopping
#### Find Products
```
try {
var content = fse.readFileSync('./sample.xml', 'UTF-8');
// console.log('content', content);
var response = await eBay.shopping.findProducts({content: content});
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
```

### Trading
#### Add Item
```
try {
var content = fse.readFileSync('./sample.xml', 'UTF-8');
// console.log('content', content);
var response = await eBay.trading.addItem({content: content});
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
```

#### Get Item
```
try {
var content = fse.readFileSync('./sample.txt', 'UTF-8');
// console.log('content', content);
var response = await eBay.trading.addItem({content: content});
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
```

#### Get Session Id
```
var devId = utils.DEV_ID;
var ruName = utils.RU_NAME;
eBay.setDevName(devId);
const obj = {
'@': {
'xmlns': 'urn:ebay:apis:eBLBaseComponents'
},
'ErrorLanguage': 'en_US',
'WarningLevel': 'High',
'RuName': ruName
};
var content = js2xmlparser.parse('GetSessionIDRequest', obj, {declaration: {encoding: 'UTF-8'}});
try {
var response = await eBay.trading.getSessionID({content: content});
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
```

### User
#### Get Redirect Url
```
Expand Down
21 changes: 21 additions & 0 deletions examples/javaScript/finding/findItemsByProduct.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';
var fse = require('fs-extra');

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

var findingRequest = async function () {
try {
var content = fse.readFileSync('./sample.xml', 'UTF-8');

var response = await eBay.finding.findItemsByProduct({content: content});
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
};

findingRequest();
7 changes: 7 additions & 0 deletions examples/javaScript/finding/sample.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<findItemsByProductRequest xmlns="http://www.ebay.com/marketplace/search/v1/services">
<productId type="ReferenceID">53039031</productId>
<paginationInput>
<entriesPerPage>2</entriesPerPage>
</paginationInput>
</findItemsByProductRequest>
2 changes: 1 addition & 1 deletion examples/javaScript/sell/inventory/getInventoryItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var utils = require('../../../javaScript/utils');
var inventoryRequest = async function () {
var userToken = utils.USER_TOKEN;
eBay.setUserToken(userToken);
var sku = '32984729384729';
var sku = '32984729384730';
try {
var response = await eBay.inventory.getInventoryItem(sku);
console.log('response ', response);
Expand Down
22 changes: 22 additions & 0 deletions examples/javaScript/shopping/findProducts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';
var fse = require('fs-extra');

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

var shoppingRequest = async function () {
try {
var content = fse.readFileSync('./sample.xml', 'UTF-8');
// console.log('content', content);

var response = await eBay.shopping.findProducts({content: content});
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
};

shoppingRequest();
6 changes: 6 additions & 0 deletions examples/javaScript/shopping/sample.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<FindProductsRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<QueryKeywords>Harry Potter</QueryKeywords>
<MaxEntries>2</MaxEntries>
<AvailableItemsOnly>true</AvailableItemsOnly>
</FindProductsRequest>
22 changes: 22 additions & 0 deletions examples/javaScript/trading/addItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';
var fse = require('fs-extra');

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

var tradingRequest = async function () {
try {
var content = fse.readFileSync('./sample.xml', 'UTF-8');
// console.log('content', content);

var response = await eBay.trading.addItem({content: content});
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
};

tradingRequest();
21 changes: 21 additions & 0 deletions examples/javaScript/trading/getItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

var clientId = process.env.EBAY_CLIENT_ID || 'YOUR_KEY';
var clientSecret = process.env.EBAY_CLIENT_SECRET || 'YOUR_SECRET';
var fse = require('fs-extra');

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

var tradingRequest = async function () {
try {
var content = fse.readFileSync('./sample.txt', 'UTF-8');
// console.log('content', content);
var response = await eBay.trading.addItem({content: content});
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
};

tradingRequest();
15 changes: 15 additions & 0 deletions examples/javaScript/trading/getItem.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<GetItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<!-- Call-specific Input Fields -->
<IncludeItemCompatibilityList>true</IncludeItemCompatibilityList>
<IncludeItemSpecifics>true</IncludeItemSpecifics>
<IncludeTaxTable>true</IncludeTaxTable>
<IncludeWatchCount>true</IncludeWatchCount>
<ItemID>SKU</ItemID>
<SKU>my-sku</SKU>
<!-- Standard Input Fields -->
<DetailLevel>DetailLevelCodeType</DetailLevel>
<!-- ... more DetailLevel values allowed here ... -->
<ErrorLanguage>en_US</ErrorLanguage>
<WarningLevel>High</WarningLevel>
</GetItemRequest>
36 changes: 36 additions & 0 deletions examples/javaScript/trading/getSessionId.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 js2xmlparser = require('js2xmlparser');

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

var tradingRequest = async function () {
var devId = utils.DEV_ID;
var ruName = utils.RU_NAME;

eBay.setDevName(devId);

const obj = {
'@': {
'xmlns': 'urn:ebay:apis:eBLBaseComponents'
},
'ErrorLanguage': 'en_US',
'WarningLevel': 'High',
'RuName': ruName
};

var content = js2xmlparser.parse('GetSessionIDRequest', obj, {declaration: {encoding: 'UTF-8'}});

try {
var response = await eBay.trading.getSessionID({content: content});
console.log('response', response);
} catch (error) {
console.log('error ', error);
return;
}
};

tradingRequest();
62 changes: 62 additions & 0 deletions examples/javaScript/trading/sample.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<AddItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<!-- Enter proper authentication token for account -->
<eBayAuthToken>AgAAAA**AQAAAA**aAAAAA**KklpXA**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wFk4ajC5iFpA2dj6x9nY+seQ**SLgEAA**AAMAAA**p0AS+8vv088NtpFvG5VTv9yCvI9cCKdQhru0LTJ0C3SWDQmEVYXiXjSMZc5r8xx1PsXHZP/SIQie4omWYQPJilhRNPbO6z0GH/kn184p8Fedx6VSgTLsJiskkOAs36f3KMuQuz2iRgTcsNLPw2hP3X70DcI2PjSdV3zsfOVjLxpQ8+Oe53ModvnCmdjOt7HUu4OUTugxhMTeDQ9TlZPUjHhyX3DSId0epD3GI5r44ygmAmPkoYQH9C+TAdj2KIg0OcwbRmcjl8wO1PyJ51oS2CicGL16c70+Cm738NU+6L3iGd7CQk2YxFIrrxPYBnrhRofm78BoSgVAhWDzpTiSnNsXrIqJgpEjmXcq5CoglYe6KHq3BXa6cT/Dl9cbLzZ4zoMbQn29L9UWvodkdUYvxE67zEpV2hPo/RWvot5TZId781ZYdO2i0fbuHljho/UGVTTOA5nSa7iWEUqVrBLePsVYmHBCK8/jnKZJAu4lmKXsM0/XtmWGYcEsuV9mdMxczZ9z5x9Rxz9vECg8myf/NAuxup3ipYEvkvKuhD6wIMXkBZNLeo1v7iPN4FAzhWCsrWIQ9Ctbvp0HFRDCeHxv/tKidPlTteJADi+hJy2oK7OUHsALr2Qp8HAk9CfQHPMgqymYqkypd4pAnrRl1NbfkeqIT0vcEQw/9rrk1vuMLG78jIzyBIKuC4rJUh8kz1d6ZS9jvWoZ7z8z979WtHnNSl9KTnhfkdN11qb+hBIirJdrGjteMHE20u/2/LYuezAg</eBayAuthToken>
</RequesterCredentials>
<ErrorLanguage>en_US</ErrorLanguage>
<WarningLevel>High</WarningLevel>
<Item>
<Title>Harry Potter and the Philosopher's Stone</Title>
<Description>This is the first book in the Harry Potter series. In excellent condition!</Description>
<PrimaryCategory>
<CategoryID>377</CategoryID>
</PrimaryCategory>
<StartPrice>1.0</StartPrice>
<CategoryMappingAllowed>true</CategoryMappingAllowed>
<Country>US</Country>
<Currency>USD</Currency>
<ConditionID>1000</ConditionID>
<DispatchTimeMax>3</DispatchTimeMax>
<ListingDuration>Days_7</ListingDuration>
<ListingType>Chinese</ListingType>
<PaymentMethods>PayPal</PaymentMethods>
<!--Enter your Paypal email address-->
<PayPalEmailAddress>XXXXX</PayPalEmailAddress>
<PictureDetails>
<PictureURL>https://mypicserver.com/myphoto.jpg</PictureURL>
</PictureDetails>
<PostalCode>95125</PostalCode>
<Quantity>1</Quantity>
<ReturnPolicy>
<ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>
<RefundOption>MoneyBack</RefundOption>
<ReturnsWithinOption>Days_30</ReturnsWithinOption>
<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>
</ReturnPolicy>
<ShippingDetails>
<ShippingType>Flat</ShippingType>
<ShippingServiceOptions>
<ShippingServicePriority>1</ShippingServicePriority>
<ShippingService>USPSMedia</ShippingService>
<ShippingServiceCost>2.50</ShippingServiceCost>
</ShippingServiceOptions>
</ShippingDetails>
<Site>US</Site>
<!-- If the seller is subscribed to Business Policies, use the <SellerProfiles> Container
instead of the <ShippingDetails>, <PaymentMethods> and <ReturnPolicy> containers.
For help, see the API Reference for Business Policies:
http://developer.ebay.com/Devzone/business-policies/CallRef/index.html -->
<!--<SellerProfiles>
<SellerShippingProfile>
<ShippingProfileID>5001287000</ShippingProfileID>
</SellerShippingProfile>
<SellerReturnProfile>
<ReturnProfileID>5001288000</ReturnProfileID>
</SellerReturnProfile>
<SellerPaymentProfile>
<PaymentProfileID>5001286000</PaymentProfileID>
</SellerPaymentProfile>
</SellerProfiles> -->
</Item>
</AddItemRequest>
4 changes: 3 additions & 1 deletion examples/javaScript/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
'use strict';
module.exports = {
USER_TOKEN: process.env.EBAY_USER_TOKEN
USER_TOKEN: process.env.EBAY_USER_TOKEN,
DEV_ID: process.env.EBAY_DEV_ID,
RU_NAME: process.env.EBAY_RU_NAME
};
Loading

0 comments on commit 562637f

Please sign in to comment.