Comparing version 0.0.1 to 0.0.2
@@ -1,7 +0,7 @@ | ||
var yo = require('../index'); | ||
var yode = require('../index'); | ||
yo = new yode(); | ||
var y = new yo(); | ||
y.authenticate('31a84ae3-dcee-43eb-14c0-184677f1b15c', function (data){ | ||
console.log(data); | ||
// authenticate, and send a yo to everyone subscribed to the account "yodenodedev" | ||
yo.authenticate('083eeb23-3d19-1adb-e618-b8c4382804fd', function (data){ | ||
yo.yoAll(); | ||
}); |
var request = require('request'); | ||
var Client = module.exports = function() { | ||
if(!(this instanceof Client)) return new Client(); | ||
var e = module.exports = function() { | ||
if(!(this instanceof e)) return new e(); | ||
}; | ||
Client.prototype.authenticate = function(api_key, cb) { | ||
e.prototype.authenticate = function(api_key, cb) { | ||
var self = this; | ||
@@ -28,24 +28,4 @@ request.get('http://api.justyo.co/subscribers_count/?api_token=' + api_key, function (err, response, body) { | ||
Client.prototype.yoAll = function(cb) { | ||
e.prototype.yo = function(usernames, cb) { | ||
var self = this; | ||
if (self.api_key != undefined) { | ||
request.post('http://api.justyo.co/yoall/', {form: { | ||
'api_token': self.api_key | ||
}}, function (err, response, body) { | ||
if (err) throw err; | ||
return cb ? cb({ | ||
"status": 1 | ||
}) : true; | ||
}); | ||
} | ||
else { | ||
return cb ? cb({ | ||
"status": 0, | ||
"error":"No API key has been set." | ||
}) : false; | ||
} | ||
}; | ||
Client.prototype.yoUser = Client.prototype.yoUsers = Client.prototype.yo = function(usernames, cb) { | ||
var self = this; | ||
if (usernames instanceof Array) { | ||
@@ -95,12 +75,31 @@ for (var i in usernames) { | ||
Client.prototype.getSubscriberCount = function(cb) { | ||
e.prototype.yoAll = function(cb) { | ||
var self = this; | ||
request.get('http://api.justyo.co/subscribers_count/?api_token=' + self.api_token, function (err, response, body) { | ||
if (self.api_key != undefined) { | ||
request.post('http://api.justyo.co/yoall/', {form: { | ||
'api_token': self.api_key | ||
}}, function (err, response, body) { | ||
if (err) throw err; | ||
return cb ? cb({ | ||
"status": 1 | ||
}) : true; | ||
}); | ||
} | ||
else { | ||
return cb ? cb({ | ||
"status": 0, | ||
"error":"No API key has been set." | ||
}) : false; | ||
} | ||
}; | ||
e.prototype.getSubscriberCount = function(cb) { | ||
var self = this; | ||
request.get('http://api.justyo.co/subscribers_count/?api_token=' + self.api_key, function (err, response, body) { | ||
if (err) throw err; | ||
var data = JSON.parse(body); | ||
console.log(body); | ||
if (data.result == 1) { | ||
return cb ? cb({ | ||
"status": 1, | ||
"api_key":data | ||
"data": data.data | ||
}) : true; | ||
@@ -107,0 +106,0 @@ } |
{ | ||
"name": "yode", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A yo api wrapper for node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
3060