|
|
|
@ -1,16 +1,31 @@ |
|
|
|
var util = require('util'); |
|
|
|
var v8type = require('v8type'); |
|
|
|
|
|
|
|
|
|
|
|
var alert_api = function(){ |
|
|
|
var alert_api = function(){}; |
|
|
|
|
|
|
|
}; |
|
|
|
alert_api.prototype.add_alert = function(alert, callback){ |
|
|
|
if(!v8type.is(alert, v8type.OBJECT)){ |
|
|
|
throw new Error('`alert` parameter must be an object'); |
|
|
|
} |
|
|
|
|
|
|
|
alert_api.prototype.add_alert = function(){ |
|
|
|
if(!alert['query']){ |
|
|
|
throw new Error('`alert["query"]` is required'); |
|
|
|
} |
|
|
|
|
|
|
|
this.request('POST', '/alert', {body: alert}, callback); |
|
|
|
}; |
|
|
|
|
|
|
|
alert_api.prototype.update_alert = function(){ |
|
|
|
alert_api.prototype.update_alert = function(alert_id, alert, callback){ |
|
|
|
if(!v8type.is(alert, v8type.OBJECT)){ |
|
|
|
throw new Error('`alert` parameter must be an object'); |
|
|
|
} |
|
|
|
|
|
|
|
if(!alert['query']){ |
|
|
|
throw new Error('`alert["query"]` is required'); |
|
|
|
} |
|
|
|
|
|
|
|
this.request('PUT', util.format('/alert/%s', alert_id), {body: alert}, callback); |
|
|
|
}; |
|
|
|
|
|
|
|
alert_api.prototype.get_alert = function(alert_id, callback){ |
|
|
|
@ -21,7 +36,7 @@ alert_api.prototype.delete_alert = function(){ |
|
|
|
this.request('DELETE', util.format('/alert/%s', alert_id), callback) |
|
|
|
}; |
|
|
|
|
|
|
|
alert_api.prototype.get_all_alerts = function(){ |
|
|
|
alert_api.prototype.get_all_alerts = function(callback){ |
|
|
|
this.request('GET', '/alert', callback) |
|
|
|
}; |
|
|
|
|
|
|
|
|