Skip to content

Commit

Permalink
chore: update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dantio committed Mar 19, 2021
1 parent ed171f5 commit 994887b
Show file tree
Hide file tree
Showing 18 changed files with 153 additions and 135 deletions.
41 changes: 20 additions & 21 deletions examples/restful/authFlow.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
// tslint:disable:no-console
// @ts-ignore
import readline from 'readline';
import EBay from '../../src';
import eBayApi from '../../src';

const ebay = EBay.fromEnv();
ebay.auth.oAuth2.setScope([
'https://api.ebay.com/oauth/api_scope',
'https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly',
'https://api.ebay.com/oauth/api_scope/sell.fulfillment'
const eBay = eBayApi.fromEnv();
eBay.auth.oAuth2.setScope([
'https://api.ebay.com/oauth/api_scope',
'https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly',
'https://api.ebay.com/oauth/api_scope/sell.fulfillment'
]);

const url = ebay.auth.oAuth2.generateAuthUrl();
const url = eBay.auth.oAuth2.generateAuthUrl();

console.log('Authorize this app by visiting this url:', url);

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

rl.question('Enter the code from that page here (from the url query ?code=) : ', async (code: string) => {
rl.close();
code = decodeURIComponent(code);
console.log('Enter code', code);
const token = await ebay.auth.oAuth2.getToken(code);
console.log('Token: ', token);
ebay.auth.oAuth2.setCredentials(token);
rl.close();
code = decodeURIComponent(code);
console.log('Enter code', code);
const token = await eBay.auth.oAuth2.getToken(code);
console.log('Token: ', token);
eBay.auth.oAuth2.setCredentials(token);

ebay.sell.fulfillment.getOrder('12-12345-12345').then(order => {
console.log('order', JSON.stringify(order, null, 2));
}).catch(e => {
console.log('error', {error: e.message});
});
eBay.sell.fulfillment.getOrder('12-12345-12345').then(order => {
console.log('order', JSON.stringify(order, null, 2));
}).catch(e => {
console.log('error', {error: e.message});
});
});
18 changes: 9 additions & 9 deletions examples/restful/buy/getAlsoBoughtProducts.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// tslint:disable:no-console
import EBay from '../../../src';
import eBayApi from '../../../src';

const ebay = EBay.fromEnv();
const eBay = eBayApi.fromEnv();

// Check OAuth Scope if this really works for you: https://developer.ebay.com/my/keys
ebay.auth.oAuth2.setScope([
'https://api.ebay.com/oauth/api_scope',
'https://api.ebay.com/oauth/api_scope/buy.marketing'
eBay.auth.oAuth2.setScope([
'https://api.ebay.com/oauth/api_scope',
'https://api.ebay.com/oauth/api_scope/buy.marketing'
]);

ebay.buy.marketing.getAlsoBoughtByProduct({
gtin: '8806088687681'
eBay.buy.marketing.getAlsoBoughtByProduct({
gtin: '8806088687681'
}).then(products => {
console.log(JSON.stringify(products, null, 2));
console.log(JSON.stringify(products, null, 2));
}).catch(e => {
console.log(e);
console.log(e);
});
18 changes: 9 additions & 9 deletions examples/restful/buy/getItem.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// tslint:disable:no-console
import EBay from '../../../src';
import eBayApi from '../../../src';

const ebay = EBay.fromEnv();
const eBay = eBayApi.fromEnv();

ebay.buy.browse.getItem('v1|382282567190|651094235351')
.then(item => {
console.log(JSON.stringify(item, null, 2));
})
.catch(e => {
console.log(e);
});
eBay.buy.browse.getItem('v1|382282567190|651094235351')
.then(item => {
console.log(JSON.stringify(item, null, 2));
})
.catch(e => {
console.log(e);
});
10 changes: 5 additions & 5 deletions examples/restful/buy/getShoppingCart.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// tslint:disable:no-console
import EBay from '../../../src';
import eBayApi from '../../../src';

const ebay = EBay.fromEnv();
const eBay = eBayApi.fromEnv();

ebay.buy.browse.getShoppingCart().then(cart => {
console.log(cart);
eBay.buy.browse.getShoppingCart().then(cart => {
console.log(cart);
}).catch(e => {
console.log(e);
console.log(e);
});
16 changes: 8 additions & 8 deletions examples/restful/postOrder/getInquiry.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// tslint:disable:no-console
import EBay from '../../../src';
import eBayApi from '../../../src';

const ebay = EBay.fromEnv();
const eBay = eBayApi.fromEnv();

(async () => {
try {
const summary = await ebay.postOrder.inquiry.getInquiry('5222222222');
console.log(JSON.stringify(summary, null, 2));
} catch (e) {
console.error(e);
}
try {
const summary = await eBay.postOrder.inquiry.getInquiry('5222222222');
console.log(JSON.stringify(summary, null, 2));
} catch (e) {
console.error(e);
}
})();
16 changes: 8 additions & 8 deletions examples/restful/postOrder/getReturn.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// tslint:disable:no-console
import EBay from '../../../src';
import eBayApi from '../../../src';

const ebay = EBay.fromEnv();
const eBay = eBayApi.fromEnv();

(async () => {
try {
const summary = await ebay.postOrder.return.getReturn('5132021997');
console.log(summary);
} catch (e) {
console.error(e);
}
try {
const summary = await eBay.postOrder.return.getReturn('5132021997');
console.log(summary);
} catch (e) {
console.error(e);
}
})();
7 changes: 4 additions & 3 deletions examples/restful/sell/getOrder.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import EBay from '../../../src';
// tslint:disable:no-console
import eBayApi from '../../../src';

const ebay = EBay.fromEnv();
const eBay = eBayApi.fromEnv();

ebay.sell.fulfillment.getOrder('<order-id>').then(order => {
eBay.sell.fulfillment.getOrder('<order-id>').then(order => {
console.log('order', JSON.stringify(order, null, 2));
}).catch(e => {
console.log('error', {error: e.message});
Expand Down
15 changes: 0 additions & 15 deletions examples/traditional/GetMyMessages.ts

This file was deleted.

19 changes: 0 additions & 19 deletions examples/traditional/GetMyeBaySelling.ts

This file was deleted.

24 changes: 0 additions & 24 deletions examples/traditional/GetPublicAlerts.ts

This file was deleted.

13 changes: 0 additions & 13 deletions examples/traditional/GeteBayOfficialTime.ts

This file was deleted.

25 changes: 25 additions & 0 deletions examples/traditional/clientAlerts.GetPublicAlerts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// tslint:disable:no-console
import eBayApi from '../../src';

import {EventType} from '../../src/api/traditional/clientAlerts';

const eBay = eBayApi.fromEnv();

eBay.clientAlerts.GetPublicAlerts({
ChannelDescriptor: [
{
ChannelType: 'Item',
ChannelID: 174028462015,
EventType: [EventType.ItemEnded]
},
{
ChannelType: 'Item',
ChannelID: 180434053857,
EventType: [EventType.ItemEnded]
}
]
}).then(result => {
console.log(JSON.stringify(result, null, 2));
}).catch(e => {
console.log(e);
});
16 changes: 16 additions & 0 deletions examples/traditional/finding.findCompletedItems.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// tslint:disable:no-console
// @ts-ignore
import eBayApi from '../../src';

const eBay = eBayApi.fromEnv();

eBay.finding.findItemsAdvanced({
itemFilter: [{
name: 'Seller',
value: 'hendt_de'
}]
}).then(result => {
console.log(JSON.stringify(result, null, 2));
}).catch(e => {
console.log(e);
})
15 changes: 15 additions & 0 deletions examples/traditional/trading.GetMyMessages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// tslint:disable:no-console
import eBayApi from '../../src';

const eBay = eBayApi.fromEnv();

eBay.trading.GetMyMessages({
MessageIDs: {
MessageID: [117475106841]
},
DetailLevel: 'ReturnMessages'
}).then(result => {
console.log(JSON.stringify(result, null, 2));
}).catch(e => {
console.error(e);
});
19 changes: 19 additions & 0 deletions examples/traditional/trading.GetMyeBaySelling.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// tslint:disable:no-console
import eBayApi from '../../src';

const eBay = eBayApi.fromEnv();

eBay.trading.GetMyeBaySelling({
SoldList: {
Include: true,
OrderStatusFilter: 'AwaitingPayment',
Pagination: {
EntriesPerPage: 20,
PageNumber: 1
}
}
}).then(result => {
console.log(JSON.stringify(result, null, 2));
}).catch(e => {
console.error(e);
});
13 changes: 13 additions & 0 deletions examples/traditional/trading.GeteBayOfficialTime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// tslint:disable:no-console
import eBayApi from '../../src';

const eBay = eBayApi.fromEnv();

(async () => {
try {
const time = await eBay.trading.GeteBayOfficialTime();
console.log(time);
} catch (e) {
console.log(e);
}
})();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"scripts": {
"build": "rimraf lib && tsc && rollup -c",
"prepare": "npm run build",
"tslint": "tslint -c tslint.json '{src,test}/**/*.ts'",
"tslint": "tslint -c tslint.json '{src,test,examples}/**/*.ts'",
"test": "mocha -r ts-node/register 'test/**/*.spec.ts' --reporter=dot",
"prerelease": "npm run tslint && npm run test && npm run build",
"release": "standard-version"
Expand Down
1 change: 1 addition & 0 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
],
"jsRules": {},
"rules": {
"indent": [true, "spaces", 2],
"object-literal-sort-keys": false,
"quotemark": [true, "single"],
"trailing-comma": [false],
Expand Down

0 comments on commit 994887b

Please sign in to comment.