pushover-notifications
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -39,11 +39,22 @@ var https = require( 'https' ), | ||
self.updateSounds(); | ||
}, 7200000 ); | ||
}, 86400000 ); | ||
}; | ||
Pushover.prototype.errors = function( d ) { | ||
if ( typeof d === 'string' ) { | ||
d = JSON.parse( d ); | ||
} | ||
if ( d.errors ) { | ||
throw new Error( d.errors[0] ); | ||
} | ||
} | ||
Pushover.prototype.updateSounds = function() { | ||
var self = this, data = ''; | ||
var surl = 'https://api.pushover.net/1/sounds.json'; | ||
var surl = 'https://api.pushover.net/1/sounds.json?token=' + self.token; | ||
var req = https.request( url.parse( surl ) , function( res ) { | ||
res.on( 'end', function() { | ||
var j = JSON.parse( data ); | ||
self.errors( data ); | ||
self.sounds = j.sounds; | ||
@@ -98,2 +109,3 @@ }); | ||
res.on( 'end', function() { | ||
self.errors( data ); | ||
if ( fn ) { | ||
@@ -100,0 +112,0 @@ fn.call( null, err, data ); |
@@ -5,3 +5,3 @@ { | ||
"description": "Pushover API for node.js", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"homepage": "http://github.com/qbit/node-pushover", | ||
@@ -8,0 +8,0 @@ "repository": { |
5445
142