Comparing version 0.0.1 to 0.1.1
122
index.js
var OAuth = require('oauth'), | ||
qs = require('querystring'); | ||
var internals = {}; | ||
/** | ||
* @name Yaboss | ||
* @param {string} consumerKey | ||
* @param {string} consumerSecret | ||
* @param {String} consumerKey | ||
* @param {String} consumerSecret | ||
* @returns {YaBoss} | ||
@@ -18,6 +20,17 @@ * @constructor | ||
/** | ||
* @name yaBoss.search | ||
* @param {string} provider one of 'web','limitedweb','images','news' ,'blogs, 'ads' | ||
* A simple implementation of object extend | ||
* @param a | ||
* @param b | ||
*/ | ||
internals.extend = function(a, b) { | ||
for (var x in b) a[x] = b[x]; | ||
return a; | ||
}; | ||
/** | ||
* @name yaBoss#search | ||
* @param {string} provider one of 'web','limitedweb','images','news' ,'blogs, 'ads' | ||
* @param {string} query search query | ||
* @param {int} count number of responses | ||
* @param {object} options - additional options. Some of the available options are: 'count', 'filter', 'sites', | ||
* for the complete list please refer to Boss's documentation: http://developer.yahoo.com/boss/search/boss_api_guide/v2_univer_api_args.html | ||
* @param {function} callback - function(err,dataFound, response){} | ||
@@ -27,10 +40,10 @@ * @description | ||
*/ | ||
YaBoss.prototype.search = function(provider, query, count, callback){ | ||
YaBoss.prototype.search = function(provider, query, options, callback){ | ||
if(callback === undefined){ | ||
callback = count; | ||
count = 10; | ||
callback = options; | ||
options = {count: 10}; // Assign default count | ||
} | ||
var webSearchUrl = 'https://yboss.yahooapis.com/ysearch/'+provider, | ||
finalUrl = webSearchUrl +'?'+ qs.stringify({q: query,count: count || 10}); | ||
finalUrl = webSearchUrl +'?'+ qs.stringify(internals.extend({q: query}, options)); | ||
@@ -43,24 +56,78 @@ var oa = new OAuth.OAuth(webSearchUrl, finalUrl , this.consumerKey, this.consumerSecret, "1.0", null, "HMAC-SHA1"); | ||
YaBoss.prototype.searchWeb = function(query, count, callback){ | ||
this.search('web',query,count,callback); | ||
/** | ||
* @name yaBoss#searchWeb | ||
* @param {string} query search query | ||
* @param {object} options - additional options. Some of the available options are: 'count', 'filter', 'sites', | ||
* for the complete list please refer to Boss's documentation: http://developer.yahoo.com/boss/search/boss_api_guide/v2_univer_api_args.html | ||
* @param {function} callback - function(err,dataFound, response){} | ||
* @description | ||
* Issue a call to web search api | ||
*/ | ||
YaBoss.prototype.searchWeb = function(query, options, callback){ | ||
this.search('web',query,options,callback); | ||
}; | ||
YaBoss.prototype.searchLimitedWeb = function(query, count, callback){ | ||
this.search('limitedweb',query,count,callback); | ||
/** | ||
* @name yaBoss#searchLimitedWeb | ||
* @param {string} query search query | ||
* @param {object} options - additional options. Some of the available options are: 'count', 'filter', 'sites', | ||
* for the complete list please refer to Boss's documentation: http://developer.yahoo.com/boss/search/boss_api_guide/v2_univer_api_args.html | ||
* @param {function} callback - function(err,dataFound, response){} | ||
* @description | ||
* Issue a call to limit web search api | ||
*/ | ||
YaBoss.prototype.searchLimitedWeb = function(query, options, callback){ | ||
this.search('limitedweb',query,options,callback); | ||
}; | ||
YaBoss.prototype.searchImages = function(query, count, callback){ | ||
this.search('images',query,count,callback); | ||
/** | ||
* @name yaBoss#searchImages | ||
* @param {string} query search query | ||
* @param {object} options - additional options. Some of the available options are: 'count', 'filter', 'sites', | ||
* for the complete list please refer to Boss's documentation: http://developer.yahoo.com/boss/search/boss_api_guide/v2_univer_api_args.html | ||
* @param {function} callback - function(err,dataFound, response){} | ||
* @description | ||
* Issue a call to images search api | ||
*/ | ||
YaBoss.prototype.searchImages = function(query, options, callback){ | ||
this.search('images',query,options,callback); | ||
}; | ||
YaBoss.prototype.searchNews = function(query, count, callback){ | ||
this.search('news',query,count,callback); | ||
/** | ||
* @name yaBoss#searchImages | ||
* @param {string} query search query | ||
* @param {object} options - additional options. Some of the available options are: 'count', 'filter', 'sites', | ||
* for the complete list please refer to Boss's documentation: http://developer.yahoo.com/boss/search/boss_api_guide/v2_univer_api_args.html | ||
* @param {function} callback - function(err,dataFound, response){} | ||
* @description | ||
* Issue a call to news search api | ||
*/ | ||
YaBoss.prototype.searchNews = function(query, options, callback){ | ||
this.search('news',query,options,callback); | ||
}; | ||
YaBoss.prototype.searchBlogs = function(query, count, callback){ | ||
this.search('blogs',query,count,callback); | ||
/** | ||
* @name yaBoss#searchBlogs | ||
* @param {string} query search query | ||
* @param {object} options - additional options. Some of the available options are: 'count', 'filter', 'sites', | ||
* for the complete list please refer to Boss's documentation: http://developer.yahoo.com/boss/search/boss_api_guide/v2_univer_api_args.html | ||
* @param {function} callback - function(err,dataFound, response){} | ||
* @description | ||
* Issue a call to search blogs api | ||
*/ | ||
YaBoss.prototype.searchBlogs = function(query, options, callback){ | ||
this.search('blogs',query,options,callback); | ||
}; | ||
YaBoss.prototype.searchAds = function(query, count, callback){ | ||
this.search('ads',query,count,callback); | ||
/** | ||
* @name yaBoss#searchAds | ||
* @param {string} query search query | ||
* @param {object} options - additional options. Some of the available options are: 'count', 'filter', 'sites', | ||
* for the complete list please refer to Boss's documentation: http://developer.yahoo.com/boss/search/boss_api_guide/v2_univer_api_args.html | ||
* @param {function} callback - function(err,dataFound, response){} | ||
* @description | ||
* Issue a call to search ads api | ||
*/ | ||
YaBoss.prototype.searchAds = function(query, options, callback){ | ||
this.search('ads',query,options,callback); | ||
}; | ||
@@ -70,5 +137,6 @@ | ||
/** | ||
* @name yaBoss.getGeoSearch | ||
* @name yaBoss#getGeoSearch | ||
* @param {string} query search query | ||
* @param {int} count number of responses | ||
* @param {object} options - additional options. Some of the available options are: 'count', 'filter', 'sites', | ||
* for the complete list please refer to Boss's documentation: http://developer.yahoo.com/boss/search/boss_api_guide/v2_univer_api_args.html | ||
* @param {function} callback - function(err,dataFound, response){} | ||
@@ -78,10 +146,10 @@ * @description | ||
*/ | ||
YaBoss.prototype.getGeoSearch = function(query, count, callback){ | ||
YaBoss.prototype.getGeoSearch = function(query, options, callback){ | ||
if(callback === undefined){ | ||
callback = count; | ||
count = 10; | ||
callback = options; | ||
options = {count: 10}; | ||
} | ||
var geoSearchUrl = 'https://yboss.yahooapis.com/geo/placefinder', | ||
finalUrl = geoSearchUrl +'?'+ qs.stringify({q: query,count: count || 10}); | ||
finalUrl = geoSearchUrl +'?'+ qs.stringify(internals.extend({q: query}, options)); | ||
@@ -88,0 +156,0 @@ var oa = new OAuth.OAuth(webSearchUrl, finalUrl , this.consumerKey, this.consumerSecret, "1.0", null, "HMAC-SHA1"); |
{ | ||
"name": "yaboss", | ||
"version": "0.0.1", | ||
"version": "0.1.1", | ||
"description": "Simple nodejs wrapper for Yahoo BOSS web api", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,9 +15,10 @@ yaboss | ||
YaBossClient.search('web','yahoo',10, function(err,dataFound,response){...}); | ||
YaBossClient.searchWeb('yahoo',10, function(err,dataFound,response){...}); | ||
YaBossClient.searchLimitedWeb('yahoo',10, function(err,dataFound,response){...}); | ||
YaBossClient.searchImages('yahoo',10, function(err,dataFound,response){...}); | ||
YaBossClient.searchNews('yahoo',10, function(err,dataFound,response){...}); | ||
YaBossClient.searchBlogs('yahoo',10, function(err,dataFound,response){...}); | ||
YaBossClient.searchAds('yahoo',10, function(err,dataFound,response){...}); | ||
YaBossClient.search('web','yahoo', {count: 10}, function(err,dataFound,response){...}); | ||
YaBossClient.searchWeb('yahoo', {count: 10}, function(err,dataFound,response){...}); | ||
YaBossClient.searchLimitedWeb('yahoo', {count: 10}, function(err,dataFound,response){...}); | ||
YaBossClient.searchImages('yahoo', {count: 10, dimensions: 'medium'}, function(err,dataFound,response){...}); | ||
YaBossClient.searchNews('yahoo', {count: 10}, function(err,dataFound,response){...}); | ||
YaBossClient.searchBlogs('yahoo', {count: 10}, function(err,dataFound,response){...}); | ||
YaBossClient.searchAds('yahoo', {count: 10}, function(err,dataFound,response){...}); | ||
YaBossClient.getGeoSearch('yahoo', {count: 10}, function(err,dataFound,response){...}); | ||
@@ -24,0 +25,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137
36
9736
7