particle-api-js 11.1.6 → 12.0.0

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