Comparing version 0.2.1 to 0.2.2
@@ -148,3 +148,3 @@ var Utils = require('./utils'); | ||
return Utils.request.post( | ||
'events', | ||
'rules', | ||
'devices/' + this.id + '/rules', | ||
@@ -151,0 +151,0 @@ { rule: _payload }).then(function(resp) { |
var Utils = require('./utils'); | ||
var Subscription = require('./subscription'); | ||
var extend = require('extend'); | ||
var Hoek = require('hoek'); | ||
var Joi = require('joi'); | ||
@@ -10,3 +12,3 @@ var Rule = function(_obj) { | ||
Rule.fetch = function(deviceId, id) { | ||
return Utils.request.get('events', 'devices/' + deviceId + '/rules/' + id).then(function(resp) { | ||
return Utils.request.get('rules', 'devices/' + deviceId + '/rules/' + id).then(function(resp) { | ||
return new Rule(resp.rule); | ||
@@ -46,2 +48,35 @@ }); | ||
Rule.prototype.createSubscription = function(_options) { | ||
var self = this; | ||
return Utils.request.post( | ||
'events', | ||
'devices/' + this.deviceId + '/subscriptions', | ||
{ subscription: Hoek.merge(_options, { object: { type: 'rule', id: self.id } }) } | ||
).then(function(resp) { | ||
return new Subscription(resp.subscription); | ||
}); | ||
}; | ||
Rule.prototype.events = function(_options) { | ||
var self = this; | ||
_options = Hoek.applyToDefaults({ limit: 20, objectId: this.id }, _options || {}); | ||
Joi.assert(_options, { | ||
limit: Joi.number().integer().min(0).max(100), | ||
since: Joi.date(), | ||
until: Joi.date(), | ||
type: Joi.string(), | ||
objectId: Joi.string(), | ||
objectType: Joi.string() | ||
}); | ||
return Utils.request.get( | ||
'events', | ||
'devices/' + self.deviceId + '/events', | ||
_options).then(function(resp) { | ||
return Utils.streamListResponse(resp, 'events', self.events, self); | ||
}); | ||
}; | ||
module.exports = Rule; |
{ | ||
"name": "vinli", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Official Node.js SDK for interacting with the Vinli Platform", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
81041
1714
34