particle-api-js 9.4.1 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +7 -5
- package/CHANGELOG.md +11 -0
- package/{test/EventStream-e2e-browser.html → EventStream-e2e-browser.html} +0 -1
- package/{test/EventStream-e2e-node.js → EventStream-e2e-node.js} +2 -3
- package/README.md +2 -2
- package/RELEASE.md +1 -1
- package/dist/particle.min.js +1 -399
- package/dist/particle.min.js.map +1 -1
- package/docs/api.md +5223 -115
- package/fs.js +2 -0
- package/karma.conf.js +18 -6
- package/package.json +23 -26
- package/src/Agent.js +407 -0
- package/src/Client.js +170 -0
- package/src/Defaults.js +7 -0
- package/src/EventStream.js +263 -0
- package/src/Library.js +33 -0
- package/src/Particle.js +2644 -0
- package/test/Agent.integration.js +5 -4
- package/test/Agent.spec.js +174 -291
- package/test/Client.spec.js +7 -7
- package/test/Defaults.spec.js +2 -2
- package/test/EventStream.spec.js +6 -4
- package/test/FakeAgent.js +2 -2
- package/test/Library.spec.js +2 -2
- package/test/Particle.integration.js +7 -7
- package/test/Particle.spec.js +332 -18
- package/test/fixtures/index.js +4 -18
- package/test/support/FixtureHttpServer.js +5 -3
- package/test/test-setup.js +5 -5
- package/tsconfig.json +14 -0
- package/webpack.config.js +45 -0
- package/.babelrc +0 -4
- package/lib/Agent.js +0 -516
- package/lib/Agent.js.map +0 -1
- package/lib/Client.js +0 -312
- package/lib/Client.js.map +0 -1
- package/lib/Defaults.js +0 -14
- package/lib/Defaults.js.map +0 -1
- package/lib/EventStream.js +0 -335
- package/lib/EventStream.js.map +0 -1
- package/lib/Library.js +0 -67
- package/lib/Library.js.map +0 -1
- package/lib/Particle.js +0 -3248
- package/lib/Particle.js.map +0 -1
- package/lib/superagent-binary-parser.js +0 -20
- package/lib/superagent-binary-parser.js.map +0 -1
- package/test/Client.integration.js +0 -69
- package/test/fixtures/tarball.tar.gz +0 -0
- package/test/fixtures/test-library-publish-0.0.1.tar.gz +0 -0
- package/test/fixtures/test-library-publish-0.0.2.tar.gz +0 -0
package/lib/Particle.js
DELETED
|
@@ -1,3248 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _assign = require('babel-runtime/core-js/object/assign');
|
|
8
|
-
|
|
9
|
-
var _assign2 = _interopRequireDefault(_assign);
|
|
10
|
-
|
|
11
|
-
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
|
12
|
-
|
|
13
|
-
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
|
14
|
-
|
|
15
|
-
var _createClass2 = require('babel-runtime/helpers/createClass');
|
|
16
|
-
|
|
17
|
-
var _createClass3 = _interopRequireDefault(_createClass2);
|
|
18
|
-
|
|
19
|
-
var _superagentBinaryParser = require('./superagent-binary-parser');
|
|
20
|
-
|
|
21
|
-
var _superagentBinaryParser2 = _interopRequireDefault(_superagentBinaryParser);
|
|
22
|
-
|
|
23
|
-
var _Defaults = require('./Defaults');
|
|
24
|
-
|
|
25
|
-
var _Defaults2 = _interopRequireDefault(_Defaults);
|
|
26
|
-
|
|
27
|
-
var _EventStream = require('./EventStream');
|
|
28
|
-
|
|
29
|
-
var _EventStream2 = _interopRequireDefault(_EventStream);
|
|
30
|
-
|
|
31
|
-
var _Agent = require('./Agent');
|
|
32
|
-
|
|
33
|
-
var _Agent2 = _interopRequireDefault(_Agent);
|
|
34
|
-
|
|
35
|
-
var _Client = require('./Client');
|
|
36
|
-
|
|
37
|
-
var _Client2 = _interopRequireDefault(_Client);
|
|
38
|
-
|
|
39
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Particle Cloud API wrapper.
|
|
43
|
-
*
|
|
44
|
-
* See <https://docs.particle.io/reference/javascript/> for examples
|
|
45
|
-
* of using the `Particle` class.
|
|
46
|
-
*
|
|
47
|
-
* Most Particle methods take a single unnamed argument object documented as
|
|
48
|
-
* `options` with key/value pairs for each option.
|
|
49
|
-
*/
|
|
50
|
-
var Particle = function () {
|
|
51
|
-
/**
|
|
52
|
-
* Contructor for the Cloud API wrapper.
|
|
53
|
-
*
|
|
54
|
-
* Create a new Particle object and call methods below on it.
|
|
55
|
-
*
|
|
56
|
-
* @param {Object} options Options for this API call Options to be used for all requests (see [Defaults](../src/Defaults.js))
|
|
57
|
-
*/
|
|
58
|
-
function Particle() {
|
|
59
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
60
|
-
(0, _classCallCheck3.default)(this, Particle);
|
|
61
|
-
|
|
62
|
-
if (options.auth) {
|
|
63
|
-
this.setDefaultAuth(options.auth);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// todo - this seems a bit dangerous - would be better to put all options/context in a contained object
|
|
67
|
-
(0, _assign2.default)(this, _Defaults2.default, options);
|
|
68
|
-
this.context = {};
|
|
69
|
-
this.agent = new _Agent2.default(this.baseUrl);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
(0, _createClass3.default)(Particle, [{
|
|
73
|
-
key: '_isValidContext',
|
|
74
|
-
value: function _isValidContext(name, context) {
|
|
75
|
-
return (name === 'tool' || name === 'project') && context !== undefined;
|
|
76
|
-
}
|
|
77
|
-
}, {
|
|
78
|
-
key: 'setContext',
|
|
79
|
-
value: function setContext(name, context) {
|
|
80
|
-
if (context !== undefined) {
|
|
81
|
-
if (this._isValidContext(name, context)) {
|
|
82
|
-
this.context[name] = context;
|
|
83
|
-
} else {
|
|
84
|
-
throw Error('unknown context name or undefined context: ' + name);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Builds the final context from the context parameter and the context items in the api.
|
|
91
|
-
* @param {Object} context The invocation context, this takes precedence over the local context.
|
|
92
|
-
* @returns {Object} The context to use.
|
|
93
|
-
* @private
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
}, {
|
|
97
|
-
key: '_buildContext',
|
|
98
|
-
value: function _buildContext(context) {
|
|
99
|
-
return (0, _assign2.default)(this.context, context);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Login to Particle Cloud using an existing Particle acccount.
|
|
104
|
-
* @param {Object} options Options for this API call
|
|
105
|
-
* @param {String} options.username Username for the Particle account
|
|
106
|
-
* @param {String} options.password Password for the Particle account
|
|
107
|
-
* @param {Number} options.tokenDuration How long the access token should last in seconds
|
|
108
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
109
|
-
* @param {Number} [options.context] Request context
|
|
110
|
-
* @returns {Promise} A promise
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
}, {
|
|
114
|
-
key: 'login',
|
|
115
|
-
value: function login(_ref) {
|
|
116
|
-
var username = _ref.username,
|
|
117
|
-
password = _ref.password,
|
|
118
|
-
_ref$tokenDuration = _ref.tokenDuration,
|
|
119
|
-
tokenDuration = _ref$tokenDuration === undefined ? this.tokenDuration : _ref$tokenDuration,
|
|
120
|
-
headers = _ref.headers,
|
|
121
|
-
context = _ref.context;
|
|
122
|
-
|
|
123
|
-
return this.request({
|
|
124
|
-
uri: '/oauth/token',
|
|
125
|
-
method: 'post',
|
|
126
|
-
headers: headers,
|
|
127
|
-
form: {
|
|
128
|
-
username: username,
|
|
129
|
-
password: password,
|
|
130
|
-
grant_type: 'password',
|
|
131
|
-
client_id: this.clientId,
|
|
132
|
-
client_secret: this.clientSecret,
|
|
133
|
-
expires_in: tokenDuration
|
|
134
|
-
},
|
|
135
|
-
context: context
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* If login failed with an 'mfa_required' error, this must be called with a valid OTP code to login
|
|
141
|
-
* @param {Object} options Options for this API call
|
|
142
|
-
* @param {String} options.mfaToken Given as 'mfa_token' in the error body of `.login()`.
|
|
143
|
-
* @param {String} options.otp Current one-time-password generated from the authentication application
|
|
144
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
145
|
-
* @param {Number} [options.context] Request context
|
|
146
|
-
* @returns {Promise} A promise
|
|
147
|
-
*/
|
|
148
|
-
|
|
149
|
-
}, {
|
|
150
|
-
key: 'sendOtp',
|
|
151
|
-
value: function sendOtp(_ref2) {
|
|
152
|
-
var mfaToken = _ref2.mfaToken,
|
|
153
|
-
otp = _ref2.otp,
|
|
154
|
-
headers = _ref2.headers,
|
|
155
|
-
context = _ref2.context;
|
|
156
|
-
|
|
157
|
-
return this.request({
|
|
158
|
-
uri: '/oauth/token',
|
|
159
|
-
method: 'post',
|
|
160
|
-
headers: headers,
|
|
161
|
-
form: {
|
|
162
|
-
grant_type: 'urn:custom:mfa-otp',
|
|
163
|
-
mfa_token: mfaToken,
|
|
164
|
-
otp: otp,
|
|
165
|
-
client_id: this.clientId,
|
|
166
|
-
client_secret: this.clientSecret
|
|
167
|
-
},
|
|
168
|
-
context: context
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Enable MFA on the currently logged in user
|
|
174
|
-
* @param {Object} options Options for this API call
|
|
175
|
-
* @param {Object} options.auth Access token
|
|
176
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
177
|
-
* @param {Object} [options.context] Request context
|
|
178
|
-
* @returns {Promise} A promise
|
|
179
|
-
*/
|
|
180
|
-
|
|
181
|
-
}, {
|
|
182
|
-
key: 'enableMfa',
|
|
183
|
-
value: function enableMfa(_ref3) {
|
|
184
|
-
var auth = _ref3.auth,
|
|
185
|
-
headers = _ref3.headers,
|
|
186
|
-
context = _ref3.context;
|
|
187
|
-
|
|
188
|
-
return this.get({ uri: '/v1/user/mfa-enable', auth: auth, headers: headers, context: context });
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Confirm MFA for the user. This must be called with current TOTP code, determined from the results of enableMfa(). You will be prompted to enter an OTP code every time you login after enrollment is confirmed.
|
|
193
|
-
* @param {Object} options Options for this API call
|
|
194
|
-
* @param {Object} options.auth Access token
|
|
195
|
-
* @param {Object} options.mfaToken Token given from previous step to
|
|
196
|
-
* @param {Object} options.otp Current one-time-password generated from the authentication app
|
|
197
|
-
* @param {Boolean} options.invalidateTokens Should all tokens be invalidated
|
|
198
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
199
|
-
* @param {Object} [options.context] Request context
|
|
200
|
-
* @returns {Promise} A promise
|
|
201
|
-
*/
|
|
202
|
-
|
|
203
|
-
}, {
|
|
204
|
-
key: 'confirmMfa',
|
|
205
|
-
value: function confirmMfa(_ref4) {
|
|
206
|
-
var mfaToken = _ref4.mfaToken,
|
|
207
|
-
otp = _ref4.otp,
|
|
208
|
-
_ref4$invalidateToken = _ref4.invalidateTokens,
|
|
209
|
-
invalidateTokens = _ref4$invalidateToken === undefined ? false : _ref4$invalidateToken,
|
|
210
|
-
auth = _ref4.auth,
|
|
211
|
-
headers = _ref4.headers,
|
|
212
|
-
context = _ref4.context;
|
|
213
|
-
|
|
214
|
-
var data = { mfa_token: mfaToken, otp: otp };
|
|
215
|
-
|
|
216
|
-
if (invalidateTokens) {
|
|
217
|
-
data.invalidate_tokens = true;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return this.post({
|
|
221
|
-
uri: '/v1/user/mfa-enable',
|
|
222
|
-
auth: auth,
|
|
223
|
-
headers: headers,
|
|
224
|
-
data: data,
|
|
225
|
-
context: context
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Disable MFA for the user.
|
|
231
|
-
* @param {Object} options Options for this API call
|
|
232
|
-
* @param {Object} options.auth Access token
|
|
233
|
-
* @param {Object} options.currentPassword User's current password
|
|
234
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
235
|
-
* @param {Object} [options.context] Request context
|
|
236
|
-
* @returns {Promise} A promise
|
|
237
|
-
*/
|
|
238
|
-
|
|
239
|
-
}, {
|
|
240
|
-
key: 'disableMfa',
|
|
241
|
-
value: function disableMfa(_ref5) {
|
|
242
|
-
var currentPassword = _ref5.currentPassword,
|
|
243
|
-
auth = _ref5.auth,
|
|
244
|
-
headers = _ref5.headers,
|
|
245
|
-
context = _ref5.context;
|
|
246
|
-
|
|
247
|
-
return this.put({
|
|
248
|
-
uri: '/v1/user/mfa-disable',
|
|
249
|
-
auth: auth,
|
|
250
|
-
headers: headers,
|
|
251
|
-
data: { current_password: currentPassword },
|
|
252
|
-
context: context
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Create Customer for Product.
|
|
258
|
-
* @param {Object} options Options for this API call
|
|
259
|
-
* @param {String} options.email Username for the Particle account
|
|
260
|
-
* @param {String} options.password Password for the Particle account
|
|
261
|
-
* @param {String} options.product Create the customer in this product ID or slug
|
|
262
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
263
|
-
* @param {Object} [options.context] Request context
|
|
264
|
-
* @returns {Promise} A promise
|
|
265
|
-
*/
|
|
266
|
-
|
|
267
|
-
}, {
|
|
268
|
-
key: 'createCustomer',
|
|
269
|
-
value: function createCustomer(_ref6) {
|
|
270
|
-
var email = _ref6.email,
|
|
271
|
-
password = _ref6.password,
|
|
272
|
-
product = _ref6.product,
|
|
273
|
-
headers = _ref6.headers,
|
|
274
|
-
context = _ref6.context;
|
|
275
|
-
|
|
276
|
-
return this.request({
|
|
277
|
-
uri: '/v1/products/' + product + '/customers',
|
|
278
|
-
method: 'post',
|
|
279
|
-
headers: headers,
|
|
280
|
-
form: {
|
|
281
|
-
email: email,
|
|
282
|
-
password: password,
|
|
283
|
-
grant_type: 'client_credentials',
|
|
284
|
-
client_id: this.clientId,
|
|
285
|
-
client_secret: this.clientSecret
|
|
286
|
-
},
|
|
287
|
-
context: context
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* Login to Particle Cloud using an OAuth client.
|
|
293
|
-
* @param {Object} options Options for this API call
|
|
294
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
295
|
-
* @param {Object} [options.context] Request context
|
|
296
|
-
* @returns {Promise} A promise
|
|
297
|
-
*/
|
|
298
|
-
|
|
299
|
-
}, {
|
|
300
|
-
key: 'loginAsClientOwner',
|
|
301
|
-
value: function loginAsClientOwner(_ref7) {
|
|
302
|
-
var headers = _ref7.headers,
|
|
303
|
-
context = _ref7.context;
|
|
304
|
-
|
|
305
|
-
return this.request({
|
|
306
|
-
uri: '/oauth/token',
|
|
307
|
-
method: 'post',
|
|
308
|
-
headers: headers,
|
|
309
|
-
form: {
|
|
310
|
-
grant_type: 'client_credentials',
|
|
311
|
-
client_id: this.clientId,
|
|
312
|
-
client_secret: this.clientSecret
|
|
313
|
-
},
|
|
314
|
-
context: context
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Create a user account for the Particle Cloud
|
|
320
|
-
* @param {Object} options Options for this API call
|
|
321
|
-
* @param {String} options.username Email of the new user
|
|
322
|
-
* @param {String} options.password Password
|
|
323
|
-
* @param {String} options.accountInfo Object that contains account information fields such as user real name, company name, business account flag etc
|
|
324
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
325
|
-
* @param {Object} [options.context] Request context
|
|
326
|
-
* @returns {Promise} A promise
|
|
327
|
-
*/
|
|
328
|
-
|
|
329
|
-
}, {
|
|
330
|
-
key: 'createUser',
|
|
331
|
-
value: function createUser(_ref8) {
|
|
332
|
-
var username = _ref8.username,
|
|
333
|
-
password = _ref8.password,
|
|
334
|
-
accountInfo = _ref8.accountInfo,
|
|
335
|
-
headers = _ref8.headers,
|
|
336
|
-
context = _ref8.context;
|
|
337
|
-
|
|
338
|
-
return this.post({
|
|
339
|
-
uri: '/v1/users',
|
|
340
|
-
headers: headers,
|
|
341
|
-
data: {
|
|
342
|
-
username: username,
|
|
343
|
-
password: password,
|
|
344
|
-
account_info: accountInfo
|
|
345
|
-
},
|
|
346
|
-
context: context
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Verify new user account via verification email
|
|
352
|
-
* @param {Object} options Options for this API call
|
|
353
|
-
* @param {String} options.token The string token sent in the verification email
|
|
354
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
355
|
-
* @param {Object} [options.context] Request context
|
|
356
|
-
* @returns {Promise} A promise
|
|
357
|
-
*/
|
|
358
|
-
|
|
359
|
-
}, {
|
|
360
|
-
key: 'verifyUser',
|
|
361
|
-
value: function verifyUser(_ref9) {
|
|
362
|
-
var token = _ref9.token,
|
|
363
|
-
headers = _ref9.headers,
|
|
364
|
-
context = _ref9.context;
|
|
365
|
-
|
|
366
|
-
return this.post({
|
|
367
|
-
uri: '/v1/user/verify',
|
|
368
|
-
headers: headers,
|
|
369
|
-
data: { token: token },
|
|
370
|
-
context: context
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Send reset password email for a Particle Cloud user account
|
|
376
|
-
* @param {Object} options Options for this API call
|
|
377
|
-
* @param {String} options.username Email of the user
|
|
378
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
379
|
-
* @param {Object} [options.context] Request context
|
|
380
|
-
* @returns {Promise} A promise
|
|
381
|
-
*/
|
|
382
|
-
|
|
383
|
-
}, {
|
|
384
|
-
key: 'resetPassword',
|
|
385
|
-
value: function resetPassword(_ref10) {
|
|
386
|
-
var username = _ref10.username,
|
|
387
|
-
headers = _ref10.headers,
|
|
388
|
-
context = _ref10.context;
|
|
389
|
-
|
|
390
|
-
return this.post({
|
|
391
|
-
uri: '/v1/user/password-reset',
|
|
392
|
-
headers: headers,
|
|
393
|
-
data: { username: username },
|
|
394
|
-
context: context
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Revoke an access token
|
|
400
|
-
* @param {Object} options Options for this API call
|
|
401
|
-
* @param {String} options.username Username of the Particle cloud account that the token belongs to.
|
|
402
|
-
* @param {String} options.password Password for the account
|
|
403
|
-
* @param {String} options.token Access token you wish to revoke
|
|
404
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
405
|
-
* @param {Object} [options.context] Request context
|
|
406
|
-
* @returns {Promise} A promise
|
|
407
|
-
*/
|
|
408
|
-
|
|
409
|
-
}, {
|
|
410
|
-
key: 'deleteAccessToken',
|
|
411
|
-
value: function deleteAccessToken(_ref11) {
|
|
412
|
-
var username = _ref11.username,
|
|
413
|
-
password = _ref11.password,
|
|
414
|
-
token = _ref11.token,
|
|
415
|
-
headers = _ref11.headers,
|
|
416
|
-
context = _ref11.context;
|
|
417
|
-
|
|
418
|
-
return this.delete({
|
|
419
|
-
uri: '/v1/access_tokens/' + token,
|
|
420
|
-
auth: { username: username, password: password },
|
|
421
|
-
headers: headers,
|
|
422
|
-
data: { access_token: token },
|
|
423
|
-
context: context
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Revoke the current session access token
|
|
429
|
-
* @param {Object} options Options for this API call
|
|
430
|
-
* @param {String} options.auth Access Token
|
|
431
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
432
|
-
* @param {Object} [options.context] Request context
|
|
433
|
-
* @returns {Promise} A promise
|
|
434
|
-
*/
|
|
435
|
-
|
|
436
|
-
}, {
|
|
437
|
-
key: 'deleteCurrentAccessToken',
|
|
438
|
-
value: function deleteCurrentAccessToken(_ref12) {
|
|
439
|
-
var auth = _ref12.auth,
|
|
440
|
-
headers = _ref12.headers,
|
|
441
|
-
context = _ref12.context;
|
|
442
|
-
|
|
443
|
-
return this.delete({
|
|
444
|
-
uri: '/v1/access_tokens/current',
|
|
445
|
-
auth: auth,
|
|
446
|
-
headers: headers,
|
|
447
|
-
context: context
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Revoke all active access tokens
|
|
453
|
-
* @param {Object} options Options for this API call
|
|
454
|
-
* @param {String} options.auth Access Token
|
|
455
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
456
|
-
* @param {Object} [options.context] Request context
|
|
457
|
-
* @returns {Promise} A promise
|
|
458
|
-
*/
|
|
459
|
-
|
|
460
|
-
}, {
|
|
461
|
-
key: 'deleteActiveAccessTokens',
|
|
462
|
-
value: function deleteActiveAccessTokens(_ref13) {
|
|
463
|
-
var auth = _ref13.auth,
|
|
464
|
-
headers = _ref13.headers,
|
|
465
|
-
context = _ref13.context;
|
|
466
|
-
|
|
467
|
-
return this.delete({
|
|
468
|
-
uri: '/v1/access_tokens',
|
|
469
|
-
auth: auth,
|
|
470
|
-
headers: headers,
|
|
471
|
-
context: context
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Delete the current user
|
|
477
|
-
* @param {Object} options Options for this API call
|
|
478
|
-
* @param {String} options.auth Access Token
|
|
479
|
-
* @param {String} options.password Password
|
|
480
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
481
|
-
* @param {Object} [options.context] Request context
|
|
482
|
-
* @returns {Promise} A promise
|
|
483
|
-
*/
|
|
484
|
-
|
|
485
|
-
}, {
|
|
486
|
-
key: 'deleteUser',
|
|
487
|
-
value: function deleteUser(_ref14) {
|
|
488
|
-
var auth = _ref14.auth,
|
|
489
|
-
password = _ref14.password,
|
|
490
|
-
headers = _ref14.headers,
|
|
491
|
-
context = _ref14.context;
|
|
492
|
-
|
|
493
|
-
return this.delete({
|
|
494
|
-
uri: '/v1/user',
|
|
495
|
-
data: { password: password },
|
|
496
|
-
auth: auth,
|
|
497
|
-
headers: headers,
|
|
498
|
-
context: context
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* List all valid access tokens for a Particle Cloud account
|
|
504
|
-
* @param {Object} options Options for this API call
|
|
505
|
-
* @param {String} options.username Username
|
|
506
|
-
* @param {String} options.password Password
|
|
507
|
-
* @param {String} options.otp Current one-time-password generated from the authentication application
|
|
508
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
509
|
-
* @param {Object} [options.context] Request context
|
|
510
|
-
* @returns {Promise} A promise
|
|
511
|
-
*/
|
|
512
|
-
|
|
513
|
-
}, {
|
|
514
|
-
key: 'listAccessTokens',
|
|
515
|
-
value: function listAccessTokens(_ref15) {
|
|
516
|
-
var username = _ref15.username,
|
|
517
|
-
password = _ref15.password,
|
|
518
|
-
otp = _ref15.otp,
|
|
519
|
-
headers = _ref15.headers,
|
|
520
|
-
context = _ref15.context;
|
|
521
|
-
|
|
522
|
-
return this.get({
|
|
523
|
-
uri: '/v1/access_tokens',
|
|
524
|
-
auth: { username: username, password: password },
|
|
525
|
-
query: otp ? { otp: otp } : undefined,
|
|
526
|
-
headers: headers,
|
|
527
|
-
context: context
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
/**
|
|
532
|
-
* Retrieves the information that is used to identify the current login for tracking.
|
|
533
|
-
* @param {Object} options Options for this API call
|
|
534
|
-
* @param {String} options.auth The access token
|
|
535
|
-
* @param {Boolean} options.full When true, retrieve all information for registering a user with the tracking API. When false,
|
|
536
|
-
* retrieve only the unique tracking ID for the current login.
|
|
537
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
538
|
-
* @param {Object} [options.context] Request context
|
|
539
|
-
* @returns {Promise<Object>} Resolve the tracking identify of the current login
|
|
540
|
-
*/
|
|
541
|
-
|
|
542
|
-
}, {
|
|
543
|
-
key: 'trackingIdentity',
|
|
544
|
-
value: function trackingIdentity() {
|
|
545
|
-
var _ref16 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
546
|
-
_ref16$full = _ref16.full,
|
|
547
|
-
full = _ref16$full === undefined ? false : _ref16$full,
|
|
548
|
-
auth = _ref16.auth,
|
|
549
|
-
headers = _ref16.headers,
|
|
550
|
-
context = _ref16.context;
|
|
551
|
-
|
|
552
|
-
return this.get({
|
|
553
|
-
uri: '/v1/user/identify',
|
|
554
|
-
auth: auth,
|
|
555
|
-
headers: headers,
|
|
556
|
-
query: full ? undefined : { tracking: 1 },
|
|
557
|
-
context: context
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* List devices claimed to the account or product
|
|
563
|
-
* @param {Object} options Options for this API call
|
|
564
|
-
* @param {String} [options.deviceId] (Product only) Filter results to devices with this ID (partial matching)
|
|
565
|
-
* @param {String} [options.deviceName] (Product only) Filter results to devices with this name (partial matching)
|
|
566
|
-
* @param {Array.<string>} [options.groups] (Product only) A list of full group names to filter results to devices belonging to these groups only.
|
|
567
|
-
* @param {String} [options.sortAttr] (Product only) The attribute by which to sort results. See API docs for options.
|
|
568
|
-
* @param {String} [options.sortDir] (Product only) The direction of sorting. See API docs for options.
|
|
569
|
-
* @param {Number} [options.page] (Product only) Current page of results
|
|
570
|
-
* @param {Number} [options.perPage] (Product only) Records per page
|
|
571
|
-
* @param {String} [options.product] List devices in this product ID or slug
|
|
572
|
-
* @param {String} options.auth Access Token
|
|
573
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
574
|
-
* @param {Object} [options.context] Request context
|
|
575
|
-
* @returns {Promise} A promise
|
|
576
|
-
*/
|
|
577
|
-
|
|
578
|
-
}, {
|
|
579
|
-
key: 'listDevices',
|
|
580
|
-
value: function listDevices(_ref17) {
|
|
581
|
-
var deviceId = _ref17.deviceId,
|
|
582
|
-
deviceName = _ref17.deviceName,
|
|
583
|
-
groups = _ref17.groups,
|
|
584
|
-
sortAttr = _ref17.sortAttr,
|
|
585
|
-
sortDir = _ref17.sortDir,
|
|
586
|
-
page = _ref17.page,
|
|
587
|
-
perPage = _ref17.perPage,
|
|
588
|
-
product = _ref17.product,
|
|
589
|
-
auth = _ref17.auth,
|
|
590
|
-
headers = _ref17.headers,
|
|
591
|
-
context = _ref17.context;
|
|
592
|
-
|
|
593
|
-
var uri = void 0,
|
|
594
|
-
query = void 0;
|
|
595
|
-
|
|
596
|
-
if (product) {
|
|
597
|
-
uri = '/v1/products/' + product + '/devices';
|
|
598
|
-
groups = Array.isArray(groups) ? groups.join(',') : undefined;
|
|
599
|
-
query = { deviceId: deviceId, deviceName: deviceName, groups: groups, sortAttr: sortAttr, sortDir: sortDir, page: page, per_page: perPage };
|
|
600
|
-
} else {
|
|
601
|
-
uri = '/v1/devices';
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
return this.get({ uri: uri, auth: auth, headers: headers, query: query, context: context });
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* Get detailed informationa about a device
|
|
609
|
-
* @param {Object} options Options for this API call
|
|
610
|
-
* @param {String} options.deviceId Device ID or Name
|
|
611
|
-
* @param {String} [options.product] Device in this product ID or slug
|
|
612
|
-
* @param {String} options.auth Access token
|
|
613
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
614
|
-
* @param {Object} [options.context] Request context
|
|
615
|
-
* @returns {Promise} A promise
|
|
616
|
-
*/
|
|
617
|
-
|
|
618
|
-
}, {
|
|
619
|
-
key: 'getDevice',
|
|
620
|
-
value: function getDevice(_ref18) {
|
|
621
|
-
var deviceId = _ref18.deviceId,
|
|
622
|
-
product = _ref18.product,
|
|
623
|
-
auth = _ref18.auth,
|
|
624
|
-
headers = _ref18.headers,
|
|
625
|
-
context = _ref18.context;
|
|
626
|
-
|
|
627
|
-
var uri = this.deviceUri({ deviceId: deviceId, product: product });
|
|
628
|
-
return this.get({ uri: uri, auth: auth, headers: headers, context: context });
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
* Claim a device to the account. The device must be online and unclaimed.
|
|
633
|
-
* @param {Object} options Options for this API call
|
|
634
|
-
* @param {String} options.deviceId Device ID
|
|
635
|
-
* @param {String} options.auth Access Token
|
|
636
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
637
|
-
* @param {Object} [options.context] Request context
|
|
638
|
-
* @returns {Promise} A promise
|
|
639
|
-
*/
|
|
640
|
-
|
|
641
|
-
}, {
|
|
642
|
-
key: 'claimDevice',
|
|
643
|
-
value: function claimDevice(_ref19) {
|
|
644
|
-
var deviceId = _ref19.deviceId,
|
|
645
|
-
requestTransfer = _ref19.requestTransfer,
|
|
646
|
-
auth = _ref19.auth,
|
|
647
|
-
headers = _ref19.headers,
|
|
648
|
-
context = _ref19.context;
|
|
649
|
-
|
|
650
|
-
return this.post({
|
|
651
|
-
uri: '/v1/devices',
|
|
652
|
-
auth: auth,
|
|
653
|
-
headers: headers,
|
|
654
|
-
data: {
|
|
655
|
-
id: deviceId,
|
|
656
|
-
request_transfer: !!requestTransfer
|
|
657
|
-
},
|
|
658
|
-
context: context
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
/**
|
|
663
|
-
* Add a device to a product or move device out of quarantine.
|
|
664
|
-
* @param {Object} options Options for this API call
|
|
665
|
-
* @param {String} options.deviceId Device ID
|
|
666
|
-
* @param {Object} options.file A file that contains a single-column list of device IDs, device serial numbers, device IMEIs, or devie ICCIDs.
|
|
667
|
-
* Node: Either a path or Buffer. Browser: a File or Blob.
|
|
668
|
-
* @param {String} options.product Add to this product ID or slug
|
|
669
|
-
* @param {String} options.auth Access Token
|
|
670
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
671
|
-
* @param {Object} [options.context] Request context
|
|
672
|
-
* @returns {Promise} A promise
|
|
673
|
-
*/
|
|
674
|
-
|
|
675
|
-
}, {
|
|
676
|
-
key: 'addDeviceToProduct',
|
|
677
|
-
value: function addDeviceToProduct(_ref20) {
|
|
678
|
-
var deviceId = _ref20.deviceId,
|
|
679
|
-
product = _ref20.product,
|
|
680
|
-
file = _ref20.file,
|
|
681
|
-
auth = _ref20.auth,
|
|
682
|
-
headers = _ref20.headers,
|
|
683
|
-
context = _ref20.context;
|
|
684
|
-
|
|
685
|
-
var files = void 0,
|
|
686
|
-
data = void 0;
|
|
687
|
-
|
|
688
|
-
if (file) {
|
|
689
|
-
files = { file: file };
|
|
690
|
-
} else if (deviceId) {
|
|
691
|
-
data = { id: deviceId };
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
return this.request({
|
|
695
|
-
uri: '/v1/products/' + product + '/devices',
|
|
696
|
-
method: 'post',
|
|
697
|
-
headers: headers,
|
|
698
|
-
data: data,
|
|
699
|
-
files: files,
|
|
700
|
-
auth: auth,
|
|
701
|
-
context: context
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
/**
|
|
706
|
-
* Unclaim / Remove a device from your account or product, or deny quarantine
|
|
707
|
-
* @param {Object} options Options for this API call
|
|
708
|
-
* @param {String} options.deviceId Device ID or Name
|
|
709
|
-
* @param {Boolean} [options.deny] (Product only) Deny this quarantined device, instead of removing an already approved device
|
|
710
|
-
* @param {String} options.product Remove from this product ID or slug
|
|
711
|
-
* @param {String} options.auth Access Token
|
|
712
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
713
|
-
* @param {Object} [options.context] Request context
|
|
714
|
-
* @returns {Promise} A promise
|
|
715
|
-
*/
|
|
716
|
-
|
|
717
|
-
}, {
|
|
718
|
-
key: 'removeDevice',
|
|
719
|
-
value: function removeDevice(_ref21) {
|
|
720
|
-
var deviceId = _ref21.deviceId,
|
|
721
|
-
deny = _ref21.deny,
|
|
722
|
-
product = _ref21.product,
|
|
723
|
-
auth = _ref21.auth,
|
|
724
|
-
headers = _ref21.headers,
|
|
725
|
-
context = _ref21.context;
|
|
726
|
-
|
|
727
|
-
var uri = this.deviceUri({ deviceId: deviceId, product: product });
|
|
728
|
-
var data = product ? { deny: deny } : undefined;
|
|
729
|
-
return this.delete({ uri: uri, data: data, auth: auth, headers: headers, context: context });
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
/**
|
|
733
|
-
* Unclaim a product device its the owner, but keep it in the product
|
|
734
|
-
* @param {Object} options Options for this API call
|
|
735
|
-
* @param {String} options.deviceId Device ID or Name
|
|
736
|
-
* @param {String} options.product Remove from this product ID or slug
|
|
737
|
-
* @param {String} options.auth Access Token
|
|
738
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
739
|
-
* @param {Object} [options.context] Request context
|
|
740
|
-
* @returns {Promise} A promise
|
|
741
|
-
*/
|
|
742
|
-
|
|
743
|
-
}, {
|
|
744
|
-
key: 'removeDeviceOwner',
|
|
745
|
-
value: function removeDeviceOwner(_ref22) {
|
|
746
|
-
var deviceId = _ref22.deviceId,
|
|
747
|
-
product = _ref22.product,
|
|
748
|
-
auth = _ref22.auth,
|
|
749
|
-
headers = _ref22.headers,
|
|
750
|
-
context = _ref22.context;
|
|
751
|
-
|
|
752
|
-
var uri = '/v1/products/' + product + '/devices/' + deviceId + '/owner';
|
|
753
|
-
return this.delete({ uri: uri, auth: auth, headers: headers, context: context });
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
/**
|
|
757
|
-
* Rename a device
|
|
758
|
-
* @param {Object} options Options for this API call
|
|
759
|
-
* @param {String} options.deviceId Device ID or Name
|
|
760
|
-
* @param {String} options.name Desired Name
|
|
761
|
-
* @param {String} [options.product] Rename device in this product ID or slug
|
|
762
|
-
* @param {String} options.auth Access Token
|
|
763
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
764
|
-
* @param {Object} [options.context] Request context
|
|
765
|
-
* @returns {Promise} A promise
|
|
766
|
-
*/
|
|
767
|
-
|
|
768
|
-
}, {
|
|
769
|
-
key: 'renameDevice',
|
|
770
|
-
value: function renameDevice(_ref23) {
|
|
771
|
-
var deviceId = _ref23.deviceId,
|
|
772
|
-
name = _ref23.name,
|
|
773
|
-
product = _ref23.product,
|
|
774
|
-
auth = _ref23.auth,
|
|
775
|
-
headers = _ref23.headers,
|
|
776
|
-
context = _ref23.context;
|
|
777
|
-
|
|
778
|
-
return this.updateDevice({ deviceId: deviceId, name: name, product: product, auth: auth, headers: headers, context: context });
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
/**
|
|
782
|
-
* Instruct the device to turn on/off the LED in a rainbow pattern
|
|
783
|
-
* @param {Object} options Options for this API call
|
|
784
|
-
* @param {String} options.deviceId Device ID or Name
|
|
785
|
-
* @param {Boolean} options.signal Signal on or off
|
|
786
|
-
* @param {String} [options.product] Device in this product ID or slug
|
|
787
|
-
* @param {String} options.auth Access Token
|
|
788
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
789
|
-
* @param {Object} [options.context] Request context
|
|
790
|
-
* @returns {Promise} A promise
|
|
791
|
-
*/
|
|
792
|
-
|
|
793
|
-
}, {
|
|
794
|
-
key: 'signalDevice',
|
|
795
|
-
value: function signalDevice(_ref24) {
|
|
796
|
-
var deviceId = _ref24.deviceId,
|
|
797
|
-
signal = _ref24.signal,
|
|
798
|
-
product = _ref24.product,
|
|
799
|
-
auth = _ref24.auth,
|
|
800
|
-
headers = _ref24.headers,
|
|
801
|
-
context = _ref24.context;
|
|
802
|
-
|
|
803
|
-
return this.updateDevice({ deviceId: deviceId, signal: signal, product: product, auth: auth, headers: headers, context: context });
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
/**
|
|
807
|
-
* Store some notes about device
|
|
808
|
-
* @param {Object} options Options for this API call
|
|
809
|
-
* @param {String} options.deviceId Device ID or Name
|
|
810
|
-
* @param {String} options.notes Your notes about this device
|
|
811
|
-
* @param {String} [options.product] Device in this product ID or slug
|
|
812
|
-
* @param {String} options.auth Access Token
|
|
813
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
814
|
-
* @param {Object} [options.context] Request context
|
|
815
|
-
* @returns {Promise} A promise
|
|
816
|
-
*/
|
|
817
|
-
|
|
818
|
-
}, {
|
|
819
|
-
key: 'setDeviceNotes',
|
|
820
|
-
value: function setDeviceNotes(_ref25) {
|
|
821
|
-
var deviceId = _ref25.deviceId,
|
|
822
|
-
notes = _ref25.notes,
|
|
823
|
-
product = _ref25.product,
|
|
824
|
-
auth = _ref25.auth,
|
|
825
|
-
headers = _ref25.headers,
|
|
826
|
-
context = _ref25.context;
|
|
827
|
-
|
|
828
|
-
return this.updateDevice({ deviceId: deviceId, notes: notes, product: product, auth: auth, headers: headers, context: context });
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
/**
|
|
832
|
-
* Mark device as being used in development of a product so it opts out of automatic firmware updates
|
|
833
|
-
* @param {Object} options Options for this API call
|
|
834
|
-
* @param {String} options.deviceId Device ID or Name
|
|
835
|
-
* @param {Boolean} options.development Set to true to mark as development, false to return to product fleet
|
|
836
|
-
* @param {String} options.product Device in this product ID or slug
|
|
837
|
-
* @param {String} options.auth Access Token
|
|
838
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
839
|
-
* @param {Object} [options.context] Request context
|
|
840
|
-
* @returns {Promise} A promise
|
|
841
|
-
*/
|
|
842
|
-
|
|
843
|
-
}, {
|
|
844
|
-
key: 'markAsDevelopmentDevice',
|
|
845
|
-
value: function markAsDevelopmentDevice(_ref26) {
|
|
846
|
-
var deviceId = _ref26.deviceId,
|
|
847
|
-
_ref26$development = _ref26.development,
|
|
848
|
-
development = _ref26$development === undefined ? true : _ref26$development,
|
|
849
|
-
product = _ref26.product,
|
|
850
|
-
auth = _ref26.auth,
|
|
851
|
-
headers = _ref26.headers,
|
|
852
|
-
context = _ref26.context;
|
|
853
|
-
|
|
854
|
-
return this.updateDevice({ deviceId: deviceId, development: development, product: product, auth: auth, headers: headers, context: context });
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
/**
|
|
858
|
-
* Mark device as being used in development of a product so it opts out of automatic firmware updates
|
|
859
|
-
* @param {Object} options Options for this API call
|
|
860
|
-
* @param {String} options.deviceId Device ID or Name
|
|
861
|
-
* @param {Number} options.desiredFirmwareVersion Lock the product device to run this firmware version.
|
|
862
|
-
* @param {Boolean} [options.flash] Immediately flash firmware indicated by desiredFirmwareVersion
|
|
863
|
-
* @param {String} options.product Device in this product ID or slug
|
|
864
|
-
* @param {String} options.auth Access Token
|
|
865
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
866
|
-
* @param {Object} [options.context] Request context
|
|
867
|
-
* @returns {Promise} A promise
|
|
868
|
-
*/
|
|
869
|
-
|
|
870
|
-
}, {
|
|
871
|
-
key: 'lockDeviceProductFirmware',
|
|
872
|
-
value: function lockDeviceProductFirmware(_ref27) {
|
|
873
|
-
var deviceId = _ref27.deviceId,
|
|
874
|
-
desiredFirmwareVersion = _ref27.desiredFirmwareVersion,
|
|
875
|
-
flash = _ref27.flash,
|
|
876
|
-
product = _ref27.product,
|
|
877
|
-
auth = _ref27.auth,
|
|
878
|
-
context = _ref27.context;
|
|
879
|
-
|
|
880
|
-
return this.updateDevice({ deviceId: deviceId, desiredFirmwareVersion: desiredFirmwareVersion, flash: flash, product: product, auth: auth, context: context });
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
/**
|
|
884
|
-
* Mark device as receiving automatic firmware updates
|
|
885
|
-
* @param {Object} options Options for this API call
|
|
886
|
-
* @param {String} options.deviceId Device ID or Name
|
|
887
|
-
* @param {String} options.product Device in this product ID or slug
|
|
888
|
-
* @param {String} options.auth Access Token
|
|
889
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
890
|
-
* @param {Object} [options.context] Request context
|
|
891
|
-
* @returns {Promise} A promise
|
|
892
|
-
*/
|
|
893
|
-
|
|
894
|
-
}, {
|
|
895
|
-
key: 'unlockDeviceProductFirmware',
|
|
896
|
-
value: function unlockDeviceProductFirmware(_ref28) {
|
|
897
|
-
var deviceId = _ref28.deviceId,
|
|
898
|
-
product = _ref28.product,
|
|
899
|
-
auth = _ref28.auth,
|
|
900
|
-
headers = _ref28.headers,
|
|
901
|
-
context = _ref28.context;
|
|
902
|
-
|
|
903
|
-
return this.updateDevice({ deviceId: deviceId, desiredFirmwareVersion: null, product: product, auth: auth, headers: headers, context: context });
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
/**
|
|
907
|
-
* Update multiple device attributes at the same time
|
|
908
|
-
* @param {Object} options Options for this API call
|
|
909
|
-
* @param {String} options.deviceId Device ID or Name
|
|
910
|
-
* @param {String} [options.name] Desired Name
|
|
911
|
-
* @param {Boolean} options.signal Signal device on or off
|
|
912
|
-
* @param {String} [options.notes] Your notes about this device
|
|
913
|
-
* @param {Boolean} [options.development] (Product only) Set to true to mark as development, false to return to product fleet
|
|
914
|
-
* @param {Number} [options.desiredFirmwareVersion] (Product only) Lock the product device to run this firmware version.
|
|
915
|
-
* Pass `null` to unlock firmware and go back to released firmware.
|
|
916
|
-
* @param {Boolean} [options.flash] (Product only) Immediately flash firmware indicated by desiredFirmwareVersion
|
|
917
|
-
* @param {String} [options.product] Device in this product ID or slug
|
|
918
|
-
* @param {String} options.auth Access Token
|
|
919
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
920
|
-
* @param {Object} [options.context] Request context
|
|
921
|
-
* @returns {Promise} A promise
|
|
922
|
-
*/
|
|
923
|
-
|
|
924
|
-
}, {
|
|
925
|
-
key: 'updateDevice',
|
|
926
|
-
value: function updateDevice(_ref29) {
|
|
927
|
-
var deviceId = _ref29.deviceId,
|
|
928
|
-
name = _ref29.name,
|
|
929
|
-
signal = _ref29.signal,
|
|
930
|
-
notes = _ref29.notes,
|
|
931
|
-
development = _ref29.development,
|
|
932
|
-
desiredFirmwareVersion = _ref29.desiredFirmwareVersion,
|
|
933
|
-
flash = _ref29.flash,
|
|
934
|
-
product = _ref29.product,
|
|
935
|
-
auth = _ref29.auth,
|
|
936
|
-
headers = _ref29.headers,
|
|
937
|
-
context = _ref29.context;
|
|
938
|
-
|
|
939
|
-
if (signal !== undefined) {
|
|
940
|
-
signal = signal ? '1' : '0';
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
var uri = this.deviceUri({ deviceId: deviceId, product: product });
|
|
944
|
-
var data = product ? { name: name, signal: signal, notes: notes, development: development, desired_firmware_version: desiredFirmwareVersion, flash: flash } : { name: name, signal: signal, notes: notes };
|
|
945
|
-
|
|
946
|
-
return this.put({ uri: uri, auth: auth, headers: headers, data: data, context: context });
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
/**
|
|
950
|
-
* Provision a new device for products that allow self-provisioning
|
|
951
|
-
* @param {Object} options Options for this API call
|
|
952
|
-
* @param {String} options.productId Product ID where to create this device
|
|
953
|
-
* @param {String} options.auth Access Token
|
|
954
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
955
|
-
* @param {Object} [options.context] Request context
|
|
956
|
-
* @returns {Promise} A promise
|
|
957
|
-
*/
|
|
958
|
-
|
|
959
|
-
}, {
|
|
960
|
-
key: 'provisionDevice',
|
|
961
|
-
value: function provisionDevice(_ref30) {
|
|
962
|
-
var productId = _ref30.productId,
|
|
963
|
-
auth = _ref30.auth,
|
|
964
|
-
headers = _ref30.headers,
|
|
965
|
-
context = _ref30.context;
|
|
966
|
-
|
|
967
|
-
return this.post({
|
|
968
|
-
uri: '/v1/devices',
|
|
969
|
-
auth: auth,
|
|
970
|
-
headers: headers,
|
|
971
|
-
data: { product_id: productId },
|
|
972
|
-
context: context
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
/**
|
|
977
|
-
* Generate a claim code to use in the device claiming process.
|
|
978
|
-
* To generate a claim code for a product, the access token MUST belong to a
|
|
979
|
-
* customer of the product.
|
|
980
|
-
* @param {Object} options Options for this API call
|
|
981
|
-
* @param {String} [options.iccid] ICCID of the SIM card used in the Electron
|
|
982
|
-
* @param {String} [options.product] Device in this product ID or slug
|
|
983
|
-
* @param {String} options.auth Access Token
|
|
984
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
985
|
-
* @param {Object} [options.context] Request context
|
|
986
|
-
* @returns {Promise} A promise
|
|
987
|
-
*/
|
|
988
|
-
|
|
989
|
-
}, {
|
|
990
|
-
key: 'getClaimCode',
|
|
991
|
-
value: function getClaimCode(_ref31) {
|
|
992
|
-
var iccid = _ref31.iccid,
|
|
993
|
-
product = _ref31.product,
|
|
994
|
-
auth = _ref31.auth,
|
|
995
|
-
headers = _ref31.headers,
|
|
996
|
-
context = _ref31.context;
|
|
997
|
-
|
|
998
|
-
var uri = product ? '/v1/products/' + product + '/device_claims' : '/v1/device_claims';
|
|
999
|
-
return this.post({ uri: uri, auth: auth, headers: headers, data: { iccid: iccid }, context: context });
|
|
1000
|
-
}
|
|
1001
|
-
}, {
|
|
1002
|
-
key: 'validatePromoCode',
|
|
1003
|
-
value: function validatePromoCode(_ref32) {
|
|
1004
|
-
var promoCode = _ref32.promoCode,
|
|
1005
|
-
auth = _ref32.auth,
|
|
1006
|
-
headers = _ref32.headers,
|
|
1007
|
-
context = _ref32.context;
|
|
1008
|
-
|
|
1009
|
-
return this.get({
|
|
1010
|
-
uri: '/v1/promo_code/' + promoCode,
|
|
1011
|
-
auth: auth,
|
|
1012
|
-
headers: headers,
|
|
1013
|
-
context: context
|
|
1014
|
-
});
|
|
1015
|
-
}
|
|
1016
|
-
}, {
|
|
1017
|
-
key: 'changeProduct',
|
|
1018
|
-
value: function changeProduct(_ref33) {
|
|
1019
|
-
var deviceId = _ref33.deviceId,
|
|
1020
|
-
productId = _ref33.productId,
|
|
1021
|
-
auth = _ref33.auth,
|
|
1022
|
-
headers = _ref33.headers,
|
|
1023
|
-
context = _ref33.context;
|
|
1024
|
-
|
|
1025
|
-
return this.put({
|
|
1026
|
-
uri: '/v1/devices/' + deviceId,
|
|
1027
|
-
auth: auth,
|
|
1028
|
-
headers: headers,
|
|
1029
|
-
data: { product_id: productId },
|
|
1030
|
-
context: context
|
|
1031
|
-
});
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
/**
|
|
1035
|
-
* Get the value of a device variable
|
|
1036
|
-
* @param {Object} options Options for this API call
|
|
1037
|
-
* @param {String} options.deviceId Device ID or Name
|
|
1038
|
-
* @param {String} options.name Variable name
|
|
1039
|
-
* @param {String} [options.product] Device in this product ID or slug
|
|
1040
|
-
* @param {String} options.auth Access Token
|
|
1041
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1042
|
-
* @param {Object} [options.context] Request context
|
|
1043
|
-
* @returns {Promise} A promise
|
|
1044
|
-
*/
|
|
1045
|
-
|
|
1046
|
-
}, {
|
|
1047
|
-
key: 'getVariable',
|
|
1048
|
-
value: function getVariable(_ref34) {
|
|
1049
|
-
var deviceId = _ref34.deviceId,
|
|
1050
|
-
name = _ref34.name,
|
|
1051
|
-
product = _ref34.product,
|
|
1052
|
-
auth = _ref34.auth,
|
|
1053
|
-
headers = _ref34.headers,
|
|
1054
|
-
context = _ref34.context;
|
|
1055
|
-
|
|
1056
|
-
var uri = product ? '/v1/products/' + product + '/devices/' + deviceId + '/' + name : '/v1/devices/' + deviceId + '/' + name;
|
|
1057
|
-
|
|
1058
|
-
return this.get({ uri: uri, auth: auth, headers: headers, context: context });
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
/**
|
|
1062
|
-
* Compile and flash application firmware to a device. Pass a pre-compiled binary to flash it directly to the device.
|
|
1063
|
-
* @param {Object} options Options for this API call
|
|
1064
|
-
* @param {String} options.deviceId Device ID or Name
|
|
1065
|
-
* @param {String} options.product Flash device in this product ID or slug
|
|
1066
|
-
* @param {Object} options.files Object containing files to be compiled and flashed. Keys should be the filenames, including relative path, and the values should be a path or Buffer of the file contents in Node, or a File or Blob in the browser.
|
|
1067
|
-
* @param {String} [options.targetVersion=latest] System firmware version to compile against
|
|
1068
|
-
* @param {String} options.auth Access Token
|
|
1069
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1070
|
-
* @param {Object} [options.context] Request context
|
|
1071
|
-
* @returns {Promise} A promise
|
|
1072
|
-
*/
|
|
1073
|
-
|
|
1074
|
-
}, {
|
|
1075
|
-
key: 'flashDevice',
|
|
1076
|
-
value: function flashDevice(_ref35) {
|
|
1077
|
-
var deviceId = _ref35.deviceId,
|
|
1078
|
-
product = _ref35.product,
|
|
1079
|
-
files = _ref35.files,
|
|
1080
|
-
targetVersion = _ref35.targetVersion,
|
|
1081
|
-
auth = _ref35.auth,
|
|
1082
|
-
headers = _ref35.headers,
|
|
1083
|
-
context = _ref35.context;
|
|
1084
|
-
|
|
1085
|
-
var uri = this.deviceUri({ deviceId: deviceId, product: product });
|
|
1086
|
-
var form = {};
|
|
1087
|
-
|
|
1088
|
-
if (targetVersion) {
|
|
1089
|
-
form.build_target_version = targetVersion;
|
|
1090
|
-
} else {
|
|
1091
|
-
form.latest = 'true';
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
return this.request({ uri: uri, method: 'put', auth: auth, headers: headers, files: files, form: form, context: context });
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
/**
|
|
1098
|
-
* DEPRECATED: Flash the Tinker application to a device. Instead compile and flash the Tinker source code.
|
|
1099
|
-
* @param {Object} options Options for this API call
|
|
1100
|
-
* @param {String} options.deviceId Device ID or Name
|
|
1101
|
-
* @param {String} options.auth Access Token
|
|
1102
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1103
|
-
* @param {Object} [options.context] Request context
|
|
1104
|
-
* @returns {Promise} A promise
|
|
1105
|
-
*/
|
|
1106
|
-
|
|
1107
|
-
}, {
|
|
1108
|
-
key: 'flashTinker',
|
|
1109
|
-
value: function flashTinker(_ref36) {
|
|
1110
|
-
var deviceId = _ref36.deviceId,
|
|
1111
|
-
auth = _ref36.auth,
|
|
1112
|
-
headers = _ref36.headers,
|
|
1113
|
-
context = _ref36.context;
|
|
1114
|
-
|
|
1115
|
-
/* eslint-disable no-console */
|
|
1116
|
-
if (console && console.warning) {
|
|
1117
|
-
console.warning('Particle.flashTinker is deprecated');
|
|
1118
|
-
}
|
|
1119
|
-
/* eslint-enable no-console */
|
|
1120
|
-
return this.put({
|
|
1121
|
-
uri: '/v1/devices/' + deviceId,
|
|
1122
|
-
headers: headers,
|
|
1123
|
-
data: { app: 'tinker' },
|
|
1124
|
-
auth: auth,
|
|
1125
|
-
context: context
|
|
1126
|
-
});
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
/**
|
|
1130
|
-
* Compile firmware using the Particle Cloud
|
|
1131
|
-
* @param {Object} options Options for this API call
|
|
1132
|
-
* @param {Object} options.files Object containing files to be compiled. Keys should be the filenames, including relative path, and the values should be a path or Buffer of the file contents in Node, or a File or Blob in the browser.
|
|
1133
|
-
* @param {Number} [options.platformId] Platform id number of the device you are compiling for. Common values are 0=Core, 6=Photon, 10=Electron.
|
|
1134
|
-
* @param {String} [options.targetVersion=latest] System firmware version to compile against
|
|
1135
|
-
* @param {String} options.auth Access Token
|
|
1136
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1137
|
-
* @param {Object} [options.context] Request context
|
|
1138
|
-
* @returns {Promise} A promise
|
|
1139
|
-
*/
|
|
1140
|
-
|
|
1141
|
-
}, {
|
|
1142
|
-
key: 'compileCode',
|
|
1143
|
-
value: function compileCode(_ref37) {
|
|
1144
|
-
var files = _ref37.files,
|
|
1145
|
-
platformId = _ref37.platformId,
|
|
1146
|
-
targetVersion = _ref37.targetVersion,
|
|
1147
|
-
auth = _ref37.auth,
|
|
1148
|
-
headers = _ref37.headers,
|
|
1149
|
-
context = _ref37.context;
|
|
1150
|
-
|
|
1151
|
-
var form = { platform_id: platformId };
|
|
1152
|
-
|
|
1153
|
-
if (targetVersion) {
|
|
1154
|
-
form.build_target_version = targetVersion;
|
|
1155
|
-
} else {
|
|
1156
|
-
form.latest = 'true';
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
return this.request({
|
|
1160
|
-
uri: '/v1/binaries',
|
|
1161
|
-
method: 'post',
|
|
1162
|
-
auth: auth,
|
|
1163
|
-
headers: headers,
|
|
1164
|
-
files: files,
|
|
1165
|
-
form: form,
|
|
1166
|
-
context: context
|
|
1167
|
-
});
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
/**
|
|
1171
|
-
* Download a firmware binary
|
|
1172
|
-
* @param {Object} options Options for this API call
|
|
1173
|
-
* @param {String} options.binaryId Binary ID received from a successful compile call
|
|
1174
|
-
* @param {String} options.auth Access Token
|
|
1175
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1176
|
-
* @param {Object} [options.context] Request context
|
|
1177
|
-
* @returns {Request} A promise
|
|
1178
|
-
*/
|
|
1179
|
-
|
|
1180
|
-
}, {
|
|
1181
|
-
key: 'downloadFirmwareBinary',
|
|
1182
|
-
value: function downloadFirmwareBinary(_ref38) {
|
|
1183
|
-
var binaryId = _ref38.binaryId,
|
|
1184
|
-
auth = _ref38.auth,
|
|
1185
|
-
headers = _ref38.headers,
|
|
1186
|
-
context = _ref38.context;
|
|
1187
|
-
|
|
1188
|
-
var req = this.request({
|
|
1189
|
-
uri: '/v1/binaries/' + binaryId,
|
|
1190
|
-
method: 'get',
|
|
1191
|
-
auth: auth,
|
|
1192
|
-
headers: headers,
|
|
1193
|
-
context: context,
|
|
1194
|
-
raw: true
|
|
1195
|
-
});
|
|
1196
|
-
|
|
1197
|
-
return this._provideFileData(req);
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
/**
|
|
1201
|
-
* Send a new device public key to the Particle Cloud
|
|
1202
|
-
* @param {Object} options Options for this API call
|
|
1203
|
-
* @param {String} options.deviceId Device ID or Name
|
|
1204
|
-
* @param {(String|Buffer)} options.key Public key contents
|
|
1205
|
-
* @param {String} [options.algorithm=rsa] Algorithm used to generate the public key. Valid values are `rsa` or `ecc`.
|
|
1206
|
-
* @param {String} options.auth Access Token
|
|
1207
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1208
|
-
* @param {Object} [options.context] Request context
|
|
1209
|
-
* @returns {Promise} A promise
|
|
1210
|
-
*/
|
|
1211
|
-
|
|
1212
|
-
}, {
|
|
1213
|
-
key: 'sendPublicKey',
|
|
1214
|
-
value: function sendPublicKey(_ref39) {
|
|
1215
|
-
var deviceId = _ref39.deviceId,
|
|
1216
|
-
key = _ref39.key,
|
|
1217
|
-
algorithm = _ref39.algorithm,
|
|
1218
|
-
auth = _ref39.auth,
|
|
1219
|
-
headers = _ref39.headers,
|
|
1220
|
-
context = _ref39.context;
|
|
1221
|
-
|
|
1222
|
-
return this.post({
|
|
1223
|
-
uri: '/v1/provisioning/' + deviceId,
|
|
1224
|
-
auth: auth,
|
|
1225
|
-
headers: headers,
|
|
1226
|
-
data: {
|
|
1227
|
-
deviceID: deviceId,
|
|
1228
|
-
publicKey: typeof key === 'string' ? key : key.toString(),
|
|
1229
|
-
filename: 'particle-api',
|
|
1230
|
-
order: 'manual_' + Date.now(),
|
|
1231
|
-
algorithm: algorithm || 'rsa'
|
|
1232
|
-
},
|
|
1233
|
-
context: context
|
|
1234
|
-
});
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
/**
|
|
1238
|
-
* Call a device function
|
|
1239
|
-
* @param {Object} options Options for this API call
|
|
1240
|
-
* @param {String} options.deviceId Device ID or Name
|
|
1241
|
-
* @param {String} options.name Function name
|
|
1242
|
-
* @param {String} options.argument Function argument
|
|
1243
|
-
* @param {String} [options.product] Device in this product ID or slug
|
|
1244
|
-
* @param {String} options.auth Access Token
|
|
1245
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1246
|
-
* @param {Object} [options.context] Request context
|
|
1247
|
-
* @returns {Promise} A promise
|
|
1248
|
-
*/
|
|
1249
|
-
|
|
1250
|
-
}, {
|
|
1251
|
-
key: 'callFunction',
|
|
1252
|
-
value: function callFunction(_ref40) {
|
|
1253
|
-
var deviceId = _ref40.deviceId,
|
|
1254
|
-
name = _ref40.name,
|
|
1255
|
-
argument = _ref40.argument,
|
|
1256
|
-
product = _ref40.product,
|
|
1257
|
-
auth = _ref40.auth,
|
|
1258
|
-
headers = _ref40.headers,
|
|
1259
|
-
context = _ref40.context;
|
|
1260
|
-
|
|
1261
|
-
var uri = product ? '/v1/products/' + product + '/devices/' + deviceId + '/' + name : '/v1/devices/' + deviceId + '/' + name;
|
|
1262
|
-
return this.post({ uri: uri, auth: auth, headers: headers, data: { args: argument }, context: context });
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
/**
|
|
1266
|
-
* Get a stream of events
|
|
1267
|
-
* @param {Object} options Options for this API call
|
|
1268
|
-
* @param {String} [options.deviceId] Device ID or Name, or `mine` to indicate only your devices.
|
|
1269
|
-
* @param {String} [options.name] Event Name
|
|
1270
|
-
* @param {String} [options.org] Organization Slug
|
|
1271
|
-
* @param {String} [options.product] Events for this product ID or slug
|
|
1272
|
-
* @param {String} options.auth Access Token
|
|
1273
|
-
* @returns {Promise} If the promise resolves, the resolution value will be an EventStream object that will
|
|
1274
|
-
* emit 'event' events.
|
|
1275
|
-
*/
|
|
1276
|
-
|
|
1277
|
-
}, {
|
|
1278
|
-
key: 'getEventStream',
|
|
1279
|
-
value: function getEventStream(_ref41) {
|
|
1280
|
-
var deviceId = _ref41.deviceId,
|
|
1281
|
-
name = _ref41.name,
|
|
1282
|
-
org = _ref41.org,
|
|
1283
|
-
product = _ref41.product,
|
|
1284
|
-
auth = _ref41.auth;
|
|
1285
|
-
|
|
1286
|
-
var uri = '/v1/';
|
|
1287
|
-
if (org) {
|
|
1288
|
-
uri += 'orgs/' + org + '/';
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
if (product) {
|
|
1292
|
-
uri += 'products/' + product + '/';
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
if (deviceId) {
|
|
1296
|
-
uri += 'devices/';
|
|
1297
|
-
if (!(deviceId.toLowerCase() === 'mine')) {
|
|
1298
|
-
uri += deviceId + '/';
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1302
|
-
uri += 'events';
|
|
1303
|
-
|
|
1304
|
-
if (name) {
|
|
1305
|
-
uri += '/' + encodeURIComponent(name);
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
auth = this._getActiveAuthToken(auth);
|
|
1309
|
-
return new _EventStream2.default('' + this.baseUrl + uri, auth).connect();
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
/**
|
|
1313
|
-
* Publish a event to the Particle Cloud
|
|
1314
|
-
* @param {Object} options Options for this API call
|
|
1315
|
-
* @param {String} options.name Event name
|
|
1316
|
-
* @param {String} options.data Event data
|
|
1317
|
-
* @param {Boolean} options.isPrivate Should the event be publicly available?
|
|
1318
|
-
* @param {String} [options.product] Event for this product ID or slug
|
|
1319
|
-
* @param {String} options.auth Access Token
|
|
1320
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1321
|
-
* @param {Object} [options.context] Request context
|
|
1322
|
-
* @returns {Promise} A promise
|
|
1323
|
-
*/
|
|
1324
|
-
|
|
1325
|
-
}, {
|
|
1326
|
-
key: 'publishEvent',
|
|
1327
|
-
value: function publishEvent(_ref42) {
|
|
1328
|
-
var name = _ref42.name,
|
|
1329
|
-
data = _ref42.data,
|
|
1330
|
-
isPrivate = _ref42.isPrivate,
|
|
1331
|
-
product = _ref42.product,
|
|
1332
|
-
auth = _ref42.auth,
|
|
1333
|
-
headers = _ref42.headers,
|
|
1334
|
-
context = _ref42.context;
|
|
1335
|
-
|
|
1336
|
-
var uri = product ? '/v1/products/' + product + '/events' : '/v1/devices/events';
|
|
1337
|
-
var postData = { name: name, data: data, private: isPrivate };
|
|
1338
|
-
return this.post({ uri: uri, auth: auth, headers: headers, data: postData, context: context });
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
/**
|
|
1342
|
-
* Create a webhook
|
|
1343
|
-
* @param {Object} options Options for this API call
|
|
1344
|
-
* @param {String} options.event The name of the Particle event that should trigger the Webhook
|
|
1345
|
-
* @param {String} options.url The web address that will be targeted when the Webhook is triggered
|
|
1346
|
-
* @param {String} [options.device] Trigger Webhook only for this device ID or Name
|
|
1347
|
-
* @param {Boolean} [options.rejectUnauthorized] Set to `false` to skip SSL certificate validation of the target URL
|
|
1348
|
-
* @param {Boolean} [options.noDefaults] Don't include default event data in the webhook request
|
|
1349
|
-
* @param {Object} [options.hook] Webhook configuration settings
|
|
1350
|
-
* @param {String} [options.hook.method=POST] Type of web request triggered by the Webhook (GET, POST, PUT, or DELETE)
|
|
1351
|
-
* @param {Object} [options.hook.auth] Auth data like `{ username: 'me', password: '1234' }` to send via basic auth header with the Webhook request
|
|
1352
|
-
* @param {Object} [options.hook.headers] Additional headers to add to the Webhook like `{ 'X-ONE': '1', X-TWO: '2' }`
|
|
1353
|
-
* @param {Object} [options.hook.query] Query params to add to the Webhook request like `{ foo: 'foo', bar: 'bar' }`
|
|
1354
|
-
* @param {Object} [options.hook.json] JSON data to send with the Webhook request - sets `Content-Type` to `application/json`
|
|
1355
|
-
* @param {Object} [options.hook.form] Form data to send with the Webhook request - sets `Content-Type` to `application/x-www-form-urlencoded`
|
|
1356
|
-
* @param {String} [options.hook.body] Custom body to send with the Webhook request
|
|
1357
|
-
* @param {Object} [options.hook.responseTemplate] Template to use to customize the Webhook response body
|
|
1358
|
-
* @param {Object} [options.hook.responseEvent] The Webhook response event name that your devices can subscribe to
|
|
1359
|
-
* @param {Object} [options.hook.errorResponseEvent] The Webhook error response event name that your devices can subscribe to
|
|
1360
|
-
* @param {String} [options.product] Webhook for this product ID or slug
|
|
1361
|
-
* @param {String} options.auth Access Token
|
|
1362
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1363
|
-
* @param {Object} [options.context] Request context
|
|
1364
|
-
* @returns {Promise} A promise
|
|
1365
|
-
*/
|
|
1366
|
-
|
|
1367
|
-
}, {
|
|
1368
|
-
key: 'createWebhook',
|
|
1369
|
-
value: function createWebhook(_ref43) {
|
|
1370
|
-
var event = _ref43.event,
|
|
1371
|
-
url = _ref43.url,
|
|
1372
|
-
device = _ref43.device,
|
|
1373
|
-
rejectUnauthorized = _ref43.rejectUnauthorized,
|
|
1374
|
-
noDefaults = _ref43.noDefaults,
|
|
1375
|
-
hook = _ref43.hook,
|
|
1376
|
-
product = _ref43.product,
|
|
1377
|
-
auth = _ref43.auth,
|
|
1378
|
-
headers = _ref43.headers,
|
|
1379
|
-
context = _ref43.context;
|
|
1380
|
-
|
|
1381
|
-
var uri = product ? '/v1/products/' + product + '/webhooks' : '/v1/webhooks';
|
|
1382
|
-
var data = { event: event, url: url, deviceId: device, rejectUnauthorized: rejectUnauthorized, noDefaults: noDefaults };
|
|
1383
|
-
|
|
1384
|
-
if (hook) {
|
|
1385
|
-
data.requestType = hook.method;
|
|
1386
|
-
data.auth = hook.auth;
|
|
1387
|
-
data.headers = hook.headers;
|
|
1388
|
-
data.query = hook.query;
|
|
1389
|
-
data.json = hook.json;
|
|
1390
|
-
data.form = hook.form;
|
|
1391
|
-
data.body = hook.body;
|
|
1392
|
-
data.responseTemplate = hook.responseTemplate;
|
|
1393
|
-
data.responseTopic = hook.responseEvent;
|
|
1394
|
-
data.errorResponseTopic = hook.errorResponseEvent;
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
if (!data.requestType) {
|
|
1398
|
-
data.requestType = 'POST';
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
return this.post({ uri: uri, auth: auth, headers: headers, data: data, context: context });
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
/**
|
|
1405
|
-
* Delete a webhook
|
|
1406
|
-
* @param {Object} options Options for this API call
|
|
1407
|
-
* @param {String} options.hookId Webhook ID
|
|
1408
|
-
* @param {String} [options.product] Webhook for this product ID or slug
|
|
1409
|
-
* @param {String} options.auth Access Token
|
|
1410
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1411
|
-
* @param {Object} [options.context] Request context
|
|
1412
|
-
* @returns {Promise} A promise
|
|
1413
|
-
*/
|
|
1414
|
-
|
|
1415
|
-
}, {
|
|
1416
|
-
key: 'deleteWebhook',
|
|
1417
|
-
value: function deleteWebhook(_ref44) {
|
|
1418
|
-
var hookId = _ref44.hookId,
|
|
1419
|
-
product = _ref44.product,
|
|
1420
|
-
auth = _ref44.auth,
|
|
1421
|
-
headers = _ref44.headers,
|
|
1422
|
-
context = _ref44.context;
|
|
1423
|
-
|
|
1424
|
-
var uri = product ? '/v1/products/' + product + '/webhooks/' + hookId : '/v1/webhooks/' + hookId;
|
|
1425
|
-
return this.delete({ uri: uri, auth: auth, headers: headers, context: context });
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
/**
|
|
1429
|
-
* List all webhooks owned by the account or product
|
|
1430
|
-
* @param {Object} options Options for this API call
|
|
1431
|
-
* @param {String} [options.product] Webhooks for this product ID or slug
|
|
1432
|
-
* @param {String} options.auth Access Token
|
|
1433
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1434
|
-
* @param {Object} [options.context] Request context
|
|
1435
|
-
* @returns {Promise} A promise
|
|
1436
|
-
*/
|
|
1437
|
-
|
|
1438
|
-
}, {
|
|
1439
|
-
key: 'listWebhooks',
|
|
1440
|
-
value: function listWebhooks(_ref45) {
|
|
1441
|
-
var product = _ref45.product,
|
|
1442
|
-
auth = _ref45.auth,
|
|
1443
|
-
headers = _ref45.headers,
|
|
1444
|
-
context = _ref45.context;
|
|
1445
|
-
|
|
1446
|
-
var uri = product ? '/v1/products/' + product + '/webhooks' : '/v1/webhooks';
|
|
1447
|
-
return this.get({ uri: uri, auth: auth, headers: headers, context: context });
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
/**
|
|
1451
|
-
* Create an integration to send events to an external service
|
|
1452
|
-
*
|
|
1453
|
-
* See the API docs for details https://docs.particle.io/reference/api/#integrations-webhooks-
|
|
1454
|
-
*
|
|
1455
|
-
* @param {Object} options Options for this API call
|
|
1456
|
-
* @param {String} options.event Event that triggers the integration
|
|
1457
|
-
* @param {Object} options.settings Settings specific to that integration type
|
|
1458
|
-
* @param {String} [options.deviceId] Trigger integration only for this device ID or Name
|
|
1459
|
-
* @param {String} [options.product] Integration for this product ID or slug
|
|
1460
|
-
* @param {String} options.auth Access Token
|
|
1461
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1462
|
-
* @param {Object} [options.context] Request context
|
|
1463
|
-
* @returns {Promise} A promise
|
|
1464
|
-
*/
|
|
1465
|
-
|
|
1466
|
-
}, {
|
|
1467
|
-
key: 'createIntegration',
|
|
1468
|
-
value: function createIntegration(_ref46) {
|
|
1469
|
-
var event = _ref46.event,
|
|
1470
|
-
settings = _ref46.settings,
|
|
1471
|
-
deviceId = _ref46.deviceId,
|
|
1472
|
-
product = _ref46.product,
|
|
1473
|
-
auth = _ref46.auth,
|
|
1474
|
-
headers = _ref46.headers,
|
|
1475
|
-
context = _ref46.context;
|
|
1476
|
-
|
|
1477
|
-
var uri = product ? '/v1/products/' + product + '/integrations' : '/v1/integrations';
|
|
1478
|
-
var data = (0, _assign2.default)({ event: event, deviceid: deviceId }, settings);
|
|
1479
|
-
return this.post({ uri: uri, data: data, auth: auth, headers: headers, context: context });
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
/**
|
|
1483
|
-
* Edit an integration to send events to an external service
|
|
1484
|
-
*
|
|
1485
|
-
* See the API docs for details https://docs.particle.io/reference/api/#integrations-webhooks-
|
|
1486
|
-
*
|
|
1487
|
-
* @param {Object} options Options for this API call
|
|
1488
|
-
* @param {String} options.integrationId The integration to edit
|
|
1489
|
-
* @param {String} [options.event] Change the event that triggers the integration
|
|
1490
|
-
* @param {Object} [options.settings] Change the settings specific to that integration type
|
|
1491
|
-
* @param {String} [options.deviceId] Trigger integration only for this device ID or Name
|
|
1492
|
-
* @param {String} [options.product] Integration for this product ID or slug
|
|
1493
|
-
* @param {String} options.auth Access Token
|
|
1494
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1495
|
-
* @param {Object} [options.context] Request context
|
|
1496
|
-
* @returns {Promise} A promise
|
|
1497
|
-
*/
|
|
1498
|
-
|
|
1499
|
-
}, {
|
|
1500
|
-
key: 'editIntegration',
|
|
1501
|
-
value: function editIntegration(_ref47) {
|
|
1502
|
-
var integrationId = _ref47.integrationId,
|
|
1503
|
-
event = _ref47.event,
|
|
1504
|
-
settings = _ref47.settings,
|
|
1505
|
-
deviceId = _ref47.deviceId,
|
|
1506
|
-
product = _ref47.product,
|
|
1507
|
-
auth = _ref47.auth,
|
|
1508
|
-
headers = _ref47.headers,
|
|
1509
|
-
context = _ref47.context;
|
|
1510
|
-
|
|
1511
|
-
var uri = product ? '/v1/products/' + product + '/integrations/' + integrationId : '/v1/integrations/' + integrationId;
|
|
1512
|
-
var data = (0, _assign2.default)({ event: event, deviceid: deviceId }, settings);
|
|
1513
|
-
return this.put({ uri: uri, auth: auth, headers: headers, data: data, context: context });
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
|
-
/**
|
|
1517
|
-
* Delete an integration to send events to an external service
|
|
1518
|
-
*
|
|
1519
|
-
* @param {Object} options Options for this API call
|
|
1520
|
-
* @param {String} options.integrationId The integration to remove
|
|
1521
|
-
* @param {String} [options.product] Integration for this product ID or slug
|
|
1522
|
-
* @param {String} options.auth Access Token
|
|
1523
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1524
|
-
* @param {Object} [options.context] Request context
|
|
1525
|
-
* @returns {Promise} A promise
|
|
1526
|
-
*/
|
|
1527
|
-
|
|
1528
|
-
}, {
|
|
1529
|
-
key: 'deleteIntegration',
|
|
1530
|
-
value: function deleteIntegration(_ref48) {
|
|
1531
|
-
var integrationId = _ref48.integrationId,
|
|
1532
|
-
product = _ref48.product,
|
|
1533
|
-
auth = _ref48.auth,
|
|
1534
|
-
headers = _ref48.headers,
|
|
1535
|
-
context = _ref48.context;
|
|
1536
|
-
|
|
1537
|
-
var uri = product ? '/v1/products/' + product + '/integrations/' + integrationId : '/v1/integrations/' + integrationId;
|
|
1538
|
-
return this.delete({ uri: uri, auth: auth, headers: headers, context: context });
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
/**
|
|
1542
|
-
* List all integrations owned by the account or product
|
|
1543
|
-
* @param {Object} options Options for this API call
|
|
1544
|
-
* @param {String} [options.product] Integrations for this product ID or slug
|
|
1545
|
-
* @param {String} options.auth Access Token
|
|
1546
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1547
|
-
* @param {Object} [options.context] Request context
|
|
1548
|
-
* @returns {Promise} A promise
|
|
1549
|
-
*/
|
|
1550
|
-
|
|
1551
|
-
}, {
|
|
1552
|
-
key: 'listIntegrations',
|
|
1553
|
-
value: function listIntegrations(_ref49) {
|
|
1554
|
-
var product = _ref49.product,
|
|
1555
|
-
auth = _ref49.auth,
|
|
1556
|
-
headers = _ref49.headers,
|
|
1557
|
-
context = _ref49.context;
|
|
1558
|
-
|
|
1559
|
-
var uri = product ? '/v1/products/' + product + '/integrations' : '/v1/integrations';
|
|
1560
|
-
return this.get({ uri: uri, auth: auth, headers: headers, context: context });
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
|
-
/**
|
|
1564
|
-
* Get details about the current user
|
|
1565
|
-
* @param {Object} options Options for this API call
|
|
1566
|
-
* @param {String} options.auth Access Token
|
|
1567
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1568
|
-
* @param {Object} [options.context] Request context
|
|
1569
|
-
* @returns {Promise} A promise
|
|
1570
|
-
*/
|
|
1571
|
-
|
|
1572
|
-
}, {
|
|
1573
|
-
key: 'getUserInfo',
|
|
1574
|
-
value: function getUserInfo(_ref50) {
|
|
1575
|
-
var auth = _ref50.auth,
|
|
1576
|
-
headers = _ref50.headers,
|
|
1577
|
-
context = _ref50.context;
|
|
1578
|
-
|
|
1579
|
-
return this.get({ uri: '/v1/user', auth: auth, headers: headers, context: context });
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
/**
|
|
1583
|
-
* Set details on the current user
|
|
1584
|
-
* @param {Object} options Options for this API call
|
|
1585
|
-
* @param {String} options.auth Access Token
|
|
1586
|
-
* @param {String} options.accountInfo Set user's extended info fields (name, business account, company name, etc)
|
|
1587
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1588
|
-
* @param {Object} [options.context] Request context
|
|
1589
|
-
* @returns {Promise} A promise
|
|
1590
|
-
*/
|
|
1591
|
-
|
|
1592
|
-
}, {
|
|
1593
|
-
key: 'setUserInfo',
|
|
1594
|
-
value: function setUserInfo(_ref51) {
|
|
1595
|
-
var accountInfo = _ref51.accountInfo,
|
|
1596
|
-
auth = _ref51.auth,
|
|
1597
|
-
headers = _ref51.headers,
|
|
1598
|
-
context = _ref51.context;
|
|
1599
|
-
|
|
1600
|
-
var data = { account_info: accountInfo };
|
|
1601
|
-
return this.put({ uri: '/v1/user', auth: auth, headers: headers, data: data, context: context });
|
|
1602
|
-
}
|
|
1603
|
-
|
|
1604
|
-
/**
|
|
1605
|
-
* Change username (i.e, email)
|
|
1606
|
-
* @param {Object} options Options for this API call
|
|
1607
|
-
* @param {String} options.auth Access Token
|
|
1608
|
-
* @param {String} options.currentPassword Current password
|
|
1609
|
-
* @param {String} options.username New email
|
|
1610
|
-
* @param {Boolean} options.invalidateTokens Should all tokens be invalidated
|
|
1611
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1612
|
-
* @param {Object} [options.context] Request context
|
|
1613
|
-
* @returns {Promise} A promise
|
|
1614
|
-
*/
|
|
1615
|
-
|
|
1616
|
-
}, {
|
|
1617
|
-
key: 'changeUsername',
|
|
1618
|
-
value: function changeUsername(_ref52) {
|
|
1619
|
-
var currentPassword = _ref52.currentPassword,
|
|
1620
|
-
username = _ref52.username,
|
|
1621
|
-
_ref52$invalidateToke = _ref52.invalidateTokens,
|
|
1622
|
-
invalidateTokens = _ref52$invalidateToke === undefined ? false : _ref52$invalidateToke,
|
|
1623
|
-
auth = _ref52.auth,
|
|
1624
|
-
headers = _ref52.headers,
|
|
1625
|
-
context = _ref52.context;
|
|
1626
|
-
|
|
1627
|
-
var data = { username: username, current_password: currentPassword };
|
|
1628
|
-
|
|
1629
|
-
if (invalidateTokens) {
|
|
1630
|
-
data.invalidate_tokens = true;
|
|
1631
|
-
}
|
|
1632
|
-
|
|
1633
|
-
return this.put({ uri: '/v1/user', auth: auth, headers: headers, data: data, context: context });
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
/**
|
|
1637
|
-
* Change user's password
|
|
1638
|
-
* @param {Object} options Options for this API call
|
|
1639
|
-
* @param {String} options.auth Access Token
|
|
1640
|
-
* @param {String} options.currentPassword Current password
|
|
1641
|
-
* @param {String} options.password New password
|
|
1642
|
-
* @param {Boolean} options.invalidateTokens Should all tokens be invalidated
|
|
1643
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1644
|
-
* @param {Object} [options.context] Request context
|
|
1645
|
-
* @returns {Promise} A promise
|
|
1646
|
-
*/
|
|
1647
|
-
|
|
1648
|
-
}, {
|
|
1649
|
-
key: 'changeUserPassword',
|
|
1650
|
-
value: function changeUserPassword(_ref53) {
|
|
1651
|
-
var currentPassword = _ref53.currentPassword,
|
|
1652
|
-
password = _ref53.password,
|
|
1653
|
-
_ref53$invalidateToke = _ref53.invalidateTokens,
|
|
1654
|
-
invalidateTokens = _ref53$invalidateToke === undefined ? false : _ref53$invalidateToke,
|
|
1655
|
-
auth = _ref53.auth,
|
|
1656
|
-
headers = _ref53.headers,
|
|
1657
|
-
context = _ref53.context;
|
|
1658
|
-
|
|
1659
|
-
var data = { password: password, current_password: currentPassword };
|
|
1660
|
-
|
|
1661
|
-
if (invalidateTokens) {
|
|
1662
|
-
data.invalidate_tokens = true;
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
|
-
return this.put({ uri: '/v1/user', auth: auth, headers: headers, data: data, context: context });
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
/**
|
|
1669
|
-
* List SIM cards owned by a user or product
|
|
1670
|
-
* @param {Object} options Options for this API call
|
|
1671
|
-
* @param {String} [options.iccid] (Product only) Filter to SIM cards matching this ICCID
|
|
1672
|
-
* @param {String} [options.deviceId] (Product only) Filter to SIM cards matching this device ID
|
|
1673
|
-
* @param {String} [options.deviceName] (Product only) Filter to SIM cards matching this device name
|
|
1674
|
-
* @param {Number} [options.page] (Product only) Current page of results
|
|
1675
|
-
* @param {Number} [options.perPage] (Product only) Records per page
|
|
1676
|
-
* @param {String} [options.product] SIM cards for this product ID or slug
|
|
1677
|
-
* @param {String} options.auth Access Token
|
|
1678
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1679
|
-
* @param {Object} [options.context] Request context
|
|
1680
|
-
* @returns {Promise} A promise
|
|
1681
|
-
*/
|
|
1682
|
-
|
|
1683
|
-
}, {
|
|
1684
|
-
key: 'listSIMs',
|
|
1685
|
-
value: function listSIMs(_ref54) {
|
|
1686
|
-
var iccid = _ref54.iccid,
|
|
1687
|
-
deviceId = _ref54.deviceId,
|
|
1688
|
-
deviceName = _ref54.deviceName,
|
|
1689
|
-
page = _ref54.page,
|
|
1690
|
-
perPage = _ref54.perPage,
|
|
1691
|
-
product = _ref54.product,
|
|
1692
|
-
auth = _ref54.auth,
|
|
1693
|
-
headers = _ref54.headers,
|
|
1694
|
-
context = _ref54.context;
|
|
1695
|
-
|
|
1696
|
-
var uri = product ? '/v1/products/' + product + '/sims' : '/v1/sims';
|
|
1697
|
-
var query = product ? { iccid: iccid, deviceId: deviceId, deviceName: deviceName, page: page, per_page: perPage } : undefined;
|
|
1698
|
-
return this.get({ uri: uri, auth: auth, headers: headers, query: query, context: context });
|
|
1699
|
-
}
|
|
1700
|
-
|
|
1701
|
-
/**
|
|
1702
|
-
* Get data usage for one SIM card for the current billing period
|
|
1703
|
-
* @param {Object} options Options for this API call
|
|
1704
|
-
* @param {String} options.iccid ICCID of the SIM card
|
|
1705
|
-
* @param {String} [options.product] SIM card for this product ID or slug
|
|
1706
|
-
* @param {String} options.auth Access Token
|
|
1707
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1708
|
-
* @param {Object} [options.context] Request context
|
|
1709
|
-
* @returns {Promise} A promise
|
|
1710
|
-
*/
|
|
1711
|
-
|
|
1712
|
-
}, {
|
|
1713
|
-
key: 'getSIMDataUsage',
|
|
1714
|
-
value: function getSIMDataUsage(_ref55) {
|
|
1715
|
-
var iccid = _ref55.iccid,
|
|
1716
|
-
product = _ref55.product,
|
|
1717
|
-
auth = _ref55.auth,
|
|
1718
|
-
headers = _ref55.headers,
|
|
1719
|
-
context = _ref55.context;
|
|
1720
|
-
|
|
1721
|
-
var uri = product ? '/v1/products/' + product + '/sims/' + iccid + '/data_usage' : '/v1/sims/' + iccid + '/data_usage';
|
|
1722
|
-
|
|
1723
|
-
return this.get({ uri: uri, auth: auth, headers: headers, context: context });
|
|
1724
|
-
}
|
|
1725
|
-
|
|
1726
|
-
/**
|
|
1727
|
-
* Get data usage for all SIM cards in a product the current billing period
|
|
1728
|
-
* @param {Object} options Options for this API call
|
|
1729
|
-
* @param {String} options.product SIM cards for this product ID or slug
|
|
1730
|
-
* @param {String} options.auth Access Token
|
|
1731
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1732
|
-
* @param {Object} [options.context] Request context
|
|
1733
|
-
* @returns {Promise} A promise
|
|
1734
|
-
*/
|
|
1735
|
-
|
|
1736
|
-
}, {
|
|
1737
|
-
key: 'getFleetDataUsage',
|
|
1738
|
-
value: function getFleetDataUsage(_ref56) {
|
|
1739
|
-
var product = _ref56.product,
|
|
1740
|
-
auth = _ref56.auth,
|
|
1741
|
-
headers = _ref56.headers,
|
|
1742
|
-
context = _ref56.context;
|
|
1743
|
-
|
|
1744
|
-
return this.get({
|
|
1745
|
-
uri: '/v1/products/' + product + '/sims/data_usage',
|
|
1746
|
-
auth: auth,
|
|
1747
|
-
headers: headers,
|
|
1748
|
-
context: context
|
|
1749
|
-
});
|
|
1750
|
-
}
|
|
1751
|
-
|
|
1752
|
-
/**
|
|
1753
|
-
* Check SIM status
|
|
1754
|
-
* @param {Object} options Options for this API call
|
|
1755
|
-
* @param {String} options.iccid ICCID of the SIM card
|
|
1756
|
-
* @param {String} options.auth Access Token
|
|
1757
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1758
|
-
* @param {Object} [options.context] Request context
|
|
1759
|
-
* @returns {Promise} A promise
|
|
1760
|
-
*/
|
|
1761
|
-
|
|
1762
|
-
}, {
|
|
1763
|
-
key: 'checkSIM',
|
|
1764
|
-
value: function checkSIM(_ref57) {
|
|
1765
|
-
var iccid = _ref57.iccid,
|
|
1766
|
-
auth = _ref57.auth,
|
|
1767
|
-
headers = _ref57.headers,
|
|
1768
|
-
context = _ref57.context;
|
|
1769
|
-
|
|
1770
|
-
return this.head({ uri: '/v1/sims/' + iccid, auth: auth, headers: headers, context: context });
|
|
1771
|
-
}
|
|
1772
|
-
|
|
1773
|
-
/**
|
|
1774
|
-
* Activate and add SIM cards to an account or product
|
|
1775
|
-
* @param {Object} options Options for this API call
|
|
1776
|
-
* @param {String} options.iccid ICCID of the SIM card
|
|
1777
|
-
* @param {Array<String>} options.iccids (Product only) ICCID of multiple SIM cards to import
|
|
1778
|
-
* @param {String} options.country The ISO country code for the SIM cards
|
|
1779
|
-
* @param {String} [options.product] SIM cards for this product ID or slug
|
|
1780
|
-
* @param {String} options.auth Access Token
|
|
1781
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1782
|
-
* @param {Object} [options.context] Request context
|
|
1783
|
-
* @returns {Promise} A promise
|
|
1784
|
-
*/
|
|
1785
|
-
|
|
1786
|
-
}, {
|
|
1787
|
-
key: 'activateSIM',
|
|
1788
|
-
value: function activateSIM(_ref58) {
|
|
1789
|
-
var iccid = _ref58.iccid,
|
|
1790
|
-
iccids = _ref58.iccids,
|
|
1791
|
-
country = _ref58.country,
|
|
1792
|
-
promoCode = _ref58.promoCode,
|
|
1793
|
-
product = _ref58.product,
|
|
1794
|
-
auth = _ref58.auth,
|
|
1795
|
-
headers = _ref58.headers,
|
|
1796
|
-
context = _ref58.context;
|
|
1797
|
-
|
|
1798
|
-
// promoCode is deprecated
|
|
1799
|
-
iccids = iccids || [iccid];
|
|
1800
|
-
var uri = product ? '/v1/products/' + product + '/sims' : '/v1/sims/' + iccid;
|
|
1801
|
-
var data = product ? { sims: iccids, country: country } : { country: country, promoCode: promoCode, action: 'activate' };
|
|
1802
|
-
var method = product ? 'post' : 'put';
|
|
1803
|
-
|
|
1804
|
-
return this.request({ uri: uri, method: method, headers: headers, data: data, auth: auth, context: context });
|
|
1805
|
-
}
|
|
1806
|
-
|
|
1807
|
-
/**
|
|
1808
|
-
* Deactivate a SIM card so it doesn't incur data usage in future months.
|
|
1809
|
-
* @param {Object} options Options for this API call
|
|
1810
|
-
* @param {String} options.iccid ICCID of the SIM card
|
|
1811
|
-
* @param {String} [options.product] SIM cards for this product ID or slug
|
|
1812
|
-
* @param {String} options.auth Access Token
|
|
1813
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1814
|
-
* @param {Object} [options.context] Request context
|
|
1815
|
-
* @returns {Promise} A promise
|
|
1816
|
-
*/
|
|
1817
|
-
|
|
1818
|
-
}, {
|
|
1819
|
-
key: 'deactivateSIM',
|
|
1820
|
-
value: function deactivateSIM(_ref59) {
|
|
1821
|
-
var iccid = _ref59.iccid,
|
|
1822
|
-
product = _ref59.product,
|
|
1823
|
-
auth = _ref59.auth,
|
|
1824
|
-
headers = _ref59.headers,
|
|
1825
|
-
context = _ref59.context;
|
|
1826
|
-
|
|
1827
|
-
var uri = product ? '/v1/products/' + product + '/sims/' + iccid : '/v1/sims/' + iccid;
|
|
1828
|
-
var data = { action: 'deactivate' };
|
|
1829
|
-
return this.put({ uri: uri, auth: auth, headers: headers, data: data, context: context });
|
|
1830
|
-
}
|
|
1831
|
-
|
|
1832
|
-
/**
|
|
1833
|
-
* Reactivate a SIM card the was deactivated or unpause a SIM card that was automatically paused
|
|
1834
|
-
* @param {Object} options Options for this API call
|
|
1835
|
-
* @param {String} options.iccid ICCID of the SIM card
|
|
1836
|
-
* @param {Number} [options.mbLimit] New monthly data limit. Necessary if unpausing a SIM card
|
|
1837
|
-
* @param {String} [options.product] SIM cards for this product ID or slug
|
|
1838
|
-
* @param {String} options.auth Access Token
|
|
1839
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1840
|
-
* @param {Object} [options.context] Request context
|
|
1841
|
-
* @returns {Promise} A promise
|
|
1842
|
-
*/
|
|
1843
|
-
|
|
1844
|
-
}, {
|
|
1845
|
-
key: 'reactivateSIM',
|
|
1846
|
-
value: function reactivateSIM(_ref60) {
|
|
1847
|
-
var iccid = _ref60.iccid,
|
|
1848
|
-
mbLimit = _ref60.mbLimit,
|
|
1849
|
-
product = _ref60.product,
|
|
1850
|
-
auth = _ref60.auth,
|
|
1851
|
-
headers = _ref60.headers,
|
|
1852
|
-
context = _ref60.context;
|
|
1853
|
-
|
|
1854
|
-
var uri = product ? '/v1/products/' + product + '/sims/' + iccid : '/v1/sims/' + iccid;
|
|
1855
|
-
var data = { mb_limit: mbLimit, action: 'reactivate' };
|
|
1856
|
-
return this.put({ uri: uri, auth: auth, headers: headers, data: data, context: context });
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
/**
|
|
1860
|
-
* Update SIM card data limit
|
|
1861
|
-
* @param {Object} options Options for this API call
|
|
1862
|
-
* @param {String} options.iccid ICCID of the SIM card
|
|
1863
|
-
* @param {Array} options.mbLimit Data limit in megabyte for the SIM card
|
|
1864
|
-
* @param {String} [options.product] SIM cards for this product ID or slug
|
|
1865
|
-
* @param {String} options.auth Access Token
|
|
1866
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1867
|
-
* @param {Object} [options.context] Request context
|
|
1868
|
-
* @returns {Promise} A promise
|
|
1869
|
-
*/
|
|
1870
|
-
|
|
1871
|
-
}, {
|
|
1872
|
-
key: 'updateSIM',
|
|
1873
|
-
value: function updateSIM(_ref61) {
|
|
1874
|
-
var iccid = _ref61.iccid,
|
|
1875
|
-
mbLimit = _ref61.mbLimit,
|
|
1876
|
-
product = _ref61.product,
|
|
1877
|
-
auth = _ref61.auth,
|
|
1878
|
-
headers = _ref61.headers,
|
|
1879
|
-
context = _ref61.context;
|
|
1880
|
-
|
|
1881
|
-
var uri = product ? '/v1/products/' + product + '/sims/' + iccid : '/v1/sims/' + iccid;
|
|
1882
|
-
var data = { mb_limit: mbLimit };
|
|
1883
|
-
return this.put({ uri: uri, auth: auth, headers: headers, data: data, context: context });
|
|
1884
|
-
}
|
|
1885
|
-
|
|
1886
|
-
/**
|
|
1887
|
-
* Remove a SIM card from an account so it can be activated by a different account
|
|
1888
|
-
* @param {Object} options Options for this API call
|
|
1889
|
-
* @param {String} options.iccid ICCID of the SIM card
|
|
1890
|
-
* @param {String} [options.product] SIM cards for this product ID or slug
|
|
1891
|
-
* @param {String} options.auth Access Token
|
|
1892
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1893
|
-
* @param {Object} [options.context] Request context
|
|
1894
|
-
* @returns {Promise} A promise
|
|
1895
|
-
*/
|
|
1896
|
-
|
|
1897
|
-
}, {
|
|
1898
|
-
key: 'removeSIM',
|
|
1899
|
-
value: function removeSIM(_ref62) {
|
|
1900
|
-
var iccid = _ref62.iccid,
|
|
1901
|
-
product = _ref62.product,
|
|
1902
|
-
auth = _ref62.auth,
|
|
1903
|
-
headers = _ref62.headers,
|
|
1904
|
-
context = _ref62.context;
|
|
1905
|
-
|
|
1906
|
-
var uri = product ? '/v1/products/' + product + '/sims/' + iccid : '/v1/sims/' + iccid;
|
|
1907
|
-
return this.delete({ uri: uri, auth: auth, headers: headers, context: context });
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
/**
|
|
1911
|
-
* List valid build targets to be used for compiling
|
|
1912
|
-
* @param {Object} options Options for this API call
|
|
1913
|
-
* @param {Boolean} [options.onlyFeatured=false] Only list featured build targets
|
|
1914
|
-
* @param {String} options.auth Access Token
|
|
1915
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1916
|
-
* @param {Object} [options.context] Request context
|
|
1917
|
-
* @returns {Promise} A promise
|
|
1918
|
-
*/
|
|
1919
|
-
|
|
1920
|
-
}, {
|
|
1921
|
-
key: 'listBuildTargets',
|
|
1922
|
-
value: function listBuildTargets(_ref63) {
|
|
1923
|
-
var onlyFeatured = _ref63.onlyFeatured,
|
|
1924
|
-
auth = _ref63.auth,
|
|
1925
|
-
headers = _ref63.headers,
|
|
1926
|
-
context = _ref63.context;
|
|
1927
|
-
|
|
1928
|
-
var query = onlyFeatured ? { featured: !!onlyFeatured } : undefined;
|
|
1929
|
-
return this.get({ uri: '/v1/build_targets', auth: auth, headers: headers, query: query, context: context });
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
|
-
/**
|
|
1933
|
-
* List firmware libraries
|
|
1934
|
-
* @param {Object} options Options for this API call
|
|
1935
|
-
* @param {Number} options.page Page index (default, first page)
|
|
1936
|
-
* @param {Number} options.limit Number of items per page
|
|
1937
|
-
* @param {String} options.filter Search term for the libraries
|
|
1938
|
-
* @param {String} options.sort Ordering key for the library list
|
|
1939
|
-
* @param {Array<String>} options.architectures List of architectures to filter
|
|
1940
|
-
* @param {String} options.category Category to filter
|
|
1941
|
-
* @param {String} options.scope The library scope to list. Default is 'all'. Other values are
|
|
1942
|
-
* - 'all' - list public libraries and my private libraries
|
|
1943
|
-
* - 'public' - list only public libraries
|
|
1944
|
-
* - 'private' - list only my private libraries
|
|
1945
|
-
* - 'mine' - list my libraries (public and private)
|
|
1946
|
-
* - 'official' - list only official libraries
|
|
1947
|
-
* - 'verified' - list only verified libraries
|
|
1948
|
-
* - 'featured' - list only featured libraries
|
|
1949
|
-
* @param {String} options.excludeScopes list of scopes to exclude
|
|
1950
|
-
* @param {String} options.category Category to filter
|
|
1951
|
-
* @param {String} options.auth Access Token
|
|
1952
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
1953
|
-
* @param {Object} [options.context] Request context
|
|
1954
|
-
* @returns {Promise} A promise
|
|
1955
|
-
*/
|
|
1956
|
-
|
|
1957
|
-
}, {
|
|
1958
|
-
key: 'listLibraries',
|
|
1959
|
-
value: function listLibraries(_ref64) {
|
|
1960
|
-
var page = _ref64.page,
|
|
1961
|
-
limit = _ref64.limit,
|
|
1962
|
-
filter = _ref64.filter,
|
|
1963
|
-
sort = _ref64.sort,
|
|
1964
|
-
architectures = _ref64.architectures,
|
|
1965
|
-
category = _ref64.category,
|
|
1966
|
-
scope = _ref64.scope,
|
|
1967
|
-
excludeScopes = _ref64.excludeScopes,
|
|
1968
|
-
auth = _ref64.auth,
|
|
1969
|
-
headers = _ref64.headers,
|
|
1970
|
-
context = _ref64.context;
|
|
1971
|
-
|
|
1972
|
-
return this.get({
|
|
1973
|
-
uri: '/v1/libraries',
|
|
1974
|
-
auth: auth,
|
|
1975
|
-
headers: headers,
|
|
1976
|
-
query: {
|
|
1977
|
-
page: page,
|
|
1978
|
-
filter: filter,
|
|
1979
|
-
limit: limit,
|
|
1980
|
-
sort: sort,
|
|
1981
|
-
architectures: this._asList(architectures),
|
|
1982
|
-
category: category,
|
|
1983
|
-
scope: scope,
|
|
1984
|
-
excludeScopes: this._asList(excludeScopes)
|
|
1985
|
-
},
|
|
1986
|
-
context: context
|
|
1987
|
-
});
|
|
1988
|
-
}
|
|
1989
|
-
}, {
|
|
1990
|
-
key: '_asList',
|
|
1991
|
-
value: function _asList(value) {
|
|
1992
|
-
return Array.isArray(value) ? value.join(',') : value;
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
|
-
/**
|
|
1996
|
-
* Get firmware library details
|
|
1997
|
-
* @param {Object} options Options for this API call
|
|
1998
|
-
* @param {String} options.name Name of the library to fetch
|
|
1999
|
-
* @param {String} options.version Version of the library to fetch (default: latest)
|
|
2000
|
-
* @param {String} options.auth Access Token
|
|
2001
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2002
|
-
* @param {Object} [options.context] Request context
|
|
2003
|
-
* @returns {Promise} A promise
|
|
2004
|
-
*/
|
|
2005
|
-
|
|
2006
|
-
}, {
|
|
2007
|
-
key: 'getLibrary',
|
|
2008
|
-
value: function getLibrary(_ref65) {
|
|
2009
|
-
var name = _ref65.name,
|
|
2010
|
-
version = _ref65.version,
|
|
2011
|
-
auth = _ref65.auth,
|
|
2012
|
-
headers = _ref65.headers,
|
|
2013
|
-
context = _ref65.context;
|
|
2014
|
-
|
|
2015
|
-
return this.get({
|
|
2016
|
-
uri: '/v1/libraries/' + name,
|
|
2017
|
-
auth: auth,
|
|
2018
|
-
headers: headers,
|
|
2019
|
-
query: { version: version },
|
|
2020
|
-
context: context
|
|
2021
|
-
});
|
|
2022
|
-
}
|
|
2023
|
-
|
|
2024
|
-
/**
|
|
2025
|
-
* Firmware library details for each version
|
|
2026
|
-
* @param {Object} options Options for this API call
|
|
2027
|
-
* @param {String} options.name Name of the library to fetch
|
|
2028
|
-
* @param {Number} options.page Page index (default, first page)
|
|
2029
|
-
* @param {Number} options.limit Number of items per page
|
|
2030
|
-
* @param {String} options.auth Access Token
|
|
2031
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2032
|
-
* @param {Object} [options.context] Request context
|
|
2033
|
-
* @returns {Promise} A promise
|
|
2034
|
-
*/
|
|
2035
|
-
|
|
2036
|
-
}, {
|
|
2037
|
-
key: 'getLibraryVersions',
|
|
2038
|
-
value: function getLibraryVersions(_ref66) {
|
|
2039
|
-
var name = _ref66.name,
|
|
2040
|
-
page = _ref66.page,
|
|
2041
|
-
limit = _ref66.limit,
|
|
2042
|
-
auth = _ref66.auth,
|
|
2043
|
-
headers = _ref66.headers,
|
|
2044
|
-
context = _ref66.context;
|
|
2045
|
-
|
|
2046
|
-
return this.get({
|
|
2047
|
-
uri: '/v1/libraries/' + name + '/versions',
|
|
2048
|
-
auth: auth,
|
|
2049
|
-
headers: headers,
|
|
2050
|
-
query: { page: page, limit: limit },
|
|
2051
|
-
context: context
|
|
2052
|
-
});
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
|
-
/**
|
|
2056
|
-
* Contribute a new library version from a compressed archive
|
|
2057
|
-
* @param {Object} options Options for this API call
|
|
2058
|
-
* @param {String} options.archive Compressed archive file containing the library sources
|
|
2059
|
-
* Either a path or Buffer of the file contents in Node, or a File or Blob in the browser.
|
|
2060
|
-
* @param {String} options.auth Access Token
|
|
2061
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2062
|
-
* @param {Object} [options.context] Request context
|
|
2063
|
-
* @returns {Promise} A promise
|
|
2064
|
-
*/
|
|
2065
|
-
|
|
2066
|
-
}, {
|
|
2067
|
-
key: 'contributeLibrary',
|
|
2068
|
-
value: function contributeLibrary(_ref67) {
|
|
2069
|
-
var archive = _ref67.archive,
|
|
2070
|
-
auth = _ref67.auth,
|
|
2071
|
-
headers = _ref67.headers,
|
|
2072
|
-
context = _ref67.context;
|
|
2073
|
-
|
|
2074
|
-
var files = {
|
|
2075
|
-
'archive.tar.gz': archive
|
|
2076
|
-
};
|
|
2077
|
-
|
|
2078
|
-
return this.request({
|
|
2079
|
-
uri: '/v1/libraries',
|
|
2080
|
-
method: 'post',
|
|
2081
|
-
auth: auth,
|
|
2082
|
-
headers: headers,
|
|
2083
|
-
files: files,
|
|
2084
|
-
context: context
|
|
2085
|
-
});
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
/**
|
|
2089
|
-
* Publish the latest version of a library to the public
|
|
2090
|
-
* @param {Object} options Options for this API call
|
|
2091
|
-
* @param {String} options.name Name of the library to publish
|
|
2092
|
-
* @param {String} options.auth Access Token
|
|
2093
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2094
|
-
* @param {Object} [options.context] Request context
|
|
2095
|
-
* @returns {Promise} A promise
|
|
2096
|
-
*/
|
|
2097
|
-
|
|
2098
|
-
}, {
|
|
2099
|
-
key: 'publishLibrary',
|
|
2100
|
-
value: function publishLibrary(_ref68) {
|
|
2101
|
-
var name = _ref68.name,
|
|
2102
|
-
auth = _ref68.auth,
|
|
2103
|
-
headers = _ref68.headers,
|
|
2104
|
-
context = _ref68.context;
|
|
2105
|
-
|
|
2106
|
-
return this.request({
|
|
2107
|
-
uri: '/v1/libraries/' + name,
|
|
2108
|
-
method: 'patch',
|
|
2109
|
-
auth: auth,
|
|
2110
|
-
headers: headers,
|
|
2111
|
-
data: { visibility: 'public' },
|
|
2112
|
-
context: context
|
|
2113
|
-
});
|
|
2114
|
-
}
|
|
2115
|
-
|
|
2116
|
-
/**
|
|
2117
|
-
* Delete one version of a library or an entire private library
|
|
2118
|
-
* @param {Object} options Options for this API call
|
|
2119
|
-
* @param {String} options.name Name of the library to remove
|
|
2120
|
-
* @param {String} options.force Key to force deleting a public library
|
|
2121
|
-
* @param {String} options.auth Access Token
|
|
2122
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2123
|
-
* @param {Object} [options.context] Request context
|
|
2124
|
-
* @returns {Promise} A promise
|
|
2125
|
-
*/
|
|
2126
|
-
|
|
2127
|
-
}, {
|
|
2128
|
-
key: 'deleteLibrary',
|
|
2129
|
-
value: function deleteLibrary(_ref69) {
|
|
2130
|
-
var name = _ref69.name,
|
|
2131
|
-
force = _ref69.force,
|
|
2132
|
-
auth = _ref69.auth,
|
|
2133
|
-
headers = _ref69.headers,
|
|
2134
|
-
context = _ref69.context;
|
|
2135
|
-
|
|
2136
|
-
return this.delete({
|
|
2137
|
-
uri: '/v1/libraries/' + name,
|
|
2138
|
-
auth: auth,
|
|
2139
|
-
headers: headers,
|
|
2140
|
-
data: { force: force },
|
|
2141
|
-
context: context
|
|
2142
|
-
});
|
|
2143
|
-
}
|
|
2144
|
-
|
|
2145
|
-
/**
|
|
2146
|
-
* Download an external file that may not be on the API
|
|
2147
|
-
* @param {Object} options Options for this API call
|
|
2148
|
-
* @param {String} options.uri URL of the file.
|
|
2149
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2150
|
-
* @param {Object} [options.context] Request context
|
|
2151
|
-
* @returns {Promise} Resolves to a buffer with the file data
|
|
2152
|
-
*/
|
|
2153
|
-
|
|
2154
|
-
}, {
|
|
2155
|
-
key: 'downloadFile',
|
|
2156
|
-
value: function downloadFile(_ref70) {
|
|
2157
|
-
var uri = _ref70.uri,
|
|
2158
|
-
headers = _ref70.headers,
|
|
2159
|
-
context = _ref70.context;
|
|
2160
|
-
|
|
2161
|
-
var req = this.request({ uri: uri, method: 'get', headers: headers, context: context, raw: true });
|
|
2162
|
-
return this._provideFileData(req);
|
|
2163
|
-
}
|
|
2164
|
-
|
|
2165
|
-
/**
|
|
2166
|
-
* List OAuth client created by the account
|
|
2167
|
-
* @param {Object} options Options for this API call
|
|
2168
|
-
* @param {String} [options.product] List clients for this product ID or slug
|
|
2169
|
-
* @param {String} options.auth Access Token
|
|
2170
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2171
|
-
* @param {Object} [options.context] Request context
|
|
2172
|
-
* @returns {Promise} A promise
|
|
2173
|
-
*/
|
|
2174
|
-
|
|
2175
|
-
}, {
|
|
2176
|
-
key: 'listOAuthClients',
|
|
2177
|
-
value: function listOAuthClients(_ref71) {
|
|
2178
|
-
var product = _ref71.product,
|
|
2179
|
-
auth = _ref71.auth,
|
|
2180
|
-
headers = _ref71.headers,
|
|
2181
|
-
context = _ref71.context;
|
|
2182
|
-
|
|
2183
|
-
var uri = product ? '/v1/products/' + product + '/clients' : '/v1/clients';
|
|
2184
|
-
return this.get({ uri: uri, auth: auth, headers: headers, context: context });
|
|
2185
|
-
}
|
|
2186
|
-
|
|
2187
|
-
/**
|
|
2188
|
-
* Create an OAuth client
|
|
2189
|
-
* @param {Object} options Options for this API call
|
|
2190
|
-
* @param {String} options.name Name of the OAuth client
|
|
2191
|
-
* @param {String} options.type web, installed or web
|
|
2192
|
-
* @param {String} [options.redirect_uri] URL to redirect after OAuth flow. Only for type web.
|
|
2193
|
-
* @param {Object} [options.scope] Limits what the access tokens created by this client can do.
|
|
2194
|
-
* @param {String} [options.product] Create client for this product ID or slug
|
|
2195
|
-
* @param {String} options.auth Access Token
|
|
2196
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2197
|
-
* @param {Object} [options.context] Request context
|
|
2198
|
-
* @returns {Promise} A promise
|
|
2199
|
-
*/
|
|
2200
|
-
|
|
2201
|
-
}, {
|
|
2202
|
-
key: 'createOAuthClient',
|
|
2203
|
-
value: function createOAuthClient(_ref72) {
|
|
2204
|
-
var name = _ref72.name,
|
|
2205
|
-
type = _ref72.type,
|
|
2206
|
-
redirect_uri = _ref72.redirect_uri,
|
|
2207
|
-
scope = _ref72.scope,
|
|
2208
|
-
product = _ref72.product,
|
|
2209
|
-
auth = _ref72.auth,
|
|
2210
|
-
headers = _ref72.headers,
|
|
2211
|
-
context = _ref72.context;
|
|
2212
|
-
|
|
2213
|
-
var uri = product ? '/v1/products/' + product + '/clients' : '/v1/clients';
|
|
2214
|
-
var data = { name: name, type: type, redirect_uri: redirect_uri, scope: scope };
|
|
2215
|
-
return this.post({ uri: uri, auth: auth, headers: headers, data: data, context: context });
|
|
2216
|
-
}
|
|
2217
|
-
|
|
2218
|
-
/**
|
|
2219
|
-
* Update an OAuth client
|
|
2220
|
-
* @param {Object} options Options for this API call
|
|
2221
|
-
* @param {String} options.clientId The OAuth client to update
|
|
2222
|
-
* @param {String} [options.name] New Name of the OAuth client
|
|
2223
|
-
* @param {Object} [options.scope] New scope of the OAuth client
|
|
2224
|
-
* @param {String} [options.product] Update client linked to this product ID or slug
|
|
2225
|
-
* @param {String} options.auth Access Token
|
|
2226
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2227
|
-
* @param {Object} [options.context] Request context
|
|
2228
|
-
* @returns {Promise} A promise
|
|
2229
|
-
*/
|
|
2230
|
-
|
|
2231
|
-
}, {
|
|
2232
|
-
key: 'updateOAuthClient',
|
|
2233
|
-
value: function updateOAuthClient(_ref73) {
|
|
2234
|
-
var clientId = _ref73.clientId,
|
|
2235
|
-
name = _ref73.name,
|
|
2236
|
-
scope = _ref73.scope,
|
|
2237
|
-
product = _ref73.product,
|
|
2238
|
-
auth = _ref73.auth,
|
|
2239
|
-
headers = _ref73.headers,
|
|
2240
|
-
context = _ref73.context;
|
|
2241
|
-
|
|
2242
|
-
var uri = product ? '/v1/products/' + product + '/clients/' + clientId : '/v1/clients/' + clientId;
|
|
2243
|
-
var data = { name: name, scope: scope };
|
|
2244
|
-
return this.put({ uri: uri, data: data, auth: auth, headers: headers, context: context });
|
|
2245
|
-
}
|
|
2246
|
-
|
|
2247
|
-
/**
|
|
2248
|
-
* Delete an OAuth client
|
|
2249
|
-
* @param {Object} options Options for this API call
|
|
2250
|
-
* @param {String} options.clientId The OAuth client to update
|
|
2251
|
-
* @param {String} [options.product] OAuth client linked to this product ID or slug
|
|
2252
|
-
* @param {String} options.auth Access Token
|
|
2253
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2254
|
-
* @param {Object} [options.context] Request context
|
|
2255
|
-
* @returns {Promise} A promise
|
|
2256
|
-
*/
|
|
2257
|
-
|
|
2258
|
-
}, {
|
|
2259
|
-
key: 'deleteOAuthClient',
|
|
2260
|
-
value: function deleteOAuthClient(_ref74) {
|
|
2261
|
-
var clientId = _ref74.clientId,
|
|
2262
|
-
product = _ref74.product,
|
|
2263
|
-
auth = _ref74.auth,
|
|
2264
|
-
headers = _ref74.headers,
|
|
2265
|
-
context = _ref74.context;
|
|
2266
|
-
|
|
2267
|
-
var uri = product ? '/v1/products/' + product + '/clients/' + clientId : '/v1/clients/' + clientId;
|
|
2268
|
-
return this.delete({ uri: uri, auth: auth, headers: headers, context: context });
|
|
2269
|
-
}
|
|
2270
|
-
|
|
2271
|
-
/**
|
|
2272
|
-
* List products the account has access to
|
|
2273
|
-
* @param {Object} options Options for this API call
|
|
2274
|
-
* @param {String} options.auth Access Token
|
|
2275
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2276
|
-
* @param {Object} [options.context] Request context
|
|
2277
|
-
* @returns {Promise} A promise
|
|
2278
|
-
*/
|
|
2279
|
-
|
|
2280
|
-
}, {
|
|
2281
|
-
key: 'listProducts',
|
|
2282
|
-
value: function listProducts(_ref75) {
|
|
2283
|
-
var auth = _ref75.auth,
|
|
2284
|
-
headers = _ref75.headers,
|
|
2285
|
-
context = _ref75.context;
|
|
2286
|
-
|
|
2287
|
-
return this.get({ uri: '/v1/products', auth: auth, headers: headers, context: context });
|
|
2288
|
-
}
|
|
2289
|
-
|
|
2290
|
-
/**
|
|
2291
|
-
* Get detailed information about a product
|
|
2292
|
-
* @param {Object} options Options for this API call
|
|
2293
|
-
* @param {String} options.product Product ID or slug
|
|
2294
|
-
* @param {String} options.auth Access token
|
|
2295
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2296
|
-
* @param {Object} [options.context] Request context
|
|
2297
|
-
* @returns {Promise} A promise
|
|
2298
|
-
*/
|
|
2299
|
-
|
|
2300
|
-
}, {
|
|
2301
|
-
key: 'getProduct',
|
|
2302
|
-
value: function getProduct(_ref76) {
|
|
2303
|
-
var product = _ref76.product,
|
|
2304
|
-
auth = _ref76.auth,
|
|
2305
|
-
headers = _ref76.headers,
|
|
2306
|
-
context = _ref76.context;
|
|
2307
|
-
|
|
2308
|
-
return this.get({ uri: '/v1/products/' + product, auth: auth, headers: headers, context: context });
|
|
2309
|
-
}
|
|
2310
|
-
|
|
2311
|
-
/**
|
|
2312
|
-
* List product firmware versions
|
|
2313
|
-
* @param {Object} options Options for this API call
|
|
2314
|
-
* @param {String} options.product Firmware for this product ID or slug
|
|
2315
|
-
* @param {String} options.auth Access Token
|
|
2316
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2317
|
-
* @param {Object} [options.context] Request context
|
|
2318
|
-
* @returns {Promise} A promise
|
|
2319
|
-
*/
|
|
2320
|
-
|
|
2321
|
-
}, {
|
|
2322
|
-
key: 'listProductFirmware',
|
|
2323
|
-
value: function listProductFirmware(_ref77) {
|
|
2324
|
-
var product = _ref77.product,
|
|
2325
|
-
auth = _ref77.auth,
|
|
2326
|
-
headers = _ref77.headers,
|
|
2327
|
-
context = _ref77.context;
|
|
2328
|
-
|
|
2329
|
-
return this.get({ uri: '/v1/products/' + product + '/firmware', auth: auth, headers: headers, context: context });
|
|
2330
|
-
}
|
|
2331
|
-
|
|
2332
|
-
/**
|
|
2333
|
-
* List product firmware versions
|
|
2334
|
-
* @param {Object} options Options for this API call
|
|
2335
|
-
* @param {Object} options.file Path or Buffer of the new firmware file
|
|
2336
|
-
* Either a path or Buffer of the file contents in Node, or a File or Blob in the browser.
|
|
2337
|
-
* @param {Number} options.version Version number of new firmware
|
|
2338
|
-
* @param {String} options.title Short identifier for the new firmware
|
|
2339
|
-
* @param {String} [options.description] Longer description for the new firmware
|
|
2340
|
-
* @param {String} options.product Firmware for this product ID or slug
|
|
2341
|
-
* @param {String} options.auth Access Token
|
|
2342
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2343
|
-
* @param {Object} [options.context] Request context
|
|
2344
|
-
* @returns {Promise} A promise
|
|
2345
|
-
*/
|
|
2346
|
-
|
|
2347
|
-
}, {
|
|
2348
|
-
key: 'uploadProductFirmware',
|
|
2349
|
-
value: function uploadProductFirmware(_ref78) {
|
|
2350
|
-
var file = _ref78.file,
|
|
2351
|
-
version = _ref78.version,
|
|
2352
|
-
title = _ref78.title,
|
|
2353
|
-
description = _ref78.description,
|
|
2354
|
-
product = _ref78.product,
|
|
2355
|
-
auth = _ref78.auth,
|
|
2356
|
-
headers = _ref78.headers,
|
|
2357
|
-
context = _ref78.context;
|
|
2358
|
-
|
|
2359
|
-
return this.request({
|
|
2360
|
-
uri: '/v1/products/' + product + '/firmware',
|
|
2361
|
-
method: 'post',
|
|
2362
|
-
auth: auth,
|
|
2363
|
-
headers: headers,
|
|
2364
|
-
form: {
|
|
2365
|
-
version: version,
|
|
2366
|
-
title: title,
|
|
2367
|
-
description: description
|
|
2368
|
-
},
|
|
2369
|
-
files: {
|
|
2370
|
-
'firmware.bin': file
|
|
2371
|
-
},
|
|
2372
|
-
context: context
|
|
2373
|
-
});
|
|
2374
|
-
}
|
|
2375
|
-
|
|
2376
|
-
/**
|
|
2377
|
-
* Get information about a product firmware version
|
|
2378
|
-
* @param {Object} options Options for this API call
|
|
2379
|
-
* @param {Number} options.version Version number of firmware
|
|
2380
|
-
* @param {String} options.product Firmware for this product ID or slug
|
|
2381
|
-
* @param {String} options.auth Access token
|
|
2382
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2383
|
-
* @param {Object} [options.context] Request context
|
|
2384
|
-
* @returns {Promise} A promise
|
|
2385
|
-
*/
|
|
2386
|
-
|
|
2387
|
-
}, {
|
|
2388
|
-
key: 'getProductFirmware',
|
|
2389
|
-
value: function getProductFirmware(_ref79) {
|
|
2390
|
-
var version = _ref79.version,
|
|
2391
|
-
product = _ref79.product,
|
|
2392
|
-
auth = _ref79.auth,
|
|
2393
|
-
headers = _ref79.headers,
|
|
2394
|
-
context = _ref79.context;
|
|
2395
|
-
|
|
2396
|
-
return this.get({
|
|
2397
|
-
uri: '/v1/products/' + product + '/firmware/' + version,
|
|
2398
|
-
auth: auth,
|
|
2399
|
-
headers: headers,
|
|
2400
|
-
context: context
|
|
2401
|
-
});
|
|
2402
|
-
}
|
|
2403
|
-
|
|
2404
|
-
/**
|
|
2405
|
-
* Update information for a product firmware version
|
|
2406
|
-
* @param {Object} options Options for this API call
|
|
2407
|
-
* @param {Number} options.version Version number of new firmware
|
|
2408
|
-
* @param {String} [options.title] New title
|
|
2409
|
-
* @param {String} [options.description] New description
|
|
2410
|
-
* @param {String} options.product Firmware for this product ID or slug
|
|
2411
|
-
* @param {String} options.auth Access Token
|
|
2412
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2413
|
-
* @param {Object} [options.context] Request context
|
|
2414
|
-
* @returns {Promise} A promise
|
|
2415
|
-
*/
|
|
2416
|
-
|
|
2417
|
-
}, {
|
|
2418
|
-
key: 'updateProductFirmware',
|
|
2419
|
-
value: function updateProductFirmware(_ref80) {
|
|
2420
|
-
var version = _ref80.version,
|
|
2421
|
-
title = _ref80.title,
|
|
2422
|
-
description = _ref80.description,
|
|
2423
|
-
product = _ref80.product,
|
|
2424
|
-
auth = _ref80.auth,
|
|
2425
|
-
headers = _ref80.headers,
|
|
2426
|
-
context = _ref80.context;
|
|
2427
|
-
|
|
2428
|
-
var uri = '/v1/products/' + product + '/firmware/' + version;
|
|
2429
|
-
return this.put({ uri: uri, auth: auth, headers: headers, data: { title: title, description: description }, context: context });
|
|
2430
|
-
}
|
|
2431
|
-
|
|
2432
|
-
/**
|
|
2433
|
-
* Download a product firmware binary
|
|
2434
|
-
* @param {Object} options Options for this API call
|
|
2435
|
-
* @param {Number} options.version Version number of new firmware
|
|
2436
|
-
* @param {String} options.product Firmware for this product ID or slug
|
|
2437
|
-
* @param {String} options.auth Access Token
|
|
2438
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2439
|
-
* @param {Object} [options.context] Request context
|
|
2440
|
-
* @returns {Request} A promise
|
|
2441
|
-
*/
|
|
2442
|
-
|
|
2443
|
-
}, {
|
|
2444
|
-
key: 'downloadProductFirmware',
|
|
2445
|
-
value: function downloadProductFirmware(_ref81) {
|
|
2446
|
-
var version = _ref81.version,
|
|
2447
|
-
product = _ref81.product,
|
|
2448
|
-
auth = _ref81.auth,
|
|
2449
|
-
headers = _ref81.headers,
|
|
2450
|
-
context = _ref81.context;
|
|
2451
|
-
|
|
2452
|
-
var req = this.request({
|
|
2453
|
-
uri: '/v1/products/' + product + '/firmware/' + version + '/binary',
|
|
2454
|
-
method: 'get',
|
|
2455
|
-
auth: auth,
|
|
2456
|
-
headers: headers,
|
|
2457
|
-
context: context,
|
|
2458
|
-
raw: true
|
|
2459
|
-
});
|
|
2460
|
-
|
|
2461
|
-
return this._provideFileData(req);
|
|
2462
|
-
}
|
|
2463
|
-
}, {
|
|
2464
|
-
key: '_provideFileData',
|
|
2465
|
-
value: function _provideFileData(req) {
|
|
2466
|
-
if (this.agent.isForBrowser()) {
|
|
2467
|
-
req = req.responseType('arraybuffer').then(function (res) {
|
|
2468
|
-
res.body = res.xhr.response;
|
|
2469
|
-
return res;
|
|
2470
|
-
});
|
|
2471
|
-
} else {
|
|
2472
|
-
req = req.buffer(true).parse(_superagentBinaryParser2.default);
|
|
2473
|
-
}
|
|
2474
|
-
return req.then(function (res) {
|
|
2475
|
-
return res.body;
|
|
2476
|
-
});
|
|
2477
|
-
}
|
|
2478
|
-
|
|
2479
|
-
/**
|
|
2480
|
-
* Release a product firmware version as the default version
|
|
2481
|
-
* @param {Object} options Options for this API call
|
|
2482
|
-
* @param {Number} options.version Version number of new firmware
|
|
2483
|
-
* @param {String} options.product Firmware for this product ID or slug
|
|
2484
|
-
* @param {String} options.auth Access Token
|
|
2485
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2486
|
-
* @param {Object} [options.context] Request context
|
|
2487
|
-
* @returns {Promise} A promise
|
|
2488
|
-
*/
|
|
2489
|
-
|
|
2490
|
-
}, {
|
|
2491
|
-
key: 'releaseProductFirmware',
|
|
2492
|
-
value: function releaseProductFirmware(_ref82) {
|
|
2493
|
-
var version = _ref82.version,
|
|
2494
|
-
product = _ref82.product,
|
|
2495
|
-
auth = _ref82.auth,
|
|
2496
|
-
headers = _ref82.headers,
|
|
2497
|
-
context = _ref82.context;
|
|
2498
|
-
|
|
2499
|
-
var uri = '/v1/products/' + product + '/firmware/release';
|
|
2500
|
-
return this.put({ uri: uri, auth: auth, headers: headers, data: { version: version }, context: context });
|
|
2501
|
-
}
|
|
2502
|
-
|
|
2503
|
-
/**
|
|
2504
|
-
* List product team members
|
|
2505
|
-
* @param {Object} options Options for this API call
|
|
2506
|
-
* @param {String} options.product Team for this product ID or slug
|
|
2507
|
-
* @param {String} options.auth Access Token
|
|
2508
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2509
|
-
* @param {Object} [options.context] Request context
|
|
2510
|
-
* @returns {Promise} A promise
|
|
2511
|
-
*/
|
|
2512
|
-
|
|
2513
|
-
}, {
|
|
2514
|
-
key: 'listTeamMembers',
|
|
2515
|
-
value: function listTeamMembers(_ref83) {
|
|
2516
|
-
var product = _ref83.product,
|
|
2517
|
-
auth = _ref83.auth,
|
|
2518
|
-
headers = _ref83.headers,
|
|
2519
|
-
context = _ref83.context;
|
|
2520
|
-
|
|
2521
|
-
return this.get({
|
|
2522
|
-
uri: '/v1/products/' + product + '/team',
|
|
2523
|
-
auth: auth,
|
|
2524
|
-
headers: headers,
|
|
2525
|
-
context: context
|
|
2526
|
-
});
|
|
2527
|
-
}
|
|
2528
|
-
|
|
2529
|
-
/**
|
|
2530
|
-
* Invite Particle user to a product team
|
|
2531
|
-
* @param {Object} options Options for this API call
|
|
2532
|
-
* @param {String} options.username Username for the Particle account
|
|
2533
|
-
* @param {String} options.product Team for this product ID or slug
|
|
2534
|
-
* @param {String} options.auth Access Token
|
|
2535
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2536
|
-
* @param {Object} [options.context] Request context
|
|
2537
|
-
* @returns {Promise} A promise
|
|
2538
|
-
*/
|
|
2539
|
-
|
|
2540
|
-
}, {
|
|
2541
|
-
key: 'inviteTeamMember',
|
|
2542
|
-
value: function inviteTeamMember(_ref84) {
|
|
2543
|
-
var username = _ref84.username,
|
|
2544
|
-
product = _ref84.product,
|
|
2545
|
-
auth = _ref84.auth,
|
|
2546
|
-
headers = _ref84.headers,
|
|
2547
|
-
context = _ref84.context;
|
|
2548
|
-
|
|
2549
|
-
return this.post({
|
|
2550
|
-
uri: '/v1/products/' + product + '/team',
|
|
2551
|
-
auth: auth,
|
|
2552
|
-
headers: headers,
|
|
2553
|
-
data: { username: username },
|
|
2554
|
-
context: context
|
|
2555
|
-
});
|
|
2556
|
-
}
|
|
2557
|
-
|
|
2558
|
-
/**
|
|
2559
|
-
* Remove Particle user to a product team
|
|
2560
|
-
* @param {Object} options Options for this API call
|
|
2561
|
-
* @param {String} options.username Username for the Particle account
|
|
2562
|
-
* @param {String} options.product Team for this product ID or slug
|
|
2563
|
-
* @param {String} options.auth Access Token
|
|
2564
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2565
|
-
* @param {Object} [options.context] Request context
|
|
2566
|
-
* @returns {Promise} A promise
|
|
2567
|
-
*/
|
|
2568
|
-
|
|
2569
|
-
}, {
|
|
2570
|
-
key: 'removeTeamMember',
|
|
2571
|
-
value: function removeTeamMember(_ref85) {
|
|
2572
|
-
var username = _ref85.username,
|
|
2573
|
-
product = _ref85.product,
|
|
2574
|
-
auth = _ref85.auth,
|
|
2575
|
-
headers = _ref85.headers,
|
|
2576
|
-
context = _ref85.context;
|
|
2577
|
-
|
|
2578
|
-
return this.delete({
|
|
2579
|
-
uri: '/v1/products/' + product + '/team/' + username,
|
|
2580
|
-
auth: auth,
|
|
2581
|
-
headers: headers,
|
|
2582
|
-
context: context
|
|
2583
|
-
});
|
|
2584
|
-
}
|
|
2585
|
-
|
|
2586
|
-
/**
|
|
2587
|
-
* Fetch details about a serial number
|
|
2588
|
-
* @param {Object} options Options for this API call
|
|
2589
|
-
* @param {String} options.serialNumber The serial number printed on the barcode of the device packaging
|
|
2590
|
-
* @param {String} options.auth Access Token
|
|
2591
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2592
|
-
* @param {Object} [options.context] Request context
|
|
2593
|
-
* @returns {Promise} A promise
|
|
2594
|
-
*/
|
|
2595
|
-
|
|
2596
|
-
}, {
|
|
2597
|
-
key: 'lookupSerialNumber',
|
|
2598
|
-
value: function lookupSerialNumber(_ref86) {
|
|
2599
|
-
var serialNumber = _ref86.serialNumber,
|
|
2600
|
-
auth = _ref86.auth,
|
|
2601
|
-
headers = _ref86.headers,
|
|
2602
|
-
context = _ref86.context;
|
|
2603
|
-
|
|
2604
|
-
return this.get({
|
|
2605
|
-
uri: '/v1/serial_numbers/' + serialNumber,
|
|
2606
|
-
auth: auth,
|
|
2607
|
-
headers: headers,
|
|
2608
|
-
context: context
|
|
2609
|
-
});
|
|
2610
|
-
}
|
|
2611
|
-
|
|
2612
|
-
/**
|
|
2613
|
-
* Create a mesh network
|
|
2614
|
-
* @param {Object} options Options for this API call
|
|
2615
|
-
* @param {String} options.name Network name
|
|
2616
|
-
* @param {String} options.deviceId Gateway device ID
|
|
2617
|
-
* @param {String} [options.iccid] ICCID of the active SIM card (only for cellular gateway devices)
|
|
2618
|
-
* @param {String} options.auth Access token
|
|
2619
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2620
|
-
* @param {Object} [options.context] Request context
|
|
2621
|
-
* @returns {Promise<Object>} A promise
|
|
2622
|
-
*/
|
|
2623
|
-
|
|
2624
|
-
}, {
|
|
2625
|
-
key: 'createMeshNetwork',
|
|
2626
|
-
value: function createMeshNetwork(_ref87) {
|
|
2627
|
-
var name = _ref87.name,
|
|
2628
|
-
deviceId = _ref87.deviceId,
|
|
2629
|
-
iccid = _ref87.iccid,
|
|
2630
|
-
auth = _ref87.auth,
|
|
2631
|
-
headers = _ref87.headers,
|
|
2632
|
-
context = _ref87.context;
|
|
2633
|
-
|
|
2634
|
-
return this.post({
|
|
2635
|
-
uri: '/v1/networks',
|
|
2636
|
-
auth: auth,
|
|
2637
|
-
headers: headers,
|
|
2638
|
-
data: { name: name, device_id: deviceId, iccid: iccid },
|
|
2639
|
-
context: context
|
|
2640
|
-
});
|
|
2641
|
-
}
|
|
2642
|
-
|
|
2643
|
-
/**
|
|
2644
|
-
* Remove a mesh network.
|
|
2645
|
-
* @param {Object} options Options for this API call
|
|
2646
|
-
* @param {String} options.networkId Network ID or name
|
|
2647
|
-
* @param {String} options.auth Access token
|
|
2648
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2649
|
-
* @param {Object} [options.context] Request context
|
|
2650
|
-
* @returns {Promise<Object>} A promise
|
|
2651
|
-
*/
|
|
2652
|
-
|
|
2653
|
-
}, {
|
|
2654
|
-
key: 'removeMeshNetwork',
|
|
2655
|
-
value: function removeMeshNetwork(_ref88) {
|
|
2656
|
-
var networkId = _ref88.networkId,
|
|
2657
|
-
auth = _ref88.auth,
|
|
2658
|
-
headers = _ref88.headers,
|
|
2659
|
-
context = _ref88.context;
|
|
2660
|
-
|
|
2661
|
-
return this.delete({ uri: '/v1/networks/' + networkId, auth: auth, headers: headers, context: context });
|
|
2662
|
-
}
|
|
2663
|
-
|
|
2664
|
-
/**
|
|
2665
|
-
* List all mesh networks
|
|
2666
|
-
* @param {Object} options Options for this API call
|
|
2667
|
-
* @param {String} options.auth Access token
|
|
2668
|
-
* @param {Number} [options.page] Current page of results
|
|
2669
|
-
* @param {Number} [options.perPage] Records per page
|
|
2670
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2671
|
-
* @param {Object} [options.context] Request context
|
|
2672
|
-
* @returns {Promise<Object>} A promise
|
|
2673
|
-
*/
|
|
2674
|
-
|
|
2675
|
-
}, {
|
|
2676
|
-
key: 'listMeshNetworks',
|
|
2677
|
-
value: function listMeshNetworks(_ref89) {
|
|
2678
|
-
var page = _ref89.page,
|
|
2679
|
-
perPage = _ref89.perPage,
|
|
2680
|
-
auth = _ref89.auth,
|
|
2681
|
-
headers = _ref89.headers,
|
|
2682
|
-
context = _ref89.context;
|
|
2683
|
-
|
|
2684
|
-
var query = page ? { page: page, per_page: perPage } : undefined;
|
|
2685
|
-
return this.get({ uri: '/v1/networks', auth: auth, headers: headers, query: query, context: context });
|
|
2686
|
-
}
|
|
2687
|
-
|
|
2688
|
-
/**
|
|
2689
|
-
* Get information about a mesh network.
|
|
2690
|
-
* @param {Object} options Options for this API call
|
|
2691
|
-
* @param {String} options.networkId Network ID or name
|
|
2692
|
-
* @param {String} options.auth Access token
|
|
2693
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2694
|
-
* @param {Object} [options.context] Request context
|
|
2695
|
-
* @returns {Promise<Object>} A promise
|
|
2696
|
-
*/
|
|
2697
|
-
|
|
2698
|
-
}, {
|
|
2699
|
-
key: 'getMeshNetwork',
|
|
2700
|
-
value: function getMeshNetwork(_ref90) {
|
|
2701
|
-
var networkId = _ref90.networkId,
|
|
2702
|
-
auth = _ref90.auth,
|
|
2703
|
-
headers = _ref90.headers,
|
|
2704
|
-
context = _ref90.context;
|
|
2705
|
-
|
|
2706
|
-
return this.get({ uri: '/v1/networks/' + networkId, auth: auth, headers: headers, context: context });
|
|
2707
|
-
}
|
|
2708
|
-
|
|
2709
|
-
/**
|
|
2710
|
-
* Modify a mesh network.
|
|
2711
|
-
* @param {Object} options Options for this API call
|
|
2712
|
-
* @param {String} options.networkId Network ID or name
|
|
2713
|
-
* @param {String} options.action 'add-device', 'remove-device', 'gateway-enable' or 'gateway-disable'
|
|
2714
|
-
* @param {String} options.deviceId Device ID
|
|
2715
|
-
* @param {String} options.auth Access token
|
|
2716
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2717
|
-
* @param {Object} [options.context] Request context
|
|
2718
|
-
* @returns {Promise<Object>} A promise
|
|
2719
|
-
*/
|
|
2720
|
-
|
|
2721
|
-
}, {
|
|
2722
|
-
key: 'updateMeshNetwork',
|
|
2723
|
-
value: function updateMeshNetwork(_ref91) {
|
|
2724
|
-
var networkId = _ref91.networkId,
|
|
2725
|
-
action = _ref91.action,
|
|
2726
|
-
deviceId = _ref91.deviceId,
|
|
2727
|
-
auth = _ref91.auth,
|
|
2728
|
-
headers = _ref91.headers,
|
|
2729
|
-
context = _ref91.context;
|
|
2730
|
-
|
|
2731
|
-
return this.put({
|
|
2732
|
-
uri: '/v1/networks/' + networkId,
|
|
2733
|
-
auth: auth,
|
|
2734
|
-
headers: headers,
|
|
2735
|
-
data: { action: action, device_id: deviceId },
|
|
2736
|
-
context: context
|
|
2737
|
-
});
|
|
2738
|
-
}
|
|
2739
|
-
|
|
2740
|
-
/**
|
|
2741
|
-
* Add a device to a mesh network.
|
|
2742
|
-
* @param {Object} options Options for this API call
|
|
2743
|
-
* @param {String} options.networkId Network ID or name
|
|
2744
|
-
* @param {String} options.deviceId Device ID
|
|
2745
|
-
* @param {String} options.auth Access token
|
|
2746
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2747
|
-
* @param {Object} [options.context] Request context
|
|
2748
|
-
* @returns {Promise<Object>} A promise
|
|
2749
|
-
*/
|
|
2750
|
-
|
|
2751
|
-
}, {
|
|
2752
|
-
key: 'addMeshNetworkDevice',
|
|
2753
|
-
value: function addMeshNetworkDevice(_ref92) {
|
|
2754
|
-
var networkId = _ref92.networkId,
|
|
2755
|
-
deviceId = _ref92.deviceId,
|
|
2756
|
-
auth = _ref92.auth,
|
|
2757
|
-
headers = _ref92.headers,
|
|
2758
|
-
context = _ref92.context;
|
|
2759
|
-
|
|
2760
|
-
return this.updateMeshNetwork({
|
|
2761
|
-
action: 'add-device',
|
|
2762
|
-
networkId: networkId,
|
|
2763
|
-
deviceId: deviceId,
|
|
2764
|
-
auth: auth,
|
|
2765
|
-
headers: headers,
|
|
2766
|
-
context: context
|
|
2767
|
-
});
|
|
2768
|
-
}
|
|
2769
|
-
|
|
2770
|
-
/**
|
|
2771
|
-
* Remove a device from a mesh network.
|
|
2772
|
-
* @param {Object} options Options for this API call
|
|
2773
|
-
* @param {String} [options.networkId] Network ID or name
|
|
2774
|
-
* @param {String} options.deviceId Device ID
|
|
2775
|
-
* @param {String} options.auth Access token
|
|
2776
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2777
|
-
* @param {Object} [options.context] Request context
|
|
2778
|
-
* @returns {Promise<Object>} A promise
|
|
2779
|
-
*/
|
|
2780
|
-
|
|
2781
|
-
}, {
|
|
2782
|
-
key: 'removeMeshNetworkDevice',
|
|
2783
|
-
value: function removeMeshNetworkDevice(_ref93) {
|
|
2784
|
-
var networkId = _ref93.networkId,
|
|
2785
|
-
deviceId = _ref93.deviceId,
|
|
2786
|
-
auth = _ref93.auth,
|
|
2787
|
-
headers = _ref93.headers,
|
|
2788
|
-
context = _ref93.context;
|
|
2789
|
-
|
|
2790
|
-
if (!networkId) {
|
|
2791
|
-
return this.delete({
|
|
2792
|
-
uri: '/v1/devices/' + deviceId + '/network',
|
|
2793
|
-
auth: auth,
|
|
2794
|
-
headers: headers, context: context
|
|
2795
|
-
});
|
|
2796
|
-
}
|
|
2797
|
-
return this.updateMeshNetwork({
|
|
2798
|
-
action: 'remove-device',
|
|
2799
|
-
networkId: networkId,
|
|
2800
|
-
deviceId: deviceId,
|
|
2801
|
-
auth: auth,
|
|
2802
|
-
headers: headers,
|
|
2803
|
-
context: context
|
|
2804
|
-
});
|
|
2805
|
-
}
|
|
2806
|
-
|
|
2807
|
-
/**
|
|
2808
|
-
* List all devices of a mesh network.
|
|
2809
|
-
* @param {Object} options Options for this API call
|
|
2810
|
-
* @param {String} options.networkId Network ID or name
|
|
2811
|
-
* @param {String} options.auth Access token
|
|
2812
|
-
* @param {Number} [options.role] Device role: 'gateway' or 'node'
|
|
2813
|
-
* @param {Number} [options.page] Current page of results
|
|
2814
|
-
* @param {Number} [options.perPage] Records per page
|
|
2815
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2816
|
-
* @param {Object} [options.context] Request context
|
|
2817
|
-
* @returns {Promise<Object>} A promise
|
|
2818
|
-
*/
|
|
2819
|
-
|
|
2820
|
-
}, {
|
|
2821
|
-
key: 'listMeshNetworkDevices',
|
|
2822
|
-
value: function listMeshNetworkDevices(_ref94) {
|
|
2823
|
-
var networkId = _ref94.networkId,
|
|
2824
|
-
role = _ref94.role,
|
|
2825
|
-
page = _ref94.page,
|
|
2826
|
-
perPage = _ref94.perPage,
|
|
2827
|
-
auth = _ref94.auth,
|
|
2828
|
-
headers = _ref94.headers,
|
|
2829
|
-
context = _ref94.context;
|
|
2830
|
-
|
|
2831
|
-
var query = role || page ? { role: role, page: page, per_page: perPage } : undefined;
|
|
2832
|
-
return this.get({
|
|
2833
|
-
uri: '/v1/networks/' + networkId + '/devices',
|
|
2834
|
-
auth: auth,
|
|
2835
|
-
headers: headers,
|
|
2836
|
-
query: query,
|
|
2837
|
-
context: context
|
|
2838
|
-
});
|
|
2839
|
-
}
|
|
2840
|
-
|
|
2841
|
-
/**
|
|
2842
|
-
* Get product configuration
|
|
2843
|
-
* @param {Object} options Options for this API call
|
|
2844
|
-
* @param {String} options.product Config for this product ID or slug
|
|
2845
|
-
* @param {String} options.auth Access Token
|
|
2846
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2847
|
-
* @param {Object} [options.context] Request context
|
|
2848
|
-
* @returns {Promise} A promise
|
|
2849
|
-
*/
|
|
2850
|
-
|
|
2851
|
-
}, {
|
|
2852
|
-
key: 'getProductConfiguration',
|
|
2853
|
-
value: function getProductConfiguration(_ref95) {
|
|
2854
|
-
var auth = _ref95.auth,
|
|
2855
|
-
product = _ref95.product,
|
|
2856
|
-
headers = _ref95.headers,
|
|
2857
|
-
context = _ref95.context;
|
|
2858
|
-
|
|
2859
|
-
return this.get({
|
|
2860
|
-
uri: '/v1/products/' + product + '/config',
|
|
2861
|
-
auth: auth,
|
|
2862
|
-
headers: headers,
|
|
2863
|
-
context: context
|
|
2864
|
-
});
|
|
2865
|
-
}
|
|
2866
|
-
|
|
2867
|
-
/**
|
|
2868
|
-
* Get product configuration schema
|
|
2869
|
-
* @param {Object} options Options for this API call
|
|
2870
|
-
* @param {String} options.product Config for this product ID or slug
|
|
2871
|
-
* @param {String} options.auth Access Token
|
|
2872
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2873
|
-
* @param {Object} [options.context] Request context
|
|
2874
|
-
* @returns {Promise} A promise
|
|
2875
|
-
*/
|
|
2876
|
-
|
|
2877
|
-
}, {
|
|
2878
|
-
key: 'getProductConfigurationSchema',
|
|
2879
|
-
value: function getProductConfigurationSchema(_ref96) {
|
|
2880
|
-
var auth = _ref96.auth,
|
|
2881
|
-
product = _ref96.product,
|
|
2882
|
-
_ref96$headers = _ref96.headers,
|
|
2883
|
-
headers = _ref96$headers === undefined ? {} : _ref96$headers,
|
|
2884
|
-
context = _ref96.context;
|
|
2885
|
-
|
|
2886
|
-
headers.accept = 'application/schema+json';
|
|
2887
|
-
return this.get({
|
|
2888
|
-
uri: '/v1/products/' + product + '/config',
|
|
2889
|
-
auth: auth,
|
|
2890
|
-
headers: headers,
|
|
2891
|
-
context: context
|
|
2892
|
-
});
|
|
2893
|
-
}
|
|
2894
|
-
|
|
2895
|
-
/**
|
|
2896
|
-
* Get product device's configuration
|
|
2897
|
-
* @param {Object} options Options for this API call
|
|
2898
|
-
* @param {String} options.product Config for this product ID or slug
|
|
2899
|
-
* @param {String} options.auth Access Token
|
|
2900
|
-
* @param {String} options.deviceId Device ID to access
|
|
2901
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2902
|
-
* @param {Object} [options.context] Request context
|
|
2903
|
-
* @returns {Promise} A promise
|
|
2904
|
-
*/
|
|
2905
|
-
|
|
2906
|
-
}, {
|
|
2907
|
-
key: 'getProductDeviceConfiguration',
|
|
2908
|
-
value: function getProductDeviceConfiguration(_ref97) {
|
|
2909
|
-
var auth = _ref97.auth,
|
|
2910
|
-
product = _ref97.product,
|
|
2911
|
-
deviceId = _ref97.deviceId,
|
|
2912
|
-
headers = _ref97.headers,
|
|
2913
|
-
context = _ref97.context;
|
|
2914
|
-
|
|
2915
|
-
return this.get({
|
|
2916
|
-
uri: '/v1/products/' + product + '/config/' + deviceId,
|
|
2917
|
-
auth: auth,
|
|
2918
|
-
headers: headers,
|
|
2919
|
-
context: context
|
|
2920
|
-
});
|
|
2921
|
-
}
|
|
2922
|
-
|
|
2923
|
-
/**
|
|
2924
|
-
* Get product device's configuration schema
|
|
2925
|
-
* @param {Object} options Options for this API call
|
|
2926
|
-
* @param {String} options.product Config for this product ID or slug
|
|
2927
|
-
* @param {String} options.auth Access Token
|
|
2928
|
-
* @param {String} options.deviceId Device ID to access
|
|
2929
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2930
|
-
* @param {Object} [options.context] Request context
|
|
2931
|
-
* @returns {Promise} A promise
|
|
2932
|
-
*/
|
|
2933
|
-
|
|
2934
|
-
}, {
|
|
2935
|
-
key: 'getProductDeviceConfigurationSchema',
|
|
2936
|
-
value: function getProductDeviceConfigurationSchema(_ref98) {
|
|
2937
|
-
var auth = _ref98.auth,
|
|
2938
|
-
product = _ref98.product,
|
|
2939
|
-
deviceId = _ref98.deviceId,
|
|
2940
|
-
headers = _ref98.headers,
|
|
2941
|
-
context = _ref98.context;
|
|
2942
|
-
|
|
2943
|
-
headers.accept = 'application/schema+json';
|
|
2944
|
-
return this.get({
|
|
2945
|
-
uri: '/v1/products/' + product + '/config/' + deviceId,
|
|
2946
|
-
auth: auth,
|
|
2947
|
-
headers: headers,
|
|
2948
|
-
context: context
|
|
2949
|
-
});
|
|
2950
|
-
}
|
|
2951
|
-
|
|
2952
|
-
/**
|
|
2953
|
-
* Set product configuration
|
|
2954
|
-
* @param {Object} options Options for this API call
|
|
2955
|
-
* @param {String} options.product Config for this product ID or slug
|
|
2956
|
-
* @param {String} options.auth Access Token
|
|
2957
|
-
* @param {Object} opitons.config Product configuration to update
|
|
2958
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2959
|
-
* @param {Object} [options.context] Request context
|
|
2960
|
-
* @returns {Promise} A promise
|
|
2961
|
-
*/
|
|
2962
|
-
|
|
2963
|
-
}, {
|
|
2964
|
-
key: 'setProductConfiguration',
|
|
2965
|
-
value: function setProductConfiguration(_ref99) {
|
|
2966
|
-
var auth = _ref99.auth,
|
|
2967
|
-
product = _ref99.product,
|
|
2968
|
-
config = _ref99.config,
|
|
2969
|
-
headers = _ref99.headers,
|
|
2970
|
-
context = _ref99.context;
|
|
2971
|
-
|
|
2972
|
-
return this.put({
|
|
2973
|
-
uri: '/v1/products/' + product + '/config',
|
|
2974
|
-
auth: auth,
|
|
2975
|
-
data: config,
|
|
2976
|
-
headers: headers,
|
|
2977
|
-
context: context
|
|
2978
|
-
});
|
|
2979
|
-
}
|
|
2980
|
-
|
|
2981
|
-
/**
|
|
2982
|
-
* Set product configuration for a specific device within the product
|
|
2983
|
-
* @param {Object} options Options for this API call
|
|
2984
|
-
* @param {String} options.product Config for this product ID or slug
|
|
2985
|
-
* @param {String} options.auth Access Token
|
|
2986
|
-
* @param {Object} opitons.config Product configuration to update
|
|
2987
|
-
* @param {String} options.deviceId Device ID to access
|
|
2988
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2989
|
-
* @param {Object} [options.context] Request context
|
|
2990
|
-
* @returns {Promise} A promise
|
|
2991
|
-
*/
|
|
2992
|
-
|
|
2993
|
-
}, {
|
|
2994
|
-
key: 'setProductDeviceConfiguration',
|
|
2995
|
-
value: function setProductDeviceConfiguration(_ref100) {
|
|
2996
|
-
var auth = _ref100.auth,
|
|
2997
|
-
product = _ref100.product,
|
|
2998
|
-
deviceId = _ref100.deviceId,
|
|
2999
|
-
config = _ref100.config,
|
|
3000
|
-
headers = _ref100.headers,
|
|
3001
|
-
context = _ref100.context;
|
|
3002
|
-
|
|
3003
|
-
return this.put({
|
|
3004
|
-
uri: '/v1/products/' + product + '/config/' + deviceId,
|
|
3005
|
-
data: config,
|
|
3006
|
-
auth: auth,
|
|
3007
|
-
headers: headers,
|
|
3008
|
-
context: context
|
|
3009
|
-
});
|
|
3010
|
-
}
|
|
3011
|
-
|
|
3012
|
-
/**
|
|
3013
|
-
* Query location for devices within a product
|
|
3014
|
-
* @param {Object} options Options for this API call
|
|
3015
|
-
* @param {String} options.product Locations for this product ID or slug
|
|
3016
|
-
* @param {String} options.auth Access Token
|
|
3017
|
-
* @param {String} options.dateRange Start and end date in ISO8601 format, separated by comma, to query
|
|
3018
|
-
* @param {String} options.rectBl Bottom left of the rectangular bounding box to query. Latitude and longitude separated by comma
|
|
3019
|
-
* @param {String} options.rectTr Top right of the rectangular bounding box to query. Latitude and longitude separated by comma
|
|
3020
|
-
* @param {String} options.deviceId Device ID prefix to include in the query
|
|
3021
|
-
* @param {String} options.deviceName Device name prefix to include in the query
|
|
3022
|
-
* @param {String} options.groups Array of group names to include in the query
|
|
3023
|
-
* @param {String} options.page Page of results to display. Defaults to 1
|
|
3024
|
-
* @param {String} options.perPage Number of results per page. Defaults to 20. Maximum of 100
|
|
3025
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3026
|
-
* @param {Object} [options.context] Request context
|
|
3027
|
-
* @returns {Promise} A promise
|
|
3028
|
-
*/
|
|
3029
|
-
|
|
3030
|
-
}, {
|
|
3031
|
-
key: 'getProductLocations',
|
|
3032
|
-
value: function getProductLocations(_ref101) {
|
|
3033
|
-
var auth = _ref101.auth,
|
|
3034
|
-
product = _ref101.product,
|
|
3035
|
-
dateRange = _ref101.dateRange,
|
|
3036
|
-
rectBl = _ref101.rectBl,
|
|
3037
|
-
rectTr = _ref101.rectTr,
|
|
3038
|
-
deviceId = _ref101.deviceId,
|
|
3039
|
-
deviceName = _ref101.deviceName,
|
|
3040
|
-
groups = _ref101.groups,
|
|
3041
|
-
page = _ref101.page,
|
|
3042
|
-
perPage = _ref101.perPage,
|
|
3043
|
-
headers = _ref101.headers,
|
|
3044
|
-
context = _ref101.context;
|
|
3045
|
-
|
|
3046
|
-
return this.get({
|
|
3047
|
-
uri: '/v1/products/' + product + '/locations',
|
|
3048
|
-
query: {
|
|
3049
|
-
date_range: dateRange,
|
|
3050
|
-
rect_bl: rectBl,
|
|
3051
|
-
rect_tr: rectTr,
|
|
3052
|
-
device_id: deviceId,
|
|
3053
|
-
device_name: deviceName,
|
|
3054
|
-
groups: groups,
|
|
3055
|
-
page: page,
|
|
3056
|
-
per_page: perPage
|
|
3057
|
-
},
|
|
3058
|
-
auth: auth,
|
|
3059
|
-
headers: headers,
|
|
3060
|
-
context: context
|
|
3061
|
-
});
|
|
3062
|
-
}
|
|
3063
|
-
|
|
3064
|
-
/**
|
|
3065
|
-
* Query location for one device within a product
|
|
3066
|
-
* @param {Object} options Options for this API call
|
|
3067
|
-
* @param {String} options.product Locations for this product ID or slug
|
|
3068
|
-
* @param {String} options.auth Access Token
|
|
3069
|
-
* @param {String} options.dateRange Start and end date in ISO8601 format, separated by comma, to query
|
|
3070
|
-
* @param {String} options.rectBl Bottom left of the rectangular bounding box to query. Latitude and longitude separated by comma
|
|
3071
|
-
* @param {String} options.rectTr Top right of the rectangular bounding box to query. Latitude and longitude separated by comma
|
|
3072
|
-
* @param {String} options.deviceId Device ID to query
|
|
3073
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3074
|
-
* @param {Object} [options.context] Request context
|
|
3075
|
-
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3076
|
-
* @param {Object} [options.context] Request context
|
|
3077
|
-
* @returns {Promise} A promise
|
|
3078
|
-
*/
|
|
3079
|
-
|
|
3080
|
-
}, {
|
|
3081
|
-
key: 'getProductDeviceLocations',
|
|
3082
|
-
value: function getProductDeviceLocations(_ref102) {
|
|
3083
|
-
var auth = _ref102.auth,
|
|
3084
|
-
product = _ref102.product,
|
|
3085
|
-
dateRange = _ref102.dateRange,
|
|
3086
|
-
rectBl = _ref102.rectBl,
|
|
3087
|
-
rectTr = _ref102.rectTr,
|
|
3088
|
-
deviceId = _ref102.deviceId,
|
|
3089
|
-
headers = _ref102.headers,
|
|
3090
|
-
context = _ref102.context;
|
|
3091
|
-
|
|
3092
|
-
return this.get({
|
|
3093
|
-
uri: '/v1/products/' + product + '/locations/' + deviceId,
|
|
3094
|
-
query: {
|
|
3095
|
-
date_range: dateRange,
|
|
3096
|
-
rect_bl: rectBl,
|
|
3097
|
-
rect_tr: rectTr
|
|
3098
|
-
},
|
|
3099
|
-
auth: auth,
|
|
3100
|
-
headers: headers,
|
|
3101
|
-
context: context
|
|
3102
|
-
});
|
|
3103
|
-
}
|
|
3104
|
-
|
|
3105
|
-
/**
|
|
3106
|
-
* Set default auth token that will be used in each method if `auth` is not provided
|
|
3107
|
-
* @param {String} auth A Particle access token
|
|
3108
|
-
* @returns {undefined}
|
|
3109
|
-
*/
|
|
3110
|
-
|
|
3111
|
-
}, {
|
|
3112
|
-
key: 'setDefaultAuth',
|
|
3113
|
-
value: function setDefaultAuth(auth) {
|
|
3114
|
-
if (typeof auth === 'string' && auth.length !== 0) {
|
|
3115
|
-
this._defaultAuth = auth;
|
|
3116
|
-
} else {
|
|
3117
|
-
throw new Error('Must pass a non-empty string');
|
|
3118
|
-
}
|
|
3119
|
-
}
|
|
3120
|
-
/**
|
|
3121
|
-
* Return provided token if truthy else use default auth if truthy else undefined
|
|
3122
|
-
* @param {*} auth Optional auth token or undefined
|
|
3123
|
-
* @private
|
|
3124
|
-
* @returns {String|undefined} a Particle auth token or undefined
|
|
3125
|
-
*/
|
|
3126
|
-
|
|
3127
|
-
}, {
|
|
3128
|
-
key: '_getActiveAuthToken',
|
|
3129
|
-
value: function _getActiveAuthToken(auth) {
|
|
3130
|
-
return auth || this._defaultAuth;
|
|
3131
|
-
}
|
|
3132
|
-
/**
|
|
3133
|
-
* API URI to access a device
|
|
3134
|
-
* @param {Object} options Options for this API call
|
|
3135
|
-
* @param {String} options.deviceId Device ID to access
|
|
3136
|
-
* @param {String} [options.product] Device only in this product ID or slug
|
|
3137
|
-
* @private
|
|
3138
|
-
* @returns {string} URI
|
|
3139
|
-
*/
|
|
3140
|
-
|
|
3141
|
-
}, {
|
|
3142
|
-
key: 'deviceUri',
|
|
3143
|
-
value: function deviceUri(_ref103) {
|
|
3144
|
-
var deviceId = _ref103.deviceId,
|
|
3145
|
-
product = _ref103.product;
|
|
3146
|
-
|
|
3147
|
-
return product ? '/v1/products/' + product + '/devices/' + deviceId : '/v1/devices/' + deviceId;
|
|
3148
|
-
}
|
|
3149
|
-
}, {
|
|
3150
|
-
key: 'get',
|
|
3151
|
-
value: function get(_ref104) {
|
|
3152
|
-
var uri = _ref104.uri,
|
|
3153
|
-
auth = _ref104.auth,
|
|
3154
|
-
headers = _ref104.headers,
|
|
3155
|
-
query = _ref104.query,
|
|
3156
|
-
context = _ref104.context;
|
|
3157
|
-
|
|
3158
|
-
context = this._buildContext(context);
|
|
3159
|
-
auth = this._getActiveAuthToken(auth);
|
|
3160
|
-
return this.agent.get({ uri: uri, auth: auth, headers: headers, query: query, context: context });
|
|
3161
|
-
}
|
|
3162
|
-
}, {
|
|
3163
|
-
key: 'head',
|
|
3164
|
-
value: function head(_ref105) {
|
|
3165
|
-
var uri = _ref105.uri,
|
|
3166
|
-
auth = _ref105.auth,
|
|
3167
|
-
headers = _ref105.headers,
|
|
3168
|
-
query = _ref105.query,
|
|
3169
|
-
context = _ref105.context;
|
|
3170
|
-
|
|
3171
|
-
context = this._buildContext(context);
|
|
3172
|
-
auth = this._getActiveAuthToken(auth);
|
|
3173
|
-
return this.agent.head({ uri: uri, auth: auth, headers: headers, query: query, context: context });
|
|
3174
|
-
}
|
|
3175
|
-
}, {
|
|
3176
|
-
key: 'post',
|
|
3177
|
-
value: function post(_ref106) {
|
|
3178
|
-
var uri = _ref106.uri,
|
|
3179
|
-
auth = _ref106.auth,
|
|
3180
|
-
headers = _ref106.headers,
|
|
3181
|
-
data = _ref106.data,
|
|
3182
|
-
context = _ref106.context;
|
|
3183
|
-
|
|
3184
|
-
context = this._buildContext(context);
|
|
3185
|
-
auth = this._getActiveAuthToken(auth);
|
|
3186
|
-
return this.agent.post({ uri: uri, auth: auth, headers: headers, data: data, context: context });
|
|
3187
|
-
}
|
|
3188
|
-
}, {
|
|
3189
|
-
key: 'put',
|
|
3190
|
-
value: function put(_ref107) {
|
|
3191
|
-
var uri = _ref107.uri,
|
|
3192
|
-
auth = _ref107.auth,
|
|
3193
|
-
headers = _ref107.headers,
|
|
3194
|
-
data = _ref107.data,
|
|
3195
|
-
context = _ref107.context;
|
|
3196
|
-
|
|
3197
|
-
context = this._buildContext(context);
|
|
3198
|
-
auth = this._getActiveAuthToken(auth);
|
|
3199
|
-
return this.agent.put({ uri: uri, auth: auth, headers: headers, data: data, context: context });
|
|
3200
|
-
}
|
|
3201
|
-
}, {
|
|
3202
|
-
key: 'delete',
|
|
3203
|
-
value: function _delete(_ref108) {
|
|
3204
|
-
var uri = _ref108.uri,
|
|
3205
|
-
auth = _ref108.auth,
|
|
3206
|
-
headers = _ref108.headers,
|
|
3207
|
-
data = _ref108.data,
|
|
3208
|
-
context = _ref108.context;
|
|
3209
|
-
|
|
3210
|
-
context = this._buildContext(context);
|
|
3211
|
-
auth = this._getActiveAuthToken(auth);
|
|
3212
|
-
return this.agent.delete({ uri: uri, auth: auth, headers: headers, data: data, context: context });
|
|
3213
|
-
}
|
|
3214
|
-
}, {
|
|
3215
|
-
key: 'request',
|
|
3216
|
-
value: function request(args) {
|
|
3217
|
-
args.context = this._buildContext(args.context);
|
|
3218
|
-
args.auth = this._getActiveAuthToken(args.auth);
|
|
3219
|
-
return this.agent.request(args);
|
|
3220
|
-
}
|
|
3221
|
-
}, {
|
|
3222
|
-
key: 'client',
|
|
3223
|
-
value: function client() {
|
|
3224
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3225
|
-
|
|
3226
|
-
return new _Client2.default((0, _assign2.default)({ api: this }, options));
|
|
3227
|
-
}
|
|
3228
|
-
|
|
3229
|
-
// Internal method used to target Particle's APIs other than the default
|
|
3230
|
-
|
|
3231
|
-
}, {
|
|
3232
|
-
key: 'setBaseUrl',
|
|
3233
|
-
value: function setBaseUrl(baseUrl) {
|
|
3234
|
-
this.baseUrl = baseUrl;
|
|
3235
|
-
this.agent.setBaseUrl(baseUrl);
|
|
3236
|
-
}
|
|
3237
|
-
}]);
|
|
3238
|
-
return Particle;
|
|
3239
|
-
}();
|
|
3240
|
-
|
|
3241
|
-
// Aliases for backwards compatibility
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
Particle.prototype.removeAccessToken = Particle.prototype.deleteAccessToken;
|
|
3245
|
-
|
|
3246
|
-
exports.default = Particle;
|
|
3247
|
-
module.exports = exports['default'];
|
|
3248
|
-
//# sourceMappingURL=Particle.js.map
|