particle-api-js 9.4.0 → 10.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.
- package/.circleci/config.yml +7 -5
- package/.eslintrc.js +3 -3
- package/CHANGELOG.md +8 -0
- package/RELEASE.md +1 -1
- package/dist/particle.min.js +227 -192
- package/dist/particle.min.js.map +1 -1
- package/docs/api.md +561 -103
- package/fs.js +2 -0
- package/lib/Agent.js +320 -221
- package/lib/Agent.js.map +1 -1
- package/lib/Particle.js +645 -62
- package/lib/Particle.js.map +1 -1
- package/package.json +10 -10
- package/test/Agent.integration.js +3 -1
- package/test/Agent.spec.js +173 -289
- package/test/EventStream.spec.js +1 -1
- package/test/Particle.integration.js +5 -4
- package/test/Particle.spec.js +325 -11
- package/lib/superagent-binary-parser.js +0 -20
- package/lib/superagent-binary-parser.js.map +0 -1
- /package/{test/EventStream-e2e-browser.html → EventStream-e2e-browser.html} +0 -0
- /package/{test/EventStream-e2e-node.js → EventStream-e2e-node.js} +0 -0
package/lib/Particle.js
CHANGED
|
@@ -16,10 +16,6 @@ var _createClass2 = require('babel-runtime/helpers/createClass');
|
|
|
16
16
|
|
|
17
17
|
var _createClass3 = _interopRequireDefault(_createClass2);
|
|
18
18
|
|
|
19
|
-
var _superagentBinaryParser = require('./superagent-binary-parser');
|
|
20
|
-
|
|
21
|
-
var _superagentBinaryParser2 = _interopRequireDefault(_superagentBinaryParser);
|
|
22
|
-
|
|
23
19
|
var _Defaults = require('./Defaults');
|
|
24
20
|
|
|
25
21
|
var _Defaults2 = _interopRequireDefault(_Defaults);
|
|
@@ -1185,16 +1181,14 @@ var Particle = function () {
|
|
|
1185
1181
|
headers = _ref38.headers,
|
|
1186
1182
|
context = _ref38.context;
|
|
1187
1183
|
|
|
1188
|
-
|
|
1184
|
+
return this.request({
|
|
1189
1185
|
uri: '/v1/binaries/' + binaryId,
|
|
1190
1186
|
method: 'get',
|
|
1191
1187
|
auth: auth,
|
|
1192
1188
|
headers: headers,
|
|
1193
1189
|
context: context,
|
|
1194
|
-
|
|
1190
|
+
isBuffer: true
|
|
1195
1191
|
});
|
|
1196
|
-
|
|
1197
|
-
return this._provideFileData(req);
|
|
1198
1192
|
}
|
|
1199
1193
|
|
|
1200
1194
|
/**
|
|
@@ -2158,8 +2152,7 @@ var Particle = function () {
|
|
|
2158
2152
|
headers = _ref70.headers,
|
|
2159
2153
|
context = _ref70.context;
|
|
2160
2154
|
|
|
2161
|
-
|
|
2162
|
-
return this._provideFileData(req);
|
|
2155
|
+
return this.request({ uri: uri, method: 'get', headers: headers, context: context, isBuffer: true });
|
|
2163
2156
|
}
|
|
2164
2157
|
|
|
2165
2158
|
/**
|
|
@@ -2449,30 +2442,13 @@ var Particle = function () {
|
|
|
2449
2442
|
headers = _ref81.headers,
|
|
2450
2443
|
context = _ref81.context;
|
|
2451
2444
|
|
|
2452
|
-
|
|
2445
|
+
return this.request({
|
|
2453
2446
|
uri: '/v1/products/' + product + '/firmware/' + version + '/binary',
|
|
2454
2447
|
method: 'get',
|
|
2455
2448
|
auth: auth,
|
|
2456
2449
|
headers: headers,
|
|
2457
2450
|
context: context,
|
|
2458
|
-
|
|
2459
|
-
});
|
|
2460
|
-
|
|
2461
|
-
return this._provideFileData(req);
|
|
2462
|
-
}
|
|
2463
|
-
}, {
|
|
2464
|
-
key: '_provideFileData',
|
|
2465
|
-
value: function _provideFileData(req) {
|
|
2466
|
-
if (this.agent.isForBrowser()) {
|
|
2467
|
-
req = req.responseType('arraybuffer').then(function (res) {
|
|
2468
|
-
res.body = res.xhr.response;
|
|
2469
|
-
return res;
|
|
2470
|
-
});
|
|
2471
|
-
} else {
|
|
2472
|
-
req = req.buffer(true).parse(_superagentBinaryParser2.default);
|
|
2473
|
-
}
|
|
2474
|
-
return req.then(function (res) {
|
|
2475
|
-
return res.body;
|
|
2451
|
+
isBuffer: true
|
|
2476
2452
|
});
|
|
2477
2453
|
}
|
|
2478
2454
|
|
|
@@ -3102,6 +3078,541 @@ var Particle = function () {
|
|
|
3102
3078
|
});
|
|
3103
3079
|
}
|
|
3104
3080
|
|
|
3081
|
+
/**
|
|
3082
|
+
* Creates a new logic block in the specified organization using the provided block data.
|
|
3083
|
+
*
|
|
3084
|
+
* When you create a logic block with PubSub matchers, events will immediately
|
|
3085
|
+
* start being handled by the block code.
|
|
3086
|
+
*
|
|
3087
|
+
* When you create a Chron matcher, it will immediately be scheduled at the next time
|
|
3088
|
+
* according to the cron and start_at properties.
|
|
3089
|
+
*
|
|
3090
|
+
* @param {Object} options The options for creating the logic block.
|
|
3091
|
+
* @param {Object} options.auth Access token
|
|
3092
|
+
* @param {string} options.org The name of the organization.
|
|
3093
|
+
* @param {Block} options.block The block object containing the block details.
|
|
3094
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3095
|
+
* @param {Object} [options.context] Request context
|
|
3096
|
+
*
|
|
3097
|
+
* @returns {Promise<{body: {block: ResponseBlock}, statusCode: int}>} A promise that resolves to the created logic block data.
|
|
3098
|
+
*/
|
|
3099
|
+
|
|
3100
|
+
}, {
|
|
3101
|
+
key: 'createLogicBlock',
|
|
3102
|
+
value: function createLogicBlock(_ref103) {
|
|
3103
|
+
var auth = _ref103.auth,
|
|
3104
|
+
org = _ref103.org,
|
|
3105
|
+
block = _ref103.block,
|
|
3106
|
+
headers = _ref103.headers,
|
|
3107
|
+
context = _ref103.context;
|
|
3108
|
+
|
|
3109
|
+
return this.post({
|
|
3110
|
+
uri: '/v1/orgs/' + org + '/blocks',
|
|
3111
|
+
auth: auth,
|
|
3112
|
+
data: { block: block },
|
|
3113
|
+
headers: headers,
|
|
3114
|
+
context: context
|
|
3115
|
+
});
|
|
3116
|
+
}
|
|
3117
|
+
|
|
3118
|
+
/**
|
|
3119
|
+
* Get a logic block in the specified organization by block ID.
|
|
3120
|
+
*
|
|
3121
|
+
* @param {Object} options The options for the logic block.
|
|
3122
|
+
* @param {Object} options.auth Access token
|
|
3123
|
+
* @param {string} options.org The name of the organization.
|
|
3124
|
+
* @param {Block} options.blockId The ID of the block to retrieve.
|
|
3125
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3126
|
+
* @param {Object} [options.context] Request context
|
|
3127
|
+
*
|
|
3128
|
+
* @returns {Promise<{body: {block: ResponseBlock}, statusCode: int}>} A promise that resolves to the specified logic block data.
|
|
3129
|
+
*/
|
|
3130
|
+
|
|
3131
|
+
}, {
|
|
3132
|
+
key: 'getLogicBlock',
|
|
3133
|
+
value: function getLogicBlock(_ref104) {
|
|
3134
|
+
var auth = _ref104.auth,
|
|
3135
|
+
org = _ref104.org,
|
|
3136
|
+
blockId = _ref104.blockId,
|
|
3137
|
+
headers = _ref104.headers,
|
|
3138
|
+
context = _ref104.context;
|
|
3139
|
+
|
|
3140
|
+
return this.get({
|
|
3141
|
+
uri: '/v1/orgs/' + org + '/blocks/' + blockId,
|
|
3142
|
+
auth: auth,
|
|
3143
|
+
headers: headers,
|
|
3144
|
+
context: context
|
|
3145
|
+
});
|
|
3146
|
+
}
|
|
3147
|
+
|
|
3148
|
+
/**
|
|
3149
|
+
* Updates an existing logic block in the specified organization using the provided block data.
|
|
3150
|
+
*
|
|
3151
|
+
* If you include an id on a matcher, it will update the matcher in place.
|
|
3152
|
+
*
|
|
3153
|
+
* @param {Object} options The options for updating the logic block.
|
|
3154
|
+
* @param {Object} options.auth The authentication object with the API key.
|
|
3155
|
+
* @param {string} options.org The unique identifier of the organization.
|
|
3156
|
+
* @param {string} options.blockId The ID of the block to update.
|
|
3157
|
+
* @param {Block} options.block The block object containing the block details.
|
|
3158
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3159
|
+
* @param {Object} [options.context] Request context.
|
|
3160
|
+
*
|
|
3161
|
+
* @returns {Promise<{body: {block: ResponseBlock}, statusCode: int}>} A promise that resolves to the updated logic block data.
|
|
3162
|
+
*/
|
|
3163
|
+
|
|
3164
|
+
}, {
|
|
3165
|
+
key: 'updateLogicBlock',
|
|
3166
|
+
value: function updateLogicBlock(_ref105) {
|
|
3167
|
+
var auth = _ref105.auth,
|
|
3168
|
+
org = _ref105.org,
|
|
3169
|
+
blockId = _ref105.blockId,
|
|
3170
|
+
block = _ref105.block,
|
|
3171
|
+
headers = _ref105.headers,
|
|
3172
|
+
context = _ref105.context;
|
|
3173
|
+
|
|
3174
|
+
return this.put({
|
|
3175
|
+
uri: '/v1/orgs/' + org + '/blocks/' + blockId,
|
|
3176
|
+
auth: auth,
|
|
3177
|
+
data: { block: block },
|
|
3178
|
+
headers: headers,
|
|
3179
|
+
context: context
|
|
3180
|
+
});
|
|
3181
|
+
}
|
|
3182
|
+
|
|
3183
|
+
/**
|
|
3184
|
+
* Deletes a logic block in the specified organization by block ID.
|
|
3185
|
+
*
|
|
3186
|
+
* @param {Object} options The options for deleting the logic block.
|
|
3187
|
+
* @param {Object} options.auth The authentication object with the API key.
|
|
3188
|
+
* @param {string} options.org The unique identifier of the organization.
|
|
3189
|
+
* @param {string} options.blockId The ID of the block to delete.
|
|
3190
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3191
|
+
* @param {Object} [options.context] Request context.
|
|
3192
|
+
*
|
|
3193
|
+
* @returns {Promise<{body: {block_id: int}, statusCode: int}>} A promise that resolves to an object containing the deleted block ID.
|
|
3194
|
+
*/
|
|
3195
|
+
|
|
3196
|
+
}, {
|
|
3197
|
+
key: 'deleteLogicBlock',
|
|
3198
|
+
value: function deleteLogicBlock(_ref106) {
|
|
3199
|
+
var auth = _ref106.auth,
|
|
3200
|
+
org = _ref106.org,
|
|
3201
|
+
blockId = _ref106.blockId,
|
|
3202
|
+
headers = _ref106.headers,
|
|
3203
|
+
context = _ref106.context;
|
|
3204
|
+
|
|
3205
|
+
return this.delete({
|
|
3206
|
+
uri: '/v1/orgs/' + org + '/blocks/' + blockId,
|
|
3207
|
+
auth: auth,
|
|
3208
|
+
headers: headers,
|
|
3209
|
+
context: context
|
|
3210
|
+
});
|
|
3211
|
+
}
|
|
3212
|
+
|
|
3213
|
+
/**
|
|
3214
|
+
* Lists all logic blocks in the specified organization.
|
|
3215
|
+
*
|
|
3216
|
+
* @param {Object} options The options for listing logic blocks.
|
|
3217
|
+
* @param {Object} options.auth The authentication object with the API key.
|
|
3218
|
+
* @param {string} options.org The unique identifier of the organization.
|
|
3219
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3220
|
+
* @param {Object} [options.context] Request context.
|
|
3221
|
+
*
|
|
3222
|
+
* @returns {Promise<{body: {blocks: ResponseBlock[]}, statusCode: int}>} A promise that resolves to an array of logic block data.
|
|
3223
|
+
*/
|
|
3224
|
+
|
|
3225
|
+
}, {
|
|
3226
|
+
key: 'listLogicBlocks',
|
|
3227
|
+
value: function listLogicBlocks(_ref107) {
|
|
3228
|
+
var auth = _ref107.auth,
|
|
3229
|
+
org = _ref107.org,
|
|
3230
|
+
headers = _ref107.headers,
|
|
3231
|
+
context = _ref107.context;
|
|
3232
|
+
|
|
3233
|
+
return this.get({
|
|
3234
|
+
uri: '/v1/orgs/' + org + '/blocks',
|
|
3235
|
+
auth: auth,
|
|
3236
|
+
headers: headers,
|
|
3237
|
+
context: context
|
|
3238
|
+
});
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
/**
|
|
3242
|
+
* Lists all block runs for the specified block.
|
|
3243
|
+
*
|
|
3244
|
+
* @param {Object} options The options for the request.
|
|
3245
|
+
* @param {Object} options.auth Access token
|
|
3246
|
+
* @param {string} options.org The unique identifier of the organization.
|
|
3247
|
+
* @param {number} options.blockId The ID of the block for which to retrieve the block runs.
|
|
3248
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3249
|
+
* @param {Object} [options.context] Request context
|
|
3250
|
+
*
|
|
3251
|
+
* @returns {Promise<{body: {block_runs: BlockRun[]}, statusCode: int}>} A promise that resolves to an array of block run data.
|
|
3252
|
+
*/
|
|
3253
|
+
|
|
3254
|
+
}, {
|
|
3255
|
+
key: 'listBlockRuns',
|
|
3256
|
+
value: function listBlockRuns(_ref108) {
|
|
3257
|
+
var auth = _ref108.auth,
|
|
3258
|
+
org = _ref108.org,
|
|
3259
|
+
blockId = _ref108.blockId,
|
|
3260
|
+
headers = _ref108.headers,
|
|
3261
|
+
context = _ref108.context;
|
|
3262
|
+
|
|
3263
|
+
return this.get({
|
|
3264
|
+
uri: '/v1/orgs/' + org + '/blocks/' + blockId + '/runs',
|
|
3265
|
+
auth: auth,
|
|
3266
|
+
headers: headers,
|
|
3267
|
+
context: context
|
|
3268
|
+
});
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
/**
|
|
3272
|
+
* Retrieves a block run by its ID for the specified block.
|
|
3273
|
+
*
|
|
3274
|
+
* @param {Object} options The options for the request.
|
|
3275
|
+
* @param {Object} options.auth Access token
|
|
3276
|
+
* @param {string} options.org The unique identifier of the organization.
|
|
3277
|
+
* @param {number} options.blockId The ID of the block for which to retrieve the block run.
|
|
3278
|
+
* @param {number} options.runId The ID of the block run to retrieve.
|
|
3279
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3280
|
+
* @param {Object} [options.context] Request context
|
|
3281
|
+
*
|
|
3282
|
+
* @returns {Promise<{body: {block_run: BlockRun}, statusCode: int}>} A promise that resolves to an array of block run data for the specified block run ID.
|
|
3283
|
+
*/
|
|
3284
|
+
|
|
3285
|
+
}, {
|
|
3286
|
+
key: 'getBlockRun',
|
|
3287
|
+
value: function getBlockRun(_ref109) {
|
|
3288
|
+
var auth = _ref109.auth,
|
|
3289
|
+
org = _ref109.org,
|
|
3290
|
+
blockId = _ref109.blockId,
|
|
3291
|
+
runId = _ref109.runId,
|
|
3292
|
+
headers = _ref109.headers,
|
|
3293
|
+
context = _ref109.context;
|
|
3294
|
+
|
|
3295
|
+
return this.get({
|
|
3296
|
+
uri: '/v1/orgs/' + org + '/blocks/' + blockId + '/runs/' + runId,
|
|
3297
|
+
auth: auth,
|
|
3298
|
+
headers: headers,
|
|
3299
|
+
context: context
|
|
3300
|
+
});
|
|
3301
|
+
}
|
|
3302
|
+
|
|
3303
|
+
/**
|
|
3304
|
+
* Retrieves the logs for a block run by its ID for the specified block.
|
|
3305
|
+
*
|
|
3306
|
+
* @param {Object} options The options for the request.
|
|
3307
|
+
* @param {Object} options.auth Access token
|
|
3308
|
+
* @param {string} options.org The unique identifier of the organization.
|
|
3309
|
+
* @param {number} options.blockId The ID of the block for which to retrieve the block run logs.
|
|
3310
|
+
* @param {number} options.runId The ID of the block run for which to retrieve the logs.
|
|
3311
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3312
|
+
* @param {Object} [options.context] Request context
|
|
3313
|
+
*
|
|
3314
|
+
* @returns {Promise<{body: {block_run_log: BlockRunLog}, statusCode: int}>} A promise that resolves to the logs for the specified block run ID.
|
|
3315
|
+
*/
|
|
3316
|
+
|
|
3317
|
+
}, {
|
|
3318
|
+
key: 'getBlockRunLog',
|
|
3319
|
+
value: function getBlockRunLog(_ref110) {
|
|
3320
|
+
var auth = _ref110.auth,
|
|
3321
|
+
org = _ref110.org,
|
|
3322
|
+
blockId = _ref110.blockId,
|
|
3323
|
+
runId = _ref110.runId,
|
|
3324
|
+
headers = _ref110.headers,
|
|
3325
|
+
context = _ref110.context;
|
|
3326
|
+
|
|
3327
|
+
return this.get({
|
|
3328
|
+
uri: '/v1/orgs/' + org + '/blocks/' + blockId + '/runs/' + runId + '/logs',
|
|
3329
|
+
auth: auth,
|
|
3330
|
+
headers: headers,
|
|
3331
|
+
context: context
|
|
3332
|
+
});
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3335
|
+
/**
|
|
3336
|
+
* Creates a new ledger definition in the specified organization.
|
|
3337
|
+
*
|
|
3338
|
+
* @param {Object} options The options for creating the ledger definition.
|
|
3339
|
+
* @param {Object} options.auth Access token
|
|
3340
|
+
* @param {string} options.org The name of the organization.
|
|
3341
|
+
* @param {Ledger} options.definition The ledger definition object.
|
|
3342
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3343
|
+
* @param {Object} [options.context] Request context
|
|
3344
|
+
*
|
|
3345
|
+
* @returns {Promise<{body: {ledger: ResponseLedger}, statusCode: int}>} A promise that resolves to the created ledger definition data.
|
|
3346
|
+
*/
|
|
3347
|
+
|
|
3348
|
+
}, {
|
|
3349
|
+
key: 'createLedger',
|
|
3350
|
+
value: function createLedger(_ref111) {
|
|
3351
|
+
var auth = _ref111.auth,
|
|
3352
|
+
org = _ref111.org,
|
|
3353
|
+
ledger = _ref111.ledger,
|
|
3354
|
+
headers = _ref111.headers,
|
|
3355
|
+
context = _ref111.context;
|
|
3356
|
+
|
|
3357
|
+
return this.post({
|
|
3358
|
+
uri: '/v1/orgs/' + org + '/ledgers',
|
|
3359
|
+
auth: auth,
|
|
3360
|
+
data: { ledger: ledger },
|
|
3361
|
+
headers: headers,
|
|
3362
|
+
context: context
|
|
3363
|
+
});
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
/**
|
|
3367
|
+
* Get a ledger definition in the specified organization by ledger name.
|
|
3368
|
+
*
|
|
3369
|
+
* @param {Object} options The options for the ledger definition.
|
|
3370
|
+
* @param {Object} options.auth Access token
|
|
3371
|
+
* @param {string} options.org The name of the organization.
|
|
3372
|
+
* @param {string} options.ledgerName The ID of the ledger definition to retrieve.
|
|
3373
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3374
|
+
* @param {Object} [options.context] Request context
|
|
3375
|
+
*
|
|
3376
|
+
* @returns {Promise<{body: {ledger: ResponseLedger}, statusCode: int}>} A promise that resolves to the specified ledger definition data.
|
|
3377
|
+
*/
|
|
3378
|
+
|
|
3379
|
+
}, {
|
|
3380
|
+
key: 'getLedger',
|
|
3381
|
+
value: function getLedger(_ref112) {
|
|
3382
|
+
var auth = _ref112.auth,
|
|
3383
|
+
org = _ref112.org,
|
|
3384
|
+
ledgerName = _ref112.ledgerName,
|
|
3385
|
+
headers = _ref112.headers,
|
|
3386
|
+
context = _ref112.context;
|
|
3387
|
+
|
|
3388
|
+
return this.get({
|
|
3389
|
+
uri: '/v1/orgs/' + org + '/ledgers/' + ledgerName,
|
|
3390
|
+
auth: auth,
|
|
3391
|
+
headers: headers,
|
|
3392
|
+
context: context
|
|
3393
|
+
});
|
|
3394
|
+
}
|
|
3395
|
+
|
|
3396
|
+
/**
|
|
3397
|
+
* Updates an existing ledger definition in the specified organization.
|
|
3398
|
+
*
|
|
3399
|
+
* @param {Object} options The options for updating the ledger definition.
|
|
3400
|
+
* @param {Object} options.auth The authentication object with the API key.
|
|
3401
|
+
* @param {string} options.org The unique identifier of the organization.
|
|
3402
|
+
* @param {string} options.ledgerName Name of the ledger definition to update.
|
|
3403
|
+
* @param {Ledger} options.ledger The ledger definition object.
|
|
3404
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3405
|
+
* @param {Object} [options.context] Request context.
|
|
3406
|
+
*
|
|
3407
|
+
* @returns {Promise<{body: {ledger: ResponseLedger}, statusCode: int}>} A promise that resolves to the updated ledger definition data.
|
|
3408
|
+
*/
|
|
3409
|
+
|
|
3410
|
+
}, {
|
|
3411
|
+
key: 'updateLedger',
|
|
3412
|
+
value: function updateLedger(_ref113) {
|
|
3413
|
+
var auth = _ref113.auth,
|
|
3414
|
+
org = _ref113.org,
|
|
3415
|
+
ledgerName = _ref113.ledgerName,
|
|
3416
|
+
ledger = _ref113.ledger,
|
|
3417
|
+
headers = _ref113.headers,
|
|
3418
|
+
context = _ref113.context;
|
|
3419
|
+
|
|
3420
|
+
return this.put({
|
|
3421
|
+
uri: '/v1/orgs/' + org + '/ledgers/' + ledgerName,
|
|
3422
|
+
auth: auth,
|
|
3423
|
+
data: { ledger: ledger },
|
|
3424
|
+
headers: headers,
|
|
3425
|
+
context: context
|
|
3426
|
+
});
|
|
3427
|
+
}
|
|
3428
|
+
|
|
3429
|
+
/**
|
|
3430
|
+
* Archives a ledger definition in the specified organization by ledger name.
|
|
3431
|
+
*
|
|
3432
|
+
* @param {Object} options The options for archiving the ledger definition.
|
|
3433
|
+
* @param {Object} options.auth The authentication object with the API key.
|
|
3434
|
+
* @param {string} options.org The unique identifier of the organization.
|
|
3435
|
+
* @param {string} options.ledgerName Name of the ledger definition to archive.
|
|
3436
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3437
|
+
* @param {Object} [options.context] Request context.
|
|
3438
|
+
*
|
|
3439
|
+
* @returns {Promise<{body: undefined, statusCode: int}>} A promise that resolves to an object confirming the ledger definition was archived.
|
|
3440
|
+
*/
|
|
3441
|
+
|
|
3442
|
+
}, {
|
|
3443
|
+
key: 'archiveLedger',
|
|
3444
|
+
value: function archiveLedger(_ref114) {
|
|
3445
|
+
var auth = _ref114.auth,
|
|
3446
|
+
org = _ref114.org,
|
|
3447
|
+
ledgerName = _ref114.ledgerName,
|
|
3448
|
+
headers = _ref114.headers,
|
|
3449
|
+
context = _ref114.context;
|
|
3450
|
+
|
|
3451
|
+
return this.delete({
|
|
3452
|
+
uri: '/v1/orgs/' + org + '/ledgers/' + ledgerName,
|
|
3453
|
+
auth: auth,
|
|
3454
|
+
headers: headers,
|
|
3455
|
+
context: context
|
|
3456
|
+
});
|
|
3457
|
+
}
|
|
3458
|
+
|
|
3459
|
+
/**
|
|
3460
|
+
* Lists all ledger definitions in the specified organization.
|
|
3461
|
+
*
|
|
3462
|
+
* @param {Object} options The options for listing ledger definitions.
|
|
3463
|
+
* @param {Object} options.auth The authentication object with the API key.
|
|
3464
|
+
* @param {string} options.org The unique identifier of the organization.
|
|
3465
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3466
|
+
* @param {Object} [options.context] Request context.
|
|
3467
|
+
*
|
|
3468
|
+
* @returns {Promise<{body: {ledgers: ResponseLedger[]}, statusCode: int}>} A promise that resolves to an array of ledger definition data.
|
|
3469
|
+
*/
|
|
3470
|
+
|
|
3471
|
+
}, {
|
|
3472
|
+
key: 'listLedgers',
|
|
3473
|
+
value: function listLedgers(_ref115) {
|
|
3474
|
+
var auth = _ref115.auth,
|
|
3475
|
+
org = _ref115.org,
|
|
3476
|
+
headers = _ref115.headers,
|
|
3477
|
+
context = _ref115.context;
|
|
3478
|
+
|
|
3479
|
+
return this.get({
|
|
3480
|
+
uri: '/v1/orgs/' + org + '/ledgers',
|
|
3481
|
+
auth: auth,
|
|
3482
|
+
headers: headers,
|
|
3483
|
+
context: context
|
|
3484
|
+
});
|
|
3485
|
+
}
|
|
3486
|
+
|
|
3487
|
+
/**
|
|
3488
|
+
* Get ledger instance data.
|
|
3489
|
+
*
|
|
3490
|
+
* @param {Object} options The options for the ledger instance.
|
|
3491
|
+
* @param {Object} options.auth Access token
|
|
3492
|
+
* @param {string} options.org The name of the organization.
|
|
3493
|
+
* @param {string} options.ledgerName Ledger name.
|
|
3494
|
+
* @param {string} options.scopeValue Scope value.
|
|
3495
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3496
|
+
* @param {Object} [options.context] Request context
|
|
3497
|
+
*
|
|
3498
|
+
* @returns {Promise<{body: {instance: ResponseLedgerInstance}, statusCode: int}>} A promise that resolves to the specified ledger instance data.
|
|
3499
|
+
*/
|
|
3500
|
+
|
|
3501
|
+
}, {
|
|
3502
|
+
key: 'getLedgerInstance',
|
|
3503
|
+
value: function getLedgerInstance(_ref116) {
|
|
3504
|
+
var auth = _ref116.auth,
|
|
3505
|
+
org = _ref116.org,
|
|
3506
|
+
ledgerName = _ref116.ledgerName,
|
|
3507
|
+
scopeValue = _ref116.scopeValue,
|
|
3508
|
+
headers = _ref116.headers,
|
|
3509
|
+
context = _ref116.context;
|
|
3510
|
+
|
|
3511
|
+
return this.get({
|
|
3512
|
+
uri: '/v1/orgs/' + org + '/ledgers/' + ledgerName + '/instances/' + scopeValue,
|
|
3513
|
+
auth: auth,
|
|
3514
|
+
headers: headers,
|
|
3515
|
+
context: context
|
|
3516
|
+
});
|
|
3517
|
+
}
|
|
3518
|
+
|
|
3519
|
+
/**
|
|
3520
|
+
* Set ledger instance data.
|
|
3521
|
+
*
|
|
3522
|
+
* @param {Object} options The options for updating the ledger instance.
|
|
3523
|
+
* @param {Object} options.auth The authentication object with the API key.
|
|
3524
|
+
* @param {string} options.org The unique identifier of the organization.
|
|
3525
|
+
* @param {string} options.ledgerName Ledger name.
|
|
3526
|
+
* @param {string} options.scopeValue Scope value.
|
|
3527
|
+
* @param {LedgerInstance} options.instance The ledger instance object.
|
|
3528
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3529
|
+
* @param {Object} [options.context] Request context.
|
|
3530
|
+
*
|
|
3531
|
+
* @returns {Promise<{body: {instance: ResponseLedgerInstance}, statusCode: int}>} A promise that resolves to the updated ledger instance data.
|
|
3532
|
+
*/
|
|
3533
|
+
|
|
3534
|
+
}, {
|
|
3535
|
+
key: 'setLedgerInstance',
|
|
3536
|
+
value: function setLedgerInstance(_ref117) {
|
|
3537
|
+
var auth = _ref117.auth,
|
|
3538
|
+
org = _ref117.org,
|
|
3539
|
+
ledgerName = _ref117.ledgerName,
|
|
3540
|
+
scopeValue = _ref117.scopeValue,
|
|
3541
|
+
data = _ref117.data,
|
|
3542
|
+
headers = _ref117.headers,
|
|
3543
|
+
context = _ref117.context;
|
|
3544
|
+
|
|
3545
|
+
return this.put({
|
|
3546
|
+
uri: '/v1/orgs/' + org + '/ledgers/' + ledgerName + '/instances/' + scopeValue,
|
|
3547
|
+
auth: auth,
|
|
3548
|
+
data: { data: data },
|
|
3549
|
+
headers: headers,
|
|
3550
|
+
context: context
|
|
3551
|
+
});
|
|
3552
|
+
}
|
|
3553
|
+
|
|
3554
|
+
/**
|
|
3555
|
+
* Delete a ledger instance in the specified organization by ledger name.
|
|
3556
|
+
*
|
|
3557
|
+
* @param {Object} options The options for archiving the ledger instance.
|
|
3558
|
+
* @param {Object} options.auth The authentication object with the API key.
|
|
3559
|
+
* @param {string} options.org The unique identifier of the organization.
|
|
3560
|
+
* @param {string} options.ledgerName Name of the ledger instance to archive.
|
|
3561
|
+
* @param {string} options.scopeValue Scope value.
|
|
3562
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3563
|
+
* @param {Object} [options.context] Request context.
|
|
3564
|
+
*
|
|
3565
|
+
* @returns {Promise<{body: undefined, statusCode: int}>} A promise that resolves to an object confirming the ledger instance was deleted.
|
|
3566
|
+
*/
|
|
3567
|
+
|
|
3568
|
+
}, {
|
|
3569
|
+
key: 'deleteLedgerInstance',
|
|
3570
|
+
value: function deleteLedgerInstance(_ref118) {
|
|
3571
|
+
var auth = _ref118.auth,
|
|
3572
|
+
org = _ref118.org,
|
|
3573
|
+
ledgerName = _ref118.ledgerName,
|
|
3574
|
+
scopeValue = _ref118.scopeValue,
|
|
3575
|
+
headers = _ref118.headers,
|
|
3576
|
+
context = _ref118.context;
|
|
3577
|
+
|
|
3578
|
+
return this.delete({
|
|
3579
|
+
uri: '/v1/orgs/' + org + '/ledgers/' + ledgerName + '/instances/' + scopeValue,
|
|
3580
|
+
auth: auth,
|
|
3581
|
+
headers: headers,
|
|
3582
|
+
context: context
|
|
3583
|
+
});
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3586
|
+
/**
|
|
3587
|
+
* Lists ledger instances.
|
|
3588
|
+
*
|
|
3589
|
+
* @param {Object} options The options for listing ledger instances.
|
|
3590
|
+
* @param {Object} options.auth The authentication object with the API key.
|
|
3591
|
+
* @param {string} options.org The unique identifier of the organization.
|
|
3592
|
+
* @param {string} options.ledgerName Name of the ledger instance to archive.
|
|
3593
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3594
|
+
* @param {Object} [options.context] Request context.
|
|
3595
|
+
*
|
|
3596
|
+
* @returns {Promise<{body: {instances: ResponseLedgerInstance[]}, statusCode: int}>} A promise that resolves to an array of ledger instance data.
|
|
3597
|
+
*/
|
|
3598
|
+
|
|
3599
|
+
}, {
|
|
3600
|
+
key: 'listLedgerInstances',
|
|
3601
|
+
value: function listLedgerInstances(_ref119) {
|
|
3602
|
+
var auth = _ref119.auth,
|
|
3603
|
+
org = _ref119.org,
|
|
3604
|
+
ledgerName = _ref119.ledgerName,
|
|
3605
|
+
headers = _ref119.headers,
|
|
3606
|
+
context = _ref119.context;
|
|
3607
|
+
|
|
3608
|
+
return this.get({
|
|
3609
|
+
uri: '/v1/orgs/' + org + '/ledgers/' + ledgerName + '/instances',
|
|
3610
|
+
auth: auth,
|
|
3611
|
+
headers: headers,
|
|
3612
|
+
context: context
|
|
3613
|
+
});
|
|
3614
|
+
}
|
|
3615
|
+
|
|
3105
3616
|
/**
|
|
3106
3617
|
* Set default auth token that will be used in each method if `auth` is not provided
|
|
3107
3618
|
* @param {String} auth A Particle access token
|
|
@@ -3140,77 +3651,149 @@ var Particle = function () {
|
|
|
3140
3651
|
|
|
3141
3652
|
}, {
|
|
3142
3653
|
key: 'deviceUri',
|
|
3143
|
-
value: function deviceUri(
|
|
3144
|
-
var deviceId =
|
|
3145
|
-
product =
|
|
3654
|
+
value: function deviceUri(_ref120) {
|
|
3655
|
+
var deviceId = _ref120.deviceId,
|
|
3656
|
+
product = _ref120.product;
|
|
3146
3657
|
|
|
3147
3658
|
return product ? '/v1/products/' + product + '/devices/' + deviceId : '/v1/devices/' + deviceId;
|
|
3148
3659
|
}
|
|
3660
|
+
|
|
3661
|
+
/**
|
|
3662
|
+
* Make a GET request
|
|
3663
|
+
* @param {string} uri The URI to request
|
|
3664
|
+
* @param {string} [auth] Authorization token to use
|
|
3665
|
+
* @param {object} [headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3666
|
+
* @param {string|object} [query] Key/VAlue pairs of query params or a correctly formatted string
|
|
3667
|
+
* @param {object} [context[ The invocation context, describing the tool and project
|
|
3668
|
+
* @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
|
|
3669
|
+
*/
|
|
3670
|
+
|
|
3149
3671
|
}, {
|
|
3150
3672
|
key: 'get',
|
|
3151
|
-
value: function get(
|
|
3152
|
-
var uri =
|
|
3153
|
-
auth =
|
|
3154
|
-
headers =
|
|
3155
|
-
query =
|
|
3156
|
-
context =
|
|
3673
|
+
value: function get(_ref121) {
|
|
3674
|
+
var uri = _ref121.uri,
|
|
3675
|
+
auth = _ref121.auth,
|
|
3676
|
+
headers = _ref121.headers,
|
|
3677
|
+
query = _ref121.query,
|
|
3678
|
+
context = _ref121.context;
|
|
3157
3679
|
|
|
3158
3680
|
context = this._buildContext(context);
|
|
3159
3681
|
auth = this._getActiveAuthToken(auth);
|
|
3160
3682
|
return this.agent.get({ uri: uri, auth: auth, headers: headers, query: query, context: context });
|
|
3161
3683
|
}
|
|
3684
|
+
|
|
3685
|
+
/**
|
|
3686
|
+
* Make a HEAD request
|
|
3687
|
+
* @param {string} uri The URI to request
|
|
3688
|
+
* @param {string} [auth] Authorization token to use
|
|
3689
|
+
* @param {object} [headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3690
|
+
* @param {string|object} [query] Key/VAlue pairs of query params or a correctly formatted string
|
|
3691
|
+
* @param {object} [context] The invocation context, describing the tool and project
|
|
3692
|
+
* @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
|
|
3693
|
+
*/
|
|
3694
|
+
|
|
3162
3695
|
}, {
|
|
3163
3696
|
key: 'head',
|
|
3164
|
-
value: function head(
|
|
3165
|
-
var uri =
|
|
3166
|
-
auth =
|
|
3167
|
-
headers =
|
|
3168
|
-
query =
|
|
3169
|
-
context =
|
|
3697
|
+
value: function head(_ref122) {
|
|
3698
|
+
var uri = _ref122.uri,
|
|
3699
|
+
auth = _ref122.auth,
|
|
3700
|
+
headers = _ref122.headers,
|
|
3701
|
+
query = _ref122.query,
|
|
3702
|
+
context = _ref122.context;
|
|
3170
3703
|
|
|
3171
3704
|
context = this._buildContext(context);
|
|
3172
3705
|
auth = this._getActiveAuthToken(auth);
|
|
3173
3706
|
return this.agent.head({ uri: uri, auth: auth, headers: headers, query: query, context: context });
|
|
3174
3707
|
}
|
|
3708
|
+
|
|
3709
|
+
/**
|
|
3710
|
+
* Make a POST request
|
|
3711
|
+
* @param {string} uri The URI to request
|
|
3712
|
+
* @param {string} [auth] Authorization token to use
|
|
3713
|
+
* @param {object} [headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3714
|
+
* @param {string|object} [query] Key/VAlue pairs of query params or a correctly formatted string
|
|
3715
|
+
* @param {object} [context] The invocation context, describing the tool and project
|
|
3716
|
+
* @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
|
|
3717
|
+
*/
|
|
3718
|
+
|
|
3175
3719
|
}, {
|
|
3176
3720
|
key: 'post',
|
|
3177
|
-
value: function post(
|
|
3178
|
-
var uri =
|
|
3179
|
-
auth =
|
|
3180
|
-
headers =
|
|
3181
|
-
data =
|
|
3182
|
-
context =
|
|
3721
|
+
value: function post(_ref123) {
|
|
3722
|
+
var uri = _ref123.uri,
|
|
3723
|
+
auth = _ref123.auth,
|
|
3724
|
+
headers = _ref123.headers,
|
|
3725
|
+
data = _ref123.data,
|
|
3726
|
+
context = _ref123.context;
|
|
3183
3727
|
|
|
3184
3728
|
context = this._buildContext(context);
|
|
3185
3729
|
auth = this._getActiveAuthToken(auth);
|
|
3186
3730
|
return this.agent.post({ uri: uri, auth: auth, headers: headers, data: data, context: context });
|
|
3187
3731
|
}
|
|
3732
|
+
|
|
3733
|
+
/**
|
|
3734
|
+
* Make a PUT request
|
|
3735
|
+
* @param {string} uri The URI to request
|
|
3736
|
+
* @param {string} [auth] Authorization token to use
|
|
3737
|
+
* @param {object} [headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3738
|
+
* @param {string|object} [query] Key/VAlue pairs of query params or a correctly formatted string
|
|
3739
|
+
* @param {object} [context] The invocation context, describing the tool and project
|
|
3740
|
+
* @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
|
|
3741
|
+
*/
|
|
3742
|
+
|
|
3188
3743
|
}, {
|
|
3189
3744
|
key: 'put',
|
|
3190
|
-
value: function put(
|
|
3191
|
-
var uri =
|
|
3192
|
-
auth =
|
|
3193
|
-
headers =
|
|
3194
|
-
data =
|
|
3195
|
-
context =
|
|
3745
|
+
value: function put(_ref124) {
|
|
3746
|
+
var uri = _ref124.uri,
|
|
3747
|
+
auth = _ref124.auth,
|
|
3748
|
+
headers = _ref124.headers,
|
|
3749
|
+
data = _ref124.data,
|
|
3750
|
+
context = _ref124.context;
|
|
3196
3751
|
|
|
3197
3752
|
context = this._buildContext(context);
|
|
3198
3753
|
auth = this._getActiveAuthToken(auth);
|
|
3199
3754
|
return this.agent.put({ uri: uri, auth: auth, headers: headers, data: data, context: context });
|
|
3200
3755
|
}
|
|
3756
|
+
|
|
3757
|
+
/**
|
|
3758
|
+
* Make a DELETE request
|
|
3759
|
+
* @param {string} uri The URI to request
|
|
3760
|
+
* @param {string} [auth] Authorization token to use
|
|
3761
|
+
* @param {object} [headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3762
|
+
* @param {string|object} [query] Key/VAlue pairs of query params or a correctly formatted string
|
|
3763
|
+
* @param {object} [context] The invocation context, describing the tool and project
|
|
3764
|
+
* @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
|
|
3765
|
+
*/
|
|
3766
|
+
|
|
3201
3767
|
}, {
|
|
3202
3768
|
key: 'delete',
|
|
3203
|
-
value: function _delete(
|
|
3204
|
-
var uri =
|
|
3205
|
-
auth =
|
|
3206
|
-
headers =
|
|
3207
|
-
data =
|
|
3208
|
-
context =
|
|
3769
|
+
value: function _delete(_ref125) {
|
|
3770
|
+
var uri = _ref125.uri,
|
|
3771
|
+
auth = _ref125.auth,
|
|
3772
|
+
headers = _ref125.headers,
|
|
3773
|
+
data = _ref125.data,
|
|
3774
|
+
context = _ref125.context;
|
|
3209
3775
|
|
|
3210
3776
|
context = this._buildContext(context);
|
|
3211
3777
|
auth = this._getActiveAuthToken(auth);
|
|
3212
3778
|
return this.agent.delete({ uri: uri, auth: auth, headers: headers, data: data, context: context });
|
|
3213
3779
|
}
|
|
3780
|
+
|
|
3781
|
+
/**
|
|
3782
|
+
*
|
|
3783
|
+
* @param {Object} args An obj with all the possible request configurations
|
|
3784
|
+
* @param {String} args.uri The URI to request
|
|
3785
|
+
* @param {String} args.method The method used to request the URI, should be in uppercase.
|
|
3786
|
+
* @param {Object} args.headers Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
3787
|
+
* @param {String} args.data Arbitrary data to send as the body.
|
|
3788
|
+
* @param {Object} args.auth Authorization
|
|
3789
|
+
* @param {String|Object} args.query Query parameters
|
|
3790
|
+
* @param {Object} args.form Form fields
|
|
3791
|
+
* @param {Object} args.files Array of file names and file content
|
|
3792
|
+
* @param {Object} args.context The invocation context, describing the tool and project.
|
|
3793
|
+
* @param {boolean} args.isBuffer Indicate if the response should be treated as Buffer instead of JSON
|
|
3794
|
+
* @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
|
|
3795
|
+
*/
|
|
3796
|
+
|
|
3214
3797
|
}, {
|
|
3215
3798
|
key: 'request',
|
|
3216
3799
|
value: function request(args) {
|