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