Comparing version 0.2.0 to 0.3.0
@@ -8,3 +8,3 @@ #!/usr/bin/env node | ||
var M2X = require("../lib/m2x"); | ||
var M2X = require("m2x"); | ||
var exec = require("child_process").exec; | ||
@@ -54,5 +54,9 @@ | ||
this.m2xClient.feeds.postMultiple(FEED, values, function(data, error, res) { | ||
if (res.statusCode !== 204) { | ||
if (error || res.statusCode !== 204) { | ||
// abort if something went wrong | ||
clearInterval(this.updateInterval); | ||
if (error) { | ||
console.log(error); | ||
} | ||
} | ||
@@ -59,0 +63,0 @@ }.bind(this)); |
@@ -15,6 +15,25 @@ 'use strict'; | ||
// List/search all the feeds that belong to the user associated | ||
// with the M2X API key supplied when initializing M2X | ||
// | ||
// The list of feeds can be filtered by using one or more of the | ||
// following optional parameters: | ||
// | ||
// * `q` text to search, matching the name and description. | ||
// * `type` one of `bleuprint`, `batch` and `datasource`. | ||
// * `tags` a comma separated list of tags. | ||
// * `limit` how many results per page. | ||
// * `page` the specific results page, starting by 1. | ||
// * `latitude` and `longitude` for searching feeds geographically. | ||
// * `distance` numeric value in `distance_unit`. | ||
// * `distance_unit` either `miles`, `mi` or `km`. | ||
Feeds.prototype.search = function(params, cb) { | ||
return this.client.get("/feeds", { qs: params || {} }, cb); | ||
}; | ||
// List all the feeds that belong to the user associated with the | ||
// M2X API key supplied when initializing M2X | ||
Feeds.prototype.list = function(cb) { | ||
return this.client.get("/feeds", cb); | ||
return this.search({}, cb); | ||
}; | ||
@@ -56,5 +75,25 @@ | ||
// Return a list with the latest values from a stream | ||
Feeds.prototype.streamValues = function(id, name, cb) { | ||
return this.client.get(helpers.url("/feeds/%s/streams/%s/values", id, name), cb); | ||
// List values from an existing data stream associated with a | ||
// specific feed, sorted in reverse chronological order (most | ||
// recent values first). | ||
// | ||
// The values can be filtered by using one or more of the following | ||
// optional parameters: | ||
// | ||
// * `start` An ISO 8601 timestamp specifying the start of the date | ||
// * range to be considered. | ||
// | ||
// * `end` An ISO 8601 timestamp specifying the end of the date | ||
// * range to be considered. | ||
// | ||
// * `limit` Maximum number of values to return. | ||
Feeds.prototype.streamValues = function(id, name, params, cb) { | ||
var url = helpers.url("/feeds/%s/streams/%s/values", id, name); | ||
if (typeof params === "function") { | ||
cb = params; | ||
params = {}; | ||
} | ||
return this.client.get(url, { qs: params }, cb); | ||
}; | ||
@@ -61,0 +100,0 @@ |
{ | ||
"name": "m2x", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "AT&T M2X API client for node.js", | ||
@@ -5,0 +5,0 @@ "main": "./lib/m2x", |
17411
335