losant-rest
Advanced tools
Comparing version 1.5.0 to 1.5.1
@@ -61,3 +61,3 @@ # Dashboards Actions | ||
Create a new dasboard | ||
Create a new dashboard | ||
@@ -64,0 +64,0 @@ ```javascript |
@@ -51,3 +51,3 @@ # Device Recipe Actions | ||
| ---- | ---- | ----------- | | ||
| 201 | [Device Recipe Bulk Create](_schemas.md#device-recipe-bulk-create) | If devices were sucessfully created | | ||
| 201 | [Device Recipe Bulk Create](_schemas.md#device-recipe-bulk-create) | If devices were successfully created | | ||
@@ -54,0 +54,0 @@ #### Error Responses |
@@ -9,2 +9,3 @@ # Devices Actions | ||
* [Export](#export) | ||
* [Get](#get) | ||
@@ -16,2 +17,46 @@ * [Post](#post) | ||
## Export | ||
Creates an export of all device metadata. | ||
```javascript | ||
var params = { | ||
applicationId: myApplicationId | ||
}; | ||
// with callbacks | ||
client.devices.export(params, function (err, result) { | ||
if (err) { return console.error(err); } | ||
console.log(result); | ||
}); | ||
// with promises | ||
client.devices.export(params) | ||
.then(console.log) | ||
.catch(console.error); | ||
``` | ||
#### Available Parameters | ||
| Name | Type | Required | Description | Default | Example | | ||
| ---- | ---- | -------- | ----------- | ------- | ------- | | ||
| applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 | | ||
| email | string | N | Email address to send export to. Defaults to current user's email. | | email@example.com | | ||
| callbackUrl | string | N | Callback URL to call with export result. | | https://example.com/cburl | | ||
#### Successful Responses | ||
| Code | Type | Description | | ||
| ---- | ---- | ----------- | | ||
| 200 | [Success](_schemas.md#success) | If generation of export was successfully started | | ||
#### Error Responses | ||
| Code | Type | Description | | ||
| ---- | ---- | ----------- | | ||
| 400 | [Error](_schemas.md#error) | Error if malformed request | | ||
| 404 | [Error](_schemas.md#error) | Error if application was not found | | ||
<br/> | ||
## Get | ||
@@ -18,0 +63,0 @@ |
@@ -61,3 +61,3 @@ var uriTemplate = require('uri-template'); | ||
/** | ||
* Create a new dasboard | ||
* Create a new dashboard | ||
* | ||
@@ -64,0 +64,0 @@ * Parameters: |
@@ -19,3 +19,3 @@ var uriTemplate = require('uri-template'); | ||
* Responses: | ||
* 201 - If devices were sucessfully created (https://api.losant.com/#/definitions/deviceRecipeBulkCreate) | ||
* 201 - If devices were successfully created (https://api.losant.com/#/definitions/deviceRecipeBulkCreate) | ||
* | ||
@@ -22,0 +22,0 @@ * Errors: |
@@ -7,2 +7,50 @@ var uriTemplate = require('uri-template'); | ||
/** | ||
* Creates an export of all device metadata. | ||
* | ||
* Parameters: | ||
* {string} applicationId - ID associated with the application | ||
* {string} email - Email address to send export to. Defaults to current user's email. | ||
* {string} callbackUrl - Callback URL to call with export result. | ||
* {string} losantdomain - Domain scope of request (rarely needed) | ||
* {boolean} _actions - Return resource actions in response | ||
* {boolean} _links - Return resource link in response | ||
* {boolean} _embedded - Return embedded resources in response | ||
* | ||
* Responses: | ||
* 200 - If generation of export was successfully started (https://api.losant.com/#/definitions/success) | ||
* | ||
* Errors: | ||
* 400 - Error if malformed request (https://api.losant.com/#/definitions/error) | ||
* 404 - Error if application was not found (https://api.losant.com/#/definitions/error) | ||
*/ | ||
internals.export = function (params, opts, cb) { | ||
if ('function' === typeof params) { | ||
cb = params; | ||
params = {}; | ||
opts = {}; | ||
} else if ('function' === typeof opts) { | ||
cb = opts; | ||
opts = {}; | ||
} | ||
params = params || {}; | ||
var tpl = uriTemplate.parse('/applications/{applicationId}/devices/export'); | ||
var pathParams = {}; | ||
var req = { | ||
method: 'POST', | ||
data: {}, | ||
headers: {}, | ||
params: { _actions: false, _links: true, _embedded: true } | ||
}; | ||
if ('undefined' !== typeof params.applicationId) { pathParams.applicationId = params.applicationId; } | ||
if ('undefined' !== typeof params.email) { req.params.email = params.email; } | ||
if ('undefined' !== typeof params.callbackUrl) { req.params.callbackUrl = params.callbackUrl; } | ||
if ('undefined' !== typeof params.losantdomain) { req.headers.losantdomain = params.losantdomain; } | ||
if ('undefined' !== typeof params._actions) { req.params._actions = params._actions; } | ||
if ('undefined' !== typeof params._links) { req.params._links = params._links; } | ||
if ('undefined' !== typeof params._embedded) { req.params._embedded = params._embedded; } | ||
req.url = tpl.expand(pathParams); | ||
return client.request(req, opts, cb); | ||
}; | ||
/** | ||
* Returns the devices for an application | ||
@@ -9,0 +57,0 @@ * |
@@ -7,3 +7,3 @@ var axios = require('axios'); | ||
* User API for accessing Losant data | ||
* version: 1.5.0 | ||
* version: 1.5.1 | ||
*/ | ||
@@ -54,3 +54,3 @@ module.exports = function (options) { | ||
Accept: 'application/json', | ||
'Accept-Version': '^1.5.0' | ||
'Accept-Version': '^1.5.1' | ||
}); | ||
@@ -57,0 +57,0 @@ if (opts.accessToken) { |
{ | ||
"name": "losant-rest", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "REST client for accessing the Losant API", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
742537
11143