particle-api-js
Advanced tools
Comparing version 5.1.1 to 5.2.0
# changelog | ||
## 5.2.0 - 3 Mar 2016 | ||
* Add support for organization and product slugs to `getEventStream`. | ||
## 5.1.1 - 26 Feb 2016 | ||
@@ -4,0 +8,0 @@ |
# callFunction | ||
[src/Particle.js:259-263](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L259-L263 "Source code on GitHub") | ||
[src/Particle.js:259-263](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L259-L263 "Source code on GitHub") | ||
@@ -19,3 +19,3 @@ Call a device function | ||
[src/Particle.js:92-97](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L92-L97 "Source code on GitHub") | ||
[src/Particle.js:92-97](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L92-L97 "Source code on GitHub") | ||
@@ -35,3 +35,3 @@ Claim a device to the account. The device must be online and unclaimed. | ||
[src/Particle.js:204-213](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L204-L213 "Source code on GitHub") | ||
[src/Particle.js:204-213](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L204-L213 "Source code on GitHub") | ||
@@ -52,3 +52,3 @@ Compile firmware using the Particle Cloud | ||
[src/Particle.js:38-42](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L38-L42 "Source code on GitHub") | ||
[src/Particle.js:38-42](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L38-L42 "Source code on GitHub") | ||
@@ -67,3 +67,3 @@ Create a user account for the Particle Cloud | ||
[src/Particle.js:320-328](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L320-L328 "Source code on GitHub") | ||
[src/Particle.js:332-340](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L332-L340 "Source code on GitHub") | ||
@@ -91,3 +91,3 @@ Create a webhook | ||
[src/Particle.js:336-338](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L336-L338 "Source code on GitHub") | ||
[src/Particle.js:348-350](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L348-L350 "Source code on GitHub") | ||
@@ -106,3 +106,3 @@ Delete a webhook | ||
[src/Particle.js:221-231](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L221-L231 "Source code on GitHub") | ||
[src/Particle.js:221-231](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L221-L231 "Source code on GitHub") | ||
@@ -121,3 +121,3 @@ Download a firmware binary | ||
[src/Particle.js:173-182](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L173-L182 "Source code on GitHub") | ||
[src/Particle.js:173-182](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L173-L182 "Source code on GitHub") | ||
@@ -138,3 +138,3 @@ Compile and flash application firmware to a device | ||
[src/Particle.js:190-194](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L190-L194 "Source code on GitHub") | ||
[src/Particle.js:190-194](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L190-L194 "Source code on GitHub") | ||
@@ -153,3 +153,3 @@ Flash the Tinker application to a device | ||
[src/Particle.js:126-128](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L126-L128 "Source code on GitHub") | ||
[src/Particle.js:126-128](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L126-L128 "Source code on GitHub") | ||
@@ -168,3 +168,3 @@ Generate a claim code to use in the device claiming process. | ||
[src/Particle.js:82-84](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L82-L84 "Source code on GitHub") | ||
[src/Particle.js:82-84](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L82-L84 "Source code on GitHub") | ||
@@ -183,3 +183,3 @@ Get detailed informationa about a device | ||
[src/Particle.js:273-287](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L273-L287 "Source code on GitHub") | ||
[src/Particle.js:275-299](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L275-L299 "Source code on GitHub") | ||
@@ -193,2 +193,4 @@ Get a stream of events | ||
- `$0.name` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)=** Event Name | ||
- `$0.org` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)=** Organization Slug | ||
- `$0.product` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)=** Product Slug | ||
- `$0.auth` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Access Token | ||
@@ -201,3 +203,3 @@ | ||
[src/Particle.js:354-356](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L354-L356 "Source code on GitHub") | ||
[src/Particle.js:366-368](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L366-L368 "Source code on GitHub") | ||
@@ -215,3 +217,3 @@ Get details about the current user | ||
[src/Particle.js:148-150](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L148-L150 "Source code on GitHub") | ||
[src/Particle.js:148-150](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L148-L150 "Source code on GitHub") | ||
@@ -231,3 +233,3 @@ Get the value of a device variable | ||
[src/Particle.js:63-65](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L63-L65 "Source code on GitHub") | ||
[src/Particle.js:63-65](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L63-L65 "Source code on GitHub") | ||
@@ -246,3 +248,3 @@ List all valid access tokens for a Particle Cloud account | ||
[src/Particle.js:382-388](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L382-L388 "Source code on GitHub") | ||
[src/Particle.js:394-400](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L394-L400 "Source code on GitHub") | ||
@@ -261,3 +263,3 @@ List valid build targets to be used for compiling | ||
[src/Particle.js:72-74](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L72-L74 "Source code on GitHub") | ||
[src/Particle.js:72-74](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L72-L74 "Source code on GitHub") | ||
@@ -275,3 +277,3 @@ List devices claimed to the account | ||
[src/Particle.js:345-347](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L345-L347 "Source code on GitHub") | ||
[src/Particle.js:357-359](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L357-L359 "Source code on GitHub") | ||
@@ -289,3 +291,3 @@ List all webhooks owned by the account | ||
[src/Particle.js:21-30](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L21-L30 "Source code on GitHub") | ||
[src/Particle.js:21-30](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L21-L30 "Source code on GitHub") | ||
@@ -305,3 +307,3 @@ Login to Particle Cloud using an existing Particle acccount. | ||
[src/Particle.js:297-303](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L297-L303 "Source code on GitHub") | ||
[src/Particle.js:309-315](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L309-L315 "Source code on GitHub") | ||
@@ -322,3 +324,3 @@ Publish a event to the Particle Cloud | ||
[src/Particle.js:51-55](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L51-L55 "Source code on GitHub") | ||
[src/Particle.js:51-55](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L51-L55 "Source code on GitHub") | ||
@@ -338,3 +340,3 @@ Revoke an access token | ||
[src/Particle.js:105-107](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L105-L107 "Source code on GitHub") | ||
[src/Particle.js:105-107](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L105-L107 "Source code on GitHub") | ||
@@ -353,3 +355,3 @@ Unclaim / Remove a device from your account | ||
[src/Particle.js:116-118](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L116-L118 "Source code on GitHub") | ||
[src/Particle.js:116-118](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L116-L118 "Source code on GitHub") | ||
@@ -369,3 +371,3 @@ Rename a device | ||
[src/Particle.js:241-249](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L241-L249 "Source code on GitHub") | ||
[src/Particle.js:241-249](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L241-L249 "Source code on GitHub") | ||
@@ -386,3 +388,3 @@ Send a new device public key to the Particle Cloud | ||
[src/Particle.js:159-163](https://github.com/spark/particle-api-js/blob/e19ae9bba68cef120ae81a88d06fd6b5b241d8ef/src/Particle.js#L159-L163 "Source code on GitHub") | ||
[src/Particle.js:159-163](https://github.com/spark/particle-api-js/blob/8955339d6ff191612135360ad527aa9ac9544dda/src/Particle.js#L159-L163 "Source code on GitHub") | ||
@@ -389,0 +391,0 @@ Instruct the device to turn on/off the LED in a rainbow pattern |
@@ -432,2 +432,4 @@ 'use strict'; | ||
* @param {String} [$0.name] Event Name | ||
* @param {String} [$0.org] Organization Slug | ||
* @param {String} [$0.product] Product Slug | ||
* @param {String} $0.auth Access Token | ||
@@ -443,11 +445,23 @@ * @return {Promise} If the promise resolves, the resolution value will be an EventStream object that will | ||
var name = _ref21.name; | ||
var org = _ref21.org; | ||
var product = _ref21.product; | ||
var auth = _ref21.auth; | ||
var uri = undefined; | ||
if (!deviceId) { | ||
uri = '/v1/events'; | ||
} else if (deviceId.toLowerCase() === 'mine') { | ||
uri = '/v1/devices/events'; | ||
var uri = '/v1/'; | ||
if (org) { | ||
uri += 'orgs/' + org + '/'; | ||
if (product) { | ||
uri += 'products/' + product + '/'; | ||
} else if (deviceId && deviceId.toLowerCase() !== 'mine') { | ||
uri += 'devices/' + deviceId + '/'; | ||
} | ||
uri += 'events'; | ||
} else { | ||
uri = '/v1/devices/' + deviceId + '/events'; | ||
if (!deviceId) { | ||
uri += 'events'; | ||
} else if (deviceId.toLowerCase() === 'mine') { | ||
uri += 'devices/events'; | ||
} else { | ||
uri += 'devices/' + deviceId + '/events'; | ||
} | ||
} | ||
@@ -729,3 +743,3 @@ | ||
Particle.VERSION = '5.1.1'; | ||
Particle.VERSION = '5.2.0'; | ||
@@ -732,0 +746,0 @@ exports.default = Particle; |
{ | ||
"name": "particle-api-js", | ||
"version": "5.1.1", | ||
"version": "5.2.0", | ||
"description": "Particle API Client", | ||
@@ -5,0 +5,0 @@ "main": "lib/Particle.js", |
@@ -313,2 +313,27 @@ const should = require('should'); // monkeypatch the world~!1 | ||
}); | ||
it('requests org\'s events', () => { | ||
return api.getEventStream({ org: 'test-org' }).then(({ uri }) => { | ||
uri.should.endWith('v1/orgs/test-org/events'); | ||
}); | ||
}); | ||
it('requests org\'s device events', () => { | ||
return api.getEventStream({ org: 'test-org', deviceId: props.deviceId }).then(({ uri }) => { | ||
uri.should.endWith(`v1/orgs/test-org/devices/${props.deviceId}/events`); | ||
}); | ||
}); | ||
it('requests org\'s device named events', () => { | ||
return api.getEventStream({ org: 'test-org', deviceId: props.deviceId, name: 'test' }).then(({ uri }) => { | ||
uri.should.endWith(`v1/orgs/test-org/devices/${props.deviceId}/events/test`); | ||
}); | ||
}); | ||
it('requests product\'s events', () => { | ||
return api.getEventStream({ org: 'test-org', product: 'test-product' }).then(({ uri }) => { | ||
uri.should.endWith('v1/orgs/test-org/products/test-product/events'); | ||
}); | ||
}); | ||
it('requests product\'s named events', () => { | ||
return api.getEventStream({ org: 'test-org', product: 'test-product', name: 'test' }).then(({ uri }) => { | ||
uri.should.endWith('v1/orgs/test-org/products/test-product/events/test'); | ||
}); | ||
}); | ||
}); | ||
@@ -315,0 +340,0 @@ describe('.publishEvent', () => { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
956500
2439