particle-api-js 10.1.0 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/particle.min.js +1 -1
- package/dist/particle.min.js.map +1 -1
- package/docs/api.md +663 -603
- package/package.json +1 -1
- package/src/Particle.js +121 -86
- package/test/Particle.spec.js +84 -47
package/package.json
CHANGED
package/src/Particle.js
CHANGED
|
@@ -2115,48 +2115,72 @@ class Particle {
|
|
|
2115
2115
|
}
|
|
2116
2116
|
|
|
2117
2117
|
/**
|
|
2118
|
-
*
|
|
2118
|
+
* Executes the provided logic function once and returns the result. No logs, runs, etc are saved
|
|
2119
2119
|
*
|
|
2120
|
-
*
|
|
2121
|
-
* start being handled by the block code.
|
|
2120
|
+
* NOTE: Any external interactions such as Particle.publish will actually occur when the logic is executed.
|
|
2122
2121
|
*
|
|
2123
|
-
*
|
|
2122
|
+
* @param {Object} options The options for creating the logic function.
|
|
2123
|
+
* @param {Object} options.auth Access token
|
|
2124
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2125
|
+
* @param {string} options.logic The logic "function" which will be executed once
|
|
2126
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2127
|
+
* @param {Object} [options.context] Request context
|
|
2128
|
+
*
|
|
2129
|
+
* @returns {Promise<RequestResponse>} A promise that resolves to the created logic function data.
|
|
2130
|
+
*/
|
|
2131
|
+
executeLogic({ auth, org, logic, headers, context }) {
|
|
2132
|
+
return this.post({
|
|
2133
|
+
uri: this._namespacedPath(org, 'logic/execute'),
|
|
2134
|
+
auth,
|
|
2135
|
+
data: logic,
|
|
2136
|
+
headers,
|
|
2137
|
+
context
|
|
2138
|
+
});
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
/**
|
|
2142
|
+
* Creates a new logic function in the specified organization or sandbox using the provided function data.
|
|
2143
|
+
*
|
|
2144
|
+
* When you create a logic function with Event logic triggers, events will immediately
|
|
2145
|
+
* start being handled by the function code.
|
|
2146
|
+
*
|
|
2147
|
+
* When you create a Scheduled logic trigger, it will immediately be scheduled at the next time
|
|
2124
2148
|
* according to the cron and start_at properties.
|
|
2125
2149
|
*
|
|
2126
|
-
* @param {Object} options The options for creating the logic
|
|
2150
|
+
* @param {Object} options The options for creating the logic function.
|
|
2127
2151
|
* @param {Object} options.auth Access token
|
|
2128
|
-
* @param {string} options.org The
|
|
2129
|
-
* @param {string} options.
|
|
2152
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2153
|
+
* @param {string} options.logicFunction The logic function object containing the function details.
|
|
2130
2154
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2131
2155
|
* @param {Object} [options.context] Request context
|
|
2132
2156
|
*
|
|
2133
|
-
* @returns {Promise<RequestResponse>} A promise that resolves to the created logic
|
|
2157
|
+
* @returns {Promise<RequestResponse>} A promise that resolves to the created logic function data.
|
|
2134
2158
|
*/
|
|
2135
|
-
|
|
2159
|
+
createLogicFunction({ auth, org, logicFunction, headers, context }) {
|
|
2136
2160
|
return this.post({
|
|
2137
|
-
uri:
|
|
2161
|
+
uri: this._namespacedPath(org, 'logic/functions'),
|
|
2138
2162
|
auth,
|
|
2139
|
-
data: {
|
|
2163
|
+
data: { logic_function: logicFunction },
|
|
2140
2164
|
headers,
|
|
2141
2165
|
context
|
|
2142
2166
|
});
|
|
2143
2167
|
}
|
|
2144
2168
|
|
|
2145
2169
|
/**
|
|
2146
|
-
* Get a logic
|
|
2170
|
+
* Get a logic function in the specified organization or sandbox by logic function ID.
|
|
2147
2171
|
*
|
|
2148
|
-
* @param {Object} options The options for the logic
|
|
2172
|
+
* @param {Object} options The options for the logic function.
|
|
2149
2173
|
* @param {Object} options.auth Access token
|
|
2150
|
-
* @param {string} options.org The
|
|
2151
|
-
* @param {string} options.
|
|
2174
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2175
|
+
* @param {string} options.logicFunctionId The ID of the logic function to retrieve.
|
|
2152
2176
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2153
2177
|
* @param {Object} [options.context] Request context
|
|
2154
2178
|
*
|
|
2155
|
-
* @returns {Promise<RequestResponse>} A promise that resolves to the specified logic
|
|
2179
|
+
* @returns {Promise<RequestResponse>} A promise that resolves to the specified logic function data.
|
|
2156
2180
|
*/
|
|
2157
|
-
|
|
2181
|
+
getLogicFunction({ auth, org, logicFunctionId, headers, context }) {
|
|
2158
2182
|
return this.get({
|
|
2159
|
-
uri:
|
|
2183
|
+
uri: this._namespacedPath(org, `logic/functions/${logicFunctionId}`),
|
|
2160
2184
|
auth,
|
|
2161
2185
|
headers,
|
|
2162
2186
|
context
|
|
@@ -2164,45 +2188,45 @@ class Particle {
|
|
|
2164
2188
|
}
|
|
2165
2189
|
|
|
2166
2190
|
/**
|
|
2167
|
-
* Updates an existing logic
|
|
2191
|
+
* Updates an existing logic function in the specified organization or sandbox using the provided function data.
|
|
2168
2192
|
*
|
|
2169
|
-
* If you include an id on a
|
|
2193
|
+
* If you include an id on a logic trigger, it will update the logic trigger in place.
|
|
2170
2194
|
*
|
|
2171
|
-
* @param {Object} options The options for updating the logic
|
|
2195
|
+
* @param {Object} options The options for updating the logic function.
|
|
2172
2196
|
* @param {Object} options.auth The authentication object with the API key.
|
|
2173
|
-
* @param {string} options.org
|
|
2174
|
-
* @param {string} options.
|
|
2175
|
-
* @param {string} options.
|
|
2197
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2198
|
+
* @param {string} options.logicFunctionId The ID of the logic function to update.
|
|
2199
|
+
* @param {string} options.logicFunction The logic function object containing the logic function details.
|
|
2176
2200
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2177
2201
|
* @param {Object} [options.context] Request context.
|
|
2178
2202
|
*
|
|
2179
|
-
* @returns {Promise<RequestResponse>} A promise that resolves to the updated logic
|
|
2203
|
+
* @returns {Promise<RequestResponse>} A promise that resolves to the updated logic function data.
|
|
2180
2204
|
*/
|
|
2181
|
-
|
|
2205
|
+
updateLogicFunction({ auth, org, logicFunctionId, logicFunction, headers, context }) {
|
|
2182
2206
|
return this.put({
|
|
2183
|
-
uri:
|
|
2207
|
+
uri: this._namespacedPath(org, `logic/functions/${logicFunctionId}`),
|
|
2184
2208
|
auth,
|
|
2185
|
-
data: {
|
|
2209
|
+
data: { logic_function: logicFunction },
|
|
2186
2210
|
headers,
|
|
2187
2211
|
context
|
|
2188
2212
|
});
|
|
2189
2213
|
}
|
|
2190
2214
|
|
|
2191
2215
|
/**
|
|
2192
|
-
* Deletes a logic
|
|
2216
|
+
* Deletes a logic function in the specified organization or sandbox by logic function ID.
|
|
2193
2217
|
*
|
|
2194
|
-
* @param {Object} options The options for deleting the logic
|
|
2218
|
+
* @param {Object} options The options for deleting the logic function.
|
|
2195
2219
|
* @param {Object} options.auth The authentication object with the API key.
|
|
2196
|
-
* @param {string} options.org
|
|
2197
|
-
* @param {string} options.
|
|
2220
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2221
|
+
* @param {string} options.logicFunctionId The ID of the logic function to delete.
|
|
2198
2222
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2199
2223
|
* @param {Object} [options.context] Request context.
|
|
2200
2224
|
*
|
|
2201
|
-
* @returns {Promise<RequestResponse>} A promise that resolves to an object containing the deleted
|
|
2225
|
+
* @returns {Promise<RequestResponse>} A promise that resolves to an object containing the deleted logic function ID.
|
|
2202
2226
|
*/
|
|
2203
|
-
|
|
2227
|
+
deleteLogicFunction({ auth, org, logicFunctionId, headers, context }) {
|
|
2204
2228
|
return this.delete({
|
|
2205
|
-
uri:
|
|
2229
|
+
uri: this._namespacedPath(org, `logic/functions/${logicFunctionId}`),
|
|
2206
2230
|
auth,
|
|
2207
2231
|
headers,
|
|
2208
2232
|
context
|
|
@@ -2210,19 +2234,19 @@ class Particle {
|
|
|
2210
2234
|
}
|
|
2211
2235
|
|
|
2212
2236
|
/**
|
|
2213
|
-
* Lists all logic
|
|
2237
|
+
* Lists all logic functions in the specified organization or sandbox.
|
|
2214
2238
|
*
|
|
2215
|
-
* @param {Object} options The options for listing logic
|
|
2239
|
+
* @param {Object} options The options for listing logic functions.
|
|
2216
2240
|
* @param {Object} options.auth The authentication object with the API key.
|
|
2217
|
-
* @param {string} options.org
|
|
2241
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2218
2242
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2219
2243
|
* @param {Object} [options.context] Request context.
|
|
2220
2244
|
*
|
|
2221
|
-
* @returns {Promise<RequestResponse>} A promise that resolves to an array of logic
|
|
2245
|
+
* @returns {Promise<RequestResponse>} A promise that resolves to an array of logic functions data.
|
|
2222
2246
|
*/
|
|
2223
|
-
|
|
2247
|
+
listLogicFunctions({ auth, org, headers, context }) {
|
|
2224
2248
|
return this.get({
|
|
2225
|
-
uri:
|
|
2249
|
+
uri: this._namespacedPath(org, 'logic/functions'),
|
|
2226
2250
|
auth,
|
|
2227
2251
|
headers,
|
|
2228
2252
|
context
|
|
@@ -2230,20 +2254,20 @@ class Particle {
|
|
|
2230
2254
|
}
|
|
2231
2255
|
|
|
2232
2256
|
/**
|
|
2233
|
-
* Lists all
|
|
2257
|
+
* Lists all logic runs for the specified logic function in the specified organization or sandbox.
|
|
2234
2258
|
*
|
|
2235
2259
|
* @param {Object} options The options for the request.
|
|
2236
2260
|
* @param {Object} options.auth Access token
|
|
2237
|
-
* @param {string} options.org
|
|
2238
|
-
* @param {number} options.
|
|
2261
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2262
|
+
* @param {number} options.logicFunctionId The ID of the logic function for which to retrieve the logic runs.
|
|
2239
2263
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2240
2264
|
* @param {Object} [options.context] Request context
|
|
2241
2265
|
*
|
|
2242
|
-
* @returns {Promise<RequestResponse>} A promise that resolves to an array of
|
|
2266
|
+
* @returns {Promise<RequestResponse>} A promise that resolves to an array of logic run data.
|
|
2243
2267
|
*/
|
|
2244
|
-
|
|
2268
|
+
listLogicRuns({ auth, org, logicFunctionId, headers, context }) {
|
|
2245
2269
|
return this.get({
|
|
2246
|
-
uri:
|
|
2270
|
+
uri: this._namespacedPath(org, `logic/functions/${logicFunctionId}/runs`),
|
|
2247
2271
|
auth,
|
|
2248
2272
|
headers,
|
|
2249
2273
|
context
|
|
@@ -2251,21 +2275,21 @@ class Particle {
|
|
|
2251
2275
|
}
|
|
2252
2276
|
|
|
2253
2277
|
/**
|
|
2254
|
-
* Retrieves a
|
|
2278
|
+
* Retrieves a logic run by its ID for the specified logic function in the specified organization or sandbox.
|
|
2255
2279
|
*
|
|
2256
2280
|
* @param {Object} options The options for the request.
|
|
2257
2281
|
* @param {Object} options.auth Access token
|
|
2258
|
-
* @param {string} options.org
|
|
2259
|
-
* @param {number} options.
|
|
2260
|
-
* @param {number} options.
|
|
2282
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2283
|
+
* @param {number} options.logicFunctionId The ID of the logic function for which to retrieve the logic run.
|
|
2284
|
+
* @param {number} options.logicRunId The ID of the logic run to retrieve.
|
|
2261
2285
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2262
2286
|
* @param {Object} [options.context] Request context
|
|
2263
2287
|
*
|
|
2264
|
-
* @returns {Promise<RequestResponse>} A promise that resolves to an array of
|
|
2288
|
+
* @returns {Promise<RequestResponse>} A promise that resolves to an array of logic run data for the specified logic run ID.
|
|
2265
2289
|
*/
|
|
2266
|
-
|
|
2290
|
+
getLogicRun({ auth, org, logicFunctionId, logicRunId, headers, context }) {
|
|
2267
2291
|
return this.get({
|
|
2268
|
-
uri:
|
|
2292
|
+
uri: this._namespacedPath(org, `logic/functions/${logicFunctionId}/runs/${logicRunId}`),
|
|
2269
2293
|
auth,
|
|
2270
2294
|
headers,
|
|
2271
2295
|
context
|
|
@@ -2273,21 +2297,21 @@ class Particle {
|
|
|
2273
2297
|
}
|
|
2274
2298
|
|
|
2275
2299
|
/**
|
|
2276
|
-
* Retrieves the logs for a
|
|
2300
|
+
* Retrieves the logs for a logic run by its ID for the specified logic function in the specified organization or sandbox.
|
|
2277
2301
|
*
|
|
2278
2302
|
* @param {Object} options The options for the request.
|
|
2279
2303
|
* @param {Object} options.auth Access token
|
|
2280
|
-
* @param {string} options.org The unique identifier of the organization.
|
|
2281
|
-
* @param {number} options.
|
|
2282
|
-
* @param {number} options.
|
|
2304
|
+
* @param {string | undefined} options.org The unique identifier of the organization.
|
|
2305
|
+
* @param {number} options.logicFunctionId The ID of the logic function for which to retrieve the logic run logs.
|
|
2306
|
+
* @param {number} options.logicRunId The ID of the logic run for which to retrieve the logs.
|
|
2283
2307
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2284
2308
|
* @param {Object} [options.context] Request context
|
|
2285
2309
|
*
|
|
2286
|
-
* @returns {Promise<RequestResponse>} A promise that resolves to the logs for the specified
|
|
2310
|
+
* @returns {Promise<RequestResponse>} A promise that resolves to the logs for the specified logic run ID.
|
|
2287
2311
|
*/
|
|
2288
|
-
|
|
2312
|
+
getLogicRunLogs({ auth, org, logicFunctionId, logicRunId, headers, context }) {
|
|
2289
2313
|
return this.get({
|
|
2290
|
-
uri:
|
|
2314
|
+
uri: this._namespacedPath(org, `logic/functions/${logicFunctionId}/runs/${logicRunId}/logs`),
|
|
2291
2315
|
auth,
|
|
2292
2316
|
headers,
|
|
2293
2317
|
context
|
|
@@ -2295,11 +2319,11 @@ class Particle {
|
|
|
2295
2319
|
}
|
|
2296
2320
|
|
|
2297
2321
|
/**
|
|
2298
|
-
* Creates a new ledger definition in the specified organization.
|
|
2322
|
+
* Creates a new ledger definition in the specified organization or sandbox.
|
|
2299
2323
|
*
|
|
2300
2324
|
* @param {Object} options The options for creating the ledger definition.
|
|
2301
2325
|
* @param {Object} options.auth Access token
|
|
2302
|
-
* @param {string} options.org The
|
|
2326
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2303
2327
|
* @param {object} options.definition The ledger definition object.
|
|
2304
2328
|
* @param {object} options.ledger The ledger definition object.
|
|
2305
2329
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
@@ -2309,7 +2333,7 @@ class Particle {
|
|
|
2309
2333
|
*/
|
|
2310
2334
|
createLedger({ auth, org, ledger, headers, context }) {
|
|
2311
2335
|
return this.post({
|
|
2312
|
-
uri:
|
|
2336
|
+
uri: this._namespacedPath(org, 'ledgers'),
|
|
2313
2337
|
auth,
|
|
2314
2338
|
data: { ledger },
|
|
2315
2339
|
headers,
|
|
@@ -2318,11 +2342,11 @@ class Particle {
|
|
|
2318
2342
|
}
|
|
2319
2343
|
|
|
2320
2344
|
/**
|
|
2321
|
-
* Get a ledger definition in the specified organization by ledger name.
|
|
2345
|
+
* Get a ledger definition in the specified organization or sandbox by ledger name.
|
|
2322
2346
|
*
|
|
2323
2347
|
* @param {Object} options The options for the ledger definition.
|
|
2324
2348
|
* @param {Object} options.auth Access token
|
|
2325
|
-
* @param {string} options.org The
|
|
2349
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2326
2350
|
* @param {string} options.ledgerName The ID of the ledger definition to retrieve.
|
|
2327
2351
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2328
2352
|
* @param {Object} [options.context] Request context
|
|
@@ -2331,7 +2355,7 @@ class Particle {
|
|
|
2331
2355
|
*/
|
|
2332
2356
|
getLedger({ auth, org, ledgerName, headers, context }) {
|
|
2333
2357
|
return this.get({
|
|
2334
|
-
uri:
|
|
2358
|
+
uri: this._namespacedPath(org, `ledgers/${ledgerName}`),
|
|
2335
2359
|
auth,
|
|
2336
2360
|
headers,
|
|
2337
2361
|
context
|
|
@@ -2339,11 +2363,11 @@ class Particle {
|
|
|
2339
2363
|
}
|
|
2340
2364
|
|
|
2341
2365
|
/**
|
|
2342
|
-
* Updates an existing ledger definition in the specified organization.
|
|
2366
|
+
* Updates an existing ledger definition in the specified organization or sandbox.
|
|
2343
2367
|
*
|
|
2344
2368
|
* @param {Object} options The options for updating the ledger definition.
|
|
2345
2369
|
* @param {Object} options.auth The authentication object with the API key.
|
|
2346
|
-
* @param {string} options.org
|
|
2370
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2347
2371
|
* @param {string} options.ledgerName Name of the ledger definition to update.
|
|
2348
2372
|
* @param {object} options.ledger The ledger definition object.
|
|
2349
2373
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
@@ -2353,7 +2377,7 @@ class Particle {
|
|
|
2353
2377
|
*/
|
|
2354
2378
|
updateLedger({ auth, org, ledgerName, ledger, headers, context }) {
|
|
2355
2379
|
return this.put({
|
|
2356
|
-
uri:
|
|
2380
|
+
uri: this._namespacedPath(org, `ledgers/${ledgerName}`),
|
|
2357
2381
|
auth,
|
|
2358
2382
|
data: { ledger },
|
|
2359
2383
|
headers,
|
|
@@ -2362,11 +2386,11 @@ class Particle {
|
|
|
2362
2386
|
}
|
|
2363
2387
|
|
|
2364
2388
|
/**
|
|
2365
|
-
* Archives a ledger definition in the specified organization by ledger name.
|
|
2389
|
+
* Archives a ledger definition in the specified organization or sandbox by ledger name.
|
|
2366
2390
|
*
|
|
2367
2391
|
* @param {Object} options The options for archiving the ledger definition.
|
|
2368
2392
|
* @param {Object} options.auth The authentication object with the API key.
|
|
2369
|
-
* @param {string} options.org
|
|
2393
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2370
2394
|
* @param {string} options.ledgerName Name of the ledger definition to archive.
|
|
2371
2395
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2372
2396
|
* @param {Object} [options.context] Request context.
|
|
@@ -2375,7 +2399,7 @@ class Particle {
|
|
|
2375
2399
|
*/
|
|
2376
2400
|
archiveLedger({ auth, org, ledgerName, headers, context }) {
|
|
2377
2401
|
return this.delete({
|
|
2378
|
-
uri:
|
|
2402
|
+
uri: this._namespacedPath(org, `ledgers/${ledgerName}`),
|
|
2379
2403
|
auth,
|
|
2380
2404
|
headers,
|
|
2381
2405
|
context
|
|
@@ -2383,11 +2407,11 @@ class Particle {
|
|
|
2383
2407
|
}
|
|
2384
2408
|
|
|
2385
2409
|
/**
|
|
2386
|
-
* Lists all ledger definitions in the specified organization.
|
|
2410
|
+
* Lists all ledger definitions in the specified organization or sandbox.
|
|
2387
2411
|
*
|
|
2388
2412
|
* @param {Object} options The options for listing ledger definitions.
|
|
2389
2413
|
* @param {Object} options.auth The authentication object with the API key.
|
|
2390
|
-
* @param {string} options.org
|
|
2414
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2391
2415
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2392
2416
|
* @param {Object} [options.context] Request context.
|
|
2393
2417
|
*
|
|
@@ -2395,7 +2419,7 @@ class Particle {
|
|
|
2395
2419
|
*/
|
|
2396
2420
|
listLedgers({ auth, org, headers, context }) {
|
|
2397
2421
|
return this.get({
|
|
2398
|
-
uri:
|
|
2422
|
+
uri: this._namespacedPath(org, 'ledgers'),
|
|
2399
2423
|
auth,
|
|
2400
2424
|
headers,
|
|
2401
2425
|
context
|
|
@@ -2407,7 +2431,7 @@ class Particle {
|
|
|
2407
2431
|
*
|
|
2408
2432
|
* @param {Object} options The options for the ledger instance.
|
|
2409
2433
|
* @param {Object} options.auth Access token
|
|
2410
|
-
* @param {string} options.org The
|
|
2434
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2411
2435
|
* @param {string} options.ledgerName Ledger name.
|
|
2412
2436
|
* @param {string} options.scopeValue Scope value.
|
|
2413
2437
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
@@ -2417,7 +2441,7 @@ class Particle {
|
|
|
2417
2441
|
*/
|
|
2418
2442
|
getLedgerInstance({ auth, org, ledgerName, scopeValue, headers, context }) {
|
|
2419
2443
|
return this.get({
|
|
2420
|
-
uri:
|
|
2444
|
+
uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances/${scopeValue}`),
|
|
2421
2445
|
auth,
|
|
2422
2446
|
headers,
|
|
2423
2447
|
context
|
|
@@ -2429,7 +2453,7 @@ class Particle {
|
|
|
2429
2453
|
*
|
|
2430
2454
|
* @param {Object} options The options for updating the ledger instance.
|
|
2431
2455
|
* @param {Object} options.auth The authentication object with the API key.
|
|
2432
|
-
* @param {string} options.org
|
|
2456
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2433
2457
|
* @param {string} options.ledgerName Ledger name.
|
|
2434
2458
|
* @param {string} options.scopeValue Scope value.
|
|
2435
2459
|
* @param {object} options.instance The ledger instance object.
|
|
@@ -2441,7 +2465,7 @@ class Particle {
|
|
|
2441
2465
|
*/
|
|
2442
2466
|
setLedgerInstance({ auth, org, ledgerName, scopeValue, data, headers, context }) {
|
|
2443
2467
|
return this.put({
|
|
2444
|
-
uri:
|
|
2468
|
+
uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances/${scopeValue}`),
|
|
2445
2469
|
auth,
|
|
2446
2470
|
data: { data },
|
|
2447
2471
|
headers,
|
|
@@ -2450,11 +2474,11 @@ class Particle {
|
|
|
2450
2474
|
}
|
|
2451
2475
|
|
|
2452
2476
|
/**
|
|
2453
|
-
* Delete a ledger instance in the specified organization by ledger name.
|
|
2477
|
+
* Delete a ledger instance in the specified organization or sandbox by ledger name.
|
|
2454
2478
|
*
|
|
2455
2479
|
* @param {Object} options The options for archiving the ledger instance.
|
|
2456
2480
|
* @param {Object} options.auth The authentication object with the API key.
|
|
2457
|
-
* @param {string} options.org
|
|
2481
|
+
* @param {string | undefined} options.org The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2458
2482
|
* @param {string} options.ledgerName Name of the ledger instance to archive.
|
|
2459
2483
|
* @param {string} options.scopeValue Scope value.
|
|
2460
2484
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
@@ -2464,7 +2488,7 @@ class Particle {
|
|
|
2464
2488
|
*/
|
|
2465
2489
|
deleteLedgerInstance({ auth, org, ledgerName, scopeValue, headers, context }) {
|
|
2466
2490
|
return this.delete({
|
|
2467
|
-
uri:
|
|
2491
|
+
uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances/${scopeValue}`),
|
|
2468
2492
|
auth,
|
|
2469
2493
|
headers,
|
|
2470
2494
|
context
|
|
@@ -2472,11 +2496,11 @@ class Particle {
|
|
|
2472
2496
|
}
|
|
2473
2497
|
|
|
2474
2498
|
/**
|
|
2475
|
-
* Lists ledger instances.
|
|
2499
|
+
* Lists ledger instances in the specified organization or sandbox.
|
|
2476
2500
|
*
|
|
2477
2501
|
* @param {Object} options The options for listing ledger instances.
|
|
2478
2502
|
* @param {Object} options.auth The authentication object with the API key.
|
|
2479
|
-
* @param {string} options.org
|
|
2503
|
+
* @param {string} [options.org] The unique identifier of the organization.
|
|
2480
2504
|
* @param {string} options.ledgerName Name of the ledger instance to archive.
|
|
2481
2505
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2482
2506
|
* @param {Object} [options.context] Request context.
|
|
@@ -2485,7 +2509,7 @@ class Particle {
|
|
|
2485
2509
|
*/
|
|
2486
2510
|
listLedgerInstances({ auth, org, ledgerName, headers, context }) {
|
|
2487
2511
|
return this.get({
|
|
2488
|
-
uri:
|
|
2512
|
+
uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances`),
|
|
2489
2513
|
auth,
|
|
2490
2514
|
headers,
|
|
2491
2515
|
context
|
|
@@ -2525,6 +2549,17 @@ class Particle {
|
|
|
2525
2549
|
return product ? `/v1/products/${product}/devices/${deviceId}` : `/v1/devices/${deviceId}`;
|
|
2526
2550
|
}
|
|
2527
2551
|
|
|
2552
|
+
/**
|
|
2553
|
+
* Helper for building API paths that support sandbox and org prefixes based on org presence
|
|
2554
|
+
* @param {string | undefined} org slug or ID
|
|
2555
|
+
* @param {string} path will be appended to the end of the org/sandbox prefix
|
|
2556
|
+
* @returns {string} the full combined path
|
|
2557
|
+
* @private
|
|
2558
|
+
*/
|
|
2559
|
+
_namespacedPath(org, path) {
|
|
2560
|
+
return org ? `/v1/orgs/${org}/${path}` : `/v1/${path}`;
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2528
2563
|
/**
|
|
2529
2564
|
* Make a GET request
|
|
2530
2565
|
* @param {object} params
|