Skip to content

Commit ceb4a70

Browse files
authored
Added deals api support (#119)
* v2.7.7 * 2.8.7 * adding deals * adding deals api * update readme * adde get deals support * updated readme * 2.8.9 * update package json
1 parent 5688d48 commit ceb4a70

File tree

8 files changed

+145
-26
lines changed

8 files changed

+145
-26
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,22 @@ let ebay = new eBay({
4141
}
4242
})
4343
```
44+
For Country Code and Marketplace id [check here](https://developer.ebay.com/DevZone/finding/CallRef/Enums/GlobalIdList.html)
4445

4546
## Starter Guide
4647

4748
Check out the [Starter Guide](https://pajaydev.github.io/ebay-node-api) documentation with examples to get started.
4849

4950
## Using Express js
50-
You can consume these ebay node api's using [Express](https://expressjs.com/). You can checkout the sample app [here]().
51+
You can consume these ebay node api's using [Express](https://expressjs.com/). You can checkout the sample app [here](https://github.com/pajaydev/ebay-node-api/tree/master/demo/node-express).
5152

5253
## API details
5354

5455
### Without Auth flow
5556

5657
HTTP Method | Methods | Description | Usage | Offical doc
5758
----------- | ------------------ | ----------- | ---------------- | --------------------------------
59+
GET | getDeals | Get details about the deals across eBay.| [Example](https://github.com/pajaydev/ebay-node-api/blob/master/demo/deals.js) | [doc](https://developer.ebay.com/devzone/finding/callref/finditemsbykeywords.html)
5860
GET | findItemsByKeywords | Searches for items on eBay by a keyword query.| [Example](https://github.com/pajaydev/ebay-node-api/blob/master/demo/finding.js#L21) | [doc](https://developer.ebay.com/devzone/finding/callref/finditemsbykeywords.html)
5961
GET | findCompletedItems | Searches for items whose listings are completed and are no longer available for sale by category (using categoryId), by keywords (using keywords), or a combination of the two.| [Example](https://github.com/pajaydev/ebay-node-api/blob/master/demo/finding.js#L40) | [doc](https://developer.ebay.com/devzone/finding/callref/findCompletedItems.html)
6062
GET | findItemsByProduct | Searches for items on eBay using specific eBay product values.| [Example](https://github.com/pajaydev/ebay-node-api/blob/master/demo/finding.js#L55) | [doc](https://developer.ebay.com/devzone/finding/callref/finditemsbykeywords.html)
@@ -127,7 +129,6 @@ ebay.findItemsAdvanced({
127129
console.log(error);
128130
});
129131
```
130-
131132
[More Examples](https://pajaydev.github.io/ebay-node-api)
132133

133134
## Test

demo/deals.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const Ebay = require('../src/index');
2+
const { clientId, clientSecret } = require('./credentials/index');
3+
4+
let ebay = new Ebay({
5+
clientID: clientId,
6+
clientSecret: clientSecret,
7+
body: {
8+
grant_type: 'client_credentials',
9+
scope: 'https://api.ebay.com/oauth/api_scope'
10+
11+
}
12+
});
13+
14+
// get top ten deals in US.
15+
ebay.getDeals().then((data) => {
16+
console.log(data);
17+
});
18+
19+
20+
// get deals for specific country code and category
21+
ebay.getDeals({
22+
limit: 50, // no of deals per request
23+
countryCode:'ebay-de',
24+
eBayCatId: '1234' // deal for specific category id
25+
}).then((data) => {
26+
console.log(data);
27+
});

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ebay-node-api",
3-
"version": "2.8.8",
3+
"version": "2.8.9",
44
"description": "Ebay node api client",
55
"main": "./src/index.js",
66
"homepage": "https://github.com/pajaydev/ebay-node-api",
@@ -10,7 +10,8 @@
1010
"docs": "docsify init ./docs",
1111
"serve-docs": "docsify serve docs",
1212
"docs-publish": "gh-pages --dist docs --dotfiles --message 'chore: Publish docs'",
13-
"prepublish": "npm run test"
13+
"prepublish": "npm run test",
14+
"release": "npm test && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
1415
},
1516
"author": "Ajaykumar prathap",
1617
"keywords": [
@@ -21,7 +22,8 @@
2122
"Browse",
2223
"Category",
2324
"FindingApi",
24-
"node-api"
25+
"node-api",
26+
"deals"
2527
],
2628
"license": "MIT",
2729
"repository": {
@@ -32,6 +34,7 @@
3234
"extends": "ajay"
3335
},
3436
"dependencies": {
37+
"axios": "^0.19.2",
3538
"eslint-config-ajay": "^1.0.6",
3639
"make-string": "^1.0.3"
3740
},
@@ -45,4 +48,4 @@
4548
"nock": "^9.2.3",
4649
"sinon": "^4.4.5"
4750
}
48-
}
51+
}

src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module.exports = {
44
PROD_OAUTHENVIRONMENT_WEBENDPOINT: 'https://auth.ebay.com/oauth2/authorize',
55
SANDBOX_OAUTHENVIRONMENT_WEBENDPOINT: 'https://auth.sandbox.ebay.com/oauth2/authorize',
6+
DEALS_BASE_URL: 'http://www.ebay.com/rps/feed/v1.1/',
67
PROD_BASE_URL: 'api.ebay.com',
78
SANDBOX_BASE_URL: 'api.sandbox.ebay.com',
89
BASE_SVC_URL: 'svcs.ebay.com',

src/credentials.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ const getAccessToken = function () {
1313
if (!this.options.clientID) throw new Error('Missing Client ID');
1414
if (!this.options.clientSecret) throw new Error('Missing Client Secret or Cert Id');
1515
if (!this.options.body) throw new Error('Missing Body, required Grant type');
16-
let scopesParam = this.options.body.scopes
17-
? Array.isArray(this.options.body.scopes)
18-
? this.options.body.scopes.join('%20')
19-
: this.options.body.scopes
16+
let scopesParam = this.options.body.scope
17+
? Array.isArray(this.options.body.scope)
18+
? this.options.body.scope.join('%20')
19+
: this.options.body.scope
2020
: DEFAULT_API_SCOPE;
2121
this.options.data = qs.stringify({
2222
grant_type: 'client_credentials',

src/deals.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
const axios = require('axios');
4+
const { parseObj } = require('./common-utils/index');
5+
const { DEALS_BASE_URL } = require('./constants');
6+
7+
module.exports = {
8+
9+
/**
10+
* @method getDeals {Function}
11+
* get deals based on site, category across ebay like (Today's top ten deals)
12+
* @param {Object} options (optional)
13+
*/
14+
getDeals: async function (options) {
15+
if (!this.options.clientID) throw new Error('Missing App id or client id');
16+
if (!options) options = {};
17+
const countryCode = options.countryCode ? options.countryCode : this.options.globalID;
18+
const qs = parseObj(options);
19+
const response = await axios.get(`${DEALS_BASE_URL}${countryCode}?${qs}`);
20+
return response.data;
21+
}
22+
};

src/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ const ebayBuyApi = require('./buy-api');
33
const shoppingApi = require('./shopping');
44
const taxonomyApi = require('./taxonomy-api');
55
const ebayFindingApi = require('./finding');
6+
const dealsApi = require('./deals');
67
const commonUtils = require('./common-utils');
7-
const { getSimilarItems, getMostWatchedItems } = require('./merchandising');
8+
const merchandisingApi = require('./merchandising');
89
const {
910
getAccessToken,
1011
getUserAuthorizationUrl,
@@ -63,13 +64,13 @@ Ebay.prototype = {
6364
getUserTokenByRefresh,
6465
setUserAccessToken,
6566
setAppAccessToken,
66-
getMostWatchedItems,
67-
getSimilarItems,
67+
...merchandisingApi,
6868
...commonUtils,
6969
...shoppingApi,
7070
...ebayBuyApi,
7171
...taxonomyApi,
72-
...ebayFindingApi
72+
...ebayFindingApi,
73+
...dealsApi
7374
};
7475

7576
module.exports = Ebay;

yarn.lock

Lines changed: 76 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,13 @@ atob@^2.1.2:
11871187
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
11881188
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
11891189

1190+
axios@^0.19.2:
1191+
version "0.19.2"
1192+
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27"
1193+
integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==
1194+
dependencies:
1195+
follow-redirects "1.5.10"
1196+
11901197
babel-plugin-dynamic-import-node@^2.3.0:
11911198
version "2.3.0"
11921199
resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.0.tgz#f00f507bdaa3c3e3ff6e7e5e98d90a7acab96f7f"
@@ -1588,7 +1595,7 @@ de-indent@^1.0.2:
15881595
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
15891596
integrity sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=
15901597

1591-
debug@3.1.0:
1598+
debug@3.1.0, debug@=3.1.0:
15921599
version "3.1.0"
15931600
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
15941601
dependencies:
@@ -2129,6 +2136,13 @@ flush-write-stream@^1.0.2:
21292136
inherits "^2.0.3"
21302137
readable-stream "^2.3.6"
21312138

2139+
follow-redirects@1.5.10:
2140+
version "1.5.10"
2141+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
2142+
integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==
2143+
dependencies:
2144+
debug "=3.1.0"
2145+
21322146
for-in@^1.0.2:
21332147
version "1.0.2"
21342148
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
@@ -2432,6 +2446,21 @@ highlight.js@^9.15.5:
24322446
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.1.tgz#ed21aa001fe6252bb10a3d76d47573c6539fe13c"
24332447
integrity sha512-OrVKYz70LHsnCgmbXctv/bfuvntIKDz177h0Co37DQ5jamGZLVmoCVMtjMtNZY3X9DrCcKfklHPNeA0uPZhSJg==
24342448

2449+
hoek@5.x.x:
2450+
version "5.0.4"
2451+
resolved "https://registry.yarnpkg.com/hoek/-/hoek-5.0.4.tgz#0f7fa270a1cafeb364a4b2ddfaa33f864e4157da"
2452+
integrity sha512-Alr4ZQgoMlnere5FZJsIyfIjORBqZll5POhDsF4q64dPuJR6rNxXdDxtHSQq8OXRurhmx+PWYEE8bXRROY8h0w==
2453+
2454+
hoek@6.x.x:
2455+
version "6.1.3"
2456+
resolved "https://registry.yarnpkg.com/hoek/-/hoek-6.1.3.tgz#73b7d33952e01fe27a38b0457294b79dd8da242c"
2457+
integrity sha512-YXXAAhmF9zpQbC7LEcREFtXfGq5K1fmd+4PHkBq8NUqmzW3G+Dq10bI/i0KucLRwss3YYFQ0fSfoxBZYiGUqtQ==
2458+
2459+
hoek@^4.2.1:
2460+
version "4.2.1"
2461+
resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.1.tgz#9634502aa12c445dd5a7c5734b572bb8738aacbb"
2462+
integrity sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==
2463+
24352464
hosted-git-info@^2.1.4:
24362465
version "2.8.8"
24372466
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
@@ -2766,6 +2795,13 @@ isarray@1.0.0, isarray@~1.0.0:
27662795
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
27672796
integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
27682797

2798+
isemail@3.x.x:
2799+
version "3.2.0"
2800+
resolved "https://registry.yarnpkg.com/isemail/-/isemail-3.2.0.tgz#59310a021931a9fb06bbb51e155ce0b3f236832c"
2801+
integrity sha512-zKqkK+O+dGqevc93KNsbZ/TqTUFd46MwWjYOoMrjIMZ51eU7DtQG3Wmd9SQQT7i7RVnuTPEiYEWHU3MSbxC1Tg==
2802+
dependencies:
2803+
punycode "2.x.x"
2804+
27692805
isexe@^2.0.0:
27702806
version "2.0.0"
27712807
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
@@ -2782,6 +2818,15 @@ isobject@^3.0.0, isobject@^3.0.1:
27822818
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
27832819
integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=
27842820

2821+
joi@^13.1.2:
2822+
version "13.7.0"
2823+
resolved "https://registry.yarnpkg.com/joi/-/joi-13.7.0.tgz#cfd85ebfe67e8a1900432400b4d03bbd93fb879f"
2824+
integrity sha512-xuY5VkHfeOYK3Hdi91ulocfuFopwgbSORmIwzcwHKESQhC7w1kD5jaVSPnqDxS2I8t3RZ9omCKAxNwXN5zG1/Q==
2825+
dependencies:
2826+
hoek "5.x.x"
2827+
isemail "3.x.x"
2828+
topo "3.x.x"
2829+
27852830
"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
27862831
version "4.0.0"
27872832
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
@@ -3181,6 +3226,11 @@ nan@^2.12.1:
31813226
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
31823227
integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==
31833228

3229+
nan@^2.13.2:
3230+
version "2.14.1"
3231+
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.1.tgz#d7be34dfa3105b91494c3147089315eff8874b01"
3232+
integrity sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==
3233+
31843234
nanomatch@^1.2.9:
31853235
version "1.2.13"
31863236
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
@@ -3230,6 +3280,14 @@ nock@^9.2.3:
32303280
qs "^6.5.1"
32313281
semver "^5.5.0"
32323282

3283+
node-expat@^2.3.18:
3284+
version "2.3.18"
3285+
resolved "https://registry.yarnpkg.com/node-expat/-/node-expat-2.3.18.tgz#d9e6949cecda15e131f14259b73dc7b9ed7bc560"
3286+
integrity sha512-9dIrDxXePa9HSn+hhlAg1wXkvqOjxefEbMclGxk2cEnq/Y3U7Qo5HNNqeo3fQ4bVmLhcdt3YN1TZy7WMZy4MHw==
3287+
dependencies:
3288+
bindings "^1.5.0"
3289+
nan "^2.13.2"
3290+
32333291
node-releases@^1.1.50:
32343292
version "1.1.50"
32353293
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.50.tgz#803c40d2c45db172d0410e4efec83aa8c6ad0592"
@@ -3293,12 +3351,6 @@ number-is-nan@^1.0.0:
32933351
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
32943352
integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=
32953353

3296-
oauth-ebay@^1.0.0:
3297-
version "1.0.0"
3298-
resolved "https://registry.yarnpkg.com/oauth-ebay/-/oauth-ebay-1.0.0.tgz#dc04c9f325eb346439280b08aac7c743d3e5d94e"
3299-
dependencies:
3300-
querystring "^0.2.0"
3301-
33023354
object-assign@^4.0.1, object-assign@^4.1.0:
33033355
version "4.1.1"
33043356
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
@@ -3646,7 +3698,7 @@ pumpify@^1.3.5:
36463698
inherits "^2.0.3"
36473699
pump "^2.0.0"
36483700

3649-
punycode@^2.1.0:
3701+
punycode@2.x.x, punycode@^2.1.0:
36503702
version "2.1.1"
36513703
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
36523704

@@ -3667,10 +3719,6 @@ query-string@^4.1.0:
36673719
object-assign "^4.1.0"
36683720
strict-uri-encode "^1.0.0"
36693721

3670-
querystring@^0.2.0:
3671-
version "0.2.0"
3672-
resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620"
3673-
36743722
raw-body@~1.1.0:
36753723
version "1.1.7"
36763724
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-1.1.7.tgz#1d027c2bfa116acc6623bca8f00016572a87d425"
@@ -4478,6 +4526,13 @@ to-through@^2.0.0:
44784526
dependencies:
44794527
through2 "^2.0.3"
44804528

4529+
topo@3.x.x:
4530+
version "3.0.3"
4531+
resolved "https://registry.yarnpkg.com/topo/-/topo-3.0.3.tgz#d5a67fb2e69307ebeeb08402ec2a2a6f5f7ad95c"
4532+
integrity sha512-IgpPtvD4kjrJ7CRA3ov2FhWQADwv+Tdqbsf1ZnPUSAtCJ9e1Z44MmoSGDXGk4IppoZA7jd/QRkNddlLJWlUZsQ==
4533+
dependencies:
4534+
hoek "6.x.x"
4535+
44814536
trim-lines@^1.0.0:
44824537
version "1.1.3"
44834538
resolved "https://registry.yarnpkg.com/trim-lines/-/trim-lines-1.1.3.tgz#839514be82428fd9e7ec89e35081afe8f6f93115"
@@ -4878,6 +4933,15 @@ x-is-string@^0.1.0:
48784933
resolved "https://registry.yarnpkg.com/x-is-string/-/x-is-string-0.1.0.tgz#474b50865af3a49a9c4657f05acd145458f77d82"
48794934
integrity sha1-R0tQhlrzpJqcRlfwWs0UVFj3fYI=
48804935

4936+
xml2json@^0.12.0:
4937+
version "0.12.0"
4938+
resolved "https://registry.yarnpkg.com/xml2json/-/xml2json-0.12.0.tgz#b2ae450b267033b76d896f86e022fa7bff678572"
4939+
integrity sha512-EPJHRWJnJUYbJlzR4pBhZODwWdi2IaYGtDdteJi0JpZ4OD31IplWALuit8r73dJuM4iHZdDVKY1tLqY2UICejg==
4940+
dependencies:
4941+
hoek "^4.2.1"
4942+
joi "^13.1.2"
4943+
node-expat "^2.3.18"
4944+
48814945
xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.0, xtend@~4.0.1:
48824946
version "4.0.2"
48834947
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"

0 commit comments

Comments
 (0)