@@ -18,7 +18,7 @@ Ebay.prototype = {
1818 this . options . name = keyword ;
1919 this . options . operationName = "findItemsByKeywords" ;
2020 this . options . param = "keywords" ;
21- let url = urlObject . buildSearchUrl ( this . options , keyword ) ;
21+ let url = urlObject . buildSearchUrl ( this . options ) ;
2222 console . log ( url ) ;
2323 return makeRequest ( url ) . then ( ( data ) => {
2424 let result = JSON . parse ( data ) ;
@@ -30,9 +30,31 @@ Ebay.prototype = {
3030
3131 } ,
3232
33+ findItemsByCategory : function ( categoryID ) {
34+ if ( ! categoryID ) throw new Error ( "Category ID is null or invalid" ) ;
35+ this . options . name = categoryID ;
36+ this . options . operationName = "findItemsByCategory" ;
37+ this . options . param = "categoryId" ;
38+ let url = urlObject . buildSearchUrl ( this . options ) ;
39+ console . log ( url ) ;
40+ return makeRequest ( url ) . then ( ( data ) => {
41+ let result = JSON . parse ( data ) ;
42+ console . log ( result ) ;
43+ return result [ "findItemsByKeywordsResponse" ] ;
44+
45+ } , ( error ) => {
46+ console . log ( error ) ;
47+ } )
48+
49+ } ,
50+
3351 getAllCategories : function ( ) {
3452 //console.log(url);
35- return makeRequest ( "http://open.api.ebay.com/Shopping?callname=GetCategoryInfo&appid=" + this . options . clientID + "&version=967&siteid=0&CategoryID=-1&responseencoding=JSON&IncludeSelector=ChildCategories" ) . then ( ( data ) => {
53+ this . options . name = keyword ;
54+ this . options . operationName = "findItemsByKeywords" ;
55+ this . options . param = "keywords" ;
56+ let url = urlObject . buildShoppingUrl ( this . options ) ;
57+ return makeRequest ( url ) . then ( ( data ) => {
3658 let result = JSON . parse ( data ) ;
3759 return result ;
3860 } , ( error ) => {
0 commit comments