particle-api-js 11.1.7 → 12.0.1

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 (85) hide show
  1. package/README.md +90 -10
  2. package/dist/particle.min.js +1 -1
  3. package/dist/particle.min.js.map +1 -1
  4. package/fs.d.ts +2 -0
  5. package/lib/fs.d.ts +2 -0
  6. package/lib/fs.js +3 -0
  7. package/lib/package.json +110 -0
  8. package/lib/src/Agent.d.ts +40 -0
  9. package/lib/src/Agent.d.ts.map +1 -0
  10. package/lib/src/Agent.js +233 -0
  11. package/lib/src/Agent.js.map +1 -0
  12. package/lib/src/Client.d.ts +80 -0
  13. package/lib/src/Client.d.ts.map +1 -0
  14. package/lib/src/Client.js +104 -0
  15. package/lib/src/Client.js.map +1 -0
  16. package/lib/src/Defaults.d.ts +6 -0
  17. package/lib/src/Defaults.d.ts.map +1 -0
  18. package/lib/src/Defaults.js +12 -0
  19. package/lib/src/Defaults.js.map +1 -0
  20. package/lib/src/EventStream.d.ts +31 -0
  21. package/lib/src/EventStream.d.ts.map +1 -0
  22. package/lib/src/EventStream.js +275 -0
  23. package/lib/src/EventStream.js.map +1 -0
  24. package/lib/src/Library.d.ts +33 -0
  25. package/lib/src/Library.d.ts.map +1 -0
  26. package/lib/src/Library.js +19 -0
  27. package/lib/src/Library.js.map +1 -0
  28. package/{src/Particle.js → lib/src/Particle.d.ts} +623 -1779
  29. package/lib/src/Particle.d.ts.map +1 -0
  30. package/lib/src/Particle.js +2578 -0
  31. package/lib/src/Particle.js.map +1 -0
  32. package/lib/src/types/common.d.ts +73 -0
  33. package/lib/src/types/common.d.ts.map +1 -0
  34. package/lib/src/types/common.js +3 -0
  35. package/lib/src/types/common.js.map +1 -0
  36. package/lib/src/types/index.d.ts +4 -0
  37. package/lib/src/types/index.d.ts.map +1 -0
  38. package/lib/src/types/index.js +20 -0
  39. package/lib/src/types/index.js.map +1 -0
  40. package/lib/src/types/requests.d.ts +568 -0
  41. package/lib/src/types/requests.d.ts.map +1 -0
  42. package/lib/src/types/requests.js +3 -0
  43. package/lib/src/types/requests.js.map +1 -0
  44. package/lib/src/types/responses.d.ts +449 -0
  45. package/lib/src/types/responses.d.ts.map +1 -0
  46. package/lib/src/types/responses.js +3 -0
  47. package/lib/src/types/responses.js.map +1 -0
  48. package/package.json +35 -14
  49. package/scripts/postprocess-docs.js +306 -0
  50. package/typedoc.json +20 -0
  51. package/.circleci/config.yml +0 -104
  52. package/.nvmrc +0 -1
  53. package/CHANGELOG.md +0 -404
  54. package/EventStream-e2e-browser.html +0 -39
  55. package/EventStream-e2e-node.js +0 -34
  56. package/RELEASE.md +0 -12
  57. package/bower.json +0 -30
  58. package/docs/api.md +0 -2594
  59. package/eslint.config.mjs +0 -7
  60. package/examples/login/login.html +0 -17
  61. package/karma.conf.js +0 -80
  62. package/src/Agent.js +0 -397
  63. package/src/Client.js +0 -171
  64. package/src/Defaults.js +0 -8
  65. package/src/EventStream.js +0 -269
  66. package/src/Library.js +0 -33
  67. package/test/Agent.integration.js +0 -23
  68. package/test/Agent.spec.js +0 -488
  69. package/test/Client.spec.js +0 -216
  70. package/test/Defaults.spec.js +0 -30
  71. package/test/EventStream.feature +0 -65
  72. package/test/EventStream.spec.js +0 -263
  73. package/test/FakeAgent.js +0 -27
  74. package/test/Library.spec.js +0 -40
  75. package/test/Particle.integration.js +0 -38
  76. package/test/Particle.spec.js +0 -3198
  77. package/test/fixtures/index.js +0 -15
  78. package/test/fixtures/libraries.json +0 -33
  79. package/test/fixtures/library.json +0 -31
  80. package/test/fixtures/libraryVersions.json +0 -211
  81. package/test/out.tmp +0 -0
  82. package/test/support/FixtureHttpServer.js +0 -28
  83. package/test/test-setup.js +0 -17
  84. package/tsconfig.json +0 -17
  85. package/webpack.config.js +0 -46
@@ -1,9 +1,8 @@
1
- 'use strict';
2
- const Defaults = require('./Defaults');
3
- const EventStream = require('./EventStream');
4
- const Agent = require('./Agent');
5
- const Client = require('./Client');
6
-
1
+ import EventStream = require('./EventStream');
2
+ import Agent = require('./Agent');
3
+ import Client = require('./Client');
4
+ import type * as T from './types';
5
+ import { type Agent as HttpAgent } from 'http';
7
6
  /**
8
7
  * Particle Cloud API wrapper.
9
8
  *
@@ -13,12 +12,21 @@ const Client = require('./Client');
13
12
  * Most Particle methods take a single unnamed argument object documented as
14
13
  * `options` with key/value pairs for each option.
15
14
  *
16
- * @typedef {import('./Agent').RequestResponse} RequestResponse
17
- * @typedef {import('./Agent').RequestError} RequestError
18
15
  */
19
- // These typedef avoid importing the type on every @return statement
20
- class Particle {
21
- /**
16
+ declare class Particle {
17
+ baseUrl: string;
18
+ clientId: string;
19
+ clientSecret: string;
20
+ tokenDuration: number;
21
+ auth: string | undefined;
22
+ context: {
23
+ tool?: T.ToolContext;
24
+ project?: T.ProjectContext;
25
+ };
26
+ agent: Agent;
27
+ httpAgent: HttpAgent | undefined;
28
+ _defaultAuth?: string;
29
+ /**
22
30
  * Contructor for the Cloud API wrapper.
23
31
  *
24
32
  * Create a new Particle object and call methods below on it.
@@ -29,63 +37,24 @@ class Particle {
29
37
  * @param {string} [options.clientId]
30
38
  * @param {number} [options.tokenDuration]
31
39
  * @param {string} [options.auth] The access token. If not specified here, will have to be added to every request
40
+ * @param {HttpAgent} [options.httpAgent] The http.Agent to use for requests (e.g. an https-proxy-agent instance for corporate proxies)
32
41
  */
33
- constructor(options = {}){
34
- if (options.auth) {
35
- this.setDefaultAuth(options.auth);
36
- }
37
-
38
- // todo - this seems a bit dangerous - would be better to put all options/context in a contained object
39
- Object.assign(this, Defaults, options);
40
- this.context = {};
41
-
42
- this.agent = new Agent(this.baseUrl);
43
- }
44
-
45
- _isValidContext(name, context){
46
- return (name === 'tool' || name === 'project') && context !== undefined;
47
- }
48
-
49
- /**
50
- * @typedef {Object} ToolContext
42
+ constructor(options?: T.ParticleOptions);
43
+ private _isValidContext;
44
+ /**
45
+ * @typedef {Object} T.ToolContext
51
46
  * @property {string} name
52
47
  * @property {string | number} [version]
53
- * @property {Omit<ToolContext, 'components'>[]} [components]
48
+ * @property {Omit<T.ToolContext, 'components'>[]} [components]
54
49
  */
55
-
56
- /**
57
- * @typedef {Record<string, string | number>} ProjectContext
50
+ /**
51
+ * @typedef {Record<string, string | number>} T.ProjectContext
58
52
  * @property {string} name
59
53
  */
60
-
61
- /**
62
- * Allows setting a tool or project context which will be sent as headers with every request.
63
- * Tool- x-particle-tool
64
- * Project- x-particle-project
65
- * @param {'tool' | 'project'} name
66
- * @param {ToolContext | ProjectContext | undefined} context
67
- */
68
- setContext(name, context){
69
- if (context !== undefined){
70
- if (this._isValidContext(name, context)){
71
- this.context[name] = context;
72
- } else {
73
- throw Error('unknown context name or undefined context: ' + name);
74
- }
75
- }
76
- }
77
-
78
- /**
79
- * Builds the final context from the context parameter and the context items in the api.
80
- * @param {Object} context The invocation context, this takes precedence over the local context.
81
- * @returns {Object} The context to use.
82
- * @private
83
- */
84
- _buildContext(context){
85
- return Object.assign(this.context, context);
86
- }
87
-
88
- /**
54
+ /** @internal */
55
+ setContext(name: 'tool' | 'project', context: T.ToolContext | T.ProjectContext | undefined): void;
56
+ private _buildContext;
57
+ /**
89
58
  * Login to Particle Cloud using an existing Particle acccount.
90
59
  * @param {Object} options Options for this API call
91
60
  * @param {String} options.username Username for the Particle account
@@ -93,68 +62,29 @@ class Particle {
93
62
  * @param {Number} options.tokenDuration How long the access token should last in seconds
94
63
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
95
64
  * @param {Number} [options.context] Request context
96
- * @returns {Promise} A promise
65
+ * @returns {Promise<T.JSONResponse<T.LoginResponse>>} A promise that resolves with the response data
97
66
  */
98
- // @ts-ignore
99
- login({ username, password, tokenDuration = this.tokenDuration, headers, context }){
100
- return this.request({
101
- uri: '/oauth/token',
102
- method: 'post',
103
- headers,
104
- form: {
105
- username,
106
- password,
107
- grant_type: 'password',
108
- // @ts-ignore
109
- client_id: this.clientId,
110
- // @ts-ignore
111
- client_secret: this.clientSecret,
112
- expires_in: tokenDuration
113
- },
114
- context
115
- });
116
- }
117
-
118
- /**
67
+ login({ username, password, tokenDuration, headers, context }: T.LoginOptions): Promise<T.JSONResponse<T.LoginResponse>>;
68
+ /**
119
69
  * If login failed with an 'mfa_required' error, this must be called with a valid OTP code to login
120
70
  * @param {Object} options Options for this API call
121
71
  * @param {String} options.mfaToken Given as 'mfa_token' in the error body of `.login()`.
122
72
  * @param {String} options.otp Current one-time-password generated from the authentication application
123
73
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
124
74
  * @param {Number} [options.context] Request context
125
- * @returns {Promise} A promise
75
+ * @returns {Promise<T.JSONResponse<T.LoginResponse>>} A promise that resolves with the response data
126
76
  */
127
- sendOtp({ mfaToken, otp, headers, context }){
128
- return this.request({
129
- uri: '/oauth/token',
130
- method: 'post',
131
- headers,
132
- form: {
133
- grant_type: 'urn:custom:mfa-otp',
134
- mfa_token: mfaToken,
135
- otp,
136
- // @ts-ignore
137
- client_id: this.clientId,
138
- // @ts-ignore
139
- client_secret: this.clientSecret
140
- },
141
- context
142
- });
143
- }
144
-
145
- /**
77
+ sendOtp({ mfaToken, otp, headers, context }: T.SendOtpOptions): Promise<T.JSONResponse<T.LoginResponse>>;
78
+ /**
146
79
  * Enable MFA on the currently logged in user
147
80
  * @param {Object} options Options for this API call
148
81
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
149
82
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
150
83
  * @param {Object} [options.context] Request context
151
- * @returns {Promise} A promise
84
+ * @returns {Promise<T.JSONResponse<T.EnableMfaResponse>>} A promise that resolves with the response data
152
85
  */
153
- enableMfa({ auth, headers, context }){
154
- return this.get({ uri: '/v1/user/mfa-enable', auth, headers, context });
155
- }
156
-
157
- /**
86
+ enableMfa({ auth, headers, context }: T.EnableMfaOptions): Promise<T.JSONResponse<T.EnableMfaResponse>>;
87
+ /**
158
88
  * 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.
159
89
  * @param {Object} options Options for this API call
160
90
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
@@ -163,44 +93,20 @@ class Particle {
163
93
  * @param {Boolean} options.invalidateTokens Should all tokens be invalidated
164
94
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
165
95
  * @param {Object} [options.context] Request context
166
- * @returns {Promise} A promise
96
+ * @returns {Promise<T.JSONResponse<T.ConfirmMfaResponse>>} A promise that resolves with the response data
167
97
  */
168
- confirmMfa({ mfaToken, otp, invalidateTokens = false, auth, headers, context }){
169
- const data = { mfa_token: mfaToken, otp };
170
-
171
- if (invalidateTokens) {
172
- data.invalidate_tokens = true;
173
- }
174
-
175
- return this.post({
176
- uri: '/v1/user/mfa-enable',
177
- auth,
178
- headers,
179
- data,
180
- context
181
- });
182
- }
183
-
184
- /**
98
+ confirmMfa({ mfaToken, otp, invalidateTokens, auth, headers, context }: T.ConfirmMfaOptions): Promise<T.JSONResponse<T.ConfirmMfaResponse>>;
99
+ /**
185
100
  * Disable MFA for the user.
186
101
  * @param {Object} options Options for this API call
187
102
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
188
103
  * @param {Object} options.currentPassword User's current password
189
104
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
190
105
  * @param {Object} [options.context] Request context
191
- * @returns {Promise} A promise
106
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
192
107
  */
193
- disableMfa({ currentPassword, auth, headers, context }){
194
- return this.put({
195
- uri: '/v1/user/mfa-disable',
196
- auth,
197
- headers,
198
- data: { current_password: currentPassword },
199
- context
200
- });
201
- }
202
-
203
- /**
108
+ disableMfa({ currentPassword, auth, headers, context }: T.DisableMfaOptions): Promise<T.JSONResponse<T.OKResponse>>;
109
+ /**
204
110
  * Create Customer for Product.
205
111
  * @param {Object} options Options for this API call
206
112
  * @param {String} options.email Username for the Particle account
@@ -208,50 +114,18 @@ class Particle {
208
114
  * @param {String} options.product Create the customer in this product ID or slug
209
115
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
210
116
  * @param {Object} [options.context] Request context
211
- * @returns {Promise} A promise
117
+ * @returns {Promise<T.JSONResponse<T.CreateCustomerResponse>>} A promise that resolves with the response data
212
118
  */
213
- createCustomer({ email, password, product, headers, context }){
214
- return this.request({
215
- uri: `/v1/products/${product}/customers`,
216
- method: 'post',
217
- headers,
218
- form: {
219
- email,
220
- password,
221
- grant_type: 'client_credentials',
222
- // @ts-ignore
223
- client_id: this.clientId,
224
- // @ts-ignore
225
- client_secret: this.clientSecret
226
- },
227
- context
228
- });
229
- }
230
-
231
- /**
119
+ createCustomer({ email, password, product, headers, context }: T.CreateCustomerOptions): Promise<T.JSONResponse<T.CreateCustomerResponse>>;
120
+ /**
232
121
  * Login to Particle Cloud using an OAuth client.
233
122
  * @param {Object} options Options for this API call
234
123
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
235
124
  * @param {Object} [options.context] Request context
236
- * @returns {Promise} A promise
125
+ * @returns {Promise<T.JSONResponse<T.LoginResponse>>} A promise that resolves with the response data
237
126
  */
238
- loginAsClientOwner({ headers, context }){
239
- return this.request({
240
- uri: '/oauth/token',
241
- method: 'post',
242
- headers,
243
- form: {
244
- grant_type: 'client_credentials',
245
- // @ts-ignore
246
- client_id: this.clientId,
247
- // @ts-ignore
248
- client_secret: this.clientSecret
249
- },
250
- context
251
- });
252
- }
253
-
254
- /**
127
+ loginAsClientOwner({ headers, context }?: T.LoginAsClientOwnerOptions): Promise<T.JSONResponse<T.LoginResponse>>;
128
+ /**
255
129
  * Create a user account for the Particle Cloud
256
130
  * @param {Object} options Options for this API call
257
131
  * @param {String} options.username Email of the new user
@@ -260,126 +134,56 @@ class Particle {
260
134
  * @param {Object} [options.utm] Object that contains info about the campaign that lead to this user creation
261
135
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
262
136
  * @param {Object} [options.context] Request context
263
- * @returns {Promise} A promise
137
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
264
138
  */
265
- createUser({ username, password, accountInfo, utm, headers, context }){
266
- return this.post({
267
- uri: '/v1/users',
268
- headers,
269
- data: {
270
- username,
271
- password,
272
- account_info: accountInfo,
273
- utm
274
- },
275
- context
276
- });
277
- }
278
-
279
- /**
280
- * Verify new user account via verification email
281
- * @param {Object} options Options for this API call
282
- * @param {String} options.token The string token sent in the verification email
283
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
284
- * @param {Object} [options.context] Request context
285
- * @returns {Promise} A promise
286
- */
287
- verifyUser({ token, headers, context }){
288
- return this.post({
289
- uri: '/v1/user/verify',
290
- headers,
291
- data: { token },
292
- context
293
- });
294
- }
295
-
296
- /**
139
+ createUser({ username, password, accountInfo, utm, headers, context }: T.CreateUserOptions): Promise<T.JSONResponse<T.OKResponse>>;
140
+ /**
297
141
  * Send reset password email for a Particle Cloud user account
298
142
  * @param {Object} options Options for this API call
299
143
  * @param {String} options.username Email of the user
300
144
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
301
145
  * @param {Object} [options.context] Request context
302
- * @returns {Promise} A promise
146
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
303
147
  */
304
- resetPassword({ username, headers, context }){
305
- return this.post({
306
- uri: '/v1/user/password-reset',
307
- headers,
308
- data: { username },
309
- context
310
- });
311
- }
312
-
313
- /**
148
+ resetPassword({ username, headers, context }: T.ResetPasswordOptions): Promise<T.JSONResponse<T.OKResponse>>;
149
+ /**
314
150
  * Revoke an access token
315
151
  * @param {Object} options Options for this API call
316
152
  * @param {String} options.token Access token you wish to revoke
317
153
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
318
154
  * @param {Object} [options.context] Request context
319
- * @returns {Promise} A promise
155
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
320
156
  */
321
- deleteAccessToken({ token, headers, context }){
322
- return this.delete({
323
- uri: `/v1/access_tokens/${token}`,
324
- headers,
325
- context
326
- });
327
- }
328
-
329
- /**
157
+ deleteAccessToken({ token, headers, context }: T.DeleteAccessTokenOptions): Promise<T.JSONResponse<T.OKResponse>>;
158
+ /**
330
159
  * Revoke the current session access token
331
160
  * @param {Object} options Options for this API call
332
161
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
333
162
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
334
163
  * @param {Object} [options.context] Request context
335
- * @returns {Promise} A promise
164
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
336
165
  */
337
- deleteCurrentAccessToken({ auth, headers, context }){
338
- return this.delete({
339
- uri: '/v1/access_tokens/current',
340
- auth,
341
- headers,
342
- context
343
- });
344
- }
345
-
346
- /**
166
+ deleteCurrentAccessToken({ auth, headers, context }: T.DeleteCurrentAccessTokenOptions): Promise<T.JSONResponse<T.OKResponse>>;
167
+ /**
347
168
  * Revoke all active access tokens
348
169
  * @param {Object} options Options for this API call
349
170
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
350
171
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
351
172
  * @param {Object} [options.context] Request context
352
- * @returns {Promise} A promise
173
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
353
174
  */
354
- deleteActiveAccessTokens({ auth, headers, context }){
355
- return this.delete({
356
- uri: '/v1/access_tokens',
357
- auth,
358
- headers,
359
- context
360
- });
361
- }
362
-
363
- /**
175
+ deleteActiveAccessTokens({ auth, headers, context }: T.DeleteActiveAccessTokensOptions): Promise<T.JSONResponse<T.OKResponse>>;
176
+ /**
364
177
  * Delete the current user
365
178
  * @param {Object} options Options for this API call
366
179
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
367
180
  * @param {String} options.password Password
368
181
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
369
182
  * @param {Object} [options.context] Request context
370
- * @returns {Promise} A promise
183
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
371
184
  */
372
- deleteUser({ auth, password, headers, context }){
373
- return this.delete({
374
- uri: '/v1/user',
375
- data: { password },
376
- auth,
377
- headers,
378
- context
379
- });
380
- }
381
-
382
- /**
185
+ deleteUser({ auth, password, headers, context }: T.DeleteUserOptions): Promise<T.JSONResponse<T.OKResponse>>;
186
+ /**
383
187
  * Retrieves the information that is used to identify the current login for tracking.
384
188
  * @param {Object} [options] Options for this API call
385
189
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
@@ -387,19 +191,10 @@ class Particle {
387
191
  * retrieve only the unique tracking ID for the current login.
388
192
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
389
193
  * @param {Object} [options.context] Request context
390
- * @returns {Promise<Object>} Resolve the tracking identify of the current login
391
- */
392
- trackingIdentity({ full = false, auth, headers, context } = {}){
393
- return this.get({
394
- uri: '/v1/user/identify',
395
- auth,
396
- headers,
397
- query: (full ? undefined : { tracking: 1 }),
398
- context
399
- });
400
- }
401
-
402
- /**
194
+ * @returns {Promise<T.JSONResponse<T.TrackingIdentityResponse>>} A promise that resolves with the response data
195
+ */
196
+ trackingIdentity({ full, auth, headers, context }?: T.TrackingIdentityOptions): Promise<T.JSONResponse<T.TrackingIdentityResponse>>;
197
+ /**
403
198
  * List devices claimed to the account or product
404
199
  * @param {Object} options Options for this API call
405
200
  * @param {String} [options.deviceId] (Product only) Filter results to devices with this ID (partial matching)
@@ -413,30 +208,10 @@ class Particle {
413
208
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
414
209
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
415
210
  * @param {Object} [options.context] Request context
416
- * @returns {Promise} A promise
211
+ * @returns {Promise<T.JSONResponse<T.DeviceInfo[] | T.DeviceListResponse>>} A promise that resolves with the response data
417
212
  */
418
- listDevices({ deviceId, deviceName, groups, sortAttr, sortDir, page, perPage, product, auth, headers, context }){
419
- let uri, query;
420
-
421
- if (product){
422
- uri = `/v1/products/${product}/devices`;
423
- query = {
424
- deviceId,
425
- deviceName,
426
- groups: Array.isArray(groups) ? groups.join(',') : undefined,
427
- sortAttr,
428
- sortDir,
429
- page,
430
- per_page: perPage
431
- };
432
- } else {
433
- uri = '/v1/devices';
434
- }
435
-
436
- return this.get({ uri, auth, headers, query, context });
437
- }
438
-
439
- /**
213
+ listDevices({ deviceId, deviceName, groups, sortAttr, sortDir, page, perPage, product, auth, headers, context }: T.ListDevicesOptions): Promise<T.JSONResponse<T.DeviceInfo[] | T.DeviceListResponse>>;
214
+ /**
440
215
  * Get detailed informationa about a device
441
216
  * @param {Object} options Options for this API call
442
217
  * @param {String} options.deviceId Device ID or Name
@@ -444,14 +219,10 @@ class Particle {
444
219
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
445
220
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
446
221
  * @param {Object} [options.context] Request context
447
- * @returns {Promise} A promise
222
+ * @returns {Promise<T.JSONResponse<T.DeviceInfo>>} A promise that resolves with the response data
448
223
  */
449
- getDevice({ deviceId, product, auth, headers, context }){
450
- const uri = this.deviceUri({ deviceId, product });
451
- return this.get({ uri, auth, headers, context });
452
- }
453
-
454
- /**
224
+ getDevice({ deviceId, product, auth, headers, context }: T.GetDeviceOptions): Promise<T.JSONResponse<T.DeviceInfo>>;
225
+ /**
455
226
  * Claim a device to the account. The device must be online and unclaimed.
456
227
  * @param {Object} options Options for this API call
457
228
  * @param {String} options.deviceId Device ID
@@ -459,22 +230,10 @@ class Particle {
459
230
  * @param {boolean} options.requestTransfer True to request the device be transfered from another user
460
231
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
461
232
  * @param {Object} [options.context] Request context
462
- * @returns {Promise} A promise
233
+ * @returns {Promise<T.JSONResponse<T.ClaimResponse>>} A promise that resolves with the response data
463
234
  */
464
- claimDevice({ deviceId, requestTransfer, auth, headers, context }){
465
- return this.post({
466
- uri: '/v1/devices',
467
- auth,
468
- headers,
469
- data: {
470
- id: deviceId,
471
- request_transfer: !!requestTransfer
472
- },
473
- context
474
- });
475
- }
476
-
477
- /**
235
+ claimDevice({ deviceId, requestTransfer, auth, headers, context }: T.ClaimDeviceOptions): Promise<T.JSONResponse<T.ClaimResponse>>;
236
+ /**
478
237
  * Add a device to a product or move device out of quarantine.
479
238
  * @param {Object} options Options for this API call
480
239
  * @param {String} options.deviceId Device ID
@@ -484,29 +243,10 @@ class Particle {
484
243
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
485
244
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
486
245
  * @param {Object} [options.context] Request context
487
- * @returns {Promise} A promise
246
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
488
247
  */
489
- addDeviceToProduct({ deviceId, product, file, auth, headers, context }){
490
- let files, data;
491
-
492
- if (file){
493
- files = { file };
494
- } else if (deviceId){
495
- data = { id: deviceId };
496
- }
497
-
498
- return this.request({
499
- uri: `/v1/products/${product}/devices`,
500
- method: 'post',
501
- headers,
502
- data,
503
- files,
504
- auth,
505
- context
506
- });
507
- }
508
-
509
- /**
248
+ addDeviceToProduct({ deviceId, product, file, auth, headers, context }: T.AddDeviceToProductOptions): Promise<T.JSONResponse<T.OKResponse>>;
249
+ /**
510
250
  * Unclaim / Remove a device from your account or product, or deny quarantine
511
251
  * @param {Object} options Options for this API call
512
252
  * @param {String} options.deviceId Device ID or Name
@@ -515,15 +255,10 @@ class Particle {
515
255
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
516
256
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
517
257
  * @param {Object} [options.context] Request context
518
- * @returns {Promise} A promise
258
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
519
259
  */
520
- removeDevice({ deviceId, deny, product, auth, headers, context }){
521
- const uri = this.deviceUri({ deviceId, product });
522
- const data = product ? { deny } : undefined;
523
- return this.delete({ uri, data, auth, headers, context });
524
- }
525
-
526
- /**
260
+ removeDevice({ deviceId, deny, product, auth, headers, context }: T.RemoveDeviceOptions): Promise<T.JSONResponse<T.OKResponse>>;
261
+ /**
527
262
  * Unclaim a product device its the owner, but keep it in the product
528
263
  * @param {Object} options Options for this API call
529
264
  * @param {String} options.deviceId Device ID or Name
@@ -531,14 +266,10 @@ class Particle {
531
266
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
532
267
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
533
268
  * @param {Object} [options.context] Request context
534
- * @returns {Promise} A promise
269
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
535
270
  */
536
- removeDeviceOwner({ deviceId, product, auth, headers, context }){
537
- const uri = `/v1/products/${product}/devices/${deviceId}/owner`;
538
- return this.delete({ uri, auth, headers, context });
539
- }
540
-
541
- /**
271
+ removeDeviceOwner({ deviceId, product, auth, headers, context }: T.RemoveDeviceOwnerOptions): Promise<T.JSONResponse<T.OKResponse>>;
272
+ /**
542
273
  * Rename a device
543
274
  * @param {Object} options Options for this API call
544
275
  * @param {String} options.deviceId Device ID or Name
@@ -547,13 +278,10 @@ class Particle {
547
278
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
548
279
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
549
280
  * @param {Object} [options.context] Request context
550
- * @returns {Promise} A promise
281
+ * @returns {Promise<T.JSONResponse<T.DeviceInfo>>} A promise that resolves with the response data
551
282
  */
552
- renameDevice({ deviceId, name, product, auth, headers, context }){
553
- return this.updateDevice({ deviceId, name, product, auth, headers, context });
554
- }
555
-
556
- /**
283
+ renameDevice({ deviceId, name, product, auth, headers, context }: T.RenameDeviceOptions): Promise<T.JSONResponse<T.DeviceInfo>>;
284
+ /**
557
285
  * Instruct the device to turn on/off the LED in a rainbow pattern
558
286
  * @param {Object} options Options for this API call
559
287
  * @param {String} options.deviceId Device ID or Name
@@ -562,13 +290,10 @@ class Particle {
562
290
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
563
291
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
564
292
  * @param {Object} [options.context] Request context
565
- * @returns {Promise} A promise
293
+ * @returns {Promise<T.JSONResponse<T.DeviceInfo>>} A promise that resolves with the response data
566
294
  */
567
- signalDevice({ deviceId, signal, product, auth, headers, context }){
568
- return this.updateDevice({ deviceId, signal, product, auth, headers, context });
569
- }
570
-
571
- /**
295
+ signalDevice({ deviceId, signal, product, auth, headers, context }: T.SignalDeviceOptions): Promise<T.JSONResponse<T.DeviceInfo>>;
296
+ /**
572
297
  * Store some notes about device
573
298
  * @param {Object} options Options for this API call
574
299
  * @param {String} options.deviceId Device ID or Name
@@ -577,13 +302,20 @@ class Particle {
577
302
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
578
303
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
579
304
  * @param {Object} [options.context] Request context
580
- * @returns {Promise} A promise
581
- */
582
- setDeviceNotes({ deviceId, notes, product, auth, headers, context }){
583
- return this.updateDevice({ deviceId, notes, product, auth, headers, context });
584
- }
585
-
586
- /**
305
+ * @returns {Promise<T.JSONResponse<T.DeviceInfo>>} A promise that resolves with the response data
306
+ */
307
+ setDeviceNotes({ deviceId, notes, product, auth, headers, context }: {
308
+ deviceId: string;
309
+ notes: string;
310
+ product?: string | number;
311
+ auth?: string;
312
+ headers?: Record<string, string>;
313
+ context?: {
314
+ tool?: T.ToolContext;
315
+ project?: T.ProjectContext;
316
+ };
317
+ }): Promise<T.JSONResponse<T.DeviceInfo>>;
318
+ /**
587
319
  * Mark device as being used in development of a product so it opts out of automatic firmware updates
588
320
  * @param {Object} options Options for this API call
589
321
  * @param {String} options.deviceId Device ID or Name
@@ -592,13 +324,20 @@ class Particle {
592
324
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
593
325
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
594
326
  * @param {Object} [options.context] Request context
595
- * @returns {Promise} A promise
596
- */
597
- markAsDevelopmentDevice({ deviceId, development = true, product, auth, headers, context }){
598
- return this.updateDevice({ deviceId, development, product, auth, headers, context });
599
- }
600
-
601
- /**
327
+ * @returns {Promise<T.JSONResponse<T.DeviceInfo>>} A promise that resolves with the response data
328
+ */
329
+ markAsDevelopmentDevice({ deviceId, development, product, auth, headers, context }: {
330
+ deviceId: string;
331
+ development?: boolean;
332
+ product: string | number;
333
+ auth?: string;
334
+ headers?: Record<string, string>;
335
+ context?: {
336
+ tool?: T.ToolContext;
337
+ project?: T.ProjectContext;
338
+ };
339
+ }): Promise<T.JSONResponse<T.DeviceInfo>>;
340
+ /**
602
341
  * Mark device as being used in development of a product, so it opts out of automatic firmware updates
603
342
  * @param {Object} options Options for this API call
604
343
  * @param {String} options.deviceId Device ID or Name
@@ -608,13 +347,21 @@ class Particle {
608
347
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
609
348
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
610
349
  * @param {Object} [options.context] Request context
611
- * @returns {Promise} A promise
612
- */
613
- lockDeviceProductFirmware({ deviceId, desiredFirmwareVersion, flash, product, auth, headers, context }){
614
- return this.updateDevice({ deviceId, desiredFirmwareVersion, flash, product, auth, headers, context });
615
- }
616
-
617
- /**
350
+ * @returns {Promise<T.JSONResponse<T.DeviceInfo>>} A promise that resolves with the response data
351
+ */
352
+ lockDeviceProductFirmware({ deviceId, desiredFirmwareVersion, flash, product, auth, headers, context }: {
353
+ deviceId: string;
354
+ desiredFirmwareVersion: number;
355
+ flash?: boolean;
356
+ product: string | number;
357
+ auth?: string;
358
+ headers?: Record<string, string>;
359
+ context?: {
360
+ tool?: T.ToolContext;
361
+ project?: T.ProjectContext;
362
+ };
363
+ }): Promise<T.JSONResponse<T.DeviceInfo>>;
364
+ /**
618
365
  * Mark device as receiving automatic firmware updates
619
366
  * @param {Object} options Options for this API call
620
367
  * @param {String} options.deviceId Device ID or Name
@@ -622,13 +369,19 @@ class Particle {
622
369
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
623
370
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
624
371
  * @param {Object} [options.context] Request context
625
- * @returns {Promise} A promise
372
+ * @returns {Promise<T.JSONResponse<T.DeviceInfo>>} A promise that resolves with the response data
626
373
  */
627
- unlockDeviceProductFirmware({ deviceId, product, auth, headers, context }){
628
- return this.updateDevice({ deviceId, desiredFirmwareVersion: null, product, auth, headers, context });
629
- }
630
-
631
- /**
374
+ unlockDeviceProductFirmware({ deviceId, product, auth, headers, context }: {
375
+ deviceId: string;
376
+ product: string | number;
377
+ auth?: string;
378
+ headers?: Record<string, string>;
379
+ context?: {
380
+ tool?: T.ToolContext;
381
+ project?: T.ProjectContext;
382
+ };
383
+ }): Promise<T.JSONResponse<T.DeviceInfo>>;
384
+ /**
632
385
  * Update multiple device attributes at the same time
633
386
  * @param {Object} options Options for this API call
634
387
  * @param {String} options.deviceId Device ID or Name
@@ -643,23 +396,10 @@ class Particle {
643
396
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
644
397
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
645
398
  * @param {Object} [options.context] Request context
646
- * @returns {Promise} A promise
399
+ * @returns {Promise<T.JSONResponse<T.DeviceInfo>>} A promise that resolves with the response data
647
400
  */
648
- updateDevice({ deviceId, name, signal, notes, development, desiredFirmwareVersion, flash, product, auth, headers, context }){
649
- let signalValue;
650
- if (signal !== undefined){
651
- signalValue = signal ? '1' : '0';
652
- }
653
-
654
- const uri = this.deviceUri({ deviceId, product });
655
- const data = product ?
656
- { name, signal: signalValue, notes, development, desired_firmware_version: desiredFirmwareVersion, flash } :
657
- { name, signal: signalValue, notes };
658
-
659
- return this.put({ uri, auth, headers, data, context });
660
- }
661
-
662
- /**
401
+ updateDevice({ deviceId, name, signal, notes, development, desiredFirmwareVersion, flash, product, auth, headers, context }: T.UpdateDeviceOptions): Promise<T.JSONResponse<T.DeviceInfo>>;
402
+ /**
663
403
  * Disable device protection.
664
404
  *
665
405
  * @param {Object} options Options for this API call.
@@ -675,46 +415,20 @@ class Particle {
675
415
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor.
676
416
  * @param {Object} [options.headers] Key/value pairs to send as headers.
677
417
  * @param {Object} [options.context] Request context.
678
- * @returns {Promise} A promise
418
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
679
419
  */
680
- unprotectDevice({ deviceId, org, product, action, serverNonce, deviceNonce, deviceSignature, devicePublicKeyFingerprint, auth, headers, context }) {
681
- const data = { action };
682
- if (deviceNonce !== undefined) {
683
- data.device_nonce = deviceNonce;
684
- }
685
- if (serverNonce !== undefined) {
686
- data.server_nonce = serverNonce;
687
- }
688
- if (deviceSignature !== undefined) {
689
- data.device_signature = deviceSignature;
690
- }
691
- if (devicePublicKeyFingerprint !== undefined) {
692
- data.device_public_key_fingerprint = devicePublicKeyFingerprint;
693
- }
694
- const uri = this.deviceUri({ deviceId, product, org }) + '/unprotect';
695
- return this.put({ uri, data, auth, headers, context });
696
- }
697
-
698
- /**
420
+ unprotectDevice({ deviceId, org, product, action, serverNonce, deviceNonce, deviceSignature, devicePublicKeyFingerprint, auth, headers, context }: T.UnprotectDeviceOptions): Promise<T.JSONResponse<T.OKResponse>>;
421
+ /**
699
422
  * Provision a new device for products that allow self-provisioning
700
423
  * @param {Object} options Options for this API call
701
424
  * @param {String} options.productId Product ID where to create this device
702
425
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
703
426
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
704
427
  * @param {Object} [options.context] Request context
705
- * @returns {Promise} A promise
428
+ * @returns {Promise<T.JSONResponse<T.DeviceInfo>>} A promise that resolves with the response data
706
429
  */
707
- provisionDevice({ productId, auth, headers, context }){
708
- return this.post({
709
- uri: '/v1/devices',
710
- auth,
711
- headers,
712
- data: { product_id: productId },
713
- context
714
- });
715
- }
716
-
717
- /**
430
+ provisionDevice({ productId, auth, headers, context }: T.ProvisionDeviceOptions): Promise<T.JSONResponse<T.DeviceInfo>>;
431
+ /**
718
432
  * Generate a claim code to use in the device claiming process.
719
433
  * To generate a claim code for a product, the access token MUST belong to a
720
434
  * customer of the product.
@@ -724,23 +438,10 @@ class Particle {
724
438
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
725
439
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
726
440
  * @param {Object} [options.context] Request context
727
- * @returns {Promise} A promise
441
+ * @returns {Promise<T.JSONResponse<T.ClaimCodeResponse>>} A promise that resolves with the response data
728
442
  */
729
- getClaimCode({ iccid, product, auth, headers, context }){
730
- const uri = product ? `/v1/products/${product}/device_claims` : '/v1/device_claims';
731
- return this.post({ uri, auth, headers, data: { iccid }, context });
732
- }
733
-
734
- validatePromoCode({ promoCode, auth, headers, context }){
735
- return this.get({
736
- uri: `/v1/promo_code/${promoCode}`,
737
- auth,
738
- headers,
739
- context
740
- });
741
- }
742
-
743
- /**
443
+ getClaimCode({ iccid, product, auth, headers, context }: T.GetClaimCodeOptions): Promise<T.JSONResponse<T.ClaimCodeResponse>>;
444
+ /**
744
445
  * Get the value of a device variable
745
446
  * @param {Object} options Options for this API call
746
447
  * @param {String} options.deviceId Device ID or Name
@@ -749,17 +450,10 @@ class Particle {
749
450
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
750
451
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
751
452
  * @param {Object} [options.context] Request context
752
- * @returns {Promise} A promise
453
+ * @returns {Promise<T.JSONResponse<T.DeviceVariableResponse>>} A promise that resolves with the response data
753
454
  */
754
- getVariable({ deviceId, name, product, auth, headers, context }){
755
- const uri = product ?
756
- `/v1/products/${product}/devices/${deviceId}/${name}` :
757
- `/v1/devices/${deviceId}/${name}`;
758
-
759
- return this.get({ uri, auth, headers, context });
760
- }
761
-
762
- /**
455
+ getVariable({ deviceId, name, product, auth, headers, context }: T.GetVariableOptions): Promise<T.JSONResponse<T.DeviceVariableResponse>>;
456
+ /**
763
457
  * Compile and flash application firmware to a device. Pass a pre-compiled binary to flash it directly to the device.
764
458
  * @param {Object} options Options for this API call
765
459
  * @param {String} options.deviceId Device ID or Name
@@ -769,48 +463,10 @@ class Particle {
769
463
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
770
464
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
771
465
  * @param {Object} [options.context] Request context
772
- * @returns {Promise} A promise
773
- */
774
- flashDevice({ deviceId, product, files, targetVersion, auth, headers, context }){
775
- const uri = this.deviceUri({ deviceId, product });
776
- const form = {};
777
-
778
- if (targetVersion){
779
- form.build_target_version = targetVersion;
780
- } else {
781
- form.latest = 'true';
782
- }
783
-
784
- return this.request({ uri, method: 'put', auth, headers, files, form, context });
785
- }
786
-
787
- /**
788
- * DEPRECATED: Flash the Tinker application to a device. Instead compile and flash the Tinker source code.
789
- * @param {Object} options Options for this API call
790
- * @param {String} options.deviceId Device ID or Name
791
- * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
792
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
793
- * @param {Object} [options.context] Request context
794
- * @returns {Promise} A promise
466
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
795
467
  */
796
- flashTinker({ deviceId, auth, headers, context }){
797
- /* eslint-disable no-console */
798
- /* @ts-ignore */
799
- if (console && console.warning){
800
- // @ts-ignore
801
- console.warning('Particle.flashTinker is deprecated');
802
- }
803
- /* eslint-enable no-console */
804
- return this.put({
805
- uri: `/v1/devices/${deviceId}`,
806
- headers,
807
- data: { app: 'tinker' },
808
- auth,
809
- context
810
- });
811
- }
812
-
813
- /**
468
+ flashDevice({ deviceId, product, files, targetVersion, auth, headers, context }: T.FlashDeviceOptions): Promise<T.JSONResponse<T.OKResponse>>;
469
+ /**
814
470
  * Compile firmware using the Particle Cloud
815
471
  * @param {Object} options Options for this API call
816
472
  * @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.
@@ -819,49 +475,20 @@ class Particle {
819
475
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
820
476
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
821
477
  * @param {Object} [options.context] Request context
822
- * @returns {Promise} A promise
478
+ * @returns {Promise<T.JSONResponse<T.CompileResponse>>} A promise that resolves with the response data
823
479
  */
824
- compileCode({ files, platformId, targetVersion, auth, headers, context }){
825
- const form = { platform_id: platformId };
826
-
827
- if (targetVersion){
828
- form.build_target_version = targetVersion;
829
- } else {
830
- form.latest = 'true';
831
- }
832
-
833
- return this.request({
834
- uri: '/v1/binaries',
835
- method: 'post',
836
- auth,
837
- headers,
838
- files,
839
- form,
840
- context
841
- });
842
- }
843
-
844
- /**
480
+ compileCode({ files, platformId, targetVersion, auth, headers, context }: T.CompileCodeOptions): Promise<T.JSONResponse<T.CompileResponse>>;
481
+ /**
845
482
  * Download a firmware binary
846
483
  * @param {Object} options Options for this API call
847
484
  * @param {String} options.binaryId Binary ID received from a successful compile call
848
485
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
849
486
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
850
487
  * @param {Object} [options.context] Request context
851
- * @returns {Promise<RequestResponse, RequestError>} A promise
852
- */
853
- downloadFirmwareBinary({ binaryId, auth, headers, context }){
854
- return this.request({
855
- uri: `/v1/binaries/${binaryId}`,
856
- method: 'get',
857
- auth,
858
- headers,
859
- context,
860
- isBuffer: true
861
- });
862
- }
863
-
864
- /**
488
+ * @returns {Promise<Buffer | ArrayBuffer>} A promise that resolves with the binary data
489
+ */
490
+ downloadFirmwareBinary({ binaryId, auth, headers, context }: T.DownloadFirmwareBinaryOptions): Promise<Buffer | ArrayBuffer>;
491
+ /**
865
492
  * Send a new device public key to the Particle Cloud
866
493
  * @param {Object} options Options for this API call
867
494
  * @param {String} options.deviceId Device ID or Name
@@ -870,25 +497,10 @@ class Particle {
870
497
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
871
498
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
872
499
  * @param {Object} [options.context] Request context
873
- * @returns {Promise} A promise
500
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
874
501
  */
875
- sendPublicKey({ deviceId, key, algorithm, auth, headers, context }){
876
- return this.post({
877
- uri: `/v1/provisioning/${deviceId}`,
878
- auth,
879
- headers,
880
- data: {
881
- deviceID: deviceId,
882
- publicKey: (typeof key === 'string' ? key : key.toString()),
883
- filename: 'particle-api',
884
- order: `manual_${ Date.now() }`,
885
- algorithm: algorithm || 'rsa'
886
- },
887
- context
888
- });
889
- }
890
-
891
- /**
502
+ sendPublicKey({ deviceId, key, algorithm, auth, headers, context }: T.SendPublicKeyOptions): Promise<T.JSONResponse<T.OKResponse>>;
503
+ /**
892
504
  * Call a device function
893
505
  * @param {Object} options Options for this API call
894
506
  * @param {String} options.deviceId Device ID or Name
@@ -898,16 +510,10 @@ class Particle {
898
510
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
899
511
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
900
512
  * @param {Object} [options.context] Request context
901
- * @returns {Promise} A promise
513
+ * @returns {Promise<T.JSONResponse<T.FunctionCallResponse>>} A promise that resolves with the response data
902
514
  */
903
- callFunction({ deviceId, name, argument, product, auth, headers, context }){
904
- const uri = product ?
905
- `/v1/products/${product}/devices/${deviceId}/${name}` :
906
- `/v1/devices/${deviceId}/${name}`;
907
- return this.post({ uri, auth, headers, data: { args: argument }, context });
908
- }
909
-
910
- /**
515
+ callFunction({ deviceId, name, argument, product, auth, headers, context }: T.CallFunctionOptions): Promise<T.JSONResponse<T.FunctionCallResponse>>;
516
+ /**
911
517
  * Get a stream of events
912
518
  * @param {Object} options Options for this API call
913
519
  * @param {String} [options.deviceId] Device ID or Name, or `mine` to indicate only your devices.
@@ -915,37 +521,11 @@ class Particle {
915
521
  * @param {String} [options.org] Organization Slug
916
522
  * @param {String} [options.product] Events for this product ID or slug
917
523
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
918
- * @returns {Promise} If the promise resolves, the resolution value will be an EventStream object that will
524
+ * @returns {Promise<EventStream>} A promise that resolves with the response data
919
525
  * emit 'event' events.
920
526
  */
921
- getEventStream({ deviceId, name, org, product, auth }){
922
- let uri = '/v1/';
923
- if (org){
924
- uri += `orgs/${org}/`;
925
- }
926
-
927
- if (product){
928
- uri += `products/${product}/`;
929
- }
930
-
931
- if (deviceId){
932
- uri += 'devices/';
933
- if (!(deviceId.toLowerCase() === 'mine')){
934
- uri += `${deviceId}/`;
935
- }
936
- }
937
-
938
- uri += 'events';
939
-
940
- if (name){
941
- uri += `/${encodeURIComponent(name)}`;
942
- }
943
-
944
- auth = this._getActiveAuthToken(auth);
945
- return new EventStream(`${this.baseUrl}${uri}`, auth).connect();
946
- }
947
-
948
- /**
527
+ getEventStream({ deviceId, name, org, product, auth }: T.GetEventStreamOptions): Promise<EventStream>;
528
+ /**
949
529
  * Publish a event to the Particle Cloud
950
530
  * @param {Object} options Options for this API call
951
531
  * @param {String} options.name Event name
@@ -955,15 +535,10 @@ class Particle {
955
535
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
956
536
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
957
537
  * @param {Object} [options.context] Request context
958
- * @returns {Promise} A promise
538
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
959
539
  */
960
- publishEvent({ name, data, isPrivate, product, auth, headers, context }){
961
- const uri = product ? `/v1/products/${product}/events` : '/v1/devices/events';
962
- const postData = { name, data, private: isPrivate };
963
- return this.post({ uri, auth, headers, data: postData, context });
964
- }
965
-
966
- /**
540
+ publishEvent({ name, data, isPrivate, product, auth, headers, context }: T.PublishEventOptions): Promise<T.JSONResponse<T.OKResponse>>;
541
+ /**
967
542
  * @typedef {Object} Hook
968
543
  * @property {String} [method=POST] Type of web request triggered by the Webhook (GET, POST, PUT, or DELETE)
969
544
  * @property {Object} [auth] Auth data like `{ user: 'me', pass: '1234' }` for basic auth or `{ bearer: 'token' }` to send with the Webhook request
@@ -976,8 +551,7 @@ class Particle {
976
551
  * @property {Object} [responseEvent] The Webhook response event name that your devices can subscribe to
977
552
  * @property {Object} [errorResponseEvent] The Webhook error response event name that your devices can subscribe to
978
553
  */
979
-
980
- /**
554
+ /**
981
555
  * Create a webhook
982
556
  * @param {Object} options Options for this API call
983
557
  * @param {String} options.event The name of the Particle event that should trigger the Webhook
@@ -990,33 +564,10 @@ class Particle {
990
564
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
991
565
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
992
566
  * @param {Object} [options.context] Request context
993
- * @returns {Promise} A promise
567
+ * @returns {Promise<T.JSONResponse<T.CreateWebhookResponse>>} A promise that resolves with the response data
994
568
  */
995
- createWebhook({ event, url, device, rejectUnauthorized, noDefaults, hook, product, auth, headers, context }){
996
- const uri = product ? `/v1/products/${product}/webhooks` : '/v1/webhooks';
997
- const data = { event, url, deviceId: device, rejectUnauthorized, noDefaults };
998
-
999
- if (hook){
1000
- data.requestType = hook.method;
1001
- data.auth = hook.auth;
1002
- data.headers = hook.headers;
1003
- data.query = hook.query;
1004
- data.json = hook.json;
1005
- data.form = hook.form;
1006
- data.body = hook.body;
1007
- data.responseTemplate = hook.responseTemplate;
1008
- data.responseTopic = hook.responseEvent;
1009
- data.errorResponseTopic = hook.errorResponseEvent;
1010
- }
1011
-
1012
- if (!data.requestType){
1013
- data.requestType = 'POST';
1014
- }
1015
-
1016
- return this.post({ uri, auth, headers, data, context });
1017
- }
1018
-
1019
- /**
569
+ createWebhook({ event, url, device, rejectUnauthorized, noDefaults, hook, product, auth, headers, context }: T.CreateWebhookOptions): Promise<T.JSONResponse<T.CreateWebhookResponse>>;
570
+ /**
1020
571
  * Delete a webhook
1021
572
  * @param {Object} options Options for this API call
1022
573
  * @param {String} options.hookId Webhook ID
@@ -1024,28 +575,20 @@ class Particle {
1024
575
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1025
576
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1026
577
  * @param {Object} [options.context] Request context
1027
- * @returns {Promise} A promise
578
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
1028
579
  */
1029
- deleteWebhook({ hookId, product, auth, headers, context }){
1030
- const uri = product ? `/v1/products/${product}/webhooks/${hookId}` : `/v1/webhooks/${hookId}`;
1031
- return this.delete({ uri, auth, headers, context });
1032
- }
1033
-
1034
- /**
580
+ deleteWebhook({ hookId, product, auth, headers, context }: T.DeleteWebhookOptions): Promise<T.JSONResponse<T.OKResponse>>;
581
+ /**
1035
582
  * List all webhooks owned by the account or product
1036
583
  * @param {Object} options Options for this API call
1037
584
  * @param {String} [options.product] Webhooks for this product ID or slug
1038
585
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1039
586
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1040
587
  * @param {Object} [options.context] Request context
1041
- * @returns {Promise} A promise
588
+ * @returns {Promise<T.JSONResponse<T.WebhookInfo[]>>} A promise that resolves with the response data
1042
589
  */
1043
- listWebhooks({ product, auth, headers, context }){
1044
- const uri = product ? `/v1/products/${product}/webhooks` : '/v1/webhooks';
1045
- return this.get({ uri, auth, headers, context });
1046
- }
1047
-
1048
- /**
590
+ listWebhooks({ product, auth, headers, context }: T.ListWebhooksOptions): Promise<T.JSONResponse<T.WebhookInfo[]>>;
591
+ /**
1049
592
  * Create an integration to send events to an external service
1050
593
  *
1051
594
  * See the API docs for details https://docs.particle.io/reference/api/#integrations-webhooks-
@@ -1058,15 +601,10 @@ class Particle {
1058
601
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1059
602
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1060
603
  * @param {Object} [options.context] Request context
1061
- * @returns {Promise} A promise
604
+ * @returns {Promise<T.JSONResponse<T.IntegrationInfo>>} A promise that resolves with the response data
1062
605
  */
1063
- createIntegration({ event, settings, deviceId, product, auth, headers, context }){
1064
- const uri = product ? `/v1/products/${product}/integrations` : '/v1/integrations';
1065
- const data = Object.assign({ event, deviceid: deviceId }, settings);
1066
- return this.post({ uri, data, auth, headers, context });
1067
- }
1068
-
1069
- /**
606
+ createIntegration({ event, settings, deviceId, product, auth, headers, context }: T.CreateIntegrationOptions): Promise<T.JSONResponse<T.IntegrationInfo>>;
607
+ /**
1070
608
  * Edit an integration to send events to an external service
1071
609
  *
1072
610
  * See the API docs for details https://docs.particle.io/reference/api/#integrations-webhooks-
@@ -1080,15 +618,10 @@ class Particle {
1080
618
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1081
619
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1082
620
  * @param {Object} [options.context] Request context
1083
- * @returns {Promise} A promise
621
+ * @returns {Promise<T.JSONResponse<T.IntegrationInfo>>} A promise that resolves with the response data
1084
622
  */
1085
- editIntegration({ integrationId, event, settings, deviceId, product, auth, headers, context }){
1086
- const uri = product ? `/v1/products/${product}/integrations/${integrationId}` : `/v1/integrations/${integrationId}`;
1087
- const data = Object.assign({ event, deviceid: deviceId }, settings);
1088
- return this.put({ uri, auth, headers, data, context });
1089
- }
1090
-
1091
- /**
623
+ editIntegration({ integrationId, event, settings, deviceId, product, auth, headers, context }: T.EditIntegrationOptions): Promise<T.JSONResponse<T.IntegrationInfo>>;
624
+ /**
1092
625
  * Delete an integration to send events to an external service
1093
626
  *
1094
627
  * @param {Object} options Options for this API call
@@ -1097,54 +630,46 @@ class Particle {
1097
630
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1098
631
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1099
632
  * @param {Object} [options.context] Request context
1100
- * @returns {Promise} A promise
633
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
1101
634
  */
1102
- deleteIntegration({ integrationId, product, auth, headers, context }){
1103
- const uri = product ? `/v1/products/${product}/integrations/${integrationId}` : `/v1/integrations/${integrationId}`;
1104
- return this.delete({ uri, auth, headers, context });
1105
- }
1106
-
1107
- /**
635
+ deleteIntegration({ integrationId, product, auth, headers, context }: T.DeleteIntegrationOptions): Promise<T.JSONResponse<T.OKResponse>>;
636
+ /**
1108
637
  * List all integrations owned by the account or product
1109
638
  * @param {Object} options Options for this API call
1110
639
  * @param {String} [options.product] Integrations for this product ID or slug
1111
640
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1112
641
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1113
642
  * @param {Object} [options.context] Request context
1114
- * @returns {Promise} A promise
643
+ * @returns {Promise<T.JSONResponse<T.IntegrationInfo[]>>} A promise that resolves with the response data
1115
644
  */
1116
- listIntegrations({ product, auth, headers, context }){
1117
- const uri = product ? `/v1/products/${product}/integrations` : '/v1/integrations';
1118
- return this.get({ uri, auth, headers, context });
1119
- }
1120
-
1121
- /**
645
+ listIntegrations({ product, auth, headers, context }: T.ListIntegrationsOptions): Promise<T.JSONResponse<T.IntegrationInfo[]>>;
646
+ /**
1122
647
  * Get details about the current user
1123
648
  * @param {Object} options Options for this API call
1124
649
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1125
650
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1126
651
  * @param {Object} [options.context] Request context
1127
- * @returns {Promise} A promise
652
+ * @returns {Promise<T.JSONResponse<T.UserInfo>>} A promise that resolves with the response data
1128
653
  */
1129
- getUserInfo({ auth, headers, context }){
1130
- return this.get({ uri: '/v1/user', auth, headers, context });
1131
- }
1132
-
1133
- /**
654
+ getUserInfo({ auth, headers, context }: {
655
+ auth?: string;
656
+ headers?: Record<string, string>;
657
+ context?: {
658
+ tool?: T.ToolContext;
659
+ project?: T.ProjectContext;
660
+ };
661
+ }): Promise<T.JSONResponse<T.UserInfo>>;
662
+ /**
1134
663
  * Set details on the current user
1135
664
  * @param {Object} options Options for this API call
1136
665
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1137
666
  * @param {String} options.accountInfo Set user's extended info fields (name, business account, company name, etc)
1138
667
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1139
668
  * @param {Object} [options.context] Request context
1140
- * @returns {Promise} A promise
669
+ * @returns {Promise<T.JSONResponse<T.UserInfo>>} A promise that resolves with the response data
1141
670
  */
1142
- setUserInfo({ accountInfo, auth, headers, context }){
1143
- const data = { account_info: accountInfo };
1144
- return this.put({ uri: '/v1/user', auth, headers, data, context });
1145
- }
1146
-
1147
- /**
671
+ setUserInfo({ accountInfo, auth, headers, context }: T.SetUserInfoOptions): Promise<T.JSONResponse<T.UserInfo>>;
672
+ /**
1148
673
  * Change username (i.e, email)
1149
674
  * @param {Object} options Options for this API call
1150
675
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
@@ -1153,19 +678,10 @@ class Particle {
1153
678
  * @param {Boolean} options.invalidateTokens Should all tokens be invalidated
1154
679
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1155
680
  * @param {Object} [options.context] Request context
1156
- * @returns {Promise} A promise
681
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
1157
682
  */
1158
- changeUsername({ currentPassword, username, invalidateTokens = false, auth, headers, context }){
1159
- const data = { username, current_password: currentPassword };
1160
-
1161
- if (invalidateTokens) {
1162
- data.invalidate_tokens = true;
1163
- }
1164
-
1165
- return this.put({ uri: '/v1/user', auth, headers, data, context });
1166
- }
1167
-
1168
- /**
683
+ changeUsername({ currentPassword, username, invalidateTokens, auth, headers, context }: T.ChangeUsernameOptions): Promise<T.JSONResponse<T.OKResponse>>;
684
+ /**
1169
685
  * Change user's password
1170
686
  * @param {Object} options Options for this API call
1171
687
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
@@ -1174,19 +690,10 @@ class Particle {
1174
690
  * @param {Boolean} options.invalidateTokens Should all tokens be invalidated
1175
691
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1176
692
  * @param {Object} [options.context] Request context
1177
- * @returns {Promise} A promise
693
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
1178
694
  */
1179
- changeUserPassword({ currentPassword, password, invalidateTokens = false, auth, headers, context }){
1180
- const data = { password, current_password: currentPassword };
1181
-
1182
- if (invalidateTokens) {
1183
- data.invalidate_tokens = true;
1184
- }
1185
-
1186
- return this.put({ uri: '/v1/user', auth, headers, data, context });
1187
- }
1188
-
1189
- /**
695
+ changeUserPassword({ currentPassword, password, invalidateTokens, auth, headers, context }: T.ChangeUserPasswordOptions): Promise<T.JSONResponse<T.OKResponse>>;
696
+ /**
1190
697
  * List SIM cards owned by a user or product
1191
698
  * @param {Object} options Options for this API call
1192
699
  * @param {String} [options.iccid] (Product only) Filter to SIM cards matching this ICCID
@@ -1198,15 +705,10 @@ class Particle {
1198
705
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1199
706
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1200
707
  * @param {Object} [options.context] Request context
1201
- * @returns {Promise} A promise
708
+ * @returns {Promise<T.JSONResponse<T.SimInfo[]>>} A promise that resolves with the response data
1202
709
  */
1203
- listSIMs({ iccid, deviceId, deviceName, page, perPage, product, auth, headers, context }){
1204
- const uri = product ? `/v1/products/${product}/sims` : '/v1/sims';
1205
- const query = product ? { iccid, deviceId, deviceName, page, per_page: perPage } : undefined;
1206
- return this.get({ uri, auth, headers, query, context });
1207
- }
1208
-
1209
- /**
710
+ listSIMs({ iccid, deviceId, deviceName, page, perPage, product, auth, headers, context }: T.ListSIMsOptions): Promise<T.JSONResponse<T.SimInfo[]>>;
711
+ /**
1210
712
  * Get data usage for one SIM card for the current billing period
1211
713
  * @param {Object} options Options for this API call
1212
714
  * @param {String} options.iccid ICCID of the SIM card
@@ -1214,123 +716,30 @@ class Particle {
1214
716
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1215
717
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1216
718
  * @param {Object} [options.context] Request context
1217
- * @returns {Promise} A promise
719
+ * @returns {Promise<T.JSONResponse<T.SimDataUsage>>} A promise that resolves with the response data
1218
720
  */
1219
- getSIMDataUsage({ iccid, product, auth, headers, context }){
1220
- const uri = product ?
1221
- `/v1/products/${product}/sims/${iccid}/data_usage` :
1222
- `/v1/sims/${iccid}/data_usage`;
1223
-
1224
- return this.get({ uri, auth, headers, context });
1225
- }
1226
-
1227
- /**
721
+ getSIMDataUsage({ iccid, product, auth, headers, context }: T.GetSIMDataUsageOptions): Promise<T.JSONResponse<T.SimDataUsage>>;
722
+ /**
1228
723
  * Get data usage for all SIM cards in a product the current billing period
1229
724
  * @param {Object} options Options for this API call
1230
725
  * @param {String} options.product SIM cards for this product ID or slug
1231
726
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1232
727
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1233
728
  * @param {Object} [options.context] Request context
1234
- * @returns {Promise} A promise
729
+ * @returns {Promise<T.JSONResponse<T.SimDataUsage>>} A promise that resolves with the response data
1235
730
  */
1236
- getFleetDataUsage({ product, auth, headers, context }){
1237
- return this.get({
1238
- uri: `/v1/products/${product}/sims/data_usage`,
1239
- auth,
1240
- headers,
1241
- context
1242
- });
1243
- }
1244
-
1245
- /**
731
+ getFleetDataUsage({ product, auth, headers, context }: T.GetFleetDataUsageOptions): Promise<T.JSONResponse<T.SimDataUsage>>;
732
+ /**
1246
733
  * Check SIM status
1247
734
  * @param {Object} options Options for this API call
1248
735
  * @param {String} options.iccid ICCID of the SIM card
1249
736
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1250
737
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1251
738
  * @param {Object} [options.context] Request context
1252
- * @returns {Promise} A promise
1253
- */
1254
- checkSIM({ iccid, auth, headers, context }){
1255
- return this.head({ uri: `/v1/sims/${iccid}`, auth, headers, context });
1256
- }
1257
-
1258
- /**
1259
- * Activate and add SIM cards to an account or product
1260
- * @param {Object} options Options for this API call
1261
- * @param {String} options.iccid ICCID of the SIM card
1262
- * @param {Array<String>} options.iccids (Product only) ICCID of multiple SIM cards to import
1263
- * @param {String} options.country The ISO country code for the SIM cards
1264
- * @param {String} [options.product] SIM cards for this product ID or slug
1265
- * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1266
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1267
- * @param {Object} [options.context] Request context
1268
- * @param {any} [options.promoCode]
1269
- * @returns {Promise} A promise
1270
- */
1271
- activateSIM({ iccid, iccids, country, promoCode, product, auth, headers, context }){
1272
- // promoCode is deprecated
1273
- iccids = iccids || [iccid];
1274
- const uri = product ? `/v1/products/${product}/sims` : `/v1/sims/${iccid}`;
1275
- const data = product ?
1276
- { sims: iccids, country } :
1277
- { country, promoCode, action: 'activate' };
1278
- const method = product ? 'post' : 'put';
1279
-
1280
- return this.request({ uri, method, headers, data, auth, context });
1281
- }
1282
-
1283
- /**
1284
- * Deactivate a SIM card so it doesn't incur data usage in future months.
1285
- * @param {Object} options Options for this API call
1286
- * @param {String} options.iccid ICCID of the SIM card
1287
- * @param {String} [options.product] SIM cards for this product ID or slug
1288
- * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1289
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1290
- * @param {Object} [options.context] Request context
1291
- * @returns {Promise} A promise
1292
- */
1293
- deactivateSIM({ iccid, product, auth, headers, context }){
1294
- const uri = product ? `/v1/products/${product}/sims/${iccid}` : `/v1/sims/${iccid}`;
1295
- const data = { action: 'deactivate' };
1296
- return this.put({ uri, auth, headers, data, context });
1297
- }
1298
-
1299
- /**
1300
- * Reactivate a SIM card the was deactivated or unpause a SIM card that was automatically paused
1301
- * @param {Object} options Options for this API call
1302
- * @param {String} options.iccid ICCID of the SIM card
1303
- * @param {Number} [options.mbLimit] New monthly data limit. Necessary if unpausing a SIM card
1304
- * @param {String} [options.product] SIM cards for this product ID or slug
1305
- * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1306
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1307
- * @param {Object} [options.context] Request context
1308
- * @returns {Promise} A promise
1309
- */
1310
- reactivateSIM({ iccid, mbLimit, product, auth, headers, context }){
1311
- const uri = product ? `/v1/products/${product}/sims/${iccid}` : `/v1/sims/${iccid}`;
1312
- const data = { mb_limit: mbLimit, action: 'reactivate' };
1313
- return this.put({ uri, auth, headers, data, context });
1314
- }
1315
-
1316
- /**
1317
- * Update SIM card data limit
1318
- * @param {Object} options Options for this API call
1319
- * @param {String} options.iccid ICCID of the SIM card
1320
- * @param {Array} options.mbLimit Data limit in megabyte for the SIM card
1321
- * @param {String} [options.product] SIM cards for this product ID or slug
1322
- * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1323
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1324
- * @param {Object} [options.context] Request context
1325
- * @returns {Promise} A promise
739
+ * @returns {Promise<T.JSONResponse<T.SimInfo>>} A promise that resolves with the response data
1326
740
  */
1327
- updateSIM({ iccid, mbLimit, product, auth, headers, context }){
1328
- const uri = product ? `/v1/products/${product}/sims/${iccid}` : `/v1/sims/${iccid}`;
1329
- const data = { mb_limit: mbLimit };
1330
- return this.put({ uri, auth, headers, data, context });
1331
- }
1332
-
1333
- /**
741
+ checkSIM({ iccid, auth, headers, context }: T.CheckSIMOptions): Promise<T.JSONResponse<T.SimInfo>>;
742
+ /**
1334
743
  * Remove a SIM card from an account so it can be activated by a different account
1335
744
  * @param {Object} options Options for this API call
1336
745
  * @param {String} options.iccid ICCID of the SIM card
@@ -1338,28 +747,20 @@ class Particle {
1338
747
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1339
748
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1340
749
  * @param {Object} [options.context] Request context
1341
- * @returns {Promise} A promise
750
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
1342
751
  */
1343
- removeSIM({ iccid, product, auth, headers, context }){
1344
- const uri = product ? `/v1/products/${product}/sims/${iccid}` : `/v1/sims/${iccid}`;
1345
- return this.delete({ uri, auth, headers, context });
1346
- }
1347
-
1348
- /**
752
+ removeSIM({ iccid, product, auth, headers, context }: T.RemoveSIMOptions): Promise<T.JSONResponse<T.OKResponse>>;
753
+ /**
1349
754
  * List valid build targets to be used for compiling
1350
755
  * @param {Object} options Options for this API call
1351
756
  * @param {Boolean} [options.onlyFeatured=false] Only list featured build targets
1352
757
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1353
758
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1354
759
  * @param {Object} [options.context] Request context
1355
- * @returns {Promise} A promise
760
+ * @returns {Promise<T.JSONResponse<T.BuildTargetsResponse>>} A promise that resolves with the response data
1356
761
  */
1357
- listBuildTargets({ onlyFeatured, auth, headers, context }){
1358
- const query = onlyFeatured ? { featured: !!onlyFeatured } : undefined;
1359
- return this.get({ uri: '/v1/build_targets', auth, headers, query, context });
1360
- }
1361
-
1362
- /**
762
+ listBuildTargets({ onlyFeatured, auth, headers, context }: T.ListBuildTargetsOptions): Promise<T.JSONResponse<T.BuildTargetsResponse>>;
763
+ /**
1363
764
  * List firmware libraries
1364
765
  * @param {Object} options Options for this API call
1365
766
  * @param {Number} options.page Page index (default, first page)
@@ -1383,30 +784,11 @@ class Particle {
1383
784
  * @param {Object} [options.context] Request context
1384
785
  * @returns {Promise} A promise
1385
786
  */
1386
- listLibraries({ page, limit, filter, sort, architectures, category, scope, excludeScopes, auth, headers, context }){
1387
- return this.get({
1388
- uri: '/v1/libraries',
1389
- auth,
1390
- headers,
1391
- query: {
1392
- page,
1393
- filter,
1394
- limit,
1395
- sort,
1396
- architectures: this._asList(architectures),
1397
- category,
1398
- scope,
1399
- excludeScopes: this._asList(excludeScopes)
1400
- },
1401
- context
1402
- });
1403
- }
1404
-
1405
- _asList(value){
1406
- return (Array.isArray(value) ? value.join(',') : value);
1407
- }
1408
-
1409
- /**
787
+ listLibraries({ page, limit, filter, sort, architectures, category, scope, excludeScopes, auth, headers, context }: T.ListLibrariesOptions): Promise<T.JSONResponse<{
788
+ data: T.LibraryInfo[];
789
+ }>>;
790
+ private _asList;
791
+ /**
1410
792
  * Get firmware library details
1411
793
  * @param {Object} options Options for this API call
1412
794
  * @param {String} options.name Name of the library to fetch
@@ -1416,17 +798,10 @@ class Particle {
1416
798
  * @param {Object} [options.context] Request context
1417
799
  * @returns {Promise} A promise
1418
800
  */
1419
- getLibrary({ name, version, auth, headers, context }){
1420
- return this.get({
1421
- uri: `/v1/libraries/${name}`,
1422
- auth,
1423
- headers,
1424
- query: { version },
1425
- context
1426
- });
1427
- }
1428
-
1429
- /**
801
+ getLibrary({ name, version, auth, headers, context }: T.GetLibraryOptions): Promise<T.JSONResponse<{
802
+ data: T.LibraryInfo;
803
+ }>>;
804
+ /**
1430
805
  * Firmware library details for each version
1431
806
  * @param {Object} options Options for this API call
1432
807
  * @param {String} options.name Name of the library to fetch
@@ -1437,17 +812,10 @@ class Particle {
1437
812
  * @param {Object} [options.context] Request context
1438
813
  * @returns {Promise} A promise
1439
814
  */
1440
- getLibraryVersions({ name, page, limit, auth, headers, context }){
1441
- return this.get({
1442
- uri: `/v1/libraries/${name}/versions`,
1443
- auth,
1444
- headers,
1445
- query: { page, limit },
1446
- context
1447
- });
1448
- }
1449
-
1450
- /**
815
+ getLibraryVersions({ name, page, limit, auth, headers, context }: T.GetLibraryVersionsOptions): Promise<T.JSONResponse<{
816
+ data: T.LibraryInfo[];
817
+ }>>;
818
+ /**
1451
819
  * Contribute a new library version from a compressed archive
1452
820
  * @param {Object} options Options for this API call
1453
821
  * @param {String | Buffer} options.archive Compressed archive file containing the library sources
@@ -1457,22 +825,10 @@ class Particle {
1457
825
  * @param {Object} [options.context] Request context
1458
826
  * @returns {Promise} A promise
1459
827
  */
1460
- contributeLibrary({ archive, auth, headers, context }){
1461
- const files = {
1462
- 'archive.tar.gz': archive
1463
- };
1464
-
1465
- return this.request({
1466
- uri: '/v1/libraries',
1467
- method: 'post',
1468
- auth,
1469
- headers,
1470
- files,
1471
- context
1472
- });
1473
- }
1474
-
1475
- /**
828
+ contributeLibrary({ archive, auth, headers, context }: T.ContributeLibraryOptions): Promise<T.JSONResponse<{
829
+ data: T.LibraryInfo;
830
+ }>>;
831
+ /**
1476
832
  * Publish the latest version of a library to the public
1477
833
  * @param {Object} options Options for this API call
1478
834
  * @param {String} options.name Name of the library to publish
@@ -1481,18 +837,10 @@ class Particle {
1481
837
  * @param {Object} [options.context] Request context
1482
838
  * @returns {Promise} A promise
1483
839
  */
1484
- publishLibrary({ name, auth, headers, context }){
1485
- return this.request({
1486
- uri: `/v1/libraries/${name}`,
1487
- method: 'patch',
1488
- auth,
1489
- headers,
1490
- data: { visibility: 'public' },
1491
- context
1492
- });
1493
- }
1494
-
1495
- /**
840
+ publishLibrary({ name, auth, headers, context }: T.PublishLibraryOptions): Promise<T.JSONResponse<{
841
+ data: T.LibraryInfo;
842
+ }>>;
843
+ /**
1496
844
  * Delete one version of a library or an entire private library
1497
845
  * @param {Object} options Options for this API call
1498
846
  * @param {String} options.name Name of the library to remove
@@ -1500,31 +848,19 @@ class Particle {
1500
848
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1501
849
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1502
850
  * @param {Object} [options.context] Request context
1503
- * @returns {Promise} A promise
851
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
1504
852
  */
1505
- deleteLibrary({ name, force, auth, headers, context }){
1506
- return this.delete({
1507
- uri: `/v1/libraries/${name}`,
1508
- auth,
1509
- headers,
1510
- data: { force },
1511
- context
1512
- });
1513
- }
1514
-
1515
- /**
853
+ deleteLibrary({ name, force, auth, headers, context }: T.DeleteLibraryOptions): Promise<T.JSONResponse<T.OKResponse>>;
854
+ /**
1516
855
  * Download an external file that may not be on the API
1517
856
  * @param {Object} options Options for this API call
1518
857
  * @param {String} options.uri URL of the file.
1519
858
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1520
859
  * @param {Object} [options.context] Request context
1521
- * @returns {Promise} Resolves to a buffer with the file data
860
+ * @returns {Promise<Buffer | ArrayBuffer>} A promise that resolves with the binary data
1522
861
  */
1523
- downloadFile({ uri, headers, context }){
1524
- return this.request({ uri, method: 'get', headers, context, isBuffer: true });
1525
- }
1526
-
1527
- /**
862
+ downloadFile({ uri, headers, context }: T.DownloadFileOptions): Promise<Buffer | ArrayBuffer>;
863
+ /**
1528
864
  * List OAuth client created by the account
1529
865
  * @param {Object} options Options for this API call
1530
866
  * @param {String} [options.product] List clients for this product ID or slug
@@ -1533,12 +869,10 @@ class Particle {
1533
869
  * @param {Object} [options.context] Request context
1534
870
  * @returns {Promise} A promise
1535
871
  */
1536
- listOAuthClients({ product, auth, headers, context }){
1537
- const uri = product ? `/v1/products/${product}/clients` : '/v1/clients';
1538
- return this.get({ uri, auth, headers, context });
1539
- }
1540
-
1541
- /**
872
+ listOAuthClients({ product, auth, headers, context }: T.ListOAuthClientsOptions): Promise<T.JSONResponse<{
873
+ clients: T.OAuthClientInfo[];
874
+ }>>;
875
+ /**
1542
876
  * Create an OAuth client
1543
877
  * @param {Object} options Options for this API call
1544
878
  * @param {String} options.name Name of the OAuth client
@@ -1549,15 +883,10 @@ class Particle {
1549
883
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1550
884
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1551
885
  * @param {Object} [options.context] Request context
1552
- * @returns {Promise} A promise
886
+ * @returns {Promise<T.JSONResponse<T.OAuthClientInfo>>} A promise that resolves with the response data
1553
887
  */
1554
- createOAuthClient({ name, type, redirect_uri, scope, product, auth, headers, context }){
1555
- const uri = product ? `/v1/products/${product}/clients` : '/v1/clients';
1556
- const data = { name, type, redirect_uri, scope };
1557
- return this.post({ uri, auth, headers, data, context });
1558
- }
1559
-
1560
- /**
888
+ createOAuthClient({ name, type, redirect_uri, scope, product, auth, headers, context }: T.CreateOAuthClientOptions): Promise<T.JSONResponse<T.OAuthClientInfo>>;
889
+ /**
1561
890
  * Update an OAuth client
1562
891
  * @param {Object} options Options for this API call
1563
892
  * @param {String} options.clientId The OAuth client to update
@@ -1567,15 +896,10 @@ class Particle {
1567
896
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1568
897
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1569
898
  * @param {Object} [options.context] Request context
1570
- * @returns {Promise} A promise
899
+ * @returns {Promise<T.JSONResponse<T.OAuthClientInfo>>} A promise that resolves with the response data
1571
900
  */
1572
- updateOAuthClient({ clientId, name, scope, product, auth, headers, context }){
1573
- const uri = product ? `/v1/products/${product}/clients/${clientId}` : `/v1/clients/${clientId}`;
1574
- const data = { name, scope };
1575
- return this.put({ uri, data, auth, headers, context });
1576
- }
1577
-
1578
- /**
901
+ updateOAuthClient({ clientId, name, scope, product, auth, headers, context }: T.UpdateOAuthClientOptions): Promise<T.JSONResponse<T.OAuthClientInfo>>;
902
+ /**
1579
903
  * Delete an OAuth client
1580
904
  * @param {Object} options Options for this API call
1581
905
  * @param {String} options.clientId The OAuth client to update
@@ -1583,14 +907,10 @@ class Particle {
1583
907
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1584
908
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1585
909
  * @param {Object} [options.context] Request context
1586
- * @returns {Promise} A promise
910
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
1587
911
  */
1588
- deleteOAuthClient({ clientId, product, auth, headers, context }){
1589
- const uri = product ? `/v1/products/${product}/clients/${clientId}` : `/v1/clients/${clientId}`;
1590
- return this.delete({ uri, auth, headers, context });
1591
- }
1592
-
1593
- /**
912
+ deleteOAuthClient({ clientId, product, auth, headers, context }: T.DeleteOAuthClientOptions): Promise<T.JSONResponse<T.OKResponse>>;
913
+ /**
1594
914
  * List products the account has access to
1595
915
  * @param {Object} options Options for this API call
1596
916
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
@@ -1598,11 +918,10 @@ class Particle {
1598
918
  * @param {Object} [options.context] Request context
1599
919
  * @returns {Promise} A promise
1600
920
  */
1601
- listProducts({ auth, headers, context }){
1602
- return this.get({ uri: '/v1/products', auth, headers, context });
1603
- }
1604
-
1605
- /**
921
+ listProducts({ auth, headers, context }: T.ListProductsOptions): Promise<T.JSONResponse<{
922
+ products: T.ProductInfo[];
923
+ }>>;
924
+ /**
1606
925
  * Get detailed information about a product
1607
926
  * @param {Object} options Options for this API call
1608
927
  * @param {String} options.product Product ID or slug
@@ -1611,24 +930,20 @@ class Particle {
1611
930
  * @param {Object} [options.context] Request context
1612
931
  * @returns {Promise} A promise
1613
932
  */
1614
- getProduct({ product, auth, headers, context }){
1615
- return this.get({ uri: `/v1/products/${product}`, auth, headers, context });
1616
- }
1617
-
1618
- /**
933
+ getProduct({ product, auth, headers, context }: T.GetProductOptions): Promise<T.JSONResponse<{
934
+ product: T.ProductInfo;
935
+ }>>;
936
+ /**
1619
937
  * List product firmware versions
1620
938
  * @param {Object} options Options for this API call
1621
939
  * @param {String} options.product Firmware for this product ID or slug
1622
940
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1623
941
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1624
942
  * @param {Object} [options.context] Request context
1625
- * @returns {Promise} A promise
943
+ * @returns {Promise<T.JSONResponse<T.ProductFirmwareInfo[]>>} A promise that resolves with the response data
1626
944
  */
1627
- listProductFirmware({ product, auth, headers, context }){
1628
- return this.get({ uri: `/v1/products/${product}/firmware`, auth, headers, context });
1629
- }
1630
-
1631
- /**
945
+ listProductFirmware({ product, auth, headers, context }: T.ListProductFirmwareOptions): Promise<T.JSONResponse<T.ProductFirmwareInfo[]>>;
946
+ /**
1632
947
  * List product firmware versions
1633
948
  * @param {Object} options Options for this API call
1634
949
  * @param {Object} options.file Path or Buffer of the new firmware file
@@ -1640,27 +955,10 @@ class Particle {
1640
955
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1641
956
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1642
957
  * @param {Object} [options.context] Request context
1643
- * @returns {Promise} A promise
958
+ * @returns {Promise<T.JSONResponse<T.ProductFirmwareInfo>>} A promise that resolves with the response data
1644
959
  */
1645
- uploadProductFirmware({ file, version, title, description, product, auth, headers, context }){
1646
- return this.request({
1647
- uri: `/v1/products/${product}/firmware`,
1648
- method: 'post',
1649
- auth,
1650
- headers,
1651
- form: {
1652
- version,
1653
- title,
1654
- description
1655
- },
1656
- files: {
1657
- 'firmware.bin': file
1658
- },
1659
- context
1660
- });
1661
- }
1662
-
1663
- /**
960
+ uploadProductFirmware({ file, version, title, description, product, auth, headers, context }: T.UploadProductFirmwareOptions): Promise<T.JSONResponse<T.ProductFirmwareInfo>>;
961
+ /**
1664
962
  * Get information about a product firmware version
1665
963
  * @param {Object} options Options for this API call
1666
964
  * @param {Number} options.version Version number of firmware
@@ -1668,18 +966,10 @@ class Particle {
1668
966
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1669
967
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1670
968
  * @param {Object} [options.context] Request context
1671
- * @returns {Promise} A promise
969
+ * @returns {Promise<T.JSONResponse<T.ProductFirmwareInfo>>} A promise that resolves with the response data
1672
970
  */
1673
- getProductFirmware({ version, product, auth, headers, context }){
1674
- return this.get({
1675
- uri: `/v1/products/${product}/firmware/${version}`,
1676
- auth,
1677
- headers,
1678
- context
1679
- });
1680
- }
1681
-
1682
- /**
971
+ getProductFirmware({ version, product, auth, headers, context }: T.GetProductFirmwareOptions): Promise<T.JSONResponse<T.ProductFirmwareInfo>>;
972
+ /**
1683
973
  * Update information for a product firmware version
1684
974
  * @param {Object} options Options for this API call
1685
975
  * @param {Number} options.version Version number of new firmware
@@ -1689,14 +979,10 @@ class Particle {
1689
979
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1690
980
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1691
981
  * @param {Object} [options.context] Request context
1692
- * @returns {Promise} A promise
982
+ * @returns {Promise<T.JSONResponse<T.ProductFirmwareInfo>>} A promise that resolves with the response data
1693
983
  */
1694
- updateProductFirmware({ version, title, description, product, auth, headers, context }){
1695
- const uri = `/v1/products/${product}/firmware/${version}`;
1696
- return this.put({ uri, auth, headers, data: { title, description }, context });
1697
- }
1698
-
1699
- /**
984
+ updateProductFirmware({ version, title, description, product, auth, headers, context }: T.UpdateProductFirmwareOptions): Promise<T.JSONResponse<T.ProductFirmwareInfo>>;
985
+ /**
1700
986
  * Download a product firmware binary
1701
987
  * @param {Object} options Options for this API call
1702
988
  * @param {Number} options.version Version number of new firmware
@@ -1704,40 +990,20 @@ class Particle {
1704
990
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1705
991
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1706
992
  * @param {Object} [options.context] Request context
1707
- * @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
1708
- */
1709
- downloadProductFirmware({ version, product, auth, headers, context }){
1710
- return this.request({
1711
- uri: `/v1/products/${product}/firmware/${version}/binary`,
1712
- method: 'get',
1713
- auth,
1714
- headers,
1715
- context,
1716
- isBuffer: true
1717
- });
1718
- }
1719
-
1720
- /**
993
+ * @returns {Promise<Buffer | ArrayBuffer>} A promise that resolves with the binary data
994
+ */
995
+ downloadProductFirmware({ version, product, auth, headers, context }: T.DownloadProductFirmwareOptions): Promise<Buffer | ArrayBuffer>;
996
+ /**
1721
997
  * Download a tachyon manufacturing backup files
1722
998
  * @param {Object} options Options for this API call
1723
999
  * @param {Number} options.deviceId Device ID
1724
1000
  * @param {String} [options.auth] The access token. Can be ignored if provided in constructor
1725
1001
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1726
1002
  * @param {Object} [options.context] Request context
1727
- * @returns {Promise<RequestResponse, RequestError>} A promise with a zip file that contains all manufacturing backup files for the specific device.
1003
+ * @returns {Promise<Buffer | ArrayBuffer>} A promise that resolves with the binary data
1728
1004
  */
1729
- downloadManufacturingBackup({ deviceId, auth, headers, context }) {
1730
- return this.request({
1731
- uri:`/v1/devices/${deviceId}/backup_files`,
1732
- method: 'put',
1733
- auth,
1734
- headers,
1735
- context,
1736
- isBuffer: true
1737
- });
1738
- }
1739
-
1740
- /**
1005
+ downloadManufacturingBackup({ deviceId, auth, headers, context }: T.DownloadManufacturingBackupOptions): Promise<Buffer | ArrayBuffer>;
1006
+ /**
1741
1007
  * Release a product firmware version as the default version
1742
1008
  * @param {Object} options Options for this API call
1743
1009
  * @param {Number} options.version Version number of new firmware
@@ -1745,32 +1011,20 @@ class Particle {
1745
1011
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1746
1012
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1747
1013
  * @param {Object} [options.context] Request context
1748
- * @returns {Promise} A promise
1014
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
1749
1015
  */
1750
- releaseProductFirmware({ version, product, auth, headers, context }){
1751
- const uri = `/v1/products/${product}/firmware/release`;
1752
- return this.put({ uri, auth, headers, data: { version }, context });
1753
- }
1754
-
1755
- /**
1016
+ releaseProductFirmware({ version, product, product_default, groups, intelligent, auth, headers, context }: T.ReleaseFirmwareOptions): Promise<T.JSONResponse<T.OKResponse>>;
1017
+ /**
1756
1018
  * List product team members
1757
1019
  * @param {Object} options Options for this API call
1758
1020
  * @param {String} options.product Team for this product ID or slug
1759
1021
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1760
1022
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1761
1023
  * @param {Object} [options.context] Request context
1762
- * @returns {Promise} A promise
1024
+ * @returns {Promise<T.JSONResponse<T.TeamMember[]>>} A promise that resolves with the response data
1763
1025
  */
1764
- listTeamMembers({ product, auth, headers, context }){
1765
- return this.get({
1766
- uri: `/v1/products/${product}/team`,
1767
- auth,
1768
- headers,
1769
- context
1770
- });
1771
- }
1772
-
1773
- /**
1026
+ listTeamMembers({ product, auth, headers, context }: T.ListTeamMembersOptions): Promise<T.JSONResponse<T.TeamMember[]>>;
1027
+ /**
1774
1028
  * Invite Particle user to a product team
1775
1029
  * @param {Object} options Options for this API call
1776
1030
  * @param {String} options.username Username for the Particle account
@@ -1778,19 +1032,10 @@ class Particle {
1778
1032
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1779
1033
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1780
1034
  * @param {Object} [options.context] Request context
1781
- * @returns {Promise} A promise
1035
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
1782
1036
  */
1783
- inviteTeamMember({ username, product, auth, headers, context }){
1784
- return this.post({
1785
- uri: `/v1/products/${product}/team`,
1786
- auth,
1787
- headers,
1788
- data: { username },
1789
- context
1790
- });
1791
- }
1792
-
1793
- /**
1037
+ inviteTeamMember({ username, product, auth, headers, context }: T.InviteTeamMemberOptions): Promise<T.JSONResponse<T.OKResponse>>;
1038
+ /**
1794
1039
  * Remove Particle user to a product team
1795
1040
  * @param {Object} options Options for this API call
1796
1041
  * @param {String} options.username Username for the Particle account
@@ -1798,228 +1043,40 @@ class Particle {
1798
1043
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1799
1044
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1800
1045
  * @param {Object} [options.context] Request context
1801
- * @returns {Promise} A promise
1046
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
1802
1047
  */
1803
- removeTeamMember({ username, product, auth, headers, context }){
1804
- return this.delete({
1805
- uri: `/v1/products/${product}/team/${username}`,
1806
- auth,
1807
- headers,
1808
- context
1809
- });
1810
- }
1811
-
1812
- /**
1048
+ removeTeamMember({ username, product, auth, headers, context }: T.RemoveTeamMemberOptions): Promise<T.JSONResponse<T.OKResponse>>;
1049
+ /**
1813
1050
  * Fetch details about a serial number
1814
1051
  * @param {Object} options Options for this API call
1815
1052
  * @param {String} options.serialNumber The serial number printed on the barcode of the device packaging
1816
1053
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1817
1054
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1818
1055
  * @param {Object} [options.context] Request context
1819
- * @returns {Promise} A promise
1056
+ * @returns {Promise<T.JSONResponse<T.SerialNumberResponse>>} A promise that resolves with the response data
1820
1057
  */
1821
- lookupSerialNumber({ serialNumber, auth, headers, context }){
1822
- return this.get({
1823
- uri: `/v1/serial_numbers/${serialNumber}`,
1824
- auth,
1825
- headers,
1826
- context
1827
- });
1828
- }
1829
-
1830
- /**
1831
- * Create a mesh network
1832
- * @param {Object} options Options for this API call
1833
- * @param {String} options.name Network name
1834
- * @param {String} options.deviceId Gateway device ID
1835
- * @param {String} [options.iccid] ICCID of the active SIM card (only for cellular gateway devices)
1836
- * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1837
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1838
- * @param {Object} [options.context] Request context
1839
- * @returns {Promise<Object>} A promise
1840
- */
1841
- createMeshNetwork({ name, deviceId, iccid, auth, headers, context }){
1842
- return this.post({
1843
- uri: '/v1/networks',
1844
- auth,
1845
- headers,
1846
- data: { name, device_id: deviceId, iccid },
1847
- context
1848
- });
1849
- }
1850
-
1851
- /**
1852
- * Remove a mesh network.
1853
- * @param {Object} options Options for this API call
1854
- * @param {String} options.networkId Network ID or name
1855
- * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1856
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1857
- * @param {Object} [options.context] Request context
1858
- * @returns {Promise<Object>} A promise
1859
- */
1860
- removeMeshNetwork({ networkId, auth, headers, context }){
1861
- return this.delete({ uri: `/v1/networks/${networkId}`, auth, headers, context });
1862
- }
1863
-
1864
- /**
1865
- * List all mesh networks
1866
- * @param {Object} options Options for this API call
1867
- * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1868
- * @param {Number} [options.page] Current page of results
1869
- * @param {Number} [options.perPage] Records per page
1870
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1871
- * @param {Object} [options.context] Request context
1872
- * @returns {Promise<Object>} A promise
1873
- */
1874
- listMeshNetworks({ page, perPage, auth, headers, context }){
1875
- const query = page ? { page, per_page: perPage } : undefined;
1876
- return this.get({ uri: '/v1/networks', auth, headers, query, context });
1877
- }
1878
-
1879
- /**
1880
- * Get information about a mesh network.
1881
- * @param {Object} options Options for this API call
1882
- * @param {String} options.networkId Network ID or name
1883
- * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1884
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1885
- * @param {Object} [options.context] Request context
1886
- * @returns {Promise<Object>} A promise
1887
- */
1888
- getMeshNetwork({ networkId, auth, headers, context }){
1889
- return this.get({ uri: `/v1/networks/${networkId}`, auth, headers, context });
1890
- }
1891
-
1892
- /**
1893
- * Modify a mesh network.
1894
- * @param {Object} options Options for this API call
1895
- * @param {String} options.networkId Network ID or name
1896
- * @param {String} options.action 'add-device', 'remove-device', 'gateway-enable' or 'gateway-disable'
1897
- * @param {String} options.deviceId Device ID
1898
- * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1899
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1900
- * @param {Object} [options.context] Request context
1901
- * @returns {Promise<Object>} A promise
1902
- */
1903
- updateMeshNetwork({ networkId, action, deviceId, auth, headers, context }){
1904
- return this.put({
1905
- uri: `/v1/networks/${networkId}`,
1906
- auth,
1907
- headers,
1908
- data: { action, device_id: deviceId },
1909
- context
1910
- });
1911
- }
1912
-
1913
- /**
1914
- * Add a device to a mesh network.
1915
- * @param {Object} options Options for this API call
1916
- * @param {String} options.networkId Network ID or name
1917
- * @param {String} options.deviceId Device ID
1918
- * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1919
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1920
- * @param {Object} [options.context] Request context
1921
- * @returns {Promise<Object>} A promise
1922
- */
1923
- addMeshNetworkDevice({ networkId, deviceId, auth, headers, context }){
1924
- return this.updateMeshNetwork({
1925
- action: 'add-device',
1926
- networkId,
1927
- deviceId,
1928
- auth,
1929
- headers,
1930
- context
1931
- });
1932
- }
1933
-
1934
- /**
1935
- * Remove a device from a mesh network.
1936
- * @param {Object} options Options for this API call
1937
- * @param {String} [options.networkId] Network ID or name
1938
- * @param {String} options.deviceId Device ID
1939
- * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1940
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1941
- * @param {Object} [options.context] Request context
1942
- * @returns {Promise<Object>} A promise
1943
- */
1944
- removeMeshNetworkDevice({ networkId, deviceId, auth, headers, context }){
1945
- if (!networkId){
1946
- return this.delete({
1947
- uri: `/v1/devices/${deviceId}/network`,
1948
- auth,
1949
- headers, context
1950
- });
1951
- }
1952
- return this.updateMeshNetwork({
1953
- action: 'remove-device',
1954
- networkId,
1955
- deviceId,
1956
- auth,
1957
- headers,
1958
- context
1959
- });
1960
- }
1961
-
1962
- /**
1963
- * List all devices of a mesh network.
1964
- * @param {Object} options Options for this API call
1965
- * @param {String} options.networkId Network ID or name
1966
- * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1967
- * @param {Number} [options.role] Device role: 'gateway' or 'node'
1968
- * @param {Number} [options.page] Current page of results
1969
- * @param {Number} [options.perPage] Records per page
1970
- * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1971
- * @param {Object} [options.context] Request context
1972
- * @returns {Promise<Object>} A promise
1973
- */
1974
- listMeshNetworkDevices({ networkId, role, page, perPage, auth, headers, context }){
1975
- const query = (role || page) ? { role, page, per_page: perPage } : undefined;
1976
- return this.get({
1977
- uri: `/v1/networks/${networkId}/devices`,
1978
- auth,
1979
- headers,
1980
- query,
1981
- context
1982
- });
1983
- }
1984
-
1985
- /**
1058
+ lookupSerialNumber({ serialNumber, auth, headers, context }: T.LookupSerialNumberOptions): Promise<T.JSONResponse<T.SerialNumberResponse>>;
1059
+ /**
1986
1060
  * Get product configuration
1987
1061
  * @param {Object} options Options for this API call
1988
1062
  * @param {String} options.product Config for this product ID or slug
1989
1063
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1990
1064
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1991
1065
  * @param {Object} [options.context] Request context
1992
- * @returns {Promise} A promise
1066
+ * @returns {Promise<T.JSONResponse<T.ProductConfigurationResponse>>} A promise that resolves with the response data
1993
1067
  */
1994
- getProductConfiguration({ auth, product, headers, context }){
1995
- return this.get({
1996
- uri: `/v1/products/${product}/config`,
1997
- auth,
1998
- headers,
1999
- context
2000
- });
2001
- }
2002
-
2003
- /**
1068
+ getProductConfiguration({ auth, product, headers, context }: T.GetProductConfigurationOptions): Promise<T.JSONResponse<T.ProductConfigurationResponse>>;
1069
+ /**
2004
1070
  * Get product configuration schema
2005
1071
  * @param {Object} options Options for this API call
2006
1072
  * @param {String} options.product Config for this product ID or slug
2007
1073
  * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
2008
1074
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2009
1075
  * @param {Object} [options.context] Request context
2010
- * @returns {Promise} A promise
1076
+ * @returns {Promise<T.JSONResponse<object>>} A promise that resolves with the response data
2011
1077
  */
2012
- getProductConfigurationSchema({ auth, product, headers = {}, context }){
2013
- headers.accept = 'application/schema+json';
2014
- return this.get({
2015
- uri: `/v1/products/${product}/config`,
2016
- auth,
2017
- headers,
2018
- context
2019
- });
2020
- }
2021
-
2022
- /**
1078
+ getProductConfigurationSchema({ auth, product, headers, context }: T.GetProductConfigurationSchemaOptions): Promise<T.JSONResponse<object>>;
1079
+ /**
2023
1080
  * Get product device's configuration
2024
1081
  * @param {Object} options Options for this API call
2025
1082
  * @param {String} options.product Config for this product ID or slug
@@ -2027,18 +1084,10 @@ class Particle {
2027
1084
  * @param {String} options.deviceId Device ID to access
2028
1085
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2029
1086
  * @param {Object} [options.context] Request context
2030
- * @returns {Promise} A promise
1087
+ * @returns {Promise<T.JSONResponse<T.ProductConfigurationResponse>>} A promise that resolves with the response data
2031
1088
  */
2032
- getProductDeviceConfiguration({ auth, product, deviceId, headers, context }){
2033
- return this.get({
2034
- uri: `/v1/products/${product}/config/${deviceId}`,
2035
- auth,
2036
- headers,
2037
- context
2038
- });
2039
- }
2040
-
2041
- /**
1089
+ getProductDeviceConfiguration({ auth, product, deviceId, headers, context }: T.GetProductDeviceConfigurationOptions): Promise<T.JSONResponse<T.ProductConfigurationResponse>>;
1090
+ /**
2042
1091
  * Get product device's configuration schema
2043
1092
  * @param {Object} options Options for this API call
2044
1093
  * @param {String} options.product Config for this product ID or slug
@@ -2046,19 +1095,10 @@ class Particle {
2046
1095
  * @param {String} options.deviceId Device ID to access
2047
1096
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2048
1097
  * @param {Object} [options.context] Request context
2049
- * @returns {Promise} A promise
1098
+ * @returns {Promise<T.JSONResponse<object>>} A promise that resolves with the response data
2050
1099
  */
2051
- getProductDeviceConfigurationSchema({ auth, product, deviceId, headers, context }){
2052
- headers.accept = 'application/schema+json';
2053
- return this.get({
2054
- uri: `/v1/products/${product}/config/${deviceId}`,
2055
- auth,
2056
- headers,
2057
- context
2058
- });
2059
- }
2060
-
2061
- /**
1100
+ getProductDeviceConfigurationSchema({ auth, product, deviceId, headers, context }: T.GetProductDeviceConfigurationSchemaOptions): Promise<T.JSONResponse<object>>;
1101
+ /**
2062
1102
  * Set product configuration
2063
1103
  * @param {Object} options Options for this API call
2064
1104
  * @param {String} options.product Config for this product ID or slug
@@ -2066,19 +1106,10 @@ class Particle {
2066
1106
  * @param {Object} options.config Product configuration to update
2067
1107
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2068
1108
  * @param {Object} [options.context] Request context
2069
- * @returns {Promise} A promise
1109
+ * @returns {Promise<T.JSONResponse<T.ProductConfigurationResponse>>} A promise that resolves with the response data
2070
1110
  */
2071
- setProductConfiguration({ auth, product, config, headers, context }){
2072
- return this.put({
2073
- uri: `/v1/products/${product}/config`,
2074
- auth,
2075
- data: config,
2076
- headers,
2077
- context
2078
- });
2079
- }
2080
-
2081
- /**
1111
+ setProductConfiguration({ auth, product, config, headers, context }: T.SetProductConfigurationOptions): Promise<T.JSONResponse<T.ProductConfigurationResponse>>;
1112
+ /**
2082
1113
  * Set product configuration for a specific device within the product
2083
1114
  * @param {Object} options Options for this API call
2084
1115
  * @param {String} options.product Config for this product ID or slug
@@ -2087,19 +1118,10 @@ class Particle {
2087
1118
  * @param {String} options.deviceId Device ID to access
2088
1119
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2089
1120
  * @param {Object} [options.context] Request context
2090
- * @returns {Promise} A promise
1121
+ * @returns {Promise<T.JSONResponse<T.ProductConfigurationResponse>>} A promise that resolves with the response data
2091
1122
  */
2092
- setProductDeviceConfiguration({ auth, product, deviceId, config, headers, context }){
2093
- return this.put({
2094
- uri: `/v1/products/${product}/config/${deviceId}`,
2095
- data: config,
2096
- auth,
2097
- headers,
2098
- context
2099
- });
2100
- }
2101
-
2102
- /**
1123
+ setProductDeviceConfiguration({ auth, product, deviceId, config, headers, context }: T.SetProductDeviceConfigurationOptions): Promise<T.JSONResponse<T.ProductConfigurationResponse>>;
1124
+ /**
2103
1125
  * Query location for devices within a product
2104
1126
  * @param {Object} options Options for this API call
2105
1127
  * @param {String} options.product Locations for this product ID or slug
@@ -2114,28 +1136,10 @@ class Particle {
2114
1136
  * @param {String} options.perPage Number of results per page. Defaults to 20. Maximum of 100
2115
1137
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2116
1138
  * @param {Object} [options.context] Request context
2117
- * @returns {Promise} A promise
1139
+ * @returns {Promise<T.JSONResponse<T.LocationListResponse>>} A promise that resolves with the response data
2118
1140
  */
2119
- getProductLocations({ auth, product, dateRange, rectBl, rectTr, deviceId, deviceName, groups, page, perPage, headers, context }){
2120
- return this.get({
2121
- uri: `/v1/products/${product}/locations`,
2122
- query: {
2123
- date_range: dateRange,
2124
- rect_bl: rectBl,
2125
- rect_tr: rectTr,
2126
- device_id: deviceId,
2127
- device_name: deviceName,
2128
- groups,
2129
- page,
2130
- per_page: perPage
2131
- },
2132
- auth,
2133
- headers,
2134
- context
2135
- });
2136
- }
2137
-
2138
- /**
1141
+ getProductLocations({ auth, product, dateRange, rectBl, rectTr, deviceId, deviceName, groups, page, perPage, headers, context }: T.GetProductLocationsOptions): Promise<T.JSONResponse<T.LocationListResponse>>;
1142
+ /**
2139
1143
  * Query location for one device within a product
2140
1144
  * @param {Object} options Options for this API call
2141
1145
  * @param {String} options.product Locations for this product ID or slug
@@ -2148,23 +1152,10 @@ class Particle {
2148
1152
  * @param {Object} [options.context] Request context
2149
1153
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2150
1154
  * @param {Object} [options.context] Request context
2151
- * @returns {Promise} A promise
1155
+ * @returns {Promise<T.JSONResponse<T.DeviceLocationInfo>>} A promise that resolves with the response data
2152
1156
  */
2153
- getProductDeviceLocations({ auth, product, dateRange, rectBl, rectTr, deviceId, headers, context }){
2154
- return this.get({
2155
- uri: `/v1/products/${product}/locations/${deviceId}`,
2156
- query: {
2157
- date_range: dateRange,
2158
- rect_bl: rectBl,
2159
- rect_tr: rectTr
2160
- },
2161
- auth,
2162
- headers,
2163
- context
2164
- });
2165
- }
2166
-
2167
- /**
1157
+ getProductDeviceLocations({ auth, product, dateRange, rectBl, rectTr, deviceId, headers, context }: T.GetProductDeviceLocationsOptions): Promise<T.JSONResponse<T.DeviceLocationInfo>>;
1158
+ /**
2168
1159
  * Executes the provided logic function once and returns the result. No logs, runs, etc are saved
2169
1160
  *
2170
1161
  * NOTE: Any external interactions such as Particle.publish will actually occur when the logic is executed.
@@ -2176,19 +1167,10 @@ class Particle {
2176
1167
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2177
1168
  * @param {Object} [options.context] Request context
2178
1169
  *
2179
- * @returns {Promise<RequestResponse>} A promise that resolves to the created logic function data.
2180
- */
2181
- executeLogic({ auth, org, logic, headers, context }) {
2182
- return this.post({
2183
- uri: this._namespacedPath(org, 'logic/execute'),
2184
- auth,
2185
- data: logic,
2186
- headers,
2187
- context
2188
- });
2189
- }
2190
-
2191
- /**
1170
+ * @returns {Promise<T.JSONResponse<T.ExecuteLogicResponse>>} A promise that resolves with the response data
1171
+ */
1172
+ executeLogic({ auth, org, logic, headers, context }: T.ExecuteLogicOptions): Promise<T.JSONResponse<T.ExecuteLogicResponse>>;
1173
+ /**
2192
1174
  * Creates a new logic function in the specified organization or sandbox using the provided function data.
2193
1175
  *
2194
1176
  * When you create a logic function with Event logic triggers, events will immediately
@@ -2204,19 +1186,12 @@ class Particle {
2204
1186
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2205
1187
  * @param {Object} [options.context] Request context
2206
1188
  *
2207
- * @returns {Promise<RequestResponse>} A promise that resolves to the created logic function data.
2208
- */
2209
- createLogicFunction({ auth, org, logicFunction, headers, context }) {
2210
- return this.post({
2211
- uri: this._namespacedPath(org, 'logic/functions'),
2212
- auth,
2213
- data: { logic_function: logicFunction },
2214
- headers,
2215
- context
2216
- });
2217
- }
2218
-
2219
- /**
1189
+ * @returns {Promise<T.RequestResponse>} A promise that resolves to the created logic function data.
1190
+ */
1191
+ createLogicFunction({ auth, org, logicFunction, headers, context }: T.CreateLogicFunctionOptions): Promise<T.JSONResponse<{
1192
+ logic_function: T.LogicFunction;
1193
+ }>>;
1194
+ /**
2220
1195
  * Get a logic function in the specified organization or sandbox by logic function ID.
2221
1196
  *
2222
1197
  * @param {Object} options The options for the logic function.
@@ -2226,18 +1201,12 @@ class Particle {
2226
1201
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2227
1202
  * @param {Object} [options.context] Request context
2228
1203
  *
2229
- * @returns {Promise<RequestResponse>} A promise that resolves to the specified logic function data.
2230
- */
2231
- getLogicFunction({ auth, org, logicFunctionId, headers, context }) {
2232
- return this.get({
2233
- uri: this._namespacedPath(org, `logic/functions/${logicFunctionId}`),
2234
- auth,
2235
- headers,
2236
- context
2237
- });
2238
- }
2239
-
2240
- /**
1204
+ * @returns {Promise<T.RequestResponse>} A promise that resolves to the specified logic function data.
1205
+ */
1206
+ getLogicFunction({ auth, org, logicFunctionId, headers, context }: T.GetLogicFunctionOptions): Promise<T.JSONResponse<{
1207
+ logic_function: T.LogicFunction;
1208
+ }>>;
1209
+ /**
2241
1210
  * Updates an existing logic function in the specified organization or sandbox using the provided function data.
2242
1211
  *
2243
1212
  * If you include an id on a logic trigger, it will update the logic trigger in place.
@@ -2250,19 +1219,12 @@ class Particle {
2250
1219
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2251
1220
  * @param {Object} [options.context] Request context.
2252
1221
  *
2253
- * @returns {Promise<RequestResponse>} A promise that resolves to the updated logic function data.
2254
- */
2255
- updateLogicFunction({ auth, org, logicFunctionId, logicFunction, headers, context }) {
2256
- return this.put({
2257
- uri: this._namespacedPath(org, `logic/functions/${logicFunctionId}`),
2258
- auth,
2259
- data: { logic_function: logicFunction },
2260
- headers,
2261
- context
2262
- });
2263
- }
2264
-
2265
- /**
1222
+ * @returns {Promise<T.RequestResponse>} A promise that resolves to the updated logic function data.
1223
+ */
1224
+ updateLogicFunction({ auth, org, logicFunctionId, logicFunction, headers, context }: T.UpdateLogicFunctionOptions): Promise<T.JSONResponse<{
1225
+ logic_function: T.LogicFunction;
1226
+ }>>;
1227
+ /**
2266
1228
  * Deletes a logic function in the specified organization or sandbox by logic function ID.
2267
1229
  *
2268
1230
  * @param {Object} options The options for deleting the logic function.
@@ -2272,18 +1234,10 @@ class Particle {
2272
1234
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2273
1235
  * @param {Object} [options.context] Request context.
2274
1236
  *
2275
- * @returns {Promise<RequestResponse>} A promise that resolves to an object containing the deleted logic function ID.
2276
- */
2277
- deleteLogicFunction({ auth, org, logicFunctionId, headers, context }) {
2278
- return this.delete({
2279
- uri: this._namespacedPath(org, `logic/functions/${logicFunctionId}`),
2280
- auth,
2281
- headers,
2282
- context
2283
- });
2284
- }
2285
-
2286
- /**
1237
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
1238
+ */
1239
+ deleteLogicFunction({ auth, org, logicFunctionId, headers, context }: T.DeleteLogicFunctionOptions): Promise<T.JSONResponse<T.OKResponse>>;
1240
+ /**
2287
1241
  * Lists all logic functions in the specified organization or sandbox.
2288
1242
  *
2289
1243
  * @param {Object} options The options for listing logic functions.
@@ -2293,21 +1247,12 @@ class Particle {
2293
1247
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2294
1248
  * @param {Object} [options.context] Request context.
2295
1249
  *
2296
- * @returns {Promise<RequestResponse>} A promise that resolves to an array of logic functions data.
2297
- */
2298
- listLogicFunctions({ auth, org, todayStats, headers, context }) {
2299
- return this.get({
2300
- uri: this._namespacedPath(org, 'logic/functions'),
2301
- query: {
2302
- today_stats: todayStats
2303
- },
2304
- auth,
2305
- headers,
2306
- context
2307
- });
2308
- }
2309
-
2310
- /**
1250
+ * @returns {Promise<T.RequestResponse>} A promise that resolves to an array of logic functions data.
1251
+ */
1252
+ listLogicFunctions({ auth, org, todayStats, headers, context }: T.ListLogicFunctionsOptions): Promise<T.JSONResponse<{
1253
+ logic_functions: T.LogicFunction[];
1254
+ }>>;
1255
+ /**
2311
1256
  * Lists all logic runs for the specified logic function in the specified organization or sandbox.
2312
1257
  *
2313
1258
  * @param {Object} options The options for the request.
@@ -2317,18 +1262,12 @@ class Particle {
2317
1262
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2318
1263
  * @param {Object} [options.context] Request context
2319
1264
  *
2320
- * @returns {Promise<RequestResponse>} A promise that resolves to an array of logic run data.
2321
- */
2322
- listLogicRuns({ auth, org, logicFunctionId, headers, context }) {
2323
- return this.get({
2324
- uri: this._namespacedPath(org, `logic/functions/${logicFunctionId}/runs`),
2325
- auth,
2326
- headers,
2327
- context
2328
- });
2329
- }
2330
-
2331
- /**
1265
+ * @returns {Promise<T.RequestResponse>} A promise that resolves to an array of logic run data.
1266
+ */
1267
+ listLogicRuns({ auth, org, logicFunctionId, headers, context }: T.ListLogicRunsOptions): Promise<T.JSONResponse<{
1268
+ logic_runs: T.LogicRun[];
1269
+ }>>;
1270
+ /**
2332
1271
  * Retrieves a logic run by its ID for the specified logic function in the specified organization or sandbox.
2333
1272
  *
2334
1273
  * @param {Object} options The options for the request.
@@ -2339,18 +1278,12 @@ class Particle {
2339
1278
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2340
1279
  * @param {Object} [options.context] Request context
2341
1280
  *
2342
- * @returns {Promise<RequestResponse>} A promise that resolves to an array of logic run data for the specified logic run ID.
2343
- */
2344
- getLogicRun({ auth, org, logicFunctionId, logicRunId, headers, context }) {
2345
- return this.get({
2346
- uri: this._namespacedPath(org, `logic/functions/${logicFunctionId}/runs/${logicRunId}`),
2347
- auth,
2348
- headers,
2349
- context
2350
- });
2351
- }
2352
-
2353
- /**
1281
+ * @returns {Promise<T.RequestResponse>} A promise that resolves to an array of logic run data for the specified logic run ID.
1282
+ */
1283
+ getLogicRun({ auth, org, logicFunctionId, logicRunId, headers, context }: T.GetLogicRunOptions): Promise<T.JSONResponse<{
1284
+ logic_run: T.LogicRun;
1285
+ }>>;
1286
+ /**
2354
1287
  * Retrieves the logs for a logic run by its ID for the specified logic function in the specified organization or sandbox.
2355
1288
  *
2356
1289
  * @param {Object} options The options for the request.
@@ -2361,18 +1294,12 @@ class Particle {
2361
1294
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2362
1295
  * @param {Object} [options.context] Request context
2363
1296
  *
2364
- * @returns {Promise<RequestResponse>} A promise that resolves to the logs for the specified logic run ID.
2365
- */
2366
- getLogicRunLogs({ auth, org, logicFunctionId, logicRunId, headers, context }) {
2367
- return this.get({
2368
- uri: this._namespacedPath(org, `logic/functions/${logicFunctionId}/runs/${logicRunId}/logs`),
2369
- auth,
2370
- headers,
2371
- context
2372
- });
2373
- }
2374
-
2375
- /**
1297
+ * @returns {Promise<T.RequestResponse>} A promise that resolves to the logs for the specified logic run ID.
1298
+ */
1299
+ getLogicRunLogs({ auth, org, logicFunctionId, logicRunId, headers, context }: T.GetLogicRunLogsOptions): Promise<T.JSONResponse<{
1300
+ logs: T.LogicRunLog[];
1301
+ }>>;
1302
+ /**
2376
1303
  * Creates a new ledger definition in the specified organization or sandbox.
2377
1304
  *
2378
1305
  * @param {Object} options The options for creating the ledger definition.
@@ -2382,19 +1309,10 @@ class Particle {
2382
1309
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2383
1310
  * @param {Object} [options.context] Request context
2384
1311
  *
2385
- * @returns {Promise<RequestResponse>} A promise that resolves to the created ledger definition data.
2386
- */
2387
- createLedger({ auth, org, ledger, headers, context }) {
2388
- return this.post({
2389
- uri: this._namespacedPath(org, 'ledgers'),
2390
- auth,
2391
- data: { ledger },
2392
- headers,
2393
- context
2394
- });
2395
- }
2396
-
2397
- /**
1312
+ * @returns {Promise<T.JSONResponse<T.LedgerDefinition>>} A promise that resolves with the response data
1313
+ */
1314
+ createLedger({ auth, org, ledger, headers, context }: T.CreateLedgerOptions): Promise<T.JSONResponse<T.LedgerDefinition>>;
1315
+ /**
2398
1316
  * Get a ledger definition in the specified organization or sandbox by ledger name.
2399
1317
  *
2400
1318
  * @param {Object} options The options for the ledger definition.
@@ -2404,18 +1322,10 @@ class Particle {
2404
1322
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2405
1323
  * @param {Object} [options.context] Request context
2406
1324
  *
2407
- * @returns {Promise<RequestResponse>} A promise that resolves to the specified ledger definition data.
2408
- */
2409
- getLedger({ auth, org, ledgerName, headers, context }) {
2410
- return this.get({
2411
- uri: this._namespacedPath(org, `ledgers/${ledgerName}`),
2412
- auth,
2413
- headers,
2414
- context
2415
- });
2416
- }
2417
-
2418
- /**
1325
+ * @returns {Promise<T.JSONResponse<T.LedgerDefinition>>} A promise that resolves with the response data
1326
+ */
1327
+ getLedger({ auth, org, ledgerName, headers, context }: T.GetLedgerOptions): Promise<T.JSONResponse<T.LedgerDefinition>>;
1328
+ /**
2419
1329
  * Updates an existing ledger definition in the specified organization or sandbox.
2420
1330
  *
2421
1331
  * @param {Object} options The options for updating the ledger definition.
@@ -2426,19 +1336,10 @@ class Particle {
2426
1336
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2427
1337
  * @param {Object} [options.context] Request context.
2428
1338
  *
2429
- * @returns {Promise<RequestResponse>} A promise that resolves to the updated ledger definition data.
2430
- */
2431
- updateLedger({ auth, org, ledgerName, ledger, headers, context }) {
2432
- return this.put({
2433
- uri: this._namespacedPath(org, `ledgers/${ledgerName}`),
2434
- auth,
2435
- data: { ledger },
2436
- headers,
2437
- context
2438
- });
2439
- }
2440
-
2441
- /**
1339
+ * @returns {Promise<T.JSONResponse<T.LedgerDefinition>>} A promise that resolves with the response data
1340
+ */
1341
+ updateLedger({ auth, org, ledgerName, ledger, headers, context }: T.UpdateLedgerOptions): Promise<T.JSONResponse<T.LedgerDefinition>>;
1342
+ /**
2442
1343
  * Archives a ledger definition in the specified organization or sandbox by ledger name.
2443
1344
  *
2444
1345
  * @param {Object} options The options for archiving the ledger definition.
@@ -2448,22 +1349,13 @@ class Particle {
2448
1349
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2449
1350
  * @param {Object} [options.context] Request context.
2450
1351
  *
2451
- * @returns {Promise<RequestResponse>} A promise that resolves to an object confirming the ledger definition was archived.
2452
- */
2453
- archiveLedger({ auth, org, ledgerName, headers, context }) {
2454
- return this.delete({
2455
- uri: this._namespacedPath(org, `ledgers/${ledgerName}`),
2456
- auth,
2457
- headers,
2458
- context
2459
- });
2460
- }
2461
-
2462
- /**
1352
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
1353
+ */
1354
+ archiveLedger({ auth, org, ledgerName, headers, context }: T.ArchiveLedgerOptions): Promise<T.JSONResponse<T.OKResponse>>;
1355
+ /**
2463
1356
  * @typedef {"Owner" | "Product" | "Device"} Scope
2464
1357
  */
2465
-
2466
- /**
1358
+ /**
2467
1359
  * Lists all ledger definitions in the specified organization or sandbox.
2468
1360
  *
2469
1361
  * @param {Object} options The options for listing ledger definitions.
@@ -2476,24 +1368,12 @@ class Particle {
2476
1368
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2477
1369
  * @param {Object} [options.context] Request context.
2478
1370
  *
2479
- * @returns {Promise<RequestResponse>} A promise that resolves to an array of ledger definition data.
2480
- */
2481
- listLedgers({ auth, org, scope, page, perPage, archived, headers, context }) {
2482
- return this.get({
2483
- uri: this._namespacedPath(org, 'ledgers'),
2484
- query: {
2485
- scope,
2486
- page,
2487
- per_page: perPage,
2488
- archived
2489
- },
2490
- auth,
2491
- headers,
2492
- context
2493
- });
2494
- }
2495
-
2496
- /**
1371
+ * @returns {Promise<T.RequestResponse>} A promise that resolves to an array of ledger definition data.
1372
+ */
1373
+ listLedgers({ auth, org, scope, page, perPage, archived, headers, context }: T.ListLedgersOptions): Promise<T.JSONResponse<{
1374
+ ledger_definitions: T.LedgerDefinition[];
1375
+ }>>;
1376
+ /**
2497
1377
  * Get ledger instance data.
2498
1378
  *
2499
1379
  * @param {Object} options The options for the ledger instance.
@@ -2504,22 +1384,13 @@ class Particle {
2504
1384
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2505
1385
  * @param {Object} [options.context] Request context
2506
1386
  *
2507
- * @returns {Promise<RequestResponse>} A promise that resolves to the specified ledger instance data.
2508
- */
2509
- getLedgerInstance({ auth, org, ledgerName, scopeValue, headers, context }) {
2510
- return this.get({
2511
- uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances/${scopeValue}`),
2512
- auth,
2513
- headers,
2514
- context
2515
- });
2516
- }
2517
-
2518
- /**
1387
+ * @returns {Promise<T.JSONResponse<T.LedgerInstance>>} A promise that resolves with the response data
1388
+ */
1389
+ getLedgerInstance({ auth, org, ledgerName, scopeValue, headers, context }: T.GetLedgerInstanceOptions): Promise<T.JSONResponse<T.LedgerInstance>>;
1390
+ /**
2519
1391
  * @typedef {"Replace" | "Merge"} SetMode
2520
1392
  */
2521
-
2522
- /**
1393
+ /**
2523
1394
  * Set ledger instance data.
2524
1395
  *
2525
1396
  * @param {Object} options The options for updating the ledger instance.
@@ -2532,22 +1403,10 @@ class Particle {
2532
1403
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2533
1404
  * @param {Object} [options.context] Request context.
2534
1405
  *
2535
- * @returns {Promise<RequestResponse>} A promise that resolves to the updated ledger instance data.
2536
- */
2537
- setLedgerInstance({ auth, org, ledgerName, scopeValue, instance, setMode, headers, context }) {
2538
- return this.put({
2539
- uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances/${scopeValue}`),
2540
- query: {
2541
- set_mode: setMode
2542
- },
2543
- auth,
2544
- data: { instance },
2545
- headers,
2546
- context
2547
- });
2548
- }
2549
-
2550
- /**
1406
+ * @returns {Promise<T.JSONResponse<T.LedgerInstance>>} A promise that resolves with the response data
1407
+ */
1408
+ setLedgerInstance({ auth, org, ledgerName, scopeValue, instance, setMode, headers, context }: T.SetLedgerInstanceOptions): Promise<T.JSONResponse<T.LedgerInstance>>;
1409
+ /**
2551
1410
  * Delete a ledger instance in the specified organization or sandbox by ledger name.
2552
1411
  *
2553
1412
  * @param {Object} options The options for archiving the ledger instance.
@@ -2558,18 +1417,10 @@ class Particle {
2558
1417
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2559
1418
  * @param {Object} [options.context] Request context.
2560
1419
  *
2561
- * @returns {Promise<RequestResponse>} A promise that resolves to an object confirming the ledger instance was deleted.
2562
- */
2563
- deleteLedgerInstance({ auth, org, ledgerName, scopeValue, headers, context }) {
2564
- return this.delete({
2565
- uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances/${scopeValue}`),
2566
- auth,
2567
- headers,
2568
- context
2569
- });
2570
- }
2571
-
2572
- /**
1420
+ * @returns {Promise<T.JSONResponse<T.OKResponse>>} A promise that resolves with the response data
1421
+ */
1422
+ deleteLedgerInstance({ auth, org, ledgerName, scopeValue, headers, context }: T.DeleteLedgerInstanceOptions): Promise<T.JSONResponse<T.OKResponse>>;
1423
+ /**
2573
1424
  * Lists ledger instances in the specified organization or sandbox.
2574
1425
  *
2575
1426
  * @param {Object} options The options for listing ledger instances.
@@ -2581,22 +1432,10 @@ class Particle {
2581
1432
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2582
1433
  * @param {Object} [options.context] Request context.
2583
1434
  *
2584
- * @returns {Promise<RequestResponse>} A promise that resolves to an array of ledger instance data.
2585
- */
2586
- listLedgerInstances({ auth, org, ledgerName, page, perPage, headers, context }) {
2587
- return this.get({
2588
- uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances`),
2589
- query: {
2590
- page,
2591
- per_page: perPage
2592
- },
2593
- auth,
2594
- headers,
2595
- context
2596
- });
2597
- }
2598
-
2599
- /**
1435
+ * @returns {Promise<T.JSONResponse<T.LedgerInstanceListResponse>>} A promise that resolves with the response data
1436
+ */
1437
+ listLedgerInstances({ auth, org, ledgerName, page, perPage, headers, context }: T.ListLedgerInstancesOptions): Promise<T.JSONResponse<T.LedgerInstanceListResponse>>;
1438
+ /**
2600
1439
  * List ledger instance versions
2601
1440
  *
2602
1441
  * @param {Object} options The options for the ledger instance.
@@ -2609,22 +1448,10 @@ class Particle {
2609
1448
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2610
1449
  * @param {Object} [options.context] Request context
2611
1450
  *
2612
- * @returns {Promise<RequestResponse>} A promise that resolves to an array of ledger instance data.
2613
- */
2614
- listLedgerInstanceVersions({ auth, org, ledgerName, scopeValue, replacedBefore, replacedAfter, headers, context }) {
2615
- return this.get({
2616
- uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances/${scopeValue}/versions`),
2617
- query: {
2618
- replaced_before: replacedBefore,
2619
- replaced_after: replacedAfter
2620
- },
2621
- auth,
2622
- headers,
2623
- context
2624
- });
2625
- }
2626
-
2627
- /**
1451
+ * @returns {Promise<T.JSONResponse<T.LedgerVersionListResponse>>} A promise that resolves with the response data
1452
+ */
1453
+ listLedgerInstanceVersions({ auth, org, ledgerName, scopeValue, replacedBefore, replacedAfter, headers, context }: T.ListLedgerInstanceVersionsOptions): Promise<T.JSONResponse<T.LedgerVersionListResponse>>;
1454
+ /**
2628
1455
  * Get specific ledger instance version
2629
1456
  *
2630
1457
  * @param {Object} options The options for the ledger instance.
@@ -2636,18 +1463,10 @@ class Particle {
2636
1463
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2637
1464
  * @param {Object} [options.context] Request context
2638
1465
  *
2639
- * @returns {Promise<RequestResponse>} A promise that resolves to the specified ledger instance data.
2640
- */
2641
- getLedgerInstanceVersion({ auth, org, ledgerName, scopeValue, version, headers, context }) {
2642
- return this.get({
2643
- uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances/${scopeValue}/versions/${version}`),
2644
- auth,
2645
- headers,
2646
- context
2647
- });
2648
- }
2649
-
2650
- /**
1466
+ * @returns {Promise<T.JSONResponse<T.LedgerInstance>>} A promise that resolves with the response data
1467
+ */
1468
+ getLedgerInstanceVersion({ auth, org, ledgerName, scopeValue, version, headers, context }: T.GetLedgerInstanceVersionOptions): Promise<T.JSONResponse<T.LedgerInstance>>;
1469
+ /**
2651
1470
  * List Device OS versions
2652
1471
  *
2653
1472
  * @param {Object} options Options for this API call
@@ -2659,26 +1478,10 @@ class Particle {
2659
1478
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2660
1479
  * @param {Object} [options.context] Request context
2661
1480
  *
2662
- * @returns {Promise<RequestResponse>} A promise that resolves to the list of Device OS versions.
2663
- */
2664
- listDeviceOsVersions({ platformId, internalVersion, page, perPage, auth, headers, context }) {
2665
- const query = {
2666
- platform_id: platformId,
2667
- internal_version: internalVersion,
2668
- page,
2669
- per_page: perPage
2670
- };
2671
-
2672
- return this.get({
2673
- uri: '/v1/device-os/versions',
2674
- query,
2675
- auth,
2676
- headers,
2677
- context
2678
- });
2679
- }
2680
-
2681
- /**
1481
+ * @returns {Promise<T.JSONResponse<T.DeviceOsVersion[]>>} A promise that resolves with the response data
1482
+ */
1483
+ listDeviceOsVersions({ platformId, internalVersion, page, perPage, auth, headers, context }: T.ListDeviceOsVersionsOptions): Promise<T.JSONResponse<T.DeviceOsVersion[]>>;
1484
+ /**
2682
1485
  * Get a specific Device OS version
2683
1486
  *
2684
1487
  * @param {Object} options Options for this API call
@@ -2688,71 +1491,135 @@ class Particle {
2688
1491
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2689
1492
  * @param {Object} [options.context] Request context
2690
1493
  *
2691
- * @returns {Promise<RequestResponse>} A promise that resolves to the specified Device OS version data.
2692
- */
2693
- getDeviceOsVersion({ version, platformId, auth, headers, context }) {
2694
- const query = platformId ? { platform_id: platformId } : {};
2695
- return this.get({
2696
- uri: `/v1/device-os/versions/${version}`,
2697
- query,
2698
- auth,
2699
- headers,
2700
- context
2701
- });
2702
- }
2703
-
2704
- /**
1494
+ * @returns {Promise<T.JSONResponse<T.DeviceOsVersion>>} A promise that resolves with the response data
1495
+ */
1496
+ getDeviceOsVersion({ version, platformId, auth, headers, context }: T.GetDeviceOsVersionOptions): Promise<T.JSONResponse<T.DeviceOsVersion>>;
1497
+ /**
1498
+ * List environment variables for the given scope.
1499
+ *
1500
+ * @param {Object} options Options for this API call
1501
+ * @param {string} [options.product] Product ID or slug.
1502
+ * @param {string} [options.org] Organization ID or slug.
1503
+ * @param {string} [options.deviceId] Device ID.
1504
+ * @param {boolean} [options.sandbox] Set to `true` to target the user sandbox scope.
1505
+ * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1506
+ * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1507
+ * @param {Object} [options.context] Request context
1508
+ *
1509
+ * @returns {Promise<T.JSONResponse<T.EnvVarsResponse>>} A promise that resolves with the env vars data
1510
+ */
1511
+ listEnvVars({ product, org, deviceId, sandbox, auth, headers, context }: T.ListEnvVarsOptions): Promise<T.JSONResponse<T.EnvVarsResponse>>;
1512
+ /**
1513
+ * Bulk update environment variables with set/unset operations.
1514
+ *
1515
+ * @param {Object} options Options for this API call
1516
+ * @param {Array} options.ops Array of operations. Each op: `{ op: "Set", key: "KEY", value: "val" }` or `{ op: "Unset", key: "KEY" }`. Max 50.
1517
+ * @param {string} [options.product] Product ID or slug.
1518
+ * @param {string} [options.org] Organization ID or slug.
1519
+ * @param {string} [options.deviceId] Device ID.
1520
+ * @param {boolean} [options.sandbox] Set to `true` to target the user sandbox scope.
1521
+ * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1522
+ * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1523
+ * @param {Object} [options.context] Request context
1524
+ *
1525
+ * @returns {Promise<T.JSONResponse<T.EnvVarsResponse>>} A promise that resolves with the updated env vars data
1526
+ */
1527
+ updateEnvVars({ ops, product, org, deviceId, sandbox, auth, headers, context }: T.UpdateEnvVarsOptions): Promise<T.JSONResponse<T.EnvVarsResponse>>;
1528
+ /**
1529
+ * Set a single environment variable.
1530
+ *
1531
+ * @param {Object} options Options for this API call
1532
+ * @param {string} options.key Environment variable name.
1533
+ * @param {string} options.value Environment variable value.
1534
+ * @param {string} [options.product] Product ID or slug.
1535
+ * @param {string} [options.org] Organization ID or slug.
1536
+ * @param {string} [options.deviceId] Device ID.
1537
+ * @param {boolean} [options.sandbox] Set to `true` to target the user sandbox scope.
1538
+ * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1539
+ * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1540
+ * @param {Object} [options.context] Request context
1541
+ *
1542
+ * @returns {Promise<T.JSONResponse<T.EnvVarsResponse>>} A promise that resolves with the updated env vars data
1543
+ */
1544
+ setEnvVar({ key, value, product, org, deviceId, sandbox, auth, headers, context }: T.SetEnvVarOptions): Promise<T.JSONResponse<T.EnvVarsResponse>>;
1545
+ /**
1546
+ * Delete a single environment variable.
1547
+ *
1548
+ * @param {Object} options Options for this API call
1549
+ * @param {string} options.key Environment variable name to delete.
1550
+ * @param {string} [options.product] Product ID or slug.
1551
+ * @param {string} [options.org] Organization ID or slug.
1552
+ * @param {string} [options.deviceId] Device ID.
1553
+ * @param {boolean} [options.sandbox] Set to `true` to target the user sandbox scope.
1554
+ * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1555
+ * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1556
+ * @param {Object} [options.context] Request context
1557
+ *
1558
+ * @returns {Promise<T.JSONResponse<T.EnvVarsResponse>>} A promise that resolves with the updated env vars data
1559
+ */
1560
+ deleteEnvVar({ key, product, org, deviceId, sandbox, auth, headers, context }: T.DeleteEnvVarOptions): Promise<T.JSONResponse<T.EnvVarsResponse>>;
1561
+ /**
1562
+ * Get the rendered (flattened) environment variables for the given scope.
1563
+ *
1564
+ * @param {Object} options Options for this API call
1565
+ * @param {string} [options.product] Product ID or slug.
1566
+ * @param {string} [options.org] Organization ID or slug.
1567
+ * @param {string} [options.deviceId] Device ID.
1568
+ * @param {boolean} [options.sandbox] Set to `true` to target the user sandbox scope.
1569
+ * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1570
+ * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1571
+ * @param {Object} [options.context] Request context
1572
+ *
1573
+ * @returns {Promise<T.JSONResponse<T.EnvVarsRenderResponse>>} A promise that resolves with the rendered env vars
1574
+ */
1575
+ renderEnvVars({ product, org, deviceId, sandbox, auth, headers, context }: T.RenderEnvVarsOptions): Promise<T.JSONResponse<T.EnvVarsRenderResponse>>;
1576
+ /**
1577
+ * Review the pending environment variables rollout changes.
1578
+ *
1579
+ * @param {Object} options Options for this API call
1580
+ * @param {string} [options.product] Product ID or slug.
1581
+ * @param {string} [options.org] Organization ID or slug.
1582
+ * @param {string} [options.deviceId] Device ID.
1583
+ * @param {boolean} [options.sandbox] Set to `true` to target the user sandbox scope.
1584
+ * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1585
+ * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1586
+ * @param {Object} [options.context] Request context
1587
+ *
1588
+ * @returns {Promise<T.JSONResponse<T.EnvVarsRolloutResponse>>} A promise that resolves with the rollout diff
1589
+ */
1590
+ reviewEnvVarsRollout({ product, org, deviceId, sandbox, auth, headers, context }: T.ReviewEnvVarsRolloutOptions): Promise<T.JSONResponse<T.EnvVarsRolloutResponse>>;
1591
+ /**
1592
+ * Start rolling out environment variables to devices.
1593
+ *
1594
+ * @param {Object} options Options for this API call
1595
+ * @param {string} options.when When to apply: `"Immediate"` or `"Connect"`.
1596
+ * @param {string} [options.product] Product ID or slug.
1597
+ * @param {string} [options.org] Organization ID or slug.
1598
+ * @param {string} [options.deviceId] Device ID.
1599
+ * @param {boolean} [options.sandbox] Set to `true` to target the user sandbox scope.
1600
+ * @param {string} [options.auth] The access token. Can be ignored if provided in constructor
1601
+ * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1602
+ * @param {Object} [options.context] Request context
1603
+ *
1604
+ * @returns {Promise<T.JSONResponse<T.EnvVarsRolloutStartResponse>>} A promise that resolves with success status
1605
+ */
1606
+ startEnvVarsRollout({ when, product, org, deviceId, sandbox, auth, headers, context }: T.StartEnvVarsRolloutOptions): Promise<T.JSONResponse<T.EnvVarsRolloutStartResponse>>;
1607
+ /**
2705
1608
  * Set default auth token that will be used in each method if `auth` is not provided
2706
1609
  * @param {string} auth The access token
2707
1610
  * @throws {Error} When not auth string is provided
2708
1611
  */
2709
- setDefaultAuth(auth){
2710
- if (typeof auth === 'string' && auth.length !== 0) {
2711
- this._defaultAuth = auth;
2712
- } else {
2713
- throw new Error('Must pass a non-empty string representing an auth token!');
2714
- }
2715
- }
2716
- /**
2717
- * Return provided token if truthy else use default auth if truthy else undefined
2718
- * @param {any} auth Optional auth token or undefined
2719
- * @private
2720
- * @returns {String|undefined} a Particle auth token or undefined
2721
- */
2722
- _getActiveAuthToken(auth) {
2723
- return auth || this._defaultAuth;
2724
- }
2725
- /**
2726
- * API URI to access a device
2727
- * @param {Object} options Options for this API call
2728
- * @param {String} options.deviceId Device ID to access
2729
- * @param {String} [options.product] Device only in this product ID or slug
2730
- * @param {String} [options.org] Device only in this organization ID or slug
2731
- * @private
2732
- * @returns {string} URI
2733
- */
2734
- deviceUri({ deviceId, product, org }){
2735
- if (org) {
2736
- return `/v1/orgs/${org}/devices/${deviceId}`;
2737
- }
2738
- if (product) {
2739
- return `/v1/products/${product}/devices/${deviceId}`;
2740
- }
2741
- return `/v1/devices/${deviceId}`;
2742
- }
2743
-
2744
- /**
2745
- * Helper for building API paths that support sandbox and org prefixes based on org presence
2746
- * @param {string | undefined} org slug or ID
2747
- * @param {string} path will be appended to the end of the org/sandbox prefix
2748
- * @returns {string} the full combined path
2749
- * @private
2750
- */
2751
- _namespacedPath(org, path) {
2752
- return org ? `/v1/orgs/${org}/${path}` : `/v1/${path}`;
2753
- }
2754
-
2755
- /**
1612
+ setDefaultAuth(auth: string): void;
1613
+ private _getActiveAuthToken;
1614
+ /** @internal */
1615
+ deviceUri({ deviceId, product, org }: {
1616
+ deviceId: string;
1617
+ product?: string | number;
1618
+ org?: string;
1619
+ }): string;
1620
+ private _namespacedPath;
1621
+ private _envVarUri;
1622
+ /**
2756
1623
  * Make a GET request
2757
1624
  * @param {object} params
2758
1625
  * @param {string} params.uri The URI to request
@@ -2760,15 +1627,10 @@ class Particle {
2760
1627
  * @param {object} [params.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2761
1628
  * @param {object} [params.query] Key/Value pairs of query params or a correctly formatted string
2762
1629
  * @param {object} [params.context] The invocation context, describing the tool and project
2763
- * @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
2764
- */
2765
- get({ uri, auth, headers, query, context }){
2766
- context = this._buildContext(context);
2767
- auth = this._getActiveAuthToken(auth);
2768
- return this.agent.get({ uri, auth, headers, query, context });
2769
- }
2770
-
2771
- /**
1630
+ * @returns {Promise<T.JSONResponse<T>>} A promise that resolves with the response data
1631
+ */
1632
+ get<T = object>({ uri, auth, headers, query, context }: T.GetHeadOptions): Promise<T.JSONResponse<T>>;
1633
+ /**
2772
1634
  * Make a HEAD request
2773
1635
  * @param {object} params
2774
1636
  * @param {string} params.uri The URI to request
@@ -2776,15 +1638,10 @@ class Particle {
2776
1638
  * @param {object} [params.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2777
1639
  * @param {object} [params.query] Key/Value pairs of query params or a correctly formatted string
2778
1640
  * @param {object} [params.context] The invocation context, describing the tool and project
2779
- * @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
2780
- */
2781
- head({ uri, auth, headers, query, context }){
2782
- context = this._buildContext(context);
2783
- auth = this._getActiveAuthToken(auth);
2784
- return this.agent.head({ uri, auth, headers, query, context });
2785
- }
2786
-
2787
- /**
1641
+ * @returns {Promise<T.JSONResponse<T>>} A promise that resolves with the response data
1642
+ */
1643
+ head<T = object>({ uri, auth, headers, query, context }: T.GetHeadOptions): Promise<T.JSONResponse<T>>;
1644
+ /**
2788
1645
  * Make a POST request
2789
1646
  * @param {object} params
2790
1647
  * @param {string} params.uri The URI to request
@@ -2792,15 +1649,10 @@ class Particle {
2792
1649
  * @param {object} [params.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2793
1650
  * @param {object} [params.data] Object to send as JSON data in the body.
2794
1651
  * @param {object} [params.context] The invocation context, describing the tool and project
2795
- * @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
2796
- */
2797
- post({ uri, auth, headers, data, context }){
2798
- context = this._buildContext(context);
2799
- auth = this._getActiveAuthToken(auth);
2800
- return this.agent.post({ uri, auth, headers, data, context });
2801
- }
2802
-
2803
- /**
1652
+ * @returns {Promise<T.JSONResponse<T>>} A promise that resolves with the response data
1653
+ */
1654
+ post<T = object>({ uri, auth, headers, data, context }: T.MutateOptions): Promise<T.JSONResponse<T>>;
1655
+ /**
2804
1656
  * Make a PUT request
2805
1657
  * @param {object} params
2806
1658
  * @param {string} params.uri The URI to request
@@ -2809,15 +1661,21 @@ class Particle {
2809
1661
  * @param {object} [params.data] Object to send as JSON data in the body.
2810
1662
  * @param {object} [params.query] Key/Value pairs of query params or a correctly formatted string
2811
1663
  * @param {object} [params.context] The invocation context, describing the tool and project
2812
- * @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
2813
- */
2814
- put({ uri, auth, headers, data, query, context }){
2815
- context = this._buildContext(context);
2816
- auth = this._getActiveAuthToken(auth);
2817
- return this.agent.put({ uri, auth, headers, data, query, context });
2818
- }
2819
-
2820
- /**
1664
+ * @returns {Promise<T.JSONResponse<T>>} A promise that resolves with the response data
1665
+ */
1666
+ put<T = object>({ uri, auth, headers, data, query, context }: T.MutateOptions): Promise<T.JSONResponse<T>>;
1667
+ /**
1668
+ * Make a PATCH request
1669
+ * @param {object} params
1670
+ * @param {string} params.uri The URI to request
1671
+ * @param {string} [params.auth] Authorization token to use
1672
+ * @param {object} [params.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
1673
+ * @param {object} [params.data] Object to send as JSON data in the body.
1674
+ * @param {object} [params.context] The invocation context, describing the tool and project
1675
+ * @returns {Promise<T.JSONResponse<T>>} A promise that resolves with the response data
1676
+ */
1677
+ patch<T = object>({ uri, auth, headers, data, context }: T.MutateOptions): Promise<T.JSONResponse<T>>;
1678
+ /**
2821
1679
  * Make a DELETE request
2822
1680
  * @param {object} params
2823
1681
  * @param {string} params.uri The URI to request
@@ -2825,15 +1683,10 @@ class Particle {
2825
1683
  * @param {object} [params.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2826
1684
  * @param {object} [params.data] Object to send as JSON data in the body.
2827
1685
  * @param {object} [params.context] The invocation context, describing the tool and project
2828
- * @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
1686
+ * @returns {Promise<T.JSONResponse<T>>} A promise that resolves with the response data
2829
1687
  */
2830
- delete({ uri, auth, headers, data, context }){
2831
- context = this._buildContext(context);
2832
- auth = this._getActiveAuthToken(auth);
2833
- return this.agent.delete({ uri, auth, headers, data, context });
2834
- }
2835
-
2836
- /**
1688
+ delete<T = object>({ uri, auth, headers, data, context }: T.MutateOptions): Promise<T.JSONResponse<T>>;
1689
+ /**
2837
1690
  *
2838
1691
  * @param {Object} args An obj with all the possible request configurations
2839
1692
  * @param {String} args.uri The URI to request
@@ -2846,24 +1699,15 @@ class Particle {
2846
1699
  * @param {Object} [args.files] Array of file names and file content
2847
1700
  * @param {Object} [args.context] The invocation context, describing the tool and project.
2848
1701
  * @param {boolean} [args.isBuffer] Indicate if the response should be treated as Buffer instead of JSON
2849
- * @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
2850
- */
2851
- request(args){
2852
- args.context = this._buildContext(args.context);
2853
- args.auth = this._getActiveAuthToken(args.auth);
2854
- return this.agent.request(args);
2855
- }
2856
-
2857
- client(options = {}){
2858
- // @ts-ignore
2859
- return new Client(Object.assign({ api: this }, options));
2860
- }
2861
-
2862
- // Internal method used to target Particle's APIs other than the default
2863
- setBaseUrl(baseUrl){
2864
- this.baseUrl = baseUrl;
2865
- this.agent.setBaseUrl(baseUrl);
2866
- }
1702
+ * @returns {Promise<T.RequestResponse>} A promise that resolves with the response data
1703
+ */
1704
+ request(args: T.AgentRequestOptions): Promise<T.RequestResponse>;
1705
+ /** @internal */
1706
+ client(options?: {
1707
+ auth?: string;
1708
+ }): Client;
1709
+ /** @internal */
1710
+ setBaseUrl(baseUrl: string): void;
2867
1711
  }
2868
-
2869
- module.exports = Particle;
1712
+ export = Particle;
1713
+ //# sourceMappingURL=Particle.d.ts.map