File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ let ebay = new Ebay({
44 clientID : "Ajaykuma-nodeapi-PRD-bf1a91299-ed4deb45" ,
55 limit : 6
66} ) ;
7- ebay . findItemsByCategory ( ) . then ( ( data ) => {
7+ ebay . findItemsByCategory ( 10181 ) . then ( ( data ) => {
88 console . log ( data ) ;
99} , ( error ) => {
1010 console . log ( error ) ;
Original file line number Diff line number Diff line change 1+ const Ebay = require ( '../src/index' ) ;
2+
3+ let ebay = new Ebay ( {
4+ clientID : "Ajaykuma-nodeapi-PRD-bf1a91299-ed4deb45" ,
5+ limit : 6
6+ } ) ;
7+ ebay . getVersion ( ) . then ( ( data ) => {
8+ console . log ( data . version ) ;
9+ } , ( error ) => {
10+ console . log ( error ) ;
11+ } ) ;
12+
13+
14+
15+
Original file line number Diff line number Diff line change 11{
22 "name" : " ebay-node-api" ,
33 "version" : " 1.0.0" ,
4- "description" : " " ,
5- "main" : " index.js" ,
4+ "description" : " Ebay node api client " ,
5+ "main" : " src/ index.js" ,
66 "scripts" : {
77 "test" : " mocha"
88 },
99 "author" : " Ajaykumar prathap" ,
10- "license" : " ISC" ,
10+ "keywords" : [
11+ " eBay" ,
12+ " Shopping" ,
13+ " Searching" ,
14+ " products"
15+ ],
16+ "license" : " MIT" ,
17+ "repository" : {
18+ "type" : " git" ,
19+ "url" : " git://github.com/t3chnoboy/amazon-product-api.git"
20+ },
1121 "devDependencies" : {
1222 "chai" : " ^4.1.2" ,
1323 "mocha" : " ^5.0.1" ,
1424 "sinon" : " ^4.4.5"
1525 }
16- }
26+ }
Original file line number Diff line number Diff line change @@ -16,20 +16,19 @@ const buildURL = {
1616 let base_url = "http://svcs.ebay.com/services/search/FindingService/v1?" ;
1717 base_url += "SECURITY-APPNAME=" + options . clientID ;
1818 base_url += "&OPERATION-NAME=" + options . operationName ;
19- base_url += "&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD& " ;
20- base_url += options . param + "=" + options . name ;
21- base_url += "&paginationInput.entriesPerPage=" + options . limit ;
22- base_url += "&GLOBAL-ID=" + options . globalID ;
19+ base_url += "&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD" ;
20+ base_url += options . param ? "&" + options . param + "=" + options . name : '' ;
21+ base_url += options . limit ? "&paginationInput.entriesPerPage=" + options . limit : '' ;
22+ base_url += options . globalID ? "&GLOBAL-ID=" + options . globalID : '' ;
2323
2424 return base_url ;
2525 } ,
2626
2727 /**
2828 * Builds the Shopping(open api) URL.
2929 *
30- * @param {String } param
31- * @param {String } data
32- * @return {String } build url
30+ * @param {Object } options
31+ * @return {String } url
3332 * @private
3433 */
3534 buildShoppingUrl ( options ) {
@@ -41,7 +40,8 @@ const buildURL = {
4140 base_url += "&paginationInput.entriesPerPage=" + options . limit ;
4241 //base_url += "&GLOBAL-ID=" + oglobalID;
4342 return base_url ;
44- }
43+ } ,
44+
4545} ;
4646
4747module . exports = buildURL ;
Original file line number Diff line number Diff line change @@ -39,27 +39,40 @@ Ebay.prototype = {
3939 console . log ( url ) ;
4040 return makeRequest ( url ) . then ( ( data ) => {
4141 let result = JSON . parse ( data ) ;
42- console . log ( result ) ;
43- return result [ "findItemsByKeywordsResponse" ] ;
42+ return result [ "findItemsByCategoryResponse" ] ;
4443
4544 } , ( error ) => {
4645 console . log ( error ) ;
4746 } )
4847
4948 } ,
5049
51- getAllCategories : function ( ) {
50+ getAllCategories : function ( categoryID ) {
5251 //console.log(url);
53- this . options . name = keyword ;
52+ this . options . name = categoryID ? categoryID : - 1 ;
5453 this . options . operationName = "findItemsByKeywords" ;
55- this . options . param = "keywords " ;
54+ this . options . param = "CategoryID " ;
5655 let url = urlObject . buildShoppingUrl ( this . options ) ;
56+ console . log ( url ) ;
5757 return makeRequest ( url ) . then ( ( data ) => {
5858 let result = JSON . parse ( data ) ;
5959 return result ;
6060 } , ( error ) => {
6161 console . log ( error ) ;
6262 } )
63+ } ,
64+
65+ getVersion : function ( ) {
66+ //this.options.name = categoryID ? categoryID : -1;
67+ this . options . operationName = "getVersion" ;
68+ //this.options.param = "CategoryID";
69+ let url = urlObject . buildSearchUrl ( this . options ) ;
70+ return makeRequest ( url ) . then ( ( data ) => {
71+ let result = JSON . parse ( data ) ;
72+ return result [ "getVersionResponse" ] [ 0 ] ;
73+ } , ( error ) => {
74+ console . log ( error ) ;
75+ } )
6376 }
6477
6578} ;
You can’t perform that action at this time.
0 commit comments